On Sun, Feb 07, 2010 at 08:03:36PM +0100, Lorenzo wrote: > > >>>> 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 > > > Another completely different approach might be to create a Pd patch with > all the 'random midi logic' and then call it from bash with the -nogui > option... But not sure if this would fit in your scenario... > I used this little script Thursday night to drop some random samples in during stops in a song. First time I've busted out tapeutape live too. It went over pretty well. Two sets of samples, triggered by two different pads on the Novation. -ken --------------- #!/usr/bin/python import os,sys import random import alsaseq import alsamidi sys.path.append('/home/music-projects/lib') import alsaevent alsaseq.client('randomsamples', 1, 1, False) def main_loop(): while True: msg=alsaseq.input() if msg: ev=alsaevent.AlsaEv(*msg) if ev.type == alsaseq.SND_SEQ_EVENT_NOTEON: if ev.notenum == 36: alsaseq.output(alsamidi.noteonevent(0, random.randint(0,24), ev.vel)) elif ev.notenum == 38: alsaseq.output(alsamidi.noteonevent(0, 30+random.randint(0,28), ev.vel)) #### MAIN if __name__ == '__main__': main_loop() _______________________________________________ Linux-audio-user mailing list Linux-audio-user@xxxxxxxxxxxxxxxxxxxx http://lists.linuxaudio.org/listinfo/linux-audio-user