Lilypond, Mutopiaproject and Pianobooster, a short tutorial

classic Classic list List threaded Threaded
11 messages Options
CRP
Reply | Threaded
Open this post in threaded view
|

Lilypond, Mutopiaproject and Pianobooster, a short tutorial

CRP
Lilypond is a typesetting system for sheet music (think LaTeX for music). It takes a text format file containing a few commands which tell how the notes are, and produces two things:
1) a very nice pdf of the score
2) a midi file which plays exactly like the score
So basically this can be very useful for educational uses, for example a teacher can write down a few simple songs and obtain a clean score with a corresponding midi file where left and right hand are clearly separated. After some work (detailed below) these midi files can then be used in Pianobooster for exercise.

LilyPond can be obtained here: http://lilypond.org/web/ (where also full tutorials and docs are available!)

Let's see a sample Lilypond file (everything preceded by a % sign is treated as a comment):
----------------------------------------------------------------------------------------
% the following line tells lilypond to print a header on the sheet
\header{
  title = "Some Exercises"
}

% now let us define the variable "right" as a sequence of notes relative to middle c
% notes are specified by the letters, and, if followed by a dash and a number, also fingerings are printed
right= \relative c' {
        c-1 e-3 d-2 f-4
        c-1 d-2 f-4 e-3
        c-1 e-3 f-4 d-2
        f-4 e-3 d-2 c-1
        e-3 c-1 f-4 d-2
        c-1 d-2 e-3 f-4
}

left= \relative c' {
        c-1 a-3 b-2 g-4
        c-1 b-2 g-4 a-3
        c-1 a-3 g-4 b-2
        g-4 a-3 b-2 c-1
        a-3 c-1 g-4 b-2
        c-1 b-2 a-3 g-4
}

% ok, now let us put everything together as a new score with a pianostaff (treble+bass keys)
\score {
  \new PianoStaff <<
        \set PianoStaff.instrumentName = #"acoustic grand" % specify instrument name for the midi file
        \new Staff = "upper" {
                \clef treble % print a treble clef
                \right % import "right" as defined above
        }

        \new Staff = "lower" {
                \clef bass % print a bass clef
                \left % import "left" as defined above
        }
  >>

  \layout{} % this tells lilypond to print the score creating a pdf
  \midi{} % this tells lilypond to create a midi file
}
----------------------------------------------------------------------------------------

After saving the above as a text file (lets call it exercise.ly), just run "lilypond exercise.ly" from the command line to compile the file and obtain pdf and midi files.

Looking at the just created midi file, one will notice that it has three channels, called "control" (this is always created, independent of user), "upper" and "lower". Basically, lilypond creates a separate channel for each staff it encounters in the .ly file.

Unfortunately, pianobooster expects midi files with the piano parts on channel 3 (right hand) and 4 (left hand), so in order to obtain a midi file which works fine in PianoBooster, a few changes are necessary. In the .ly file, the part which defines the score has to be modified like this:
----------------------------------------------------------------------------------------
\score {
  \new PianoStaff <<
        \set PianoStaff.instrumentName = #"acoustic grand" % specify instrument name for the midi file
        \new Staff ="" {} % create an empty staff which will go in channel 2 of the midi file
        % now we will switch "upper" and "lower", so that "lower" goes in channel 3 and "upper" in channel 4
        \new Staff = "lower" {
                \clef bass % print a bass clef
                \left % import "left" as defined above
        }

        \new Staff = "upper" {
                \clef treble % print a treble clef
                \right % import "right" as defined above
        }
  >>

  \layout{} % this tells lilypond to print the score creating a pdf
  \midi{} % this tells lilypond to create a midi file
}
----------------------------------------------------------------------------------------
Now compile again and you will have a midi file which works fine in PianoBooster.

There is a large collection of free sheet music on www.mutopiaproject.org, and for each piece there is also the .ly file available, so following the example above it is very easy to convert each piece into a midi file which works fine in PianoBooster.

It would also be nice if someone put up a repository for some simple sheet music to be used for learning purposes with PianoBooster. Also, I hope sooner or later PianoBooster will allow to select midi channels to be used for left and right hand more easily so that nonstandard midi files can be used with this wonderful program more easily.

Cheers
Chris


Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

vmcb
Thanks for this, just what I was looking for.

Looking forwrd to trying it out

Veronica
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

vmcb
These modifications really muck up the pdf output though.  It looks like you need separate ly files for midi generation and pdf generation this way.

But now I know how to reassign channels in Piano Booster so maybe won't worry about the modifications.

Veronica
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

Louis B.
Administrator
If you manage to create any copyright free  PB midi files. It would be grate if you could post them here and we can added them the distribution.

let us know how you get on (I am on holiday for one week).

Thanks

Louis
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

jesselks
Louis,

Would it be possible to change which midi channels PB expects to match what lilypond produces?

I realize that PB may need more info than Lilypond provides, or perhaps there's some other technical issue, but it would be nice to have easier access to existing midi.

Alternatively, perhaps it's worth talking with the Lilypond folks to encourage them to alter their midi generation code. It may make sense to them to support PB.

Jesse
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

Louis B.
Administrator
Hi Jesse,

You can already set the MIDI piano channels by right clicking on the channels or alternatively through song menu.

However pb also tries to automatically detect MIDI piano parts on channels 3 & 4. What channels does lilypond use? Perhaps you can post a sample MIDI file from lilypond.

L.

"jesselks [via Piano Booster]" <[hidden email]> wrote:
Louis,

Would it be possible to change which midi channels PB expects to match what lilypond produces?

I realize that PB may need more info than Lilypond provides, or perhaps there's some other technical issue, but it would be nice to have easier access to existing midi.

Alternatively, perhaps it's worth talking with the Lilypond folks to encourage them to alter their midi generation code. It may make sense to them to support PB.

Jesse


If you reply to this email, your message will be added to the discussion below:
http://piano-booster.2625608.n2.nabble.com/Lilypond-Mutopiaproject-and-Pianobooster-a-short-tutorial-tp2574387p6373825.html
To start a new topic under Piano Booster Users, email [hidden email]
To unsubscribe from Piano Booster Users, click here.
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

m.tarenskeen
In reply to this post by CRP
I was looking for an answer to exactly this issue.
I tried your solution ... it does not work, or at least it does not work anymore using LilyPond 2.13.34 that I am using now. The problem is: with your solution my piano parts go to MIDI channel 1 and 2. The empty Staff does not occupy a MIDI channel anymore. The first channel is assigned to the first staff that has notes in it.
Apparently LilyPond behaviour has changed since 2009?
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

pczhang
I second this. The solution does not seem to work anymore.
Ion
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

Ion
Hey fellas, I have prepared a pretty long midi file for learning the notes in the bass clef.
It has only quarter notes and they are all random (I generated it with a small program that outputs lilypond files and midi files) so that you can't memorize them. It starts with a range from F2 to C3 and gradually adds lower notes every 20 bars or so.
As I say I generate these files with a tiny program I wrote in C++ (cause I kept memorizing all the beginner's lessons) so if you need to practice a specific interval, I can generate like a thousand bars in no time.
It is intended only to learn how to read the notes, not really to learn how to play, that is, it's for total noobs.
If you want the .ly file or pdf I can give them too.

www.estonomecuadra.com/file/clefbassrandomgradual.midi

I hope someone finds it as useful as I have.
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

robert1968
Sound interesting.i will check it.
Thanks for efforts. Robert
Reply | Threaded
Open this post in threaded view
|

Re: Lilypond, Mutopiaproject and Pianobooster, a short tutorial

JasonWoof
In reply to this post by CRP
Hi all. I'm new to pianobooster, and loving it!

Thank you CRP for figuring out how to separate the tracks for pianobooster!

... but then I read that lilypond now ignores empty staves, so there was no obvious way to achieve the midi track numbers that pianobooster expects. I had the idea of putting a rest on the empty staves, and it worked!

Below I'll paste my full lilypond file. It renders beautifully to PDF, and the midi file opens in pianobooster with the correct hand mappings.

\version "2.10.33"
\header {
	filename =    "half-steps.ly"
	title =       "Half-steps"
	source =      ""
	composer =    "Jason Woofenden"
	enteredby =   "Jason Woofenden"
	copyright =   "Public Domain 2007"
	footer = ""
	tagline = ""
}

#(set-default-paper-size "letter")

bassline = {
	\new Staff {
		\context Voice {
			\relative c'' {
				\set Score.barNumberVisibility = #'()
				\tempo 4.=150
				\time 6/8
				\clef bass
				\key c \major

				\repeat volta 2 {
					<<
						{ g,4. fis f e dis d cis c b ais a gis a ais b c }
						{ g4.  fis f e dis d cis c b ais a gis a ais b c }
					>>
				} \break

				\repeat volta 2 {
					<<
						{ cis'4. d dis e f fis g gis  g fis f e dis d cis c }
						{ cis,4. d dis e f fis g gis  g fis f e dis d cis c }
					>>
				} \break
			}
		}
	}
}

melody = {
	\new Staff {
		\context Voice {
			\relative c'' {
				\set Score.barNumberVisibility = #'()
				\time 6/8
				\clef treble
				\key c \major

				\repeat volta 2 {
					g8 a b   a g fis   a g f       e4.     fis8 g a   fis g a     f dis cis   c4.  \break
					d8 r d   cis4.     c8 cis d    dis4.   cis8 c b   ais a gis   fis4.       g4.
				} \break

				\repeat volta 2 {
					fis8 ais fis  a f a  g fis g  gis4.    a8 c dis  cis ais cis  d b f'  dis4.  \break
					g8 d b  fis' c a  dis4 c8       e4.    dis8 d dis  d dis e  f dis cis  c4.
				} \break
			}
		}
	}
}


\score {
	<<
		\melody
		\bassline
	>>
	\layout { }
}

% pianobooster wants melody on track 4 and bass on track 3:
\score {
	\unfoldRepeats
	<<
		\new Staff { \context Voice { r8 } }
		\new Staff { \context Voice { r8 } }
		\bassline
		\melody
	>>
	\midi { }
}