/** * This program loads FM instrument definitions onto the specified sound card. * This program assumes the presence of the 4 files defined in midi.c as * O3MELODIC, O3DRUMS, SBMELODIC, SBDRUMS. * * Tested under Linux 2.4 on Intel architecture only. * * Author: Adam Buckley, adambuckley@gmx.net * Version: $Id: fmload.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 "midi.c" #include // Constants // --------- #define MAX_DEV_NUM 99 void printUsage() { printf("fmload [-r] [-n device_number] [-t fm_chip_type]\n\t-t fm_chip_type is either 'opl3' or 'sb'\n\t-r use reverb\n"); } // Main // ---- int main(int argc, char **argv) { char* dev = "/dev/sequencer2"; char command; int chip = FM_INSTR_SB; int devNum = 0; int reverb = 0; // Process command line while((command = getopt(argc, argv, "?rt:n:")) != -1) { switch(command) { case 't': if(strcmp(optarg, "opl3")==0) chip = FM_INSTR_OPL3; else if(strcmp(optarg, "sb")==0) chip = FM_INSTR_SB; else { printf("fmload: illegal value for t parameter\n"); printUsage(); } exit(-1); break; case 'r': reverb = 1; break; case 'n': devNum = atol(optarg); if(devNum<0 || devNum>MAX_DEV_NUM) { printf("fmload: n must be between 0 and %d inclusive\n", MAX_DEV_NUM); exit(-1); } break; case '?': printUsage(); exit(0); break; default: break; } } // Load FM instrument definitions startMidi(dev, devNum); fmload(devNum, reverb, chip); stopMidi(); return 0; }