bug-lilypond
[Top][All Lists]
Advanced

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

Re: "Problematic" conversion from MIDI: c4*5, c1 (in 3/4 time) etc.


From: David Wright
Subject: Re: "Problematic" conversion from MIDI: c4*5, c1 (in 3/4 time) etc.
Date: Sun, 31 Jul 2016 13:16:22 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri 29 Jul 2016 at 23:02:22 (+0200), Mojca Miklavec wrote:
> On 29 July 2016 at 21:55, David Wright wrote:
> > On Fri 29 Jul 2016 at 14:29:57 (+0200), Mojca Miklavec wrote:
> >> I have a midi file that I wanted to convert into scores, but the
> >> scores simply don't look right.
> >>
> >> While I have a real (relatively long) song in the MIDI, I believe that
> >> I can fully reproduce the problem with the following simple example:
> >>
> >>     \score {
> >>       \new Voice = "melody" {
> >>         \set Staff.midiInstrument = "accordion"
> >>         \time 3/4
> >>         \relative c' {
> >>           c4 c c |
> >>           c1 d4 e |
> >>           f4*5 g4 |
> >>           f2.~ | % becomes f4*5
> >>           f2 e4 |
> >>           d4*3 | % becomes d2.
> >>           c4 c2~ | % becomes c1
> >>           c2
> >>         }
> >>       }
> >>       \midi { \tempo 4 = 160 }
> >>       \layout {}
> >>     }
> >>
> >> (I picked accordion because one doesn't hear the duration with piano.)
> >>
> >> The idea is to make midi from the above example first (lilypond
> >> test.ly), then convert midi to scores (midi2ly test.midi -o test2.ly)
> >> and typeset again (lilypond test2.ly).
> >>
> >>
> >> The resulting MIDI file sounds right, but the typesetting of it is
> >> very strange. I get just a single quarter note printed out rather than
> >> something that takes the duration of five times a quarter.
> >>
> >> OK, that's probably expected when I consciously enter the above
> >> syntax, but not after conversion from a MIDI file.
> >>
> >> I noticed that the whole idea of the asterisk operator is to print a
> >> single unit, but to prolong it in MIDI (or for other purposes). But
> >> there's a lot of inconsistency:
> >> - if I properly enter c2.~ c2, I get c4*5 from the midi conversion
> >> - if I properly enter c2~ c2, I get c1 which is "forbidden" inside 3/4
> >> - if I sloppily enter c4*3 which would typset in a very weird way, it
> >> comes out OK after the conversion as c2.
> >>
> >> None of that makes any sense to me.
> >>
> >> Sure I can manually fix the resulting plain text file, but I was
> >> wondering if there was really no better way to get this done properly
> >> and automatically.
> >
> > In the absence of any output examples, I've attached what my system
> > produces from your source. Let us know what's incorrect.
> 
> Oh wait!
> 
> The "answer" to my question has always been there in the generated ly
> file. These are the important settings that make all the difference:
> 
>     \remove "Note_heads_engraver"
>     \consists "Completion_heads_engraver"
> 
> (plus of course those for rests).
> 
> The main problem is that what I do is:
> - run midi2ly (outputting absolute pitches & durations) to get the melody out
> - copy just the melody to a different file template to get exactly the
> staff arrangement I want (the default output is semi-useless for my
> particular use case)
> 
> In fact I didn't realize that I would get correct PDF if I kept those
> two settings.
> 
> This approach of copying just the melody avoids many useless settings like
>     \set Staff.instrumentName = "\new:melody"
> but the two/four necessary lines were accidentally omitted.
> 
> > It looks to
> > me as if the original score is just what you (idiosyncratically) asked
> > for and the subsequent score has been "conventionalised" as one might
> > expect, because the midi performer has no way of representing your
> > odd notation.
> 
> I don't think so. I didn't try to manually inspect the dump of the
> midi file (maybe I should), but I strongly suspect that there will be
> absolutely no difference in midi irrespective of whether I enter
> c2.~c2 or c4*5.

That's what I said: the midi performer has no way of representing your
odd notation. The MIDI file has note pitches, starting times, and
durations, expressed in beats. Your "odd notation", whether it's
c2.~c2 or c4*5, and whether the former's tie is conventionally placed,
makes no difference to the starting time and duration.

> It must be midi2ly that eventually decides what to do
> with pitches that last for some "weird durations".

There are no weird durations in the MIDI; there are just durations. A
note lasts as long as the composer writes into the score. AFAICT all
midi2ly does is to perform some mechanical arithmetical reductions
corresponding to a schoolchild learning cancellation in fractions¹.
IOW c4*4 can be written as c1, c4*10 as c2*5, and so on. What it never
appears to do is to create two notes and a tie.

> midi2ly already provides options for outputting absolute or relative
> pitches, to always include the timing (or only when necessary), ...
> There could potentially be another parameter to determine whether
> midi2ly should produce "c1" or "c2.~c4". Or perhaps some way to fix
> this with python-ly that I have to run anyway. Maybe that exists
> already.

This just complicates midi2ly without adding any functionality lacking
elsewhere. If it worries you, it's easy to spot the overlapping notes.
¹Because midi2ly knows when it "cheats", it doesn't break the output
line and write "a | % NN" (which would cause a barcheck) until it
finds a barline with no overlapping note, so at these places the bar
numbering jumps by more than 1.

> ... the easiest solution would be simply add
>     \remove "Note_heads_engraver"
>     \consists "Completion_heads_engraver"
> to my main document and stop worrying.

Cheers,
David.



reply via email to

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