Re: [LAU] sending random midi notes from a bash script

From: Pedro Lopez-Cabanillas <pedro.lopez.cabanillas@email-addr-hidden>
Date: Sun Feb 07 2010 - 15:51:26 EET

On Sunday, February 7, 2010, james morris wrote:
> On 6/2/2010, "Pedro Lopez-Cabanillas"
>
> <pedro.lopez.cabanillas@email-addr-hidden> wrote:
> >> The tool would just be required to send a single midi note to some port.
> >> The note to be sent should be specifiable on command line, along with
> >> length/velocity ... probably would be enough.
> >>
> >> Any ideas?
> >
> >As an example, here is a bash script that can be used with cron, to play
> >hourly a tune and some strokes.
>
> Thanks Pedro, that's quite useful.
>
> I'm using the playnote function from your script. I see you make a
> translation of note names to other ascii chars using tr (before you call
> playnote), and it's this latter "scale" string I'm interested in, as
> my script does not need to deal with note names at this stage.
>
> I've used an expansion of the string "<>@ACEGHJLMOQS" to
> "<>@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" which does

This translation requires a bit of explanation. The first set of characters
("cdefgabCDEFGAB") are two octaves, the lower one represented by the
symbols "cdefgab" and the upper one by the symbols "CDEFGAB". The two sets
are note names used in the tune, declared at the top:

tune="C 4, E 4, D 4, g 2, C 4, D 4, E 4, C 2, \
      E 4, C 4, D 4, g 2, g 4, D 4, E 4, C 2,"

But the MIDI devices expect MIDI note numbers instead of symbolic names, so a
translation is needed. The symbol "c" is translated into the character "<"
(character code 0x3C, decimal 60), and the symbol "C" into the character "H"
(code 0x48, decimal 72). The character codes are the MIDI note numbers, and
we are writting them to character devices (/dev/midi*).

The MIDI note numbers and their corresponding musical notes can be seen in
this nice graphic:
http://en.wikipedia.org/wiki/File:NoteNamesFrequenciesAndMidiNumbers.svg

If you don't need to deal with note names, I suggest you to use the MIDI note
numbers directly. This gives you the widest possible range of notes.

> give me a wider range of notes, but is very middly, there's no bass
> notes nor anything from the high octaves.
>
> How might I get the bass and high end?

Another example is attached. In this case, the script plays a more complex
tune for two voices codified without using symbolic note names. Using this
technique you can even specify different velocities for each note (although
this example uses 0x64, dec.100 for all notes). The sample also uses running
status and knows how to cope with silences.

Regards,
Pedro

_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user

Received on Sun Feb 7 16:15:03 2010

This archive was generated by hypermail 2.1.8 : Sun Feb 07 2010 - 16:15:03 EET