/* moxctest.c -- a test program illustrating moxc */ /* * this program plays a short figure on every keydown */ #include "cmtprog.h" mainscore() begin int r; /* * turning on continuous controller messages (DX7 aftertouch messages) * will REALLY load the cpu, so only use this if you need it! */ /* midi_cont(true); */ /* * play a note with a random pitch: */ note(r = random(0, 100), 20); /* * cause mainscore to run every 2 seconds */ cause(200, mainscore); printf("random(0, 100) = %d\n", r); end keyup(c, k) /* this gets called whenever a key goes up */ begin /* turn off all the notes turned on by keydown */ cause(40, midi_note, c, k+1, 0); cause(70, midi_note, c, k-1, 0); cause(95, midi_note, c, k+2, 0); cause(115, midi_note, c, k-2, 0); cause(130, midi_note, c, k+3, 0); cause(140, midi_note, c, k-3, 0); cause(145, midi_note, c, k+4, 0); end keydown(c, k, v) /* this is called when a keyboard note is pressed */ begin /* schedule a short phrase transposed by k */ cause(40, midi_note, c, k+1, v); cause(70, midi_note, c, k-1, v); cause(95, midi_note, c, k+2, v); cause(115, midi_note, c, k-2, v); cause(130, midi_note, c, k+3, v); cause(140, midi_note, c, k-3, v); cause(145, midi_note, c, k+4, v); end ctrlchange(chan, ctrl, value) begin printf("ctrlchange: chan %d, ctrl %d, value %d\n", chan, ctrl, value); end bendchange(chan, value) begin printf("bendchange: chan %d, value %d\n", chan, value); end peddown(c) begin printf("peddown, chan %d\n", c); end pedup(c) begin printf("pedup, chan %d\n", c); end asciievent(c) { if (c == 'q') quit(); else if (c == 'n') midi_thru(true); else if (c == 'f') midi_thru(false); else printf("Type q to quit.\n"); }