//------------------------------------------------------------------------- // Filename: program2program.cc // Version: $Id: program2program.cc,v 1.1.2.2 1999/06/09 10:14:05 erik Exp $ // Copyright: Copyright (C) 1999, Erik Mouw (J.A.K.Mouw@its.tudelft.nl) // Author: Erik Mouw // Description: Remap MIDI programs // Created at: Mon May 24 15:30:16 1999 // Modified by: Erik Mouw // Modified at: Wed Jun 9 12:09:32 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: program2program.cc,v 1.1.2.2 1999/06/09 10:14:05 erik Exp $" #ifdef HAVE_CONFIG_H # include "config.h" #endif #ifdef MUSICA_DEBUG # include #endif #include #include "program2program.hh" static const char *deviceType = "program-to-program"; midiProgram2Program::midiProgram2Program(const char *theName) : midiDevice(theName) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif setDevice(0); setDefaultPrograms(); type = deviceType; } midiProgram2Program::~midiProgram2Program(void) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif // don't delete the device! } void midiProgram2Program::setDevice(midiDevice *d) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif device = d; } midiDevice *midiProgram2Program::getDevice(void) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif return(device); } void midiProgram2Program::setProgram(int from, int to) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif assert(from >= 0 && from < numMaxMidiPrograms); assert(to >= -1 && to < numMaxMidiPrograms); programMap[from] = to; } void midiProgram2Program::setDefaultPrograms(void) { int i; #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif for(i = 0; i < numMaxMidiPrograms; i++) programMap[i] = i; } int midiProgram2Program::getProgram(int from) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif assert(from >= 0 && from < numMaxMidiPrograms); return(programMap[from]); } bool midiProgram2Program::open(void) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif // do nothing return(true); } bool midiProgram2Program::close(void) { #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif // do nothing return(true); } void midiProgram2Program::noteOn(int channel, int key, int velocity) { if(device != 0) device->noteOn(channel, key, velocity); } void midiProgram2Program::noteOff(int channel, int key, int velocity) { if(device != 0) device->noteOff(channel, key, velocity); } void midiProgram2Program::keyPressure(int channel, int key, int pressure) { if(device != 0) device->keyPressure(channel, key, pressure); } void midiProgram2Program::channelPressure(int channel, int pressure) { if(device != 0) device->channelPressure(channel, pressure); } void midiProgram2Program::pitchBend(int channel, int fine, int coarse) { if(device != 0) device->pitchBend(channel, fine, coarse); } void midiProgram2Program::controlChange(int channel, int controller, int value) { if(device != 0) device->controlChange(channel, controller, value); } void midiProgram2Program::programChange(int channel, int program) { if((device != 0) && (programMap[program] != -1)) { #ifdef MUSICA_DEBUG cerr<< __FUNCTION__<< ": "<< getType()<< "("<< getName()<< ") ch# "<< channel<< " prgm# "<< program<< " --> "<< device->getType()<< "("<< device->getName()<< ") prgm# "<< programMap[program]<< endl; #endif device->programChange(channel, programMap[program]); } } void midiProgram2Program::allNoteOff(void) { if(device != 0) device->allNoteOff(); } void midiProgram2Program::systemReset(void) { if(device != 0) device->systemReset(); }