kontrapunktstefan has asked for the wisdom of the Perl Monks concerning the following question:

Dear community, I have a question concerning perl and midi. I would like to read the input of a midi-keyboard and to transform in the syntax of the musical notation software lilypond. What I have in mind is e.g. pressing midi-key 60 and getting c'. Is this possible with perl?

Replies are listed 'Best First'.
Re: listen to a midi keyboard
by GrandFather (Saint) on Dec 28, 2013 at 11:02 UTC

    It's possible with pretty much any language if you have the right hardware. What hardware (midi to computer interface) have you got and what software bindings are provided with the driver for your midi interface?

    True laziness is hard work
Re: listen to a midi keyboard
by Anonymous Monk on Dec 28, 2013 at 14:47 UTC
    This can get quite complicated if you expect to be playing multiple notes at a time or keeping track of their lengths or...

    I'd recommend looking at software that can export to lilypond. I hesitate to mention Rosegarden (Linux-only) since it was terribly crashy and dog-slow the last time I tried it... But hmm, Denemo looks promising. It even uses lilypond under the hood.

    Besides, the MIDI-related Perl modules I can find on CPAN seem to be mostly about reading and writing .midi files, or writing to a MIDI device (i.e. playing such a file), and pretty much nothing about reading from a MIDI device. Maybe MIDI::ALSA or Win32API::MIDI can do something?

      Oh, and this one guy wrote a MIDI-to-lilypond plugin for jEdit which sounds like worth a try. (It's mentioned at the middle of the page.)

      Did Rosegarden or Denemo ever work as expected?

      I forgot how often this **** chrashed on my old Debian Box.

      Regards, Karl (loosing all his XPs)

      «The Crux of the Biscuit is the Apostrophe»

Re: listen to a midi keyboard
by karlgoethebier (Abbot) on Dec 28, 2013 at 13:15 UTC
    "...the musical notation software lilypond"

    I don't know very much about MIDI but i know a little bit about musical typesetting.

    IMHO you should think about a commercial solution instead of using lilypond.

    Or do you really want to learn Scheme?

    If so, i wish you well ;-) You need to do this if you want that lilypond does what you want.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      Dear Carl, I've been working for Years with Sibelius but I changed to lilypond, because it's better, in my opinion! I don't have any problems with the syntax, although I didn't learn scheme. The only thing I'm missing is the possibility of midi input via keyboard. I just wanted to know if perl could help me with that!

        OK, i surrender, sorry.

        But did you really like something like this:

        F = #(let ((m (make-music 'ArticulationEvent 'articulation-type "flageolet"))) (set! (ly:music-property m 'tweaks) (acons 'font-size -3 (ly:music-property m 'tweaks))) m) \relative c'' { c4^\F c4_\F }

        Shit, looks like elisp ;-)

        Update: BTW, Avid killed Sibelius.

        My best regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

      Could you please explain your observed (non)relation between "commercial solution" and "Scheme"?

      Cheers Rolf

      ( addicted to the Perl Programming Language)

Re: listen to a midi keyboard
by sundialsvc4 (Abbot) on Dec 30, 2013 at 01:29 UTC

    In the arena of musical notation software, I have tried several (including commercial products such as Sibelius), and hands down I have settled on ... an open-source, free product: MuseScore.   Runs on Windows, OS/X, and Linux, with numerous packages and ready-made installers.   Yes, this is meant as a two-thumbs-up endorsement.

    It is strictly a musical notation program, not a DAW, and don’t expect to “play a tune on your MIDI keyboard and have a score come out.”   It doesn’t do that ... that is excluded from the scope of its design.   It does include a SoundFont-based synthesizer ... standard files are included, with references to and instructions for downloading many more.   This is intended specifically to allow you to “proof” your scores as you are composing them, and as a matter of fact it does a very good job.   You can export your music as MusicXML (its native format), MIDI, and various sound files.   However, it is primarily a musical score-creation tool.

    After all, I don’t just “do Perl” for my daily bread.   This is the tool that I have contentedly settled upon.

    Since MusicXML is an open-standard format, understood by many applications, you could use Perl to manipulate it as XML.   Likewise, CPAN includes many libraries for MIDI files.   I would not attempt to use Perl to create a device-interface, but I would if necessary consider using it to manipulate the captured musical data.