//------------------------------------------------------------------------- // Filename: main.cc // Version: $Id: main.cc,v 1.1.4.2 1999/06/09 10:14:04 erik Exp $ // Copyright: Copyright (C) 1999, Erik Mouw (J.A.K.Mouw@its.tudelft.nl) // Author: Erik Mouw // Description: main file for Musica // Created at: Sun Feb 28 18:08:10 1999 // Modified by: Erik Mouw // Modified at: Sun Jun 6 15:12:52 1999 //------------------------------------------------------------------------- // // This program 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 program 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. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #ident "$Id: main.cc,v 1.1.4.2 1999/06/09 10:14:04 erik Exp $" #ifdef HAVE_CONFIG_H # include #endif #include #include "main.hh" #include "gui.hh" #include "mididevice.hh" #include "ossmidi.hh" #include "channel2device.hh" #include "program2device.hh" #include "channel2channel.hh" #include "program2program.hh" #include "player.hh" midiDevice *theDevice = 0; midiPlayer *thePlayer = 0; static char deviceName[] = "/dev/sequencer"; int main(int argc, char *argv[]) { int i; GtkWidget *mainWindow; ossSequencer *rolandHp330; midiChannel2Channel *rolandHp330ChannelMap; midiProgram2Program *rolandHp330ProgramMap; ossSequencer *sbAwe64; midiProgram2Device *mainDeviceMap; midiChannel2Device *mainChannelMap; // initialise widget set gtk_init(&argc, &argv); // create some MIDI devices // first a "real" device: the Roland HP330 on the external MIDI port rolandHp330 = new ossSequencer("External MIDI port"); rolandHp330->setDevice(deviceName, 0); rolandHp330->open(); // map all channels on channel 0 (the default receive channel) rolandHp330ChannelMap = new midiChannel2Channel("HP-330 channel map"); rolandHp330ChannelMap->setDevice(rolandHp330); for(i = minMidiChannel; i <= maxMidiChannel; i++) rolandHp330ChannelMap->setChannel(i, i); rolandHp330ChannelMap->open(); // the HP 330 is only realy good at playing the piano // FIXME: lookup the default GM map rolandHp330ProgramMap = new midiProgram2Program("HP-330 program map"); rolandHp330ProgramMap->setDevice(rolandHp330ChannelMap); rolandHp330ProgramMap->setDefaultPrograms(); rolandHp330ProgramMap->open(); // another "real" device: the EMU 8000 synthesiser on the SB 64 AWE Gold sbAwe64 = new ossSequencer("SB AWE 64"); sbAwe64->setDevice(deviceName, 1); sbAwe64->open(); // the main MIDI device: play everything on the AWE 64, except for the piano mainDeviceMap = new midiProgram2Device("device map"); mainDeviceMap->setAllDevices(sbAwe64); rolandHp330ProgramMap->setProgram(0, 0); // acoustic piano mainDeviceMap->setDevice(0, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(1, 1); // bright piano mainDeviceMap->setDevice(1, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(3, 9); // honky tonk mainDeviceMap->setDevice(3, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(4, 5); // electric piano 1 mainDeviceMap->setDevice(4, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(5, 6); // electric piano 2 mainDeviceMap->setDevice(5, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(6, 3); // harpsichord mainDeviceMap->setDevice(6, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(13, 4); // xylophon mainDeviceMap->setDevice(13, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(19, 7); // church organ mainDeviceMap->setDevice(19, rolandHp330ProgramMap); rolandHp330ProgramMap->setProgram(49, 8); // slow strings mainDeviceMap->setDevice(49, rolandHp330ProgramMap); mainDeviceMap->open(); // The main channel map: map everything to the main device map, // except for channel 9 (drum channel) which goed directly to the SB mainChannelMap = new midiChannel2Device("channel map"); mainChannelMap->setAllDevices(mainDeviceMap); mainChannelMap->setDevice(9, sbAwe64); mainChannelMap->open(); theDevice = mainChannelMap; if(theDevice->open() == false) return(-1); // create MIDI player thePlayer = new midiPlayer; thePlayer->setDevice(theDevice); // create main window and show it if(argc > 1) mainWindow = createMainWindow(argv[argc - 1]); else mainWindow = createMainWindow(); gtk_widget_show(mainWindow); // main loop gtk_main(); // cleanup memory delete thePlayer; mainChannelMap->close(); delete mainChannelMap; mainDeviceMap->close(); delete mainDeviceMap; rolandHp330ProgramMap->close(); delete rolandHp330ProgramMap; rolandHp330ChannelMap->close(); delete rolandHp330ChannelMap; sbAwe64->close(); delete sbAwe64; rolandHp330->close(); delete rolandHp330; return(0); }