lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bounty] context generating function - how to get context def from its n


From: Janek Warchoł
Subject: [bounty] context generating function - how to get context def from its name?
Date: Fri, 25 Jul 2014 20:03:21 +0200

Hi all,

i got stuck when working on a function that creates custom context
definitions.  The idea is to have a function \newInstrument that would
take a list of settings and create new customized xxxStaff and
xxxVoice contexts - something like this:

newInstrument =
#(define-scheme-function
  (parser location instrName parentName settings)(string? ly:context-mod?)
  ;; ...
    #{
      \layout {
        \context {
          ;; create "instrNameStaff" context, derived from "parentNameStaff",
          ;; with default child "instrNameVoice", and modifications specified
          ;; in "settings" argument
        }
        \context {
          ;; create "instrNameVoice" context, derived from "parentNameVoice",
        }
      }
    #})

As you can see, i want to be able to specify the "parent" instrument
from which the new instrument will "inherit" settings.  For example, i
want to define a "Vocals" instrument (=> VocalsStaff and VocalsVoice
contexts, derived from Staff and Voice, respectively) and a "Soprano"
instrument derived from "Vocals" (=> SopranoStaff and SopranoVoice
contexts, derived from VocalsStaff and VocalsVoice, respectively).

I managed to write a function that does something like this, but I
have two problems:
1) inside the function, i don't know how to get a context definition
from its name (i.e. from a string).  Right now i have to pass parent
contexts' definitions as separate arguments, but this means that i
have three arguments instead of one.
2) i didn't manage to get midi stuff done inside the same function as
the layout stuff - but i think that i'll be able to solve that if i
have a solution to 1).

I offer €25 bounty for solving 1).  I may also offer a bounty for 2)
if i won't manage to do it myself :)
See the attachment for the code that i already have.

best,
Janek



reply via email to

[Prev in Thread] Current Thread [Next in Thread]