Can arbitrary text strings be embedded in the MIDI output?
I notice that when I use timidity to play a MIDI file generated by LilyPond, it prints: Text: creator: Text: LilyPond 2.24.2 and also "Sequence:", "Instrument:" "Track name:" and, if I use \sectionLabel, the label text gets shown as "([label])". Can I include my own text strings in the generated MIDI?
Re: Conditional code in the midi block
Thank you all for your suggestions. I finally have the flag working after years of just editing my master file when I wanted one track per voice! Thanks, Carolyn > On May 20, 2024, at 6:09 AM, Jean Abou Samra wrote: > > >> nostaffmidi = >> #(define-scheme-function () () >> (if TrackPerVoice #{ \context { \Staff \remove "Staff_performer" } #})) > > > Ah, that proves me wrong. I didn't recall the parser was smart enough for > this. > > >> Although, I don't understand why the contents of the scheme functions cannot >> be placed directly into the midi block like this >> >> \midi { >> #(if TrackPerVoice #{ \context { \Staff \remove "Staff_performer" } #}) >> #(if TrackPerVoice #{ \context { \Voice \consists "Staff_performer" } #}) >> } > > > It works with $ instead of # , as explained in my other post. > > >
Re: Conditional code in the midi block
Jean Abou Samra writes: > Alternatively, you can do it more like you were envisioning, but for > technical reasons, you have to start the Scheme code with $ , not # , > and you also have to include an extra \midi { } around the \context > blocks (basically because \context outside \layout or \midi is a > different command). > The # vs $ issue is explained here: > https://extending-lilypond.gitlab.io/en/extending/lily-and-scheme.html#hash-vs-dollar No, it isn't. What happens here is actually not as much a "technical reason" as a design decision. The difference between $ and # explained in the manual entry is orthogonal to it. Here is the rundown: $ produces a token category based on the type of the expression. That means that the type of the expression can change the way the parser parses an expression, and that can be important since the parser may use lookahead to make its decisions, and that may mean that the type of the token (and thus the underlying expression) may need to be known before the previous expression is given its place in the grammar. # does produce a single token category. That means that the parsing can go ahead without even knowing the value of the expression, and the expression is only evaluated once its value is actually needed, making for more predictable evaluation order. That much is sort of in the manual. But what isn't there is that whenever # is going to be accepted, there must be an explicit rule in the grammar accepting it, and that essentially means that when that rule is considered applicable, the grammar is fixed. That still is sort of in the manual. But here is where the design decision comes into play: Scheme may be executed for the purpose of creating a side effect, like assigning a value to a variable. When a Scheme function is being called, it doesn't know whether its return value is going to get used for anything, and a Scheme function executed for its side effect may or may not return a meaningful value. The most prominent side effect is a variable assignment. So as kind of a design rule, at any place in the grammar where you could conceivably write an assignment, the value returned by #... is getting ignored because the expression may only have been called for its side effect, like an assigment. Now $ should never be called just for a side effect (because it is kind of a sledgehammer you should not be using unnecessarily). Function calls introduced by \ are explicitly declared to be of the kind where LilyPond knows when it is supposed to be using the return value. And calling a variable by its name \... does not cause a side effect, so it is safe to assume that you are not invoking its name for the purpose of getting a side effect. So this "I am ignoring the result in contexts where assignments may occur" rule only is made to affect # as a way of invoking Scheme expressions. Where and how should we document/put this rationale so that future contributors and power users are able to understand the current behavior and make qualified decisions about future behavior? I am not sold on this being the best/simplest/most logical that LilyPond can be made to behave. But at the current point of time, I don't know how to do better. And when someone wants to change it, I'd like them to be aware of the rationale behind the current behavior. -- David Kastrup
Re: Conditional code in the midi block
Am So., 19. Mai 2024 um 21:28 Uhr schrieb Carolyn Beeton : > > I would like to include some Staff and Voice context settings in the \midi > block only if a flag is set to ##t and I have not been able to figure out how > to do this. When I try to wrap the \context blocks in a code block with > #{…#} I get this error: > trackPerVoiceMWE.ly:31:16: error: syntax error, unexpected '{', expecting > SCM_IDENTIFIER or SCM_TOKEN or STRING or SYMBOL > \context { > Is there any way to conditionally change the Staff_performer based on a flag > setting? > > This is my non-working MWE: > > \version "2.24.0" > \include "english.ly" > > global = { > \key c \major > \time 4/4 > } > TrackPerVoice = ##t > \score { > \new ChoirStaff << > \new Staff << > \new Voice = "soprano" << > \global > \relative c' { c'4 d e f << g1 \\ { g4 f e2 } >> } > >> > \new Voice = "alto" << > \global > \voiceTwo > \relative c' { c'4 b a g | f e d2 } > >> > >> > >> > \layout {} > \midi { > #(display (format #f "TrackPerVoice is ~a\n" TrackPerVoice)) > #(if TrackPerVoice #{ > #(display "One track per Voice (may make too many voices with > polyphony)") > #(display "Turn this off to get sop and alto combined in one track.") > \context { > \Staff > \remove "Staff_performer" > } > \context { > \Voice > \consists "Staff_performer" > } > #} ) > } > } > > Thanks, > Carolyn Here my take on this. Modeled after `enablePolymeter`. Prpbably overkill, though... \version "2.24.3" enableVoicePerformer = #(define-void-function (do-it) (boolean?) (when do-it (display "One track per Voice (may make too many voices with polyphony)") (display "Turn this off to get sop and alto combined in one track.") (let ((module (current-module)) (cmod-remove (ly:make-context-mod)) (cmod-consists (ly:make-context-mod))) (if (not (output-module? module)) (ly:parser-error (G_ "Not in an output definition"))) (ly:add-context-mod cmod-remove (list 'remove 'Staff_performer)) (ly:add-context-mod cmod-consists (list 'consists 'Staff_performer)) ;; FIXME: any chance to use ly:output-find-context-def here? The ;; problem is that we don't have access to the context def, just ;; its scope (module). (module-map (lambda (_sym var) (if (variable-bound? var) (let ((cdef (variable-ref var))) (if (ly:context-def? cdef) (let* ((context-name (ly:context-def-lookup cdef 'context-name)) (aliases (ly:context-def-lookup cdef 'aliases)) (all-names (cons context-name aliases))) (cond ((memq 'Staff all-names) (variable-set! var (ly:context-def-modify cdef cmod-remove))) ((memq 'Voice all-names) (variable-set! var (ly:context-def-modify cdef cmod-consists) module global = { \key c \major \time 4/4 } TrackPerVoice = ##t \score { \new ChoirStaff << \new Staff \with { midiInstrument = "acoustic grand" } << \new Voice = "soprano" \with { midiInstrument = "marimba" } << \global \relative c' { c'4 d e f << g1 \\ { g4 f e2 } >> } >> \new Voice = "alto" \with { midiInstrument = "violin" } << \global \voiceTwo \relative c' { c'4 b a g | f e d2 } >> >> >> \layout {} \midi { \enableVoicePerformer \TrackPerVoice } } Cheers, Harm
Re: Conditional code in the midi block
> nostaffmidi = > #(define-scheme-function () () >(if TrackPerVoice #{ \context { \Staff \remove "Staff_performer" } #})) Ah, that proves me wrong. I didn't recall the parser was smart enough for this. > Although, I don't understand why the contents of the scheme functions cannot > be placed directly into the midi block like this > > \midi { > #(if TrackPerVoice #{ \context { \Staff \remove "Staff_performer" } #}) > #(if TrackPerVoice #{ \context { \Voice \consists "Staff_performer" } #}) > } It works with $ instead of # , as explained in my other post. signature.asc Description: This is a digitally signed message part
Re: Conditional code in the midi block
> I would like to include some Staff and Voice context settings in the > \midi block only if a flag is set to ##t and I have not been able to > figure out how to do this. When I try to wrap the \context blocks > in a code block with #{…#} I get this error: > trackPerVoiceMWE.ly:31:16: error: syntax error, unexpected '{', expecting > SCM_IDENTIFIER or SCM_TOKEN or STRING or SYMBOL > \context { Probably the easiest way is to include or exclude a whole \midi block like this: \version "2.24.0" \include "english.ly" global = { \key c \major \time 4/4 } TrackPerVoice = ##t \score { \new ChoirStaff << \new Staff << \new Voice = "soprano" << \global \relative c' { c'4 d e f << g1 \\ { g4 f e2 } >> } >> \new Voice = "alto" << \global \voiceTwo \relative c' { c'4 b a g | f e d2 } >> >> >> \layout { } #(if TrackPerVoice (begin (display "One track per Voice (may make too many voices with polyphony)") (display "Turn this off to get sop and alto combined in one track.") #{ \midi { \context { \Staff \remove "Staff_performer" } \context { \Voice \consists "Staff_performer" } } #}) #{ \midi { } #}) } Alternatively, you can do it more like you were envisioning, but for technical reasons, you have to start the Scheme code with $ , not # , and you also have to include an extra \midi { } around the \context blocks (basically because \context outside \layout or \midi is a different command). \version "2.24.0" \include "english.ly" global = { \key c \major \time 4/4 } TrackPerVoice = ##t \score { \new ChoirStaff << \new Staff << \new Voice = "soprano" << \global \relative c' { c'4 d e f << g1 \\ { g4 f e2 } >> } >> \new Voice = "alto" << \global \voiceTwo \relative c' { c'4 b a g | f e d2 } >> >> >> \layout { } \midi { $(if TrackPerVoice (begin (display "One track per Voice (may make too many voices with polyphony)") (display "Turn this off to get sop and alto combined in one track.") #{ \midi { \context { \Staff \remove "Staff_performer" } \context { \Voice \consists "Staff_performer" } } #})) } } The # vs $ issue is explained here: https://extending-lilypond.gitlab.io/en/extending/lily-and-scheme.html#hash-vs-dollar HTH Jean signature.asc Description: This is a digitally signed message part
Re: Conditional code in the midi block
On 19/05/2024 20:27, Carolyn Beeton wrote: I would like to include some Staff and Voice context settings in the \midi block only if a flag is set to ##t and I have not been able to figure out how to do this. When I try to wrap the \context blocks in a code block with #{…#} I get this error: trackPerVoiceMWE.ly:31:16: error: syntax error, unexpected '{', expecting SCM_IDENTIFIER or SCM_TOKEN or STRING or SYMBOL \context { Is there any way to conditionally change the Staff_performer based on a flag setting? I think this does what you want. \version "2.24.0" \include "english.ly" TrackPerVoice = ##t nostaffmidi = #(define-scheme-function () () (if TrackPerVoice #{ \context { \Staff \remove "Staff_performer" } #})) voicemidi = #(define-scheme-function () () (if TrackPerVoice #{ \context { \Voice \consists "Staff_performer" } #})) global = { \key c \major \time 4/4 } \score { \new ChoirStaff << \new Staff << \new Voice = "soprano" << \global \relative c' { c'4 d e f << g1 \\ { g4 f e2 } >> } >> \new Voice = "alto" << \global \voiceTwo \relative c' { c'4 b a g | f e d2 } >> >> >> \layout {} \midi { #(ly:message "TrackPerVoice is ~a\n" TrackPerVoice) #(when TrackPerVoice (ly:message "One track per Voice (may make too many voices with polyphony)") (ly:message "Turn this off to get sop and alto combined in one track.")) \nostaffmidi \voicemidi } Although, I don't understand why the contents of the scheme functions cannot be placed directly into the midi block like this \midi { #(if TrackPerVoice #{ \context { \Staff \remove "Staff_performer" } #}) #(if TrackPerVoice #{ \context { \Voice \consists "Staff_performer" } #}) } -- Timothy Lanfear, Bristol, UK.
Conditional code in the midi block
I would like to include some Staff and Voice context settings in the \midi block only if a flag is set to ##t and I have not been able to figure out how to do this. When I try to wrap the \context blocks in a code block with #{…#} I get this error: trackPerVoiceMWE.ly:31:16: error: syntax error, unexpected '{', expecting SCM_IDENTIFIER or SCM_TOKEN or STRING or SYMBOL \context { Is there any way to conditionally change the Staff_performer based on a flag setting? This is my non-working MWE: \version "2.24.0" \include "english.ly" global = { \key c \major \time 4/4 } TrackPerVoice = ##t \score { \new ChoirStaff << \new Staff << \new Voice = "soprano" << \global \relative c' { c'4 d e f << g1 \\ { g4 f e2 } >> } >> \new Voice = "alto" << \global \voiceTwo \relative c' { c'4 b a g | f e d2 } >> >> >> \layout {} \midi { #(display (format #f "TrackPerVoice is ~a\n" TrackPerVoice)) #(if TrackPerVoice #{ #(display "One track per Voice (may make too many voices with polyphony)") #(display "Turn this off to get sop and alto combined in one track.") \context { \Staff \remove "Staff_performer" } \context { \Voice \consists "Staff_performer" } #} ) } } Thanks, Carolyn
Re: Key signatures in MIDI output
Yes - that would be the way to go. However, the midi notes will play correctly anyway, and the Lilypond output is far better than the staff view in my sequencer. There is even a virtue to it as when I am playing along to the sequencer and I forget what key I am playing in, all my sharps and flats will be right there for me to see. I have actually found myself wishing for this on occasion, so all is well. From: David Kastrup Sent: 14 May 2024 19:33 To: Giles Boardman Cc: msk...@ansuz.sooke.bc.ca ; lilypond-user@gnu.org Subject: Re: Key signatures in MIDI output Giles Boardman writes: > Hello, > > I have figured "it" out - Cakewalk expects Key Signature to be in > Track 0 of a Midi file and Lilypond puts it in whichever track has it > in, which is much more sensible. I realized this while compiling the > cry for help below, so I've left my workings out in the message, but > that seems to be the long and short of it. Using a tool to convert the MIDI file to format 0 (or what it was called) might help? -- David Kastrup
Re: Key signatures in MIDI output
Giles Boardman writes: > Hello, > > I have figured "it" out - Cakewalk expects Key Signature to be in > Track 0 of a Midi file and Lilypond puts it in whichever track has it > in, which is much more sensible. I realized this while compiling the > cry for help below, so I've left my workings out in the message, but > that seems to be the long and short of it. Using a tool to convert the MIDI file to format 0 (or what it was called) might help? -- David Kastrup
Re: Key signatures in MIDI output
Hello, I have figured "it" out - Cakewalk expects Key Signature to be in Track 0 of a Midi file and Lilypond puts it in whichever track has it in, which is much more sensible. I realized this while compiling the cry for help below, so I've left my workings out in the message, but that seems to be the long and short of it. Thanks for everyone's support. Best Giles Here is an example of my input/output: I create this by reading output from MIDIDSM which disassembles MIDI files and outputs text which I manipulate into the Lilypond code below. I can't with certainty provide the original source file, but it is not part of the workflow in question - it provided \key d\major \time 6/8 This is not the only way I get data into Lilypond - as previously mentioned, I also import using Frescobaldi, but it's what happens on the way out, I am trying to figure out. When I run the snippet .. \version "2.18.2" \score { { \mark "Boore's Dance" \key d\major \time 6/8 a''4. g''4 d''8 g''8 e''4. fis''4 a''4. fis''4 d''8 g''4 e''8 d''4. \bar ".." } \layout { } \midi { } } I get [cid:82b004c6-1e2c-4107-8b76-af84dd4b4476] and a .MID that looks like this when I open it in Cakewalk without any further processing. [cid:68c9f205-686b-4668-b485-006aaf8495cf] Interestingly, my new installation (about a week old) on Windows 11, produces a file showing the \mark as a marker in Cakewalk, but still without the Key Sig. ... and produces this when processed by MIDIDSM with the options to export TIme/Key Sigs ticked .. [cid:e9904548-372b-4782-9068-8348b490ab60] MThd | Format=1 | # of Tracks=2 | Division=384 Track #0 ** Time Event 1: 1: 0 |Time Sig | 6/8 | MIDI-clocks\click=18 | 32nds\quarter=8 |End of track| Track #1 ** Time Event 1: 1: 0 |Key Sig | D Major | |On Note | chan= 1 | pitch=A 4 | vol=90 4: 0 |(Off) Note | chan= 1 | pitch=a 4 followed by lots more Notes On/Off until |End of track| I just noticed this, because I ran David Wright's midi file through MIDIDSM and the Key Sigs stand out because there's more than one. So, Cakewalk expects Key Signatures in Track #0 and Lilypond doesn't put them there and how data is brought into Lilypond won't change that. From: David Kastrup Sent: 11 May 2024 20:22 To: Giles Boardman Cc: msk...@ansuz.sooke.bc.ca ; lilypond-user@gnu.org Subject: Re: Key signatures in MIDI output Giles Boardman writes: > You are, of course, right. Your evidence is clear. The position of the \key > command seems a strong candidate but I can't get it into the .MID even in the > simplest of snippet. > > As I mentioned I also have other behaviour I can't explain so it could also > be version related. I reinstalled the latest version I could find before the > release date of Windows 10, but it hasn't changed anything. I prefer to keep > my music-related work on a Windows 8.1 machine but that can change . > > What I am trying to do is this: > > I have a big "library" of small, simple tunes that are variables, named for > their name and reference. > I have "compiled" the library and found errors, which I have corrected. > Now I can create medleys and audition them much more quickly than otherwise > possible by referring to the pieces by their variable name. > Like this . > > \version "2.18.2" > % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly" > % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly" > > "1K002-1a-_WILLIE_SHAW" = { \mark "1K002-1a-" \time 4/4 \key d\major { \time > 1/8 \partial 8 g''8 \time 4/4 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. > d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 > \time 7/8 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } } > \score { > { > \key d\major > \"1K002-1a-_WILLIE_SHAW" > } > > \layout { } > > \midi { } > } Filename: /tmp/xxx.midi MIDI format: 1 (one or more simultaneous tracks) Divisions:1536 per whole note #Tracks: 2 Track 1: Time 0: Text: creator: Text: LilyPond 2.25.12 Time signature: 1/8, metronome 1/8 Marker: 1K002-1a- Tempo: 100 msec/quarter Time 192: Time signature: 4/4, metronome 1/4 Time 4800: Time signature: 7/8, metronome 1/8 Time 6144: End of Track Track 2: Time 0: Track name: \new: Key signature: D major Note on: Channel 0, G5(79)@90 Time 192: Note off: Channel 0, G5(79) Note on: Channel 0, Fis5(78)@90 Time 288: N
Re: Can I output PNG and midi from the same file?
Yes, this fixes the problem! By adding \layout {} inside my \score next to \midi I now get both outputs. Thank you. From: William Rehwinkel Sent: Sunday, May 12, 2024 9:22 PM To: Peter Baughman; lilypond-user@gnu.org Subject: Re: Can I output PNG and midi from the same file? Dear Peter, Assuming you wrote something like % - \version "2.25.7" \score { c'4 \midi {} } % - and then ran lilypond --PNG midi.ly, then there would be no PNG output. This is because if you only include the \midi block, then lilypond produces no visual output at all. But if you don't include either \layout or \midi then lilypond defaults to visual output only. If you add \layout {} next to \midi {} then it should produce both visual and midi output. Thanks, -William On 5/12/24 23:21, Peter Baughman wrote: > Greetings, > > I have a few .ly files that work great and produce lovely pictures when > I build then with a command like: > > |lilypond --png my_song.ly| > > I started to play around with midi output and was a little suprised to > find that I needed to add a \midi code block to my file (instead of some > other command-line flag when building) but this was not a big deal - > After 20 or 30 minutes I figured out how to do it and got some lovely > sound output. > > I was surprised, though to discover that when I built my songs they were > no longer producing png output. > > Is there a way to get both PNG and midi output from the same .ly file, > or do I need to invent some preprocessor step that adds a |\midi| block > to a file or perhaps removes one from a file to get png output? > > Thank you, > Pete Baughman -- William Rehwinkel - Oberlin College and Conservatory '24 will...@williamrehwinkel.net PGP key: https://ftp.williamrehwinkel.net/pubkey.txt
Re: Can I output PNG and midi from the same file?
On Mon 13 May 2024 at 03:21:35 (+), Peter Baughman wrote: > I have a few .ly files that work great and produce lovely pictures when I > build then with a command like: > > lilypond --png my_song.ly > > I started to play around with midi output and was a little suprised to find > that I needed to add a \midi code block to my file (instead of some other > command-line flag when building) but this was not a big deal - After 20 or 30 > minutes I figured out how to do it and got some lovely sound output. > > I was surprised, though to discover that when I built my songs they were no > longer producing png output. > > Is there a way to get both PNG and midi output from the same .ly file, or do > I need to invent some preprocessor step that adds a \midi block to a file or > perhaps removes one from a file to get png output? In the absence of both \layout { } and \midi { }, LP produces a score. If you add a \midi { } and you still want a score, you must add a \layout { } too. Cheers, David.
Re: Can I output PNG and midi from the same file?
Dear Peter, Assuming you wrote something like % - \version "2.25.7" \score { c'4 \midi {} } % - and then ran lilypond --PNG midi.ly, then there would be no PNG output. This is because if you only include the \midi block, then lilypond produces no visual output at all. But if you don't include either \layout or \midi then lilypond defaults to visual output only. If you add \layout {} next to \midi {} then it should produce both visual and midi output. Thanks, -William On 5/12/24 23:21, Peter Baughman wrote: Greetings, I have a few .ly files that work great and produce lovely pictures when I build then with a command like: |lilypond --png my_song.ly| I started to play around with midi output and was a little suprised to find that I needed to add a \midi code block to my file (instead of some other command-line flag when building) but this was not a big deal - After 20 or 30 minutes I figured out how to do it and got some lovely sound output. I was surprised, though to discover that when I built my songs they were no longer producing png output. Is there a way to get both PNG and midi output from the same .ly file, or do I need to invent some preprocessor step that adds a |\midi| block to a file or perhaps removes one from a file to get png output? Thank you, Pete Baughman -- William Rehwinkel - Oberlin College and Conservatory '24 will...@williamrehwinkel.net PGP key: https://ftp.williamrehwinkel.net/pubkey.txt OpenPGP_signature.asc Description: OpenPGP digital signature
Can I output PNG and midi from the same file?
Greetings, I have a few .ly files that work great and produce lovely pictures when I build then with a command like: lilypond --png my_song.ly I started to play around with midi output and was a little suprised to find that I needed to add a \midi code block to my file (instead of some other command-line flag when building) but this was not a big deal - After 20 or 30 minutes I figured out how to do it and got some lovely sound output. I was surprised, though to discover that when I built my songs they were no longer producing png output. Is there a way to get both PNG and midi output from the same .ly file, or do I need to invent some preprocessor step that adds a \midi block to a file or perhaps removes one from a file to get png output? Thank you, Pete Baughman
Re: Key signatures in MIDI output
On Sat 11 May 2024 at 15:14:47 (+), Giles Boardman wrote: > You are, of course, right. Your evidence is clear. The position of the \key > command seems a strong candidate but I can't get it into the .MID even in the > simplest of snippet. > > As I mentioned I also have other behaviour I can't explain so it could also > be version related. I reinstalled the latest version I could find before the > release date of Windows 10, but it hasn't changed anything. I prefer to keep > my music-related work on a Windows 8.1 machine but that can change . > > What I am trying to do is this: > > I have a big "library" of small, simple tunes that are variables, named for > their name and reference. > I have "compiled" the library and found errors, which I have corrected. > Now I can create medleys and audition them much more quickly than otherwise > possible by referring to the pieces by their variable name. > Like this . > > \version "2.18.2" > % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly" > % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly" > > "1K002-1a-_WILLIE_SHAW" = { \mark "1K002-1a-" \time 4/4 \key d\major { \time > 1/8 \partial 8 g''8 \time 4/4 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. > d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 > \time 7/8 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } } > \score { > { > \key d\major > \"1K002-1a-_WILLIE_SHAW" > } > > \layout { } > > \midi { } > } [ … ] Perhaps it's time for you to attach some evidence in the form of a MIDI file that you have produced. You might also attach the .ly file that you obtain by "importing" my attached MIDI file into LilyPond (through whatever process you habitually use). AFAICT, the other people in this thread are decoding MIDI files that they themselves generated. Cheers, David. ksigm.midi Description: audio/sp-midi
Re: Key signatures in MIDI output
Giles Boardman writes: > You are, of course, right. Your evidence is clear. The position of the \key > command seems a strong candidate but I can't get it into the .MID even in the > simplest of snippet. > > As I mentioned I also have other behaviour I can't explain so it could also > be version related. I reinstalled the latest version I could find before the > release date of Windows 10, but it hasn't changed anything. I prefer to keep > my music-related work on a Windows 8.1 machine but that can change . > > What I am trying to do is this: > > I have a big "library" of small, simple tunes that are variables, named for > their name and reference. > I have "compiled" the library and found errors, which I have corrected. > Now I can create medleys and audition them much more quickly than otherwise > possible by referring to the pieces by their variable name. > Like this . > > \version "2.18.2" > % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly" > % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly" > > "1K002-1a-_WILLIE_SHAW" = { \mark "1K002-1a-" \time 4/4 \key d\major { \time > 1/8 \partial 8 g''8 \time 4/4 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. > d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 > \time 7/8 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } } > \score { > { > \key d\major > \"1K002-1a-_WILLIE_SHAW" > } > > \layout { } > > \midi { } > } Filename: /tmp/xxx.midi MIDI format: 1 (one or more simultaneous tracks) Divisions:1536 per whole note #Tracks: 2 Track 1: Time 0: Text: creator: Text: LilyPond 2.25.12 Time signature: 1/8, metronome 1/8 Marker: 1K002-1a- Tempo: 100 msec/quarter Time 192: Time signature: 4/4, metronome 1/4 Time 4800: Time signature: 7/8, metronome 1/8 Time 6144: End of Track Track 2: Time 0: Track name: \new: Key signature: D major Note on: Channel 0, G5(79)@90 Time 192: Note off: Channel 0, G5(79) Note on: Channel 0, Fis5(78)@90 Time 288: Note off: Channel 0, Fis5(78) Note on: Channel 0, D5(74)@90 Time 576: Note off: Channel 0, D5(74) Note on: Channel 0, B4(71)@90 Time 864: Note off: Channel 0, B4(71) Note on: Channel 0, D5(74)@90 Time 960: Note off: Channel 0, D5(74) Note on: Channel 0, A4(69)@90 Time 1344: Note off: Channel 0, A4(69) Note on: Channel 0, Fis4(66)@90 Time 1728: Note off: Channel 0, Fis4(66) Note on: Channel 0, Fis4(66)@90 Time 1824: Note off: Channel 0, Fis4(66) Note on: Channel 0, A4(69)@90 Time 2112: Note off: Channel 0, A4(69) Note on: Channel 0, D5(74)@90 Time 2400: Note off: Channel 0, D5(74) Note on: Channel 0, Fis5(78)@90 Time 2496: Note off: Channel 0, Fis5(78) Note on: Channel 0, G5(79)@90 Time 2592: Note off: Channel 0, G5(79) Note on: Channel 0, E5(76)@90 Time 2880: Note off: Channel 0, E5(76) Note on: Channel 0, E5(76)@90 Time 3168: Note off: Channel 0, E5(76) Note on: Channel 0, G5(79)@90 Time 3264: Note off: Channel 0, G5(79) Note on: Channel 0, Fis5(78)@90 Time 3360: Note off: Channel 0, Fis5(78) Note on: Channel 0, D5(74)@90 Time 3648: Note off: Channel 0, D5(74) Note on: Channel 0, B4(71)@90 Time 3936: Note off: Channel 0, B4(71) Note on: Channel 0, D5(74)@90 Time 4032: Note off: Channel 0, D5(74) Note on: Channel 0, A4(69)@90 Time 4416: Note off: Channel 0, A4(69) Note on: Channel 0, Fis4(66)@90 Time 4800: Note off: Channel 0, Fis4(66) Note on: Channel 0, Fis4(66)@90 Time 4896: Note off: Channel 0, Fis4(66) Note on: Channel 0, A4(69)@90 Time 5184: Note off: Channel 0, A4(69) Note on: Channel 0, D5(74)@90 Time 5472: Note off: Channel 0, D5(74) Note on: Channel 0, E5(76)@90 Time 5568: Note off: Channel 0, E5(76) Note on: Channel 0, Fis5(78)@90 Time 5664: Note off: Channel 0, Fis5(78) Note on: Channel 0, D5(74)@90 Time 5952: Note off: Channel 0, D5(74) Note on: Channel 0, D5(74)@90 Time 6144: Note off: Channel 0, D5(74) End of Track As you can see, the key signature is right with the content track (track 2) and right at the start. You really need to figure out which part of your processing then loses it. -- David Kastrup
Re: Key signatures in MIDI output
You are, of course, right. Your evidence is clear. The position of the \key command seems a strong candidate but I can't get it into the .MID even in the simplest of snippet. As I mentioned I also have other behaviour I can't explain so it could also be version related. I reinstalled the latest version I could find before the release date of Windows 10, but it hasn't changed anything. I prefer to keep my music-related work on a Windows 8.1 machine but that can change . What I am trying to do is this: I have a big "library" of small, simple tunes that are variables, named for their name and reference. I have "compiled" the library and found errors, which I have corrected. Now I can create medleys and audition them much more quickly than otherwise possible by referring to the pieces by their variable name. Like this . \version "2.18.2" % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly" % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly" "1K002-1a-_WILLIE_SHAW" = { \mark "1K002-1a-" \time 4/4 \key d\major { \time 1/8 \partial 8 g''8 \time 4/4 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 \time 7/8 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } } \score { { \key d\major \"1K002-1a-_WILLIE_SHAW" } \layout { } \midi { } } or without the variable, but with the includes activated - the first one contains "1K002-1a-_WILLIE_SHAW" and its notes etc. I have also explicitly pasted the notes into the score: \version "2.18.2" % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly" % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly" \score { { \mark "1K002-1a-" { \time 4/4 \key d\major \time 1/8 \partial 8 g''8 \time 4/4 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 \time 7/8 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } } } \layout { } \midi { } } With and without the braces and with and without my \time to mimic anacrusis for the benefit of Cakewalk - ideally, I'd like to hide them but haven't figured that out. Lastly, I've taken all the \key and \time out of the explicit notes \version "2.18.2" % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly" % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly" \score { \time 4/4 \key d\major { \mark "1K002-1a-" { \partial 8 g''8 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } } } \layout { } \midi { } } I read that SectionLabel and other marks are supported in MIDI output, but I can't get Section Label to work at all, and my \mark doesn't come through and neither does the default rehearsal mark, which appears in the layout. I've also failed in other attempts to get the same effect by other means (not necessarily for MIDI) like instrumentName = Thanks again for your support. From: msk...@ansuz.sooke.bc.ca Sent: 11 May 2024 15:46 To: Giles Boardman Cc: Hans Åberg ; lilypond-user@gnu.org Subject: Re: Key signatures in MIDI output On Sat, 11 May 2024, Giles Boardman wrote: > I have now been more systematic in my approach and conclude that \key is not > reflected in MIDI output. I tried various positions for events and in each Well, it definitely is reflected in the output in my own tests. The example code I posted, when run through Lilypond 2.24.1, produces a MIDI file containing key change events. There may be some relevant distinctions in terms of which version of Lilypond you're running and exactly where you put the \key commands in the input. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
On Sat, 11 May 2024, Giles Boardman wrote: > I have now been more systematic in my approach and conclude that \key is not > reflected in MIDI output. I tried various positions for events and in each Well, it definitely is reflected in the output in my own tests. The example code I posted, when run through Lilypond 2.24.1, produces a MIDI file containing key change events. There may be some relevant distinctions in terms of which version of Lilypond you're running and exactly where you put the \key commands in the input. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
msk...@ansuz.sooke.bc.ca writes: > On Sat, 11 May 2024, Giles Boardman wrote: > >> When I create MIDI output from Lilypond, if I have imported a MIDI file and >> then resaved it with changes made in LilyPond, the output is like that, too. > > Lilypond as such does not import MIDI files. I think you must be using > some piece of software other than Lilypond, and that is relevant to the > issues you're experiencing. > > On the off chance that you might be using midi2ly, I tried round-tripping > my example code through that, and got suggestive results. A good viewer of MIDI file content is lilymidi --pretty followed by the MIDI file name on the command line. -- David Kastrup
Re: Key signatures in MIDI output
Thank you for your efforts, Matt, and everyone else who has spent any time looking into this. To answer Matt, I did use Midi2ly by way of Frescobaldi and I must also have previously found a way to run a command line batch (if only a repetitive list) because I have way to many files to have done it manually and they don't have names I would have chosen. I absolutely understand that LilyPond is not intended as a MIDI editor, but it's a pretty good one in a lot of ways. I am more productive on the MIDI side as well as the publishing side when using some of its features, hence my questions are about what LilyPond can and cannot do, rather than asking for it to do things it isn't intended for. The scope of its intended use is also hard to limit! I just read a script that conditionally determines layout based on content, which is pretty advanced for a "mere" engraver! I have now been more systematic in my approach and conclude that \key is not reflected in MIDI output. I tried various positions for events and in each case I got Time Signature information in my MID file but not Key Signature when viewed in Staff View. But the conclusive evidence for me is that when I use MIDIDSM to create a TXT file the Time Sig event is missing. I must have been mistaken in thinking I had seen the information in some output and not in other. My apologies. From: msk...@ansuz.sooke.bc.ca Sent: 11 May 2024 13:40 To: Giles Boardman Cc: Hans Åberg ; lilypond-user@gnu.org Subject: Re: Key signatures in MIDI output On Sat, 11 May 2024, Giles Boardman wrote: > When I create MIDI output from Lilypond, if I have imported a MIDI file and > then resaved it with changes made in LilyPond, the output is like that, too. Lilypond as such does not import MIDI files. I think you must be using some piece of software other than Lilypond, and that is relevant to the issues you're experiencing. On the off chance that you might be using midi2ly, I tried round-tripping my example code through that, and got suggestive results. I take this code: \score { \new Voice { \key c \major c'4 d'4 e'4 f'4 | \key d \minor bes4 a4 g4 f4 | } \layout { } \midi { } } and run it through Lilypond to get a MIDI file. Then I take the resulting MIDI file, which contains key changes at the marked locations, and run it through midi2ly. The result is a complicated mess, 74 lines long. If I run *that*, the midi2ly output, through Lilypond a second time to get a PDF file, then the PDF file shows a D-minor key signature at the start of each of the two bars, no C-major at all. That seems like it could be relevant to the complaint of Lilypond losing key changes. It seems to come about because the control track in the MIDI file translates into a silent voice in the midi2ly output, and that voice has a D-minor key signature at the start which overrides the C-major key signature in the other voice. But it's an issue on *input*, in that midi2csv is creating an unusual file structure, nothing to do with MIDI output or the Lilypond program itself. I think it's important to understand that Lilypond is not a MIDI file editor. MIDI files in Lilypond are treated as final output (much like PDF files), not as an editable format. To start with a MIDI file, "import" it with midi2ly, edit the resulting Lilypond code, and then "resave" it with Lilypond, is not the usual workflow and is likely to cause problems even if there is some technical possibility of doing it. "Importing" and "resaving" are not ordinarily done with Lilypond. The intended use of Lilypond is in a one-way flow from ideas to *.ly source code to PDF or MIDI output, and the midi2ly utility which creates an exception to that flow is intended only to be used once, to produce a file parts of which can be cut and pasted into a new Lilypond source file. Repeated round-trips between MIDI and Lilypond source format are asking for trouble. Of course, you may not actually be using midi2ly at all, in which case the above is irrelevant. I'm only guessing based on your description of "importing" a MIDI file, which stands out as an unusual (indeed, impossible) thing to do with the main Lilypond program. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
On Sat, 11 May 2024, Giles Boardman wrote: > When I create MIDI output from Lilypond, if I have imported a MIDI file and > then resaved it with changes made in LilyPond, the output is like that, too. Lilypond as such does not import MIDI files. I think you must be using some piece of software other than Lilypond, and that is relevant to the issues you're experiencing. On the off chance that you might be using midi2ly, I tried round-tripping my example code through that, and got suggestive results. I take this code: \score { \new Voice { \key c \major c'4 d'4 e'4 f'4 | \key d \minor bes4 a4 g4 f4 | } \layout { } \midi { } } and run it through Lilypond to get a MIDI file. Then I take the resulting MIDI file, which contains key changes at the marked locations, and run it through midi2ly. The result is a complicated mess, 74 lines long. If I run *that*, the midi2ly output, through Lilypond a second time to get a PDF file, then the PDF file shows a D-minor key signature at the start of each of the two bars, no C-major at all. That seems like it could be relevant to the complaint of Lilypond losing key changes. It seems to come about because the control track in the MIDI file translates into a silent voice in the midi2ly output, and that voice has a D-minor key signature at the start which overrides the C-major key signature in the other voice. But it's an issue on *input*, in that midi2csv is creating an unusual file structure, nothing to do with MIDI output or the Lilypond program itself. I think it's important to understand that Lilypond is not a MIDI file editor. MIDI files in Lilypond are treated as final output (much like PDF files), not as an editable format. To start with a MIDI file, "import" it with midi2ly, edit the resulting Lilypond code, and then "resave" it with Lilypond, is not the usual workflow and is likely to cause problems even if there is some technical possibility of doing it. "Importing" and "resaving" are not ordinarily done with Lilypond. The intended use of Lilypond is in a one-way flow from ideas to *.ly source code to PDF or MIDI output, and the midi2ly utility which creates an exception to that flow is intended only to be used once, to produce a file parts of which can be cut and pasted into a new Lilypond source file. Repeated round-trips between MIDI and Lilypond source format are asking for trouble. Of course, you may not actually be using midi2ly at all, in which case the above is irrelevant. I'm only guessing based on your description of "importing" a MIDI file, which stands out as an unusual (indeed, impossible) thing to do with the main Lilypond program. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
> On 10 May 2024, at 22:21, msk...@ansuz.sooke.bc.ca wrote: > > On Fri, 10 May 2024, Hans Åberg wrote: > >>> signature. The MIDI file does not contain that information; it is up to >>> whatever software reads the MIDI file, to display it appropriately. >> >> So to go back to staff notation from MIDI, one must know what enharmonic >> equivalences that have been applied. > > Yes - and it's not Lilypond that does that step, so if the translation > back to staff notation is not as desired, there's little that can be done > within Lilypond to fix it. On traditional meantone keyboards with 12 keys per octave, a common way to chose the notes are, expressed in iterated fifths: E♭ B♭ F C G D A E B F♯ C♯ G♯ One could indicate a note, like A, and from that, get 6 fifths down and 5 fifths up.
Re: Key signatures in MIDI output
Giles Boardman writes: > However, when I create new files, I am getting output that is as if I > have chosen to write everything in C major, with all the flats and > sharps shown explicitly. Nevertheless, the screen and pdf output are > written in, for example G, with no sharps on the individual fis notes. This is when further discussion becomes pointless without an actual example illustrating the problem. -- David Kastrup
Re: Key signatures in MIDI output
The issue is consistency and I'm perhaps not using the terms precisely enough to describe what I am seeing. I understand about MIDI notes and that they are neither sharpened not flattened, but each has their own value. In my sequencer (Cakewalk ProAudio 9), if my piece has a Key Signature event in the .MIDI (I'm not talking about a Cakewalk format file) file of "G", I see a staff with an F sharp at the beginning of the staff and no sharp signs on Fs in the piece. When I create MIDI output from Lilypond, if I have imported a MIDI file and then resaved it with changes made in LilyPond, the output is like that, too. However, when I create new files, I am getting output that is as if I have chosen to write everything in C major, with all the flats and sharps shown explicitly. Nevertheless, the screen and pdf output are written in, for example G, with no sharps on the individual fis notes. So ,what appears to me to be happening is I have written code that works for layout {} but just this aspect of it is ignored by midi {} But I am new to LilyPond so that deduction may be nonsense. I have much more experience of MIDI files and have been using the same software for many years and am aware of its idiosyncracies. In LilyPond, I have other similar issues which suggest to me I am making a bigger, more fundamental mistake in my coding, so I will investigate that before asking for any more help and in that case I will bring the necessary snippets to the forum. Thanks for your interest. From: msk...@ansuz.sooke.bc.ca Sent: 10 May 2024 21:21 To: Hans Åberg Cc: Giles Boardman ; lilypond-user@gnu.org Subject: Re: Key signatures in MIDI output On Fri, 10 May 2024, Hans Åberg wrote: > > signature. The MIDI file does not contain that information; it is up to > > whatever software reads the MIDI file, to display it appropriately. > > So to go back to staff notation from MIDI, one must know what enharmonic > equivalences that have been applied. Yes - and it's not Lilypond that does that step, so if the translation back to staff notation is not as desired, there's little that can be done within Lilypond to fix it. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
Giles Boardman writes: > Hello, > > I am reading that I can create MIDI output which is different from the > printed output. For example, I can unfold repeats in the midi output > but use alternative endings and double barlines in my score. Awesome! > > So, I tried it and I notice that my MIDI output doesn't reflect the > key signatures (everything is in C with accidentals) while my > on-screen preview (even when I only have a midi block and no layout > block) and the .pdf have sharps and flats at the beginning of the > staff. > > The snippet about midi output in the documentation show the key > signature as written in the example, but as mentioned, that doesn't > mean it has made it into the MIDI file. Before I troubleshoot further, > can anyone confirm what I should expect, please? Key signatures are a facet of MIDI files, not of a live MIDI stream. If you play music via a sequencer, the sequencer knows the signature, the instrument doesn't. At least that's what I remember. -- David Kastrup
Re: Key signatures in MIDI output
On Fri, 10 May 2024, Hans Åberg wrote: > > signature. The MIDI file does not contain that information; it is up to > > whatever software reads the MIDI file, to display it appropriately. > > So to go back to staff notation from MIDI, one must know what enharmonic > equivalences that have been applied. Yes - and it's not Lilypond that does that step, so if the translation back to staff notation is not as desired, there's little that can be done within Lilypond to fix it. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
> On 10 May 2024, at 21:50, msk...@ansuz.sooke.bc.ca wrote: > > On Fri, 10 May 2024, Hans Åberg wrote: > >> Programs like ABC work so that one writes the music without accidentals, >> and then apply a key signature to get them. It was my reading that the >> OP asked for that. > > Okay. I didn't read it that way because the OP said he was getting > correct output in the PDF, and if he'd misunderstood the input format in > the way you describe, then the PDF would be wrong too. > > But something else that occurred to me is that there may be a further > misunderstanding of MIDI format in play here: MIDI never contains > "accidentals" at all. It only contains note numbers. MIDI is based on E12, the 12-equal tone system. The staff notation, as used in LilyPond, is originally based on Pythagorean tuning, without enharmonic equivalences, which must be applied for the MIDI output. > In my example code: > > \score { > \new Voice { >\key c \major >c'4 d'4 e'4 f'4 | >\key d \minor >bes4 a4 g4 f4 | > } > \layout { } > \midi { } > } > > The MIDI output will contain roughly this information: > > key change, C major > note 60 > note 62 > note 64 > note 65 > key change, D minor > note 58 > note 57 > note 55 > note 53 > > If some other software, reading the MIDI file, displays these as notes > with or without accidentals, and does or doesn't make the key-change > events visible, then that has very little to do with Lilypond, which only > generates the above data. Note 60, for instance, might be a C or a > B-sharp. Even if it is B-sharp, it might be displayed with or without a > sharp sign depending on whether there is one in the displayed key > signature. The MIDI file does not contain that information; it is up to > whatever software reads the MIDI file, to display it appropriately. So to go back to staff notation from MIDI, one must know what enharmonic equivalences that have been applied.
Re: Key signatures in MIDI output
On Fri, 10 May 2024, Hans Åberg wrote: > Programs like ABC work so that one writes the music without accidentals, > and then apply a key signature to get them. It was my reading that the > OP asked for that. Okay. I didn't read it that way because the OP said he was getting correct output in the PDF, and if he'd misunderstood the input format in the way you describe, then the PDF would be wrong too. But something else that occurred to me is that there may be a further misunderstanding of MIDI format in play here: MIDI never contains "accidentals" at all. It only contains note numbers. In my example code: \score { \new Voice { \key c \major c'4 d'4 e'4 f'4 | \key d \minor bes4 a4 g4 f4 | } \layout { } \midi { } } The MIDI output will contain roughly this information: key change, C major note 60 note 62 note 64 note 65 key change, D minor note 58 note 57 note 55 note 53 If some other software, reading the MIDI file, displays these as notes with or without accidentals, and does or doesn't make the key-change events visible, then that has very little to do with Lilypond, which only generates the above data. Note 60, for instance, might be a C or a B-sharp. Even if it is B-sharp, it might be displayed with or without a sharp sign depending on whether there is one in the displayed key signature. The MIDI file does not contain that information; it is up to whatever software reads the MIDI file, to display it appropriately. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
> On 10 May 2024, at 20:18, msk...@ansuz.sooke.bc.ca wrote: > > On Fri, 10 May 2024, Hans Åberg wrote: > >> To change the MIDI output, you will need to change the notes, say by >> transposing or something else. > > MIDI files can include events ("key-change meta messages") for key > signatures, each specifying a root and whether it's major or minor (which > actually makes them more expressive than standard notation which can't > distinguish, for instance, between C major and A minor). Lilypond > generates these events in the MIDI files on each key change in my > installation. If Giles's installation appears not to, I wonder whether > that may be due to an issue with the software he's using to examine the > MIDI files. > > For instance, this input produces a MIDI file with key-change events at > the indicated places: > > \score { > \new Voice { >\key c \major > c'4 d'4 e'4 f'4 | >\key d \minor >bes4 a4 g4 f4 | > } > \layout { } > \midi { } > } Programs like ABC work so that one writes the music without accidentals, and then apply a key signature to get them. It was my reading that the OP asked for that.
Re: Key signatures in MIDI output
On Fri, 10 May 2024, Hans Åberg wrote: > To change the MIDI output, you will need to change the notes, say by > transposing or something else. MIDI files can include events ("key-change meta messages") for key signatures, each specifying a root and whether it's major or minor (which actually makes them more expressive than standard notation which can't distinguish, for instance, between C major and A minor). Lilypond generates these events in the MIDI files on each key change in my installation. If Giles's installation appears not to, I wonder whether that may be due to an issue with the software he's using to examine the MIDI files. For instance, this input produces a MIDI file with key-change events at the indicated places: \score { \new Voice { \key c \major c'4 d'4 e'4 f'4 | \key d \minor bes4 a4 g4 f4 | } \layout { } \midi { } } -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Key signatures in MIDI output
> On 10 May 2024, at 16:26, Giles Boardman wrote: > > I am reading that I can create MIDI output which is different from the > printed output. For example, I can unfold repeats in the midi output but use > alternative endings and double barlines in my score. Awesome! > > So, I tried it and I notice that my MIDI output doesn't reflect the key > signatures (everything is in C with accidentals) while my on-screen preview > (even when I only have a midi block and no layout block) and the .pdf have > sharps and flats at the beginning of the staff. > > The snippet about midi output in the documentation show the key signature as > written in the example, but as mentioned, that doesn't mean it has made it > into the MIDI file. Before I troubleshoot further, can anyone confirm what I > should expect, please? The signatures are only a notational convenience to simplify reading; traditionally, they do not indicate even the key, even though "key signature" somehow got popular in English. To change the MIDI output, you will need to change the notes, say by transposing or something else.
Key signatures in MIDI output
Hello, I am reading that I can create MIDI output which is different from the printed output. For example, I can unfold repeats in the midi output but use alternative endings and double barlines in my score. Awesome! So, I tried it and I notice that my MIDI output doesn't reflect the key signatures (everything is in C with accidentals) while my on-screen preview (even when I only have a midi block and no layout block) and the .pdf have sharps and flats at the beginning of the staff. The snippet about midi output in the documentation show the key signature as written in the example, but as mentioned, that doesn't mean it has made it into the MIDI file. Before I troubleshoot further, can anyone confirm what I should expect, please? Thank you Giles
Re: MIDI format and MIDI resolution
Indeed, Martin. But I am more of a troubadour than a musician and more of a business analyst than a programmer, so I have cobbled together some "utilities" that help me make music from assorted midi files and long before I understood the role I might make LilyPond play I choose a midi resolution and it isn't 384. I believe ABC2MIDI also outputs at a fixed resolution, though I could be wrong. So, you're right, my "software" doesn't conform to the MIDI standard, but it doesn't really need to because it has a user group of one. Best Giles From: lilypond-user-bounces+giles.boardman=hotmail.co...@gnu.org on behalf of Martin Tarenskeen Sent: 10 May 2024 10:06 To: lilypond-user@gnu.org Subject: Re: MIDI format and MIDI resolution Op donderdag 9 mei 2024 om 16:33:02 +00:00:00 schreef Giles Boardman : > Hello, > Can anyone tell me if it is possible to generate Midi format 0 files > and whether it is possible to control the resolution setting. I have > been standardising resolution for midi files from different sources > and the value I chose is not the one output by Lilypond. What is the reason you want to standardise the resolution for your midi files anyway? If there is software that you use that requires a standardized midi resolution, then this software was not designed conform the MIDI standard. Any software that can load MIDI files should be able to read any possible resolution from a MIDI file and calculate whatever it needs for it's own native resolution from there. -- Martin
Re: MIDI format and MIDI resolution
Op donderdag 9 mei 2024 om 16:33:02 +00:00:00 schreef Giles Boardman : Hello, Can anyone tell me if it is possible to generate Midi format 0 files and whether it is possible to control the resolution setting. I have been standardising resolution for midi files from different sources and the value I chose is not the one output by Lilypond. What is the reason you want to standardise the resolution for your midi files anyway? If there is software that you use that requires a standardized midi resolution, then this software was not designed conform the MIDI standard. Any software that can load MIDI files should be able to read any possible resolution from a MIDI file and calculate whatever it needs for it's own native resolution from there. -- Martin
Re: MIDI format and MIDI resolution
Giles Boardman writes: > Is that "no, you can't tell me" or "no, it can't be done? (Just > kidding). Thanks very much. It will save me spending time looking. It is "it is hardwired into the source code to a degree where it would require some really heavy lifting to make it adaptable". It would be easier (but not trivial) to hardwire it to a different fixed value, but then your copy of LilyPond would be incompatible with everybody else's which is a maintenance nightmare, meaning that it should only be attempted by people who are probably versed enough as programmers as to be able to contribute a variable-size tick. "it can't be done" is not a thing with Free Software. It's more like "if you have to ask, you may be the wrong person to do this as your first project". -- David Kastrup
Re: MIDI format and MIDI resolution
Is that "no, you can't tell me" or "no, it can't be done? (Just kidding). Thanks very much. It will save me spending time looking. From: David Kastrup Sent: 09 May 2024 18:41 To: Giles Boardman Cc: lilypond-user@gnu.org Subject: Re: MIDI format and MIDI resolution Giles Boardman writes: > Hello, > Can anyone tell me if it is possible to generate Midi format 0 files No. > and whether it is possible to control the resolution setting. No. > I have been standardising resolution for midi files from different > sources and the value I chose is not the one output by Lilypond. Why? You can use MIDI processors to generate format 0 and change resolution. -- David Kastrup
Re: MIDI format and MIDI resolution
Giles Boardman writes: > Hello, > Can anyone tell me if it is possible to generate Midi format 0 files No. > and whether it is possible to control the resolution setting. No. > I have been standardising resolution for midi files from different > sources and the value I chose is not the one output by Lilypond. Why? You can use MIDI processors to generate format 0 and change resolution. -- David Kastrup
MIDI format and MIDI resolution
Hello, Can anyone tell me if it is possible to generate Midi format 0 files and whether it is possible to control the resolution setting. I have been standardising resolution for midi files from different sources and the value I chose is not the one output by Lilypond. Thanks Giles
Re: Adjusting instrumentation of a MIDI output?
Hi. Le mer. 8 mai 2024 à 06:54, Alasdair McAndrew a écrit : > > Hello, > > I've set various instruments for my MIDI output (from an early 18th century > piece), but I have a new soundfont with better instruments. Is there any way > I can get lilypond to pick up, as it were, the instrument from this > soundfont? As it is, I just set the Staff.midiInstrument to one of the > standard values, and lilypond does the rest. But I'd like to mix and match, > as it were, instruments from different soundfonts. Which soundfont is used when listening to a MIDI [1] file depends on the configuration of the MIDI player (IOW, LilyPond has nothing to do with that). Regards, Gilles [1] https://en.wikipedia.org/wiki/General_MIDI
Adjusting instrumentation of a MIDI output?
Hello, I've set various instruments for my MIDI output (from an early 18th century piece), but I have a new soundfont with better instruments. Is there any way I can get lilypond to pick up, as it were, the instrument from this soundfont? As it is, I just set the Staff.midiInstrument to one of the standard values, and lilypond does the rest. But I'd like to mix and match, as it were, instruments from different soundfonts. Many thanks, Alasdair -- Alasdair McAndrew (he/him) mob: 0432 854 858 https://numbersandshapes.net
Re: How to manually set MIDI channel # for a staff?
Jean Abou Samra writes: > Le lundi 29 avril 2024 à 06:31 -0500, Jason Yip a écrit : >> Hi, >> >> Does anyone know how to manually set the midi channel # for a staff to >> something other than the default of channel 0/1? Without having to >> create dummy staffs with just `s256` as the voice content preceding the >> desired staff? The staff in question usually only has one voice, so I >> modified the midi context as shown below simply made a bunch of dummy >> voices with only `s256` as the content so that they don't at least >> affect the graphical output: >> >> ``` >> \midi { >> \context { >> \Staff >> \remove "Staff_performer" >> } >> \context { >> \Voice >> \consists "Staff_performer" >> } >> } >> ``` > > > You can do \set Score.midiChannelMapping = #'voice as an alternative to that. We really need a plain simple way to set a fixed channel. There is enough hardware around using dedicated channels. -- David Kastrup
Re: How to manually set MIDI channel # for a staff?
On 2024-04-29 06:48, Jean Abou Samra - jean(a)abou-samra.fr wrote: You can do \set Score.midiChannelMapping = #'voice as an alternative to that. Also \new Voice { } should work (untested) instead of \new Voice { s256 }. I don't think there's a better way. Setting midiChannelMapping property didn't deliver my desired results. My way worked apparently. Removing the s256 doesn't also deliver my desired results.
Re: How to manually set MIDI channel # for a staff?
Le lundi 29 avril 2024 à 06:31 -0500, Jason Yip a écrit : > Hi, > > Does anyone know how to manually set the midi channel # for a staff to > something other than the default of channel 0/1? Without having to > create dummy staffs with just `s256` as the voice content preceding the > desired staff? The staff in question usually only has one voice, so I > modified the midi context as shown below simply made a bunch of dummy > voices with only `s256` as the content so that they don't at least > affect the graphical output: > > ``` > \midi { > \context { > \Staff > \remove "Staff_performer" > } > \context { > \Voice > \consists "Staff_performer" > } > } > ``` You can do \set Score.midiChannelMapping = #'voice as an alternative to that. Also \new Voice { } should work (untested) instead of \new Voice { s256 }. I don't think there's a better way. signature.asc Description: This is a digitally signed message part
How to manually set MIDI channel # for a staff?
Hi, Does anyone know how to manually set the midi channel # for a staff to something other than the default of channel 0/1? Without having to create dummy staffs with just `s256` as the voice content preceding the desired staff? The staff in question usually only has one voice, so I modified the midi context as shown below simply made a bunch of dummy voices with only `s256` as the content so that they don't at least affect the graphical output: ``` \midi { \context { \Staff \remove "Staff_performer" } \context { \Voice \consists "Staff_performer" } } ``` It's definitely a hacky solution, especially given that my program that automatically generates lilypond code has to output `\new Voice { s256 }\n` n - 1 times before the actual content then wrap the voices with << >>. If this is the only way to do it, is there some sort of way to substitute `s256` with something else that doesn't occupy length but at least lets the performer still assign a channel to the dummy staff/voices? Thanks!
Re: Encoding Bar, Line breaks into MIDI?
Actually, this was a stupid question. Apologies for the noise. The bar line, the line break, and the starting note of the next bar all share the same moment. Which isn't helpful in terms of playing back a video of the score. What's necessary is to interpolate "when the bar is" in the playback based on the speed of the music and the distance (difference in x positions) between the last note, the bar line, and the next note. I need a different approach. On Tue, 2023-12-19 at 21:14 -0800, Stefano Antonelli wrote: > Hello list, > > I'd like to encode bar lines and line breaks into the midi output. > > There are some general purpose midi control change messages that > could > be abused for this purpose. These general purpose control change > messages have id's of 80-84. I don't see a way to use them in the > lilypond documentation though. > > There seem to be some predefined control change messages: > > midiBalance (number) > midiChorusLevel (number) > midiExpression (number) > midiPanPosition (number) > midiReverbLevel (number) > > And since this output is being generated specifically for ly2video I > can look for any of those control change messages and interpret them > as > bar lines or line breaks. > > Is there any way to call those functions when bars or line breaks are > encountered during the midi translation? > > Thanks, > Stef > >
Encoding Bar, Line breaks into MIDI?
Hello list, I'd like to encode bar lines and line breaks into the midi output. There are some general purpose midi control change messages that could be abused for this purpose. These general purpose control change messages have id's of 80-84. I don't see a way to use them in the lilypond documentation though. There seem to be some predefined control change messages: midiBalance (number) midiChorusLevel (number) midiExpression (number) midiPanPosition (number) midiReverbLevel (number) And since this output is being generated specifically for ly2video I can look for any of those control change messages and interpret them as bar lines or line breaks. Is there any way to call those functions when bars or line breaks are encountered during the midi translation? Thanks, Stef
MidiToLily, Windows console app that converts MIDI files to Lily format, now available
I mentioned previously that I wrote a program to convert MIDI files to LilyPond files. That program is called MidiToLily and it’s now freely available on GitHub. It’s a console app, doesn’t have an installer, and doesn’t store things in the registry or anywhere else. It does have command line help, including a few examples. https://github.com/victimofleisure/MidiToLily Notes can be quantized to a regular grid, a triplet grid, or both grids, in which case the note snaps to whichever grid is nearest. The title, composer, and copyright can be specified, with Unicode support. Clef overrides, sections, and ottavas are also supported. The tempo, time signature, and key signature are read from the input MIDI file. I have only tested MidiToLily on type 1 MIDI files. MidiToLily includes a verification feature which is very useful to me. It depends on the fact that LilyPond can output a MIDI file that corresponds to its engraving. MidiToLily invokes this feature in the .ly file it creates, so after LilyPond runs, in addition to a PDF, you’ll also have a .mid file. Run MidiToLily a second time, specifying the verify flag, and instead of outputting a LilyPond file, MidiToLily looks for a .mid file with the same name as the output file. It then compares that LilyPond-generated MIDI file to the original MIDI file. The comparison automatically accounts for certain expected differences, and it creates two text files: MidiToLilyIn.txt for the original MIDI, and LilyPondMidi.txt for LilyPond’s MIDI. If MidiToLily reports differences, you can investigate them by comparing these two text files, using a source comparison utility, such as WinMerge for example. MidiToLily does what I need it to do, but undoubtably it could be improved. I make no claim that it’s useful to others, but I hope so. Best regards,Chrishttps://www.chriskorda.com/
Re: Fw: I wrote a MIDI to Lily front end; also questions about video
Karlin High wrote: FluidSynth can do it. I use VLC Player which I think contains it. Prior post explains: <https://lists.gnu.org/archive/html/lilypond-user/2017-04/msg00764.html> My contribution to that thread is outdated: midi returned to VLC with version 3.0.8 Cheers, Robin
Re: Fw: I wrote a MIDI to Lily front end; also questions about video
On 12/7/2023 12:48 PM, Stefano Antonelli wrote: Is downloading soundfonts 'standard practice' for working with midi on Windows? Would anyone wanting to use ly2video on windows already know this if they are familiar with midi? I doubt it is common for Windows users to interact with soundfonts. I know it wasn't for me, anyway. My computer experience began and continues with Windows. I was using Windows for a good number of years before encountering the term: A sound FONT, huh. What's next, a text EQ? People who don't know how MIDI differs from audio recordings will probably just use whatever opens it, Windows Media Player even. And those who are really into MIDI probably will use DAW software with virtual-instrument plugins. -- Karlin High Missouri, USA
Re: Fw: I wrote a MIDI to Lily front end; also questions about video
On Thu, 2023-12-07 at 12:37 -0600, Karlin High wrote: > On 12/7/2023 12:30 PM, Stefano Antonelli wrote: > > It's the same deal for fluidsynth which doesn't come with sound > > fonts. > > What's the windows way to convert midi to wav? > > FluidSynth can do it. I use VLC Player which I think contains it. > > Prior post explains: > > < > https://lists.gnu.org/archive/html/lilypond-user/2017-04/msg00764.html > > ly2video doesn't work with fluidsynth yet. Maybe I'll look into that. > Here is my favorite place to get soundfonts: > > <http://www.schristiancollins.com/generaluser.php> Right I have that page already open in my browser. It wasn't hard to find from the fluidsynth page, but I don't yet know how to make it work with timidity. Is downloading soundfonts 'standard practice' for working with midi on Windows? Would anyone wanting to use ly2video on windows already know this if they are familiar with midi?
Re: Fw: I wrote a MIDI to Lily front end; also questions about video
On 12/7/2023 12:30 PM, Stefano Antonelli wrote: It's the same deal for fluidsynth which doesn't come with sound fonts. What's the windows way to convert midi to wav? FluidSynth can do it. I use VLC Player which I think contains it. Prior post explains: <https://lists.gnu.org/archive/html/lilypond-user/2017-04/msg00764.html> Here is my favorite place to get soundfonts: <http://www.schristiancollins.com/generaluser.php> -- Karlin High Missouri, USA
Re: Fw: I wrote a MIDI to Lily front end; also questions about video
On Thu, 2023-12-07 at 02:43 +, Chris Korda wrote: > Doesn’t LilyPond already contain python? There’s a python.exe in the > bin folder, and it appears to run the python scripts that come with > LilyPond, can I just use that to run ly2video? I’m guessing not > because that would be too easy. ly2video was super easy on linux and ideally would be just as easy to use on windows. And the easiest way is probably a self contained python binary of ly2video. I was able to package ly2video as an exe from linux using wine and pyinstaller. However when I tested it in wine, I ran into an issue: external dependencies. lilypond is required. No problem, just download windows binaries and modify the path so that lilypond works from anywhere. ffmpeg is required. No problem, just download windows binaries and modify the path so that ffmpeg works from anywhere. It was smooth sailing until timidity. l2video uses timidity to process the midi file into wav. And that works fine on linux. Odd because it was originally developed for windows. I can find timidity for windows, but it's not a nice installable package complete with soudfonts. And it's missing timidity.cfg which is needed to find the soundfont files after they've been installed. I can find the soundfonts, but this seems completely awkward. It's the same deal for fluidsynth which doesn't come with sound fonts. There is a Chocolatey package manager (?!) that has a fluidsynth package, but I have no idea what that is or why anyone would use it. I looked into the package and all it does is download and install the fluidsynth zip file that you can get off the github releases page. It does not contain soundfonts. What's the windows way to convert midi to wav? -Stef
Re: Fw: I wrote a MIDI to Lily front end; also questions about video
On Thu, 2023-12-07 at 02:43 +, Chris Korda wrote: > Doesn’t LilyPond already contain python? There’s a python.exe in the > bin folder, and it appears to run the python scripts that come with > LilyPond, can I just use that to run ly2video? I’m guessing not > because that would be too easy. ly2video is designed for easy installation via pip, the python package installer. I have been able to run it without installing via pip for development, but I have no idea how you would do that on Windows. ly2video has some other python library dependencies which are taken care of via pip. You can't just run python.exe. I don't use Windows so I have no idea how any of it works there.
Fw: I wrote a MIDI to Lily front end; also questions about video
Hi Stefano, I’m sure it would’ve been nicer, but life is short and I’m old, with way too many projects already (thirteen of them public, all FOSS). Thanks for the suggestions, but I’ve been programming in Windows since 1999, and wrestling with Linux is not on my bucket list. I agree that fragmentation is a problem. Recruit some young folks to fix midi2ly? Offer them free ponies? I don’t know. Doesn’t LilyPond already contain python? There’s a python.exe in the bin folder, and it appears to run the python scripts that come with LilyPond, can I just use that to run ly2video? I’m guessing not because that would be too easy.Chris On Thursday, December 7, 2023 at 01:05:38 AM GMT+1, Stefano Antonelli wrote: On Wed, 2023-12-06 at 17:21 +, Chris Korda wrote: > I spent much of the last week converting my compositions from MIDI > files to Lily format. I tried midi2ly first, but found it lacking, > and decided to roll my own in C++. I gather there are other > converters around, as I saw at least one on GitHub. It probably would have been nicer to fix midi2ly. It's been around for a long time. Fragmentation in the open source world is high and no one benefits from it. > My actual question regards video. I have investigated the various > methods, and I'm considering rolling my own, partly because I'm Again fragmentation is high. There are at least 4 different projects that do this in various ways. Most use python and one uses bash/scheme. > reluctant to install Python, but also because it's an interesting > problem. I tried outputting the score as one long strip, via ly:one- > line-breaking, nice and easy. Presumably I could then scroll the > resulting PNG file to generate video frames. But would I know the ly2video already does it that way. You can search for ly2video on youtube and find some examples. Like this: <https://www.youtube.com/watch?v=vDOZZzbfL00> I'm actually working on adding some new modes to ly2video right now. Not for horizontal scrolling though. The reason I'm working on ly2video is because it already supports midi rubato. Which I need to sync recorded audio to moving transcriptions. For what it's worth, I despise python. Rather than rolling my own though, I decided to modify ly2video. I'm not a Windows user anymore, so I don't know your Python pain. For end users of the program though it's possible to build a self contained python executable. I think this can be run through github actions too (though I haven't done it). So if properly set up, the end user just downloads a windows binary and runs it. For development, you can upload to github and download a build. You may not need to install Python. It's a little slow. Another option might be Windows Subsystem for Linux. You should be able to install Python there and work with it like the rest of us linux people do. I've never tried it though so I don't know if that's a good option. -Stef
Re: I wrote a MIDI to Lily front end; also questions about video
Yeah I figured using event-listener.ly wasn’t likely to work, because that was too easy. This other thing that you linked is hella complicated. It also does many things that I don’t need to do. All I need out of this is a text file just like the one that comes from event listener, except with X and Y. Everything else I can handle myself, with ffmpeg and my own code. So basically, the issue is that what you gave me is overkill for what I’m trying to do, and I don’t have a prayer of understanding it well enough to just rip out the part that I need. I don’t even know where it’s supposed to go. Chris On Thursday, December 7, 2023 at 01:05:21 AM GMT+1, Jean Abou Samra wrote: Thanks for your reply. Regarding scheme code: it seems to me that the simplest solution would be to modify event-listener.ly so that instead of storing point-and-click data (row and column within the lily file), it instead stores the pixel coordinate X, Y of the note’s (or rest’s) glyph within the output PNG image. I have tried that, but so far my efforts are not successful, due to my weak understanding of the language and LilyPond’s data architecture. I would happily accept a “cookbook” solution for the above, as this would spare me countless hours of possibly futile effort. Any reason not to reuse the code I linked inside ly2video as a cookbook solution? Anything implementing this sort of functionality is basically bound to use the same kind of technique. Note that you cannot extend event-listener.ly to output coordinates because event listeners in engravers are run during the translation process where LilyPond converts the music to a net of graphical objects, long before those objects are placed on the page. It may help to read this if you want to understand the different phases of compilation. You want grob callbacks, which is what that code does. Re MusicXML, can you recommend a FOSS MIDI to MusicXML converter that runs on Windows? Have you tried MuseScore's import then export? Last time I looked, this seemed to be the most accurate.
Re: I wrote a MIDI to Lily front end; also questions about video
On Wed, 2023-12-06 at 17:21 +, Chris Korda wrote: > I spent much of the last week converting my compositions from MIDI > files to Lily format. I tried midi2ly first, but found it lacking, > and decided to roll my own in C++. I gather there are other > converters around, as I saw at least one on GitHub. It probably would have been nicer to fix midi2ly. It's been around for a long time. Fragmentation in the open source world is high and no one benefits from it. > My actual question regards video. I have investigated the various > methods, and I'm considering rolling my own, partly because I'm Again fragmentation is high. There are at least 4 different projects that do this in various ways. Most use python and one uses bash/scheme. > reluctant to install Python, but also because it's an interesting > problem. I tried outputting the score as one long strip, via ly:one- > line-breaking, nice and easy. Presumably I could then scroll the > resulting PNG file to generate video frames. But would I know the ly2video already does it that way. You can search for ly2video on youtube and find some examples. Like this: <https://www.youtube.com/watch?v=vDOZZzbfL00> I'm actually working on adding some new modes to ly2video right now. Not for horizontal scrolling though. The reason I'm working on ly2video is because it already supports midi rubato. Which I need to sync recorded audio to moving transcriptions. For what it's worth, I despise python. Rather than rolling my own though, I decided to modify ly2video. I'm not a Windows user anymore, so I don't know your Python pain. For end users of the program though it's possible to build a self contained python executable. I think this can be run through github actions too (though I haven't done it). So if properly set up, the end user just downloads a windows binary and runs it. For development, you can upload to github and download a build. You may not need to install Python. It's a little slow. Another option might be Windows Subsystem for Linux. You should be able to install Python there and work with it like the rest of us linux people do. I've never tried it though so I don't know if that's a good option. -Stef
Re: I wrote a MIDI to Lily front end; also questions about video
> Thanks for your reply. Regarding scheme code: it seems to me that the > simplest solution would be to modify event-listener.ly so that instead of > storing point-and-click data (row and column within the lily file), it > instead stores the pixel coordinate X, Y of the note’s (or rest’s) glyph > within the output PNG image. I have tried that, but so far my efforts are not > successful, due to my weak understanding of the language and LilyPond’s data > architecture. > > I would happily accept a “cookbook” solution for the above, as this would > spare me countless hours of possibly futile effort. Any reason not to reuse the code I linked inside ly2video as a cookbook solution? Anything implementing this sort of functionality is basically bound to use the same kind of technique. Note that you cannot extend event-listener.ly to output coordinates because event listeners in engravers are run during the translation process where LilyPond converts the music to a net of graphical objects, long before those objects are placed on the page. It may help to read [this](https://extending-lilypond.gitlab.io/en/extending/intro.html#overview-of-lilypond-s-inner-workings-and-how-you-might-hook-in-them) if you want to understand the different phases of compilation. You want grob callbacks, which is what that code does. > Re MusicXML, can you recommend a FOSS MIDI to MusicXML converter that runs on > Windows? Have you tried MuseScore's import then export? Last time I looked, this seemed to be the most accurate. signature.asc Description: This is a digitally signed message part
Re: I wrote a MIDI to Lily front end; also questions about video
Hi Jean, Thanks for your reply. Regarding scheme code: it seems to me that the simplest solution would be to modify event-listener.ly so that instead of storing point-and-click data (row and column within the lily file), it instead stores the pixel coordinate X, Y of the note’s (or rest’s) glyph within the output PNG image. I have tried that, but so far my efforts are not successful, due to my weak understanding of the language and LilyPond’s data architecture. I would happily accept a “cookbook” solution for the above, as this would spare me countless hours of possibly futile effort. Re MusicXML, can you recommend a FOSS MIDI to MusicXML converter that runs on Windows? I looked around, but didn’t find one. I tried one that was available on GitHub, and it generated Neutrino output, which musicxml2ly did not like. Converting MIDI to Lily is a messy process at best, and the best argument for using my homegrown code is that I understand it, and it gives me maximum control over the conversion. On Wednesday, December 6, 2023 at 11:31:54 PM GMT+1, Jean Abou Samra wrote: Hi, I spent much of the last week converting my compositions from MIDI files to Lily format. I tried midi2ly first, but found it lacking, and decided to roll my own in C++. I gather there are other converters around, as I saw at least one on GitHub. I may put mine on GitHub too, after its code settles down a bit. It assumes the MIDI file is already quantized, but it handles triplets, and works well enough for me. If you're curious, some of the scores I created with it are here: https://www.chriskorda.com/misc/scores.html Just out of curiosity: have you tried first converting the MIDI to MusicXML (using one of the various available tools), then converting that MusicXML to LilyPond using either musicxml2ly or xml2ly? I'd expect this to produce much better results than midi2ly. Presumably I could then scroll the resulting PNG file to generate video frames. But would I know the pixel offsets of notes/rests within each measure? You need some Scheme code for that. See here for what ly2video uses.
Re: I wrote a MIDI to Lily front end; also questions about video
Hi, > I spent much of the last week converting my compositions from MIDI files to > Lily format. I tried midi2ly first, but found it lacking, and decided to roll > my own in C++. I gather there are other converters around, as I saw at least > one on GitHub. I may put mine on GitHub too, after its code settles down a > bit. It assumes the MIDI file is already quantized, but it handles triplets, > and works well enough for me. If you're curious, some of the scores I created > with it are here: > [https://www.chriskorda.com/misc/scores.html](https://www.chriskorda.com/misc/scores.html) Just out of curiosity: have you tried first converting the MIDI to MusicXML (using one of the various available tools), then converting that MusicXML to LilyPond using either musicxml2ly or [xml2ly](https://github.com/jacques-menu/musicformats)? I'd expect this to produce much better results than midi2ly. > Presumably I could then scroll the resulting PNG file to generate video > frames. But would I know the pixel offsets of notes/rests within each measure? You need some Scheme code for that. See [here](https://github.com/aspiers/ly2video/blob/41364ad9c5d512c502de2c9b06f7878bd88b77e1/ly2video/cli.py#L1326) for what ly2video uses. signature.asc Description: This is a digitally signed message part
I wrote a MIDI to Lily front end; also questions about video
Hi all, I'm a composer and a software developer, and I started using LilyPond only a week ago. I'm very impressed with LilyPond; its functionality and documentation are outstanding. I had previously tried Sibelius and MuseScore, but had many issues with them. I spent much of the last week converting my compositions from MIDI files to Lily format. I tried midi2ly first, but found it lacking, and decided to roll my own in C++. I gather there are other converters around, as I saw at least one on GitHub. I may put mine on GitHub too, after its code settles down a bit. It assumes the MIDI file is already quantized, but it handles triplets, and works well enough for me. If you're curious, some of the scores I created with it are here: https://www.chriskorda.com/misc/scores.html My program is a Windows VisualStudio C++ console app. I expect it could be ported to other platforms easily enough, as it doesn't have many dependencies, except a few basic MFC classes like CString, CArray and CStdioFile. My actual question regards video. I have investigated the various methods, and I'm considering rolling my own, partly because I'm reluctant to install Python, but also because it's an interesting problem. I tried outputting the score as one long strip, via ly:one-line-breaking, nice and easy. Presumably I could then scroll the resulting PNG file to generate video frames. But would I know the pixel offsets of notes/rests within each measure? I saw one solution has a blue line moving through the score to indicate position, whereas another solution highlights individual notes. How was this done? Any hints would be greatly appreciated. Best wishes, Chris Kordahttps://www.chriskorda.com/index.html
Re: MIDI Drums to lilypond
Yes, sorry. I did find that after typing the email... It is the GM mapping, it's just that I didn't want to retype it all by hand, if I could parse it from somewhere, you see Thanks! L On Fri, Nov 17, 2023 at 11:05 AM Mark Knoop wrote: > You'll find it in drumpitch-init.ly, I believe it's just the > standard General MIDI percussion keymap. > > At 10:52 on 17 Nov 2023, Luca Fascione wrote: > > Hi, > > I'm converting a MIDI file to lilypond with a drumset track. > > > My process goes through MusicXML, but the `musicxml2ly` script I have > > (2.22.2) emits pitches instead of percussion notes. > > > I can write a script to map those, but if anyone had a starting point, > > that'd be grand. > > > In my mind, the mapping lilypond uses to go from the percussion notes to > > its MIDI output is all I need (and then I can reverse that). If someone > > could get me a breadcrumb to that, that'd be grand. > > > Thanks > > Luca > > -- > Mark Knoop > -- Luca Fascione
Re: MIDI Drums to lilypond
You'll find it in drumpitch-init.ly, I believe it's just the standard General MIDI percussion keymap. At 10:52 on 17 Nov 2023, Luca Fascione wrote: > Hi, > I'm converting a MIDI file to lilypond with a drumset track. > My process goes through MusicXML, but the `musicxml2ly` script I have > (2.22.2) emits pitches instead of percussion notes. > I can write a script to map those, but if anyone had a starting point, > that'd be grand. > In my mind, the mapping lilypond uses to go from the percussion notes to > its MIDI output is all I need (and then I can reverse that). If someone > could get me a breadcrumb to that, that'd be grand. > Thanks > Luca -- Mark Knoop
MIDI Drums to lilypond
Hi, I'm converting a MIDI file to lilypond with a drumset track. My process goes through MusicXML, but the `musicxml2ly` script I have (2.22.2) emits pitches instead of percussion notes. I can write a script to map those, but if anyone had a starting point, that'd be grand. In my mind, the mapping lilypond uses to go from the percussion notes to its MIDI output is all I need (and then I can reverse that). If someone could get me a breadcrumb to that, that'd be grand. Thanks Luca -- Luca Fascione
Re: top-level `\midi` doesn't work as expected
> Would it be possible to reformulate a bit to make it even more clear > that this is analogous to how \layout blocks behave (the only > difference being that a \score block that contains nor a layout > neither a midi block implicitly contains a layout block). For > example: [...] Sorry for the late reply. I've amended the wording, thanks. Werner
Re: top-level `\midi` doesn't work as expected
On 2023-11-12 14:31, Werner LEMBERG wrote: MIDI settings can be changed globally (or in a book or bookpart), but the generation of an actual MIDI file is only triggered when a \midi block is encountered inside of a \score . Thanks for the idea and wording. https://gitlab.com/lilypond/lilypond/-/merge_requests/2171 Would it be possible to reformulate a bit to make it even more clear that this is analogous to how \layout blocks behave (the only difference being that a \score block that contains nor a layout neither a midi block implicitly contains a layout block). For example: A @code{@bs{}midi} block at the top level can be used to change MIDI settings globally; however, the generation of an actual MIDI file only happens when a @code{@bs{}midi} block is part of a @code{@bs{}score} block. Similarly, a @code{@bs{}layout} block at the top level affect layout settings globally, but does not influence if printed output is produced or not. /Mats
Re: top-level `\midi` doesn't work as expected
> MIDI settings can be changed globally (or in a book or bookpart), but > the generation of an actual MIDI file is only triggered when a \midi > block is encountered inside of a \score . Thanks for the idea and wording. https://gitlab.com/lilypond/lilypond/-/merge_requests/2171 Werner
Re: top-level `\midi` doesn't work as expected
Werner LEMBERG writes: > +A @code{@bs{}midi} block outside of @code{@bs{}score} does > +@emph{not} create a MIDI file.} MIDI settings can be changed globally (or in a book or bookpart), but the generation of an actual MIDI file is only triggered when a \midi block is encountered inside of a \score . Something like that. It doesn't help the user as much when you tell them what doesn't create a MIDI file: after all, they will rather be looking at how to create one. -- David Kastrup
Re: top-level `\midi` doesn't work as expected
> Thanks. I'll add this information to the NR. > > > Right now, the NR says the following > (https://lilypond.org/doc/v2.24/Documentation/notation/the-midi-block.html). > What > do you think needs to be clarified? > > To create a MIDI output file from a LilyPond input file, insert > a\midi block, which can be empty, within the \score block; > >\score { > … music … > \layout { } > \midi { } > } Since it is often not necessary to use `\score` for printed output explicitly I would like to add the patch below to make it clear that for MIDI output a `\score` block is mandatory. Werner == diff --git a/Documentation/en/notation/input.itely b/Documentation/en/notation/input.itely index 02621905aa..e6e26f8967 100644 --- a/Documentation/en/notation/input.itely +++ b/Documentation/en/notation/input.itely @@ -3830,7 +3830,10 @@ To create a MIDI output file from a LilyPond input file, insert a @warning{A @code{@bs{}score} block that, as well as the music, contains only a @code{@bs{}midi} block (i.e., @emph{without} the @code{@bs{}layout} block), will only produce MIDI output files. No -notation will be printed.} +notation will be printed. + +A @code{@bs{}midi} block outside of @code{@bs{}score} does +@emph{not} create a MIDI file.} The default output file extension (@code{.midi}) can be changed by using the @code{-dmidi-extension} option with the @code{lilypond} command:
Re: top-level `\midi` doesn't work as expected
Thanks. I'll add this information to the NR. Right now, the NR says the following (https://lilypond.org/doc/v2.24/Documentation/notation/the-midi-block.html). What do you think needs to be clarified? To create a MIDI output file from a LilyPond input file, insert a\midi block, which can be empty, within the \score block; \score { … music … \layout { } \midi { } }
Re: top-level `\midi` doesn't work as expected
>> I wonder whether it is expected that this simple input >> >> ``` >> { c' } >> \midi{} >> ``` >> >> doesn't create a MIDI file. > > > Yes. [...] Thanks. I'll add this information to the NR. Werner
Re: top-level `\midi` doesn't work as expected
> I wonder whether it is expected that this simple input > > ``` > { c' } > \midi{} > ``` > > doesn't create a MIDI file. Yes. Otherwise you could not do ``` \midi { global MIDI settings ... } fooMusic = ... \score { \fooMusic \layout { } } \score { \unfoldRepeats \fooMusic \midi { } } barMusic = ... \score { \barMusic \layout { } } \score { \unfoldRepeats \barMusic \midi { } } ``` signature.asc Description: This is a digitally signed message part
top-level `\midi` doesn't work as expected
[2.24.2, 2.25.10] I wonder whether it is expected that this simple input ``` { c' } \midi{} ``` doesn't create a MIDI file. I have to explicitly put everything into a `\score` block to get that. For me, this looks odd, and I couldn't find a hint in the documentation for that behaviour. Werner
Re: Initial rests in MIDI not included?
Le jeudi 28 septembre 2023 à 13:14 +0200, David Kastrup a écrit : > A quick `git grep lilymidi` confirms that there is is no documentation > for lilymidi. Zero, zilch, nada. > > It is installed with other binaries and is used by > elisp/lilypond-song.el (but what for?). There is this comment in elisp/lilypond-song.el: ;; We can't use midi files in ecasound directly, because setpos ;; doesn't work on them. Apparently its output is being used as some intermediate format, but don't ask me about it. The whole lilysong stuff is not documented either and I don't even know if it's working. I imagine it can also serve as a way of testing the midi.py module that also powers midi2ly (the latter is not exactly in a fabulous state of maintenance either ...). signature.asc Description: This is a digitally signed message part
Re: Initial rests in MIDI not included?
David Wright writes: > Yes, like lilymidi --pretty, the evidence that there was silence > at the beginning of the file is circumstantial, necessitating that > the OP believed I sat through the 160 seconds of silence before > any notes were played. > > BTW where is the output of lilymidi documented? A quick `git grep lilymidi` confirms that there is is no documentation for lilymidi. Zero, zilch, nada. It is installed with other binaries and is used by elisp/lilypond-song.el (but what for?). I'd have expected it to be used as part of 'make check' for comparing MIDI outputs, but that doesn't appear to be the case, either. So I don't really know how I know about it: probably by typing lily and getting curious about the completions. It is a rather handy checking tool for which I found no obvious substitute in the boxes of MIDI tools available on a typical GNU/Linux installation. -- David Kastrup
Re: Initial rests in MIDI not included?
On Wed 27 Sep 2023 at 10:22:04 (+0200), David Kastrup wrote: > David Wright writes: > > On Wed 27 Sep 2023 at 01:13:09 (+0200), Jean Abou Samra wrote: > >> After replacing “ ... ” with “ c' ”, I got the expected MIDI output with > >> LilyPond 2.24.2, i.e., lots of silence and four C notes at the end. > > > > I did the same, and I attach a screenshot of audacious playing the > > file, called mid.midi. The little white blip above the Play button > > is the equaliser graph displaying the first c' at 2 min 40 sec of > > playing time. (Yawn.) > > > > I also attach a screenshot of timidity playing the same file. Notice > > the length of the file: 4 seconds; and that's how long it plays for. > > That's all circumstantial evidence. Nobody so far has actually attached > the resulting MIDI file and/or the output of > > lilymidi --pretty > > on it. That would be way more informative. I dashed off my first reply before I dashed off to choir practice, just to give a (correct, as it turned out) hint to the OP to try playing the file with a different player. I didn't really look at the code as it involved repeats, and I know they've been changed in some way, which I haven't yet read up on. When I got back, I saw only Jean's reply, which still didn't mention how the file was being played, so I thought I'd give examples that showed the contrasting behaviour between two different players. Yes, like lilymidi --pretty, the evidence that there was silence at the beginning of the file is circumstantial, necessitating that the OP believed I sat through the 160 seconds of silence before any notes were played. BTW where is the output of lilymidi documented? Cheers, David.
Re: Initial rests in MIDI not included?
Kevin Cole writes: > On Wed, Sep 27, 2023 at 8:28 AM Jean Abou Samra wrote: > >> Le mercredi 27 septembre 2023 à 08:22 -0400, Kevin Cole a écrit : >> > And... we have a winner! It's a timidity problem! >> >> From what I can read, it is the expected behavior of timidity, but there >> is a --preserve-silence option to change it. >> > > Yeah, I was getting to that. ;-) Once it became a timidity issue, I > suspected there would be an option to alter that behavior. It just > hadn't occurred to me that timidity would default to happily ignoring > the quiet bits. I have no idea why anybody would consider that a sensible default, to be honest. I have a hard time imagining a sensible use case at all. Possibly skipping initial silences in manually recorded MIDI files that aren't edited at all in a sequencer? But that does not really sound all that sensible. -- David Kastrup
Re: Initial rests in MIDI not included?
Jean Abou Samra writes: > Le mercredi 27 septembre 2023 à 08:22 -0400, Kevin Cole a écrit : >> And... we have a winner! It's a timidity problem! > > > From what I can read, it is the expected behavior of timidity, but there > is a --preserve-silence option to change it. I don't have timidity installed and consequently am also missing its manual pages or I'd have checked. -- David Kastrup
Re: Initial rests in MIDI not included?
On Wed, Sep 27, 2023 at 8:28 AM Jean Abou Samra wrote: > Le mercredi 27 septembre 2023 à 08:22 -0400, Kevin Cole a écrit : > > And... we have a winner! It's a timidity problem! > > From what I can read, it is the expected behavior of timidity, but there > is a --preserve-silence option to change it. > Yeah, I was getting to that. ;-) Once it became a timidity issue, I suspected there would be an option to alter that behavior. It just hadn't occurred to me that timidity would default to happily ignoring the quiet bits. Especially since most of my problems end up being a misunderstanding of LilyPond or music theory. So naturally, I defaulted to those as the source of my troubles.
Re: Initial rests in MIDI not included?
Le mercredi 27 septembre 2023 à 08:22 -0400, Kevin Cole a écrit : > And... we have a winner! It's a timidity problem! From what I can read, it is the expected behavior of timidity, but there is a --preserve-silence option to change it. signature.asc Description: This is a digitally signed message part
Re: Initial rests in MIDI not included?
On Wed, Sep 27, 2023 at 8:04 AM David Kastrup wrote: What is apparent is that it may be a bad idea to first pause a number of > bars and only then include \global with a different \tempo . > Oops. Good catch. Thanks. But the location of the tempo change aside your principal problem, like > before, seems to be that timidity as a player skips initial rests. > And... we have a winner! It's a timidity problem! Try fluidsynth -ia pulseaudio -n on your MIDI file as an alternative (on > my system, I get inexplicable problems with -ia pipewire or -ia alsa) > instead. > Thanks!
Re: Initial rests in MIDI not included?
Kevin Cole writes: > I just tried it again with the attached, and still do not get "The Sound of > Silence" ;-) > > $ cat mwe.ly > \version "2.24.2" > \language "english" > global = { > \time 4/4 > \key f \major > \tempo 4=150 > } > PartFour = \relative a { > \global > \clef "treble" > \partial 4 a4 > } > \score { > \new Voice = "PartFour" { > R1*32 R1*24 > \repeat unfold 4 { > \transpose c c,, { \PartFour } > } > } > \midi { } > } $ lilymidi --pretty /tmp/mwe.midi Filename: /tmp/mwe.midi MIDI format: 1 (one or more simultaneous tracks) Divisions:1536 per whole note #Tracks: 2 Track 1: Time 0: Text: creator: Text: LilyPond 2.24.2 Time signature: 4/4, metronome 1/4 Tempo: 100 msec/quarter Time 86016: Time signature: 4/4, metronome 1/4 Tempo: 40 msec/quarter Time 86400: Time signature: 4/4, metronome 1/4 Time 86784: Time signature: 4/4, metronome 1/4 Time 87168: Time signature: 4/4, metronome 1/4 Time 87552: End of Track Track 2: Time 0: Track name: \new:PartFour Time 86016: Key signature: F major Note on: Channel 0, A1(33)@90 Time 86400: Note off: Channel 0, A1(33) Key signature: F major Note on: Channel 0, A1(33)@90 Time 86784: Note off: Channel 0, A1(33) Key signature: F major Note on: Channel 0, A1(33)@90 Time 87168: Note off: Channel 0, A1(33) Key signature: F major Note on: Channel 0, A1(33)@90 Time 87552: Note off: Channel 0, A1(33) End of Track What is apparent is that it may be a bad idea to first pause a number of bars and only then include \global with a different \tempo . But the location of the tempo change aside your principal problem, like before, seems to be that timidity as a player skips initial rests. Try fluidsynth -ia pulseaudio -n on your MIDI file as an alternative (on my system, I get inexplicable problems with -ia pipewire or -ia alsa) instead. -- David Kastrup
Re: Initial rests in MIDI not included?
On 2023-09-27 4:20 am, Kevin Cole wrote: I just tried it again with the attached, and still do not get "The Sound of Silence" ;-) $ cat mwe.ly \version "2.24.2" \language "english" global = { \time 4/4 \key f \major \tempo 4=150 } PartFour = \relative a { \global \clef "treble" \partial 4 a4 } \score { \new Voice = "PartFour" { R1*32 R1*24 \repeat unfold 4 { \transpose c c,, { \PartFour } } } \midi { } } $ lilypond mwe.ly GNU LilyPond 2.24.2 (running Guile 2.2) Processing `mwe.ly' Parsing... Interpreting music... MIDI output to `mwe.midi'... Success: compilation successfully completed $ timidity mwe.midi Playing mwe.midi MIDI file: mwe.midi Format: 1 Tracks: 2 Divisions: 384 Text: creator: Text: LilyPond 2.24.2 Track name: \new:PartFour Playing time: ~5 seconds Notes cut: 0 Notes lost totally: 0 Loads into a sequencer as expected, so the MIDI file itself seems fine. -- Aaron Hill
Re: Initial rests in MIDI not included?
I just tried it again with the attached, and still do not get "The Sound of Silence" ;-) $ cat mwe.ly \version "2.24.2" \language "english" global = { \time 4/4 \key f \major \tempo 4=150 } PartFour = \relative a { \global \clef "treble" \partial 4 a4 } \score { \new Voice = "PartFour" { R1*32 R1*24 \repeat unfold 4 { \transpose c c,, { \PartFour } } } \midi { } } $ lilypond mwe.ly GNU LilyPond 2.24.2 (running Guile 2.2) Processing `mwe.ly' Parsing... Interpreting music... MIDI output to `mwe.midi'... Success: compilation successfully completed $ timidity mwe.midi Playing mwe.midi MIDI file: mwe.midi Format: 1 Tracks: 2 Divisions: 384 Text: creator: Text: LilyPond 2.24.2 Track name: \new:PartFour Playing time: ~5 seconds Notes cut: 0 Notes lost totally: 0 mwe.midi Description: MIDI audio \version "2.24.2" \language "english" global = { \time 4/4 \key f \major \tempo 4=150 } PartFour = \relative a { \global \clef "treble" \partial 4 a4 } \score { \new Voice = "PartFour" { R1*32 R1*24 \repeat unfold 4 { \transpose c c,, { \PartFour } } } \midi { } }
Re: Initial rests in MIDI not included?
David Wright writes: > On Wed 27 Sep 2023 at 01:13:09 (+0200), Jean Abou Samra wrote: >> After replacing “ ... ” with “ c' ”, I got the expected MIDI output with >> LilyPond 2.24.2, i.e., lots of silence and four C notes at the end. > > I did the same, and I attach a screenshot of audacious playing the > file, called mid.midi. The little white blip above the Play button > is the equaliser graph displaying the first c' at 2 min 40 sec of > playing time. (Yawn.) > > I also attach a screenshot of timidity playing the same file. Notice > the length of the file: 4 seconds; and that's how long it plays for. That's all circumstantial evidence. Nobody so far has actually attached the resulting MIDI file and/or the output of lilymidi --pretty on it. That would be way more informative. -- David Kastrup
Re: Suppressing a voice in the midi output
Karsten, a new answer to your question arrived 5 years later, thanks to Stephen. I thought it would be useful to share back in the mailing list :) Ref: https://lists.gnu.org/archive/html/lilypond-user/2019-12/msg00276.html On Sun, Sep 24, 2023 at 03:16:59PM -0700, Stephen Riddle wrote: > Hi Sandro > > I'm not a member of the news list where you posted this (five years ago) > > but this is what I would have answered, > > I have found either all on or all off midi settings kind of awkward myself. > > Use the \with command when you start a new voice or staff or chordNames or > whatever: chordProgression = \chordmode { c1:sus2 \( c1 c1:sus2 c1 \) } > > \new ChordNames \with { \remove "Staff_performer" }{ \chordProgression } > \new Staff \with { \remove "Staff_performer" } { \chordProgression } > \new Staff { c'4 d' e' c'' b' c'' b' e'' d'' c'' d'' c''1 } > > which shuts down midi output for a single context. > > > Stephen
Re: Initial rests in MIDI not included?
On Wed 27 Sep 2023 at 01:13:09 (+0200), Jean Abou Samra wrote: > After replacing “ ... ” with “ c' ”, I got the expected MIDI output with > LilyPond 2.24.2, i.e., lots of silence and four C notes at the end. I did the same, and I attach a screenshot of audacious playing the file, called mid.midi. The little white blip above the Play button is the equaliser graph displaying the first c' at 2 min 40 sec of playing time. (Yawn.) I also attach a screenshot of timidity playing the same file. Notice the length of the file: 4 seconds; and that's how long it plays for. Cheers, David.
Re: Initial rests in MIDI not included?
On Tue 26 Sep 2023 at 18:52:52 (-0400), Kevin Cole wrote: > Once again, I'm flummoxed by some syntax problem... I was hoping for 40 > measures of silence, as I plan to mix it with other parts, and want to be > able to mute parts interactively. However the following doesn't give me 40 > measures of silence, but starts right in on PartTwo. What have I missed > THIS time? > > %%% > \version "2.24.2" > > PartTwo = \relative a { ... } > > \score { > \unfoldRepeats { > \new Voice = "PartTwo" { > R1*32 R1*8 > \repeat unfold 4 { > \transpose c c' { \PartTwo } > } > } > } > > \midi { } > } > %%% Is it possible your player is set to skip leading/trailing silence, which is quite usual. Cheers, David.
Re: Initial rests in MIDI not included?
After replacing “ ... ” with “ c' ”, I got the expected MIDI output with LilyPond 2.24.2, i.e., lots of silence and four C notes at the end. signature.asc Description: This is a digitally signed message part
Initial rests in MIDI not included?
Once again, I'm flummoxed by some syntax problem... I was hoping for 40 measures of silence, as I plan to mix it with other parts, and want to be able to mute parts interactively. However the following doesn't give me 40 measures of silence, but starts right in on PartTwo. What have I missed THIS time? %%% \version "2.24.2" PartTwo = \relative a { ... } \score { \unfoldRepeats { \new Voice = "PartTwo" { R1*32 R1*8 \repeat unfold 4 { \transpose c c' { \PartTwo } } } } \midi { } } %%%
Re: Is there a way to get a "round" to play in the MIDI without making several staggered identical voices?
On Wed, Sep 20, 2023 at 09:37:27AM -0400, Kevin Cole wrote: >I'm not quite sure how to ask the question. >Is there a way to play the same melody as different voices with different >time offsets -- i.e. without duplicating it and adding rests at the >beginnings of the duplicates? (I only want it in the MIDI part, as the >printed part would only need to display the basic melody once.) Assign the music to a variable, and reuse it multiple times: myMusic = { ... % music notes here } % Printed score \score { \new Staff { \myMusic } \layout {} } % MIDI \score { << \new Staff { \myMusic } \new Staff { R1 % whatever time offset you want here \myMusic } \new Staff { R1*2% deeper time offset \myMusic } >> \midi {} } T -- "The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts." -- Bertrand Russell. "How come he didn't put 'I think' at the end of it?" -- Anonymous
Re: Is there a way to get a "round" to play in the MIDI without making several staggered identical voices?
Am 20.09.23 um 15:37 schrieb Kevin Cole: I'm not quite sure how to ask the question. Is there a way to play the same melody as different voices with different time offsets -- i.e. without duplicating it and adding rests at the beginnings of the duplicates? (I only want it in the MIDI part, as the printed part would only need to display the basic melody once.) You mean like a round? I split the melody into single parts (entries) and re-combine them differently for layout and midi. See attachment. Hraban\version "2.22.0" %\include "../global.ly" \include "articulate.ly" % für besseres MIDI \header{ title = "Hejo, spann den Wagen an" poet = "mündl. überl." %composer = "M: " %arranger = "arr." %instrument = "2 voc + git" source = "Codex Patomomomensis" %maintainer = "Henning Hraban Ramm" %maintainerWeb = "http://angerweit.tikon.ch/lieder/; lastupdated = "2015-10-05" } global = { \clef treble \key b \minor \time 4/4 } akkorde = \chordmode { \repeat unfold 6 { e2:m b:m } } dynamics = \relative c { r4\mp } einsatzI = \relative c' { e2^\markup{1.} d | e8 e e e b2 | } einsatzII = \relative c' { e4^\markup{2.} e fis fis | g8 g g g fis2 | } einsatzIII = \relative c'' { b8^\markup{3.} b b b b4 b | b8 b b b b( a) g( fis) } einsatzIIIend = \relative c'' { b8^\markup{3.} b b b b4 b | b8 b b b b4 b } oberstimme = \relative c' { \einsatzI \einsatzII \einsatzIII \bar ":|." } einsatzLeer = \relative c' { s1 s } textI = \lyricmode { %\set stanza = "1. " He -- jo, spann den Wa -- gen an, denn der Wind treibt Re -- gen ü -- bers Land. Hol die gold -- nen Gar -- ben, hol die gold -- nen Gar -- ben. } % Papier-Ausgabe \score { \transpose e a << \context ChordNames { \akkorde } \context Staff = Oben << \global \context Voice = "eins" \oberstimme >> \new Lyrics \lyricsto "eins" { \textI } >> \layout { } } \markup{ \vspace #2.0 } \markup { \fill-line { \hspace #0.1 % Abstand vom linken Rand \column { \line { "de" \column { "Hejo, spann den Wagen an," "denn der Wind treibt Regen übers Land." "Hol die goldnen Garben," "hol die goldnen Garben." %"‿" } } \vspace #1.5 % Abstand zwischen Strophen \line { "–" \column { "Blut, Blut, Räuber saufen Blut." "Mord und Brand und Pulverdampf sind gut." "Hoch vom Galgen wimmert’s," "hoch vom Galgen wimmert’s." } } } \hspace #0.5 % Abstand zwischen Spalten \column { \line { "en" \column { "Hey ho, anybody home?" "Food and drink and money have I none." "Yet I will be merry," "yet I will be merry." } } } \hspace #0.1 % Abstand zum rechten Rand } } % MIDI \score { \unfoldRepeats { \transpose e a << \set Score.midiReverbLevel = #0.5 \set Score.midiChorusLevel = #0.5 \context Staff = "chords" << \set Staff.midiInstrument = "fx 4 (atmosphere)" \context Voice = "vchords" { \transpose c c, << \dynamics \akkorde >> } >> \context Staff = oberI << \articulate \set Staff.midiInstrument = "recorder" \set Staff.midiPanPosition = #-0.5 \set Staff.midiBalance = #-0.5 \context Voice = "vober" { \repeat unfold 3 { \oberstimme } \einsatzI \einsatzII } >> \context Staff = oberII << \articulate \set Staff.midiInstrument = "viola" \set Staff.midiPanPosition = #0.75 \set Staff.midiBalance = #0.75 \context Voice = "vober" { \einsatzLeer \repeat unfold 3 { \oberstimme } \einsatzI } >> \context Staff = oberIII << \articulate \set Staff.midiInstrument = "voice oohs" \set Staff.midiPanPosition = #0.25 \set Staff.midiBalance = #0.25 \context Voice = "vober" { \einsatzLeer \einsatzLeer \repeat unfold 2 { \oberstimme } \einsatzI \einsatzII \einsatzIIIend } >> >> } \midi { \tempo 4 = 120 } }
Is there a way to get a "round" to play in the MIDI without making several staggered identical voices?
I'm not quite sure how to ask the question. Is there a way to play the same melody as different voices with different time offsets -- i.e. without duplicating it and adding rests at the beginnings of the duplicates? (I only want it in the MIDI part, as the printed part would only need to display the basic melody once.)
Re: Script for midi rehearsal files per voice
I use Frescobaldi that essentially creates skeletons for that. Mobil gesendet > Am 28.07.2023 um 12:20 schrieb Stephan Schöll : > > Hi all > > Years ago I stumbled upon a script that generates midi rehearsal files > for each voice of an SATB choir e.g. and I missed the chance to bookmark > or save it somehow. > > After registering each voice with the script, it iterates through all > the voices. Each file contains all the voices keeping one voice louder > than the others. > > I'm not able to locate that in the docs, the LSR or in the archive anymore. > > I'd like to avoid static, manually written \book {} blocks for each > voice in each song. > > Any hint or advice is highly appreciated! TIA > > Stephan > >
Re: Script for midi rehearsal files per voice
It’s in Frescobaldi. Choose the SATB choir template and make sure the rehearsal midi checkbox is checked. HTH, Carl
Re: Script for midi rehearsal files per voice
> On 28 Jul 2023, at 16:15, Stephan Schöll wrote: > > Hi all > > Years ago I stumbled upon a script that generates midi rehearsal files > for each voice of an SATB choir e.g. and I missed the chance to bookmark > or save it somehow. > > After registering each voice with the script, it iterates through all > the voices. Each file contains all the voices keeping one voice louder > than the others. > > I'm not able to locate that in the docs, the LSR or in the archive anymore. > > I'd like to avoid static, manually written \book {} blocks for each > voice in each song. > > Any hint or advice is highly appreciated! TIA > > Stephan > > My gut feel would be that you’re referring to https://github.com/openlilylib/snippets/blob/master/ly/gridly/grid-templates.ily. It contains a rehearsalMidi function to create a midi highlighting a single given voice Kind regards, Hans
Script for midi rehearsal files per voice
Hi all Years ago I stumbled upon a script that generates midi rehearsal files for each voice of an SATB choir e.g. and I missed the chance to bookmark or save it somehow. After registering each voice with the script, it iterates through all the voices. Each file contains all the voices keeping one voice louder than the others. I'm not able to locate that in the docs, the LSR or in the archive anymore. I'd like to avoid static, manually written \book {} blocks for each voice in each song. Any hint or advice is highly appreciated! TIA Stephan
Re: Doubling a note makes MIDI output louder
On Sun, 9 Jul 2023, Knute Snortum wrote: > note out of the other hand. This is why I suggested that the MIDI performer > could ignore \parenthesize notes. Would this create a pile of workarounds > for you? Not as long as I don't use \parenthesize. But I think it's preferable not to have a presentation command ("print this in parentheses") with non-obvious semantic consequences ("don't include these notes in MIDI output"). Parentheses can mean many different things in different pieces of music; your situation is only one of those. Making remove-from-MIDI always the behaviour of parentheses, or the default unless overridden, would create Surprises! for anyone who tries to use parentheses for some other purpose and expects them to just be marks on the page. Better for "don't include this in MIDI" to be a separate command instead of a side effect of parentheses. Less good, but pragmatic because it doesn't require changing LilyPond, would be to use "tagging" to exclude the unwanted notes from the version of the music used to generate MIDI. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before tribes. https://ansuz.sooke.bc.ca/
Re: Doubling a note makes MIDI output louder
On Sun, Jul 9, 2023 at 7:54 AM wrote: > On Sun, 9 Jul 2023, David Wright wrote: > > > players. But that's the problem here. When two real voices happen on > > the same note, the result doesn't sound like one louder voice, yet > > that's the effect you get from MIDI,¹ where the "two" voices are > > Not on *my* MIDI synthesizer. Two notes are two notes! I'm inclined to > be concerned by this because I do a lot of doubling of notes between > different MIDI channels. Each channel plays on a different patch, or in a > separate monophonic recording run on the same patch, and a doubled note is > quite different from a louder note. > > If LilyPond were to start automatically deleting notes because someone > think's it's a bug for unisons to exist between MIDI tracks, it would make > the pile of workarounds I already need to use to get decent MIDI out of > LilyPond, that much worse. > Well, I didn't say it was a bug, and surely two MIDI tracks should normally play two notes, especially if they are different instruments. But I'm talking about a specific piano performance technique. When two voices (hands) have the same note written, the pianist doesn't play the same note with both hands. Instead they pick a hand to play the note and leave the note out of the other hand. This is why I suggested that the MIDI performer could ignore \parenthesize notes. Would this create a pile of workarounds for you? -- Knute Snortum
Re: Doubling a note makes MIDI output louder
On Sun 09 Jul 2023 at 10:53:58 (-0400), msk...@ansuz.sooke.bc.ca wrote: > On Sun, 9 Jul 2023, David Wright wrote: > > > players. But that's the problem here. When two real voices happen on > > the same note, the result doesn't sound like one louder voice, yet > > that's the effect you get from MIDI,¹ where the "two" voices are > > Not on *my* MIDI synthesizer. Two notes are two notes! I'm inclined to > be concerned by this because I do a lot of doubling of notes between > different MIDI channels. Each channel plays on a different patch, or in a > separate monophonic recording run on the same patch, and a doubled note is > quite different from a louder note. That may explain why you asked whether it was a problem. It is, but perhaps only with certain devices (like the poor snipped PCs). Even there, it could depend on the specific software involved. > If LilyPond were to start automatically deleting notes because someone > think's it's a bug for unisons to exist between MIDI tracks, it would make > the pile of workarounds I already need to use to get decent MIDI out of > LilyPond, that much worse. That's your terminology, not mine. I have no idea what LP's actions are when two voices play the same note, partcombined or not, nor how difficult it would be to make LP automatically delete particular notes upon instructions to do so. If the problem was of sufficient importance to me, I'd attack it in a completely different way, by postprocessing the MIDI output. Cheers, David.