> . . . I am currently writing a program that transforms scores expressed > in a piano-roll-like format into LilyPond scores . . .
> I'm especially thinking of how to resolve a note like "c3" (where 3 > means 3 quarter note beats) into Lilypond's "c2." . . . in this case, > the input data is mostly "clean" . . . If the data isn't _all_ clean, then that will be your biggest headache. You have received some suggestions that you write your program to convert your source files into MIDI format; that's presumably a good idea if you already know the syntax & semantics of MIDI files. Is the unit of measurement of note durations in the source _always_ a quarter note? If it is, that'll save you some trouble. If you don't go the MIDI route and you decide to write a program to convert directly to LilyPond, then I have one suggestion. If you choose to write a (calculational) algorithm to convert your source "c3" to LilyPond "c2.", then you will spend a long time writing and debugging the algorithm. But if you look over your source files and find that the actual number of different note-durations is small (less than a dozen different durations, say), then it will be much easier to just construct, by brute force, two string vectors -- S(1)="1" LP(1)="4" S(2)="2" LP(2)="2" S(3)="3" LP(3)="2." S(4)="4" LP(4)="1" S(5)="1/2" LP(5)="8" % I don't know source notation for short notes S(6)="3/4" LP(6)="8." % ditto etc. so you could search the S( ) vector for each source-note duration; if S(3) matched the source duration, then LP(3) would give the LilyPond duration. This of course does not solve the problem that probably some of your source notes will have durations exceeding 4 (i.e., will represent notes longer than a whole note). If the source duration SD of a note is greater than 4, you will need to calculate SD div 4 = the number of whole notes you will need to tie together SD mod 4 = the source-duration of the additional note you will have to tie onto the preceding string of tied whole notes; you will have to find n such that S(n)=SD mod 4 to obtain LP(n), where LP(n) is the LilyPond duration of this final tied note. And as others have pointed out, you will have to use the Completion_Heads_Engraver (user manual section 6.2.6). There are other complications: (a) Tuplets: modifying the procedure I sketched above to handle tuplets would be very hard. *And* the Completion_Head_Engraver apparently (?) is not able to handle tuplets anyway. (b) The Completion_Head_Engraver can't split rests at all, according to the user manual; that may be a fatal problem. Now that I look at it, that's all pretty awful, isn't it? Probably you would be better off learning how to construct MIDI files (something I've never done...). -- Tom _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user