00001 /* 00002 * @(#)util/MidiScheduler.h 3.00 2 August 2000 00003 * 00004 * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org) 00005 * 00006 * This file is part of TSE3 - the Trax Sequencer Engine version 3.00. 00007 * 00008 * This library is modifiable/redistributable under the terms of the GNU 00009 * General Public License. 00010 * 00011 * You should have received a copy of the GNU General Public License along 00012 * with this program; see the file COPYING. If not, write to the Free Software 00013 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00014 * 00015 */ 00016 00017 #ifndef TSE3_UTIL_MIDISCHEDULER_H 00018 #define TSE3_UTIL_MIDISCHEDULER_H 00019 00020 #include "tse3/MidiScheduler.h" 00021 00022 #include <iostream> 00023 #include <cstddef> 00024 00025 namespace TSE3 00026 { 00027 namespace Util 00028 { 00040 class StreamMidiScheduler : public MidiScheduler 00041 { 00042 public: 00043 00044 StreamMidiScheduler(std::ostream &stream = std::cout); 00045 virtual ~StreamMidiScheduler(); 00046 00047 protected: 00048 00052 virtual const char *impl_implementationName() const; 00056 virtual const char *impl_portName(int port) const; 00060 virtual const char *impl_portType(int port) const; 00064 virtual bool impl_portReadable(int port) const; 00068 virtual bool impl_portWriteable(int port) const; 00072 virtual void impl_start(Clock clock); 00076 virtual void impl_stop(Clock clock); 00080 virtual void impl_moveTo(Clock moveTime, Clock newTime); 00084 virtual Clock impl_clock(); 00088 virtual int impl_msecs(); 00092 virtual void impl_setTempo(int tempo, Clock changeTime); 00096 virtual bool impl_eventWaiting(); 00100 virtual MidiEvent impl_rx(); 00104 virtual void impl_tx(MidiCommand mc); 00108 virtual void impl_tx(MidiEvent mc); 00112 virtual void impl_txSysEx(int port, 00113 const unsigned char *data, 00114 size_t size); 00115 00116 private: 00117 00118 StreamMidiScheduler &operator=(const StreamMidiScheduler &); 00119 StreamMidiScheduler(const StreamMidiScheduler &); 00120 00121 void outClock(Clock c); 00122 void outMidiCommand(MidiCommand mc); 00123 00124 std::ostream &out; 00125 Clock clock; 00126 }; 00127 00138 class NullMidiScheduler : public MidiScheduler 00139 { 00140 public: 00141 00142 NullMidiScheduler(); 00143 virtual ~NullMidiScheduler(); 00144 00145 protected: 00146 00150 virtual const char *impl_implementationName() const; 00154 virtual const char *impl_portName(int port) const; 00158 virtual const char *impl_portType(int port) const; 00162 virtual bool impl_portReadable(int port) const; 00166 virtual bool impl_portWriteable(int port) const; 00170 virtual void impl_start(Clock clock); 00174 virtual void impl_stop(Clock clock); 00178 virtual void impl_moveTo(Clock moveTime, Clock newTime); 00182 virtual Clock impl_clock(); 00186 virtual int impl_msecs(); 00190 virtual void impl_setTempo(int tempo, Clock changeTime); 00194 virtual bool impl_eventWaiting(); 00198 virtual MidiEvent impl_rx(); 00202 virtual void impl_tx(MidiCommand mc); 00206 virtual void impl_tx(MidiEvent mc); 00210 virtual void impl_txSysEx(int port, 00211 const unsigned char *data, 00212 size_t size); 00213 00214 private: 00215 00216 NullMidiScheduler &operator=(const NullMidiScheduler &); 00217 NullMidiScheduler(const NullMidiScheduler &); 00218 00219 Clock clock; 00220 }; 00221 } 00222 } 00223 00224 #endif