Hello, Lukas. I've re-drafted a mock up of the function in question. but
now the mock up actually worked... I was just not adding the hash "#" to
the number argument.... Still, I'll attach the function below to see if it
can be better optimized.

%%CODE BEGINS
%%
someFunction =
#(define-music-function
( ; beginning of arguments
 note ; music expression to be repeated and transposed
 transposeCoeficient ; number from 1 to 12 that would filter if (or COND)
statements.
) ; end of arguments
( ; beginning of type predicates
  ly:music?
 number?
) ; end of type predicates
( ; beginning of function block (which is wrong and nonsensical).
  make-relative (note) note ; have the transposed note be relative to it's
original.
   (cond
((= transposeCoeficient 1 ) #{$note \transpose c des { $note }#} ) ;
statement 1, related to a semitone increase from the original/prime note.
((= transposeCoeficient 2 ) #{$note \transpose c d { $note }#} )
((= transposeCoeficient 3 ) #{$note \transpose c ees { $note }#} )
((= transposeCoeficient 4 ) #{$note \transpose c e { $note }#} )
((= transposeCoeficient 5 ) #{$note \transpose c f { $note }#} )
((= transposeCoeficient 6 ) #{$note \transpose c fis { $note }#} )
((= transposeCoeficient 7 ) #{$note \transpose c g { $note }#} )
((= transposeCoeficient 8 ) #{$note \transpose c aes { $note }#} )
((= transposeCoeficient 9 ) #{$note \transpose c a { $note }#} )
((= transposeCoeficient 10 ) #{$note \transpose c bes { $note }#} )
((= transposeCoeficient 11 ) #{$note \transpose c b { $note }#} )
((= transposeCoeficient 12 ) #{$note \transpose c c' { $note }#} )
   ) ; end pre cond parenthesis
) ; end of function block
) % end of function
\score {\relative c' {\someFunction c #12 }}
%%
%%CODE ENDS

Em qui., 20 de mar. de 2025 às 04:32, Lukas-Fabian Moser <l...@gmx.de>
escreveu:

> Hi Lucas,
>
> this sounds absolutely possible, but can you please give more details or -
> better still - an example of what you want to achieve?
>
> Lukas
>
> Lucas Cavalcanti <lucaspi...@gmail.com> schrieb am Do., 20. März 2025,
> 02:05:
>
>> Hello! I'm in need of help in regards to writing a music function that
>> has conditions inside it: I need my argument (a number between 1 to 12) to
>> be evaluated by an if statement, so that it can run "\transpose c
>> someNote". This function would reduce a lot of code to a project of mine.
>> I've only found one Stack Exchange post
>> <https://music.stackexchange.com/questions/124792/using-conditionals-in-lilypond-scheme-functions>
>> but it uses #define-scheme-function, something of which I don't know if it
>> affects the function or not.
>>
>

Reply via email to