


Print ("target note not in specified range.") Transposed_note = starting_pitch + (octave_delta_from_bottom *12) If octave_delta_from_bottom = octave_delta_from_top: Octave_delta_from_top = (-(starting_pitch - top_of_range)) // 12 Octave_delta_from_bottom = -((starting_pitch - bottom_of_range) // 12) Starting_pitch = 67 # these values are just examplesīottom_of_range = 48 # 'c' in Lilypond, C below middle C
#Lilypond transpose code#
Here's Python code implementing that logic, based on numeric values for pitches: # find same note at a different octave, ie in specified range A condition is involved, but not the one I originally imagined.
#Lilypond transpose series#
I can imagine a fairly general approach that takes any specified note in a series as the reference point for the up/down decision, but for this purpose the reference note will always be the first one in the chord, for example the c in the C major triad.Įdit/addition: Since I first posted, I've figured out working logic for transposing to a range. ):Ĭ.tmpdocument.ly:7:3: Wrong type argument in position 1 (expecting Prob): from-to Parsing.C.tmpdocument.ly:7:3: In procedure ly:music-set-property! in expression ((setter ly:music-property) (quote from-to) music. To be clear, since I can't follow the Scheme in that link, I'm not sure how – or if – the code is relevant to my problem, other than that both involve some sort of conditional transposition. And it gave me an error when I tried to run it using the sample LilyPond music passage ("input") (see below). There is one discussion of conditional transposing I found via a Google search but the Scheme code is opaque to me-with the sparse comments I can't even understand what the original poster was trying to accomplish, much less the proposed solution. I can't find any relevant snippets in the LilyPond snippet library.
#Lilypond transpose free#
Please feel free to improve on/simplify this description of what I'm looking for. In the typical case, you want a chord voicing that is not too low to be muddy, but as low as you can get it so it stays more or less out of the way of the melody. The reference note is the only one that must fall in the specified range. The result would be that the entire chunk – including the reference note and all the other notes therein – would be transposed by the same amount and in the same direction. LilyPond/Scheme would take over to figure out the details of the \transpose command, up or down by how many octaves, and would apply that command to the entirety of the original subject 'chunk' of music. I just want to pick a note in the chord/music as the reference note, choose a transposition key/note name, and define a range into which the transposed note must fall after transposition. This would require some sort of conditional (in concept, something like: "try transposing the chord down if the lowest note of the downward transposition is too low, transpose up").Īdded to clarify (?) the goal: Typically chord voicings are fairly tight, with separations between the notes of no more than a 6th and usually less, but the solution shouldn't be based on the distance (or any other relationship) between the notes being transposed. Use case: I want to make a set of chord voicings, each in multiple transpositions, with the lowest note of each transposed voicing always within a specified octave, say between c and b (the octave below middle C in LilyPond notation). In version 2.19.x, how can I make LilyPond decide whether – and by how much – to transpose up or down, depending on a target octave/range for one of the transposed notes (I'll call that note the "reference note")?Īll the other notes are to be transposed in the same direction and by the same amount as the reference note, so a single LilyPond \transpose command will handle all of the transposed music.
