Source: midimountain/mcOSSIO.h


Annotated List
Files
Globals
Hierarchy
Index
//=============================================================================
//  TMidiIO class definition
//=============================================================================
// Author  : Adrian Meyer
//           based on Craig Stuart Sapp, craig@ccrma.stanford.edu
//           sequencer class
// Version : 0.2.0
// Log     :
//=============================================================================
// 04.03.2001 building class
//=============================================================================
// to do:
//=============================================================================

#ifndef __MCOSSIO__
#define __MCOSSIO__

#include <mcBase.h>
#include <mcIO.h>
#include <strings.h>

//const long cMMDeviceCreate           = cMCDevice << 16 | 0x0001;

#define MIDI_EXTERNAL  (1)
#define MIDI_INTERNAL  (2)

const int SEQ_BUFSIZE = 1024;

typedef unsigned char uchar;

class TMidiOSSIO: public TMidiIO
{
private:
	int fInputDevice;                               // active input device
	int fOutputDevice;                              // active output device
	long fCurrentTime;
	long fStartTime;
	long fEchoTime;

	void buildInfoDatabase     (void);

	int  getFd(void) const { return seq_fd; };
	void setFd(int anFd) { seq_fd = anFd; };

	int  getInDeviceValue      (int aDevice) const;
	int  getInputType          (int aDevice) const;
	int  getOutDeviceValue     (int aDevice) const;
	int  getOutputType         (int aDevice) const;
	void removeInfoDatabase    (void);

	void getEvents();
	void sendTimingEcho(long until);
	void seqbuf_dump(void);

	void          writeInternal(int aDevice, int aByte);
	void          transmitMessageToInternalSynth(void);
	void          transmitVoiceMessage(void);
	void          transmitCommonMessage(void);

	int           seq_fd;
	unsigned char _seqbuf[SEQ_BUFSIZE];
	int           _seqbuflen;
	int           _seqbufptr;

	static const char* sequencer;         // name of sequencer device
	static int    class_count;            // number of existing classes using
	static uchar  midi_write_packet[4];   // for writing MIDI bytes out
	static uchar  midi_read_packet[4];    // for reading MIDI bytes out
	static uchar  synth_write_message[8]; // for writing to internal seq
	static int    indevcount;             // number of MIDI input devices
	static int    outdevcount;            // number of MIDI output devices
	static char** indevnames;             // MIDI input device names
	static char** outdevnames;            // MIDI output device names
	static int*   indevnum;               // total number of MIDI inputs
	static int*   outdevnum;              // total number of MIDI outputs
	static int*   indevtype;              // 1 = External, 2 = Internal
	static int*   outdevtype;             // 1 = External, 2 = Internal
	static uchar  synth_message_buffer[1024];   // hold bytes for synth dev
	static int    synth_message_buffer_count;   // count of synth buffer
	static int    synth_message_bytes_expected; // expected count of synth
	static int    synth_message_curr_device;    // for keeping track of dev

public:
	TMidiOSSIO( int autoOpen = 1 );
	~TMidiOSSIO();

  // returns true if this IO device is open
  virtual int        is_open(void) const;

  // Open the device
  virtual int        open(void);

  // Close the device
  virtual void       close(void);

  // Read an event
  virtual TMidiEvent *read();

  // Write an event to the specified device
  virtual void       Write(int aDevice, TMidiEvent *ev);

  // Start playing (for example start the timer)
  virtual void       Start(void);

  // Stop playing
  virtual void       Stop(void);

  // Get the current time in ticks
  virtual long       GetTime(void);

  // Set the tempo at the specified time
  virtual void       SetTempo(int tempo, long ticks);

	// Set the timebase value
	virtual void       SetTimebase(int timebase);

	virtual void       rebuildInfoDatabase  (void);

	virtual int GetInputCount( void ) const;
	virtual int GetOutputCount( void ) const;

	virtual int GetInputDevice( void );            // read input device
	virtual void SetInputDevice( int aInputDevice ); // set input device

	virtual int GetOutputDevice( void );                   // read output device
	virtual void SetOutputDevice( int aOutputDevice ); // set output device

	virtual const char* GetInputName ( int aDevice ) const;
	virtual const char* GetOutputName ( int aDevice ) const;
};

#endif

Generated by: root@castle on Fri Jul 20 00:33:17 2001, using kdoc 2.0a36.