deviceman.h
00001 /* deviceman.h - The device manager, that hides the use of midiOut 00002 This file is part of LibKMid 0.9.5 00003 Copyright (C) 1997,98,99,2000 Antonio Larrosa Jimenez 00004 LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 00020 Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org> 00021 00022 ***************************************************************************/ 00023 #ifndef DEVICEMAN_H 00024 #define DEVICEMAN_H 00025 00026 #include <libkmid/dattypes.h> 00027 #include <kdelibs_export.h> 00028 00029 class MidiOut; 00030 class MidiMapper; 00031 00047 class KMID_EXPORT DeviceManager 00048 { 00049 protected: 00050 00055 MidiOut **device; 00056 00061 struct midi_info *midiinfo; 00062 00067 struct synth_info *synthinfo; 00068 00073 int chn2dev[16]; 00074 00079 int n_synths; 00080 00085 int n_midi; 00086 00091 int n_total; 00092 00097 int m_rate; 00098 00103 double convertrate; 00104 00109 int timerstarted; 00110 00115 double lastwaittime; 00116 00123 MidiMapper *mapper_tmp; 00124 00125 int initialized; 00126 00131 int seqfd; 00132 00137 int default_dev; 00138 00142 int _ok; 00143 00148 bool alsa; 00149 00153 void seqbuf_dump (void); 00154 00158 void seqbuf_clean (void); 00159 00163 void checkAlsa (void); 00164 public: 00172 DeviceManager(int def=-1); 00173 00178 ~DeviceManager(void); 00179 00191 int initManager(void); 00192 00200 int checkInit(void); 00201 00206 MidiOut *chntodev(int chn) 00207 { return deviceForChannel(chn); } 00208 00217 MidiOut *deviceForChannel(int chn) 00218 { return (device!=0L) ? device[chn2dev[chn]] : 0L ; } 00219 00223 int deviceNumberForChannel(int chn) { return chn2dev[chn]; } 00224 00228 void setDeviceNumberForChannel(int chn, int dev); 00229 00234 int ok(void); 00235 00239 int usingAlsa(void) { return alsa; } 00240 00241 // The following function are here to emulate a midi, so that the 00242 // DeviceManager sends the events to the appropriate devices. 00243 00255 void openDev (void); 00256 00262 void closeDev (void); 00263 00269 void initDev (void); 00270 00280 void noteOn ( uchar chn, uchar note, uchar vel ); 00281 00292 void noteOff ( uchar chn, uchar note, uchar vel ); 00293 00302 void keyPressure ( uchar chn, uchar note, uchar vel ); 00303 00312 void chnPatchChange ( uchar chn, uchar patch ); 00313 00321 void chnPressure ( uchar chn, uchar vel ); 00322 00333 void chnPitchBender ( uchar chn, uchar lsb, uchar msb ); 00334 00348 void chnController ( uchar chn, uchar ctl , uchar v ); 00349 00362 void sysEx ( uchar *data,ulong size); 00363 00369 void wait (double ms); 00370 00375 void tmrSetTempo(int v); 00376 00380 void tmrStart(long int tpcn); 00381 00386 void tmrStop(void); 00387 00392 void tmrContinue(void); 00393 00397 void allNotesOff(void); 00398 00409 void sync(bool f=0); 00410 00421 void setVolumePercentage(int i); 00422 00429 int defaultDevice(void); 00430 00440 void setDefaultDevice(int i); 00441 00470 int setPatchesToUse(int *patchesused); 00471 00478 const char *midiMapFilename(void); 00479 00488 void setMidiMap(MidiMapper *map); 00489 00493 int rate(void) { return m_rate; } 00494 00504 int midiPorts(void) { return n_midi; } 00505 00515 int synthDevices(void) { return n_synths; } 00516 00523 const char *name(int i); 00524 00530 const char *type(int i); 00531 00532 private: 00533 class DeviceManagerPrivate; 00534 DeviceManagerPrivate *d; 00535 }; 00536 00537 #endif