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 Kastrup
Subject: Re: "Problematic" conversion from MIDI: c4*5, c1 (in 3/4 time) etc.
Date: Fri, 29 Jul 2016 16:00:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Mojca Miklavec <address@hidden> writes:

> 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.

Yes, this sucks.  The salient point is that the durations are not
necessarily detected correctly, and more importantly, that their
relation to the bar lines (which a single timing mistake will move who
knows where) is not really known to be correct.  So midi2ly does not try
meddling with ~ and such stuff but converts every note to a single
recognizable entity.

You can partly fix this up using the Completion_heads_engraver like
follows:

\score {
  \new Voice = "melody"
  \with {
    \remove "Note_heads_engraver"
    \remove "Rest_engraver"
    \consists "Completion_heads_engraver"
    \consists "Completion_rest_engraver"
    completionUnit = #(ly:make-moment 3/4)
    completionFactor = 1
  }
  {
    \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 {}
}
But you'll notice that this still does not deliver perfect results.  You
won't get around reediting, really.

> 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.

midi2ly produces a single note/note-length and a maximum of one dot.
The rest it does by scaling.

I'm not going to defend it.  midi2ly is an old utility and it suffers
from being a batch tool.  An interactive tool that would correct
bar-lines as the user corrects recognized durations and then can
re-split durations after correction would have a lot more sanity going
for it.

> 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.

Completion_* engravers fix a bit of the typeset result but not
necessarily enough, and the input stays ugly.

-- 
David Kastrup

reply via email to

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