/** * This program plays a scale which is looped until you press CTRL-C and is * used to test that midi.c and /dev/sequencer2 are working. * * Tested under Linux 2.4, OSS/Free on Intel architecture only. * * Author: Adam Buckley, adambuckley@gmx.net * Version: $Id: seq2test.c,v 1.2 2002/05/23 12:13:55 adam Exp $ */ /** * This source code is copyright (c) 2002 Adam Buckley, . * * This source code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This source code is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * The GNU General Public License can be found at * http://www.gnu.org/licenses/gpl.html */ #include #include "midi.c" // main // ---- int main(int argc, char** argv) { char* dev = "/dev/sequencer2"; int i; // patch = 77 flute for debugging awe32 int devNum = 0, channel = 0, patch = 0, velocity = 100; int notes[8] = {60, 62, 64, 65, 67, 69, 71, 72}; // Get device number if(argc >= 2) devNum = atoi(argv[1]); // Get MIDI resources startMidi(dev, devNum); // Set patch to default SEQ_SET_PATCH(devNum, channel, patch); // Set volume to maximum SEQ_CONTROL(devNum, channel, CTL_MAIN_VOLUME, 100); // Set pan to middle SEQ_CONTROL(devNum, channel, CTL_PAN, 64); // Play notes while(1) { for(i=0; i<8; i++) { if(sendVoiceMessage(devNum, MIDI_NOTEON, channel, notes[i], velocity, TRUE) < 0) { printf("Error writing to %s\n", dev); exit(1); } usleep(50000); if(sendVoiceMessage(devNum, MIDI_NOTEON, channel, notes[i], 0, TRUE) < 0) { printf("Error writing to %s\n", dev); exit(1); } usleep(150000); } } usleep(400000); stopMidi(); return 0; }