Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

/home/pete/Work/TSE3.svn/tse3/src/tse3/plt/OSS.h

Go to the documentation of this file.
00001 /*
00002  * @(#)plt/OSS.h 3.00 20 July 1999
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_PLT_OSS_H
00018 #define TSE3_PLT_OSS_H
00019 
00020 #include "tse3/MidiScheduler.h"
00021 
00022 #include <string>
00023 #include <list>
00024 
00025 #ifdef HAVE_CONFIG_H
00026 #include "config.h"
00027 #endif
00028 
00029 #ifdef TSE3_WITH_OSS
00030 #include <sys/soundcard.h>
00031 #else
00032     struct synth_info;
00033     struct midi_info;
00034 #endif
00035 
00036 namespace TSE3
00037 {
00038     namespace Plt
00039     {
00040         class OSSMidiScheduler_SynthDevice;
00041 
00063         class OSSMidiScheduler : public MidiScheduler
00064         {
00065             public:
00066 
00070                 OSSMidiScheduler();
00071                 virtual ~OSSMidiScheduler();
00072 
00073                 /**************************************************************
00074                  * OSS specific settings
00075                  *************************************************************/
00076 
00087                 static std::string &fmPatchesDirectory();
00088 
00095                 static void setFmPatchesDirectory(const std::string &dir);
00096 
00109                 static std::string &gusPatchesDirectory();
00110 
00117                 static void setGusPatchesDirectory(const std::string &dir);
00118 
00119             protected:
00120 
00124                 virtual const char *impl_implementationName() const;
00128                 virtual const char *impl_portName(int port) const;
00132                 virtual const char *impl_portType(int port) const;
00136                 virtual bool impl_portReadable(int port) const;
00140                 virtual bool impl_portWriteable(int port) const;
00144                 virtual void impl_start(Clock clock);
00148                 virtual void impl_stop(Clock clock);
00152                 virtual void impl_moveTo(Clock moveTime, Clock newTime);
00156                 virtual Clock impl_clock();
00160                 virtual int impl_msecs();
00164                 virtual void impl_setTempo(int tempo, Clock changeTime);
00168                 virtual bool impl_eventWaiting();
00172                 virtual MidiEvent impl_rx();
00176                 virtual void impl_tx(MidiCommand mc);
00180                 virtual void impl_tx(MidiEvent mc);
00184                 virtual void impl_txSysEx(int port,
00185                                           const unsigned char *data,
00186                                           size_t size);
00187 
00188             private:
00189 
00190                 OSSMidiScheduler(const OSSMidiScheduler &);
00191                 OSSMidiScheduler &operator=(const OSSMidiScheduler &);
00192 
00198                 void tx(const MidiCommand mc, bool outOfBand);
00199 
00200                 unsigned char *running;     // running status values
00201                 bool          *useRunning;  // does device support running sts?
00202                 unsigned int   nosynths;    // no of internal synth devices
00203                 unsigned int   nomidis;     // no of MIDI ports
00204                 unsigned int   nodevices;   // nosynths + nomidis
00205                 int            rate;        // sequencer timer rate (in ms)
00206                 int            rateDivisor; // value to / timer by to get ms
00207                 synth_info    *synthinfo;   // synth_info for each synth device
00208                 midi_info     *midiinfo;    // midi_info for each MIDI device
00209 
00210                 // In C we write SEQ_DEFINEBUF(1024); to set up some OSS magic
00211                 // which creates a buffer that the OSS macros write data into.
00212                 // However, this won't work in a class declaration. Sigh.
00213                 // So this is how we do it.
00214                 int            seqfd;          // file descfor /dev/sequencer
00215                 unsigned char *_seqbuf;        // buffer for /dev/sequencer data
00216                 int            _seqbuflen;     // size of _seqbuf
00217                 int            _seqbufptr;     // pointer to end of pending data
00218                 void           seqbuf_dump();  // wrts _seqbuf to /dev/sequencer
00219                 void           seqbuf_clean(); // flushes the buffer
00220 
00221                 // For a given port (TSE3 speak, same as OSS device number) is
00222                 // it a synth or MIDI device?
00223                 bool isSynth(unsigned int port) const
00224                 {
00225                     return port < nosynths;
00226                 }
00227                 bool isMidi(unsigned int port) const
00228                 {
00229                     return port >= nosynths;
00230                 }
00231 
00232                 // MIDI devices are easy to send data too, but the synths need
00233                 // some special massaging. The classes held in this table do
00234                 // just that.
00235                 OSSMidiScheduler_SynthDevice **devices;
00236 
00237                 // Output malarky
00238                 Clock lastTxTime; // Time last MidiCommand was scheduled
00239 
00240                 // Input malarky
00241                 bool        input;   // true if there is an input command
00242                 MidiCommand command; // if input is true, this holds the input
00243                 Clock       time;    // time of the input MidiCommand
00244 
00251                 void readInput();
00252         };
00253     }
00254 }
00255 
00256 #endif

Generated on Wed May 25 14:45:09 2005 for TSE3 by doxygen 1.3.2