From ceac394c2133d44e81db2eb633ff54a9ad6ce7c5 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 10 Nov 2005 05:52:11 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r3865, which included commits to RCS files with non-trunk default branches. svn path=/trunk/extensions/gripd/; revision=3866 --- src/midiio/src/MidiInPort_unsupported.cpp | 487 ++++++++++++++++++++++++++++++ 1 file changed, 487 insertions(+) create mode 100644 src/midiio/src/MidiInPort_unsupported.cpp (limited to 'src/midiio/src/MidiInPort_unsupported.cpp') diff --git a/src/midiio/src/MidiInPort_unsupported.cpp b/src/midiio/src/MidiInPort_unsupported.cpp new file mode 100644 index 0000000..584a468 --- /dev/null +++ b/src/midiio/src/MidiInPort_unsupported.cpp @@ -0,0 +1,487 @@ +// +// Programmer: Craig Stuart Sapp +// Creation Date: Wed Jan 21 22:46:30 GMT-0800 1998 +// Last Modified: Thu Jan 22 22:53:53 GMT-0800 1998 +// Last Modified: Wed Jun 30 11:42:59 PDT 1999 (added sysex capability) +// Filename: ...sig/code/control/MidiInPort/unsupported/MidiInPort_unsupported.cpp +// Web Address: http://www-ccrma.stanford.edu/~craig/improv/src/MidiInPort_unsupported.cpp +// Syntax: C++ +// +// Description: An interface for MIDI input capabilities of +// an unknown sound driver's specific MIDI input methods. +// This class is inherited privately by the MidiInPort class. +// This class is used when there is no MIDI input, so +// that MIDI programs can otherwise be compiled and run. +// This file can also serve as a template for creating +// an OS specific class for MIDI input. +// + +#include "MidiInPort_unsupported.h" +#include +#include + + +#define DEFAULT_INPUT_BUFFER_SIZE (1024) + +// initialized static variables +int MidiInPort_unsupported::numDevices = 0; +int MidiInPort_unsupported::objectCount = 0; +int* MidiInPort_unsupported::openQ = NULL; +int* MidiInPort_unsupported::portObjectCount = NULL; +CircularBuffer* MidiInPort_unsupported::midiBuffer = NULL; +int MidiInPort_unsupported::channelOffset = 0; +int* MidiInPort_unsupported::sysexWriteBuffer = NULL; +Array** MidiInPort_unsupported::sysexBuffers = NULL; + + +////////////////////////////// +// +// MidiInPort_unsupported::MidiInPort_unsupported +// default values: autoOpen = 1 +// + +MidiInPort_unsupported::MidiInPort_unsupported(void) { + if (objectCount == 0) { + initialize(); + } + objectCount++; + + port = -1; + setPort(0); +} + + +MidiInPort_unsupported::MidiInPort_unsupported(int aPort, int autoOpen) { + if (objectCount == 0) { + initialize(); + } + objectCount++; + + port = -1; + setPort(aPort); + if (autoOpen) { + open(); + } +} + + + +////////////////////////////// +// +// MidiInPort_unsupported::~MidiInPort_unsupported +// + +MidiInPort_unsupported::~MidiInPort_unsupported() { + objectCount--; + if (objectCount == 0) { + deinitialize(); + } else if (objectCount < 0) { + std::cerr << "Error: bad MidiInPort_unsupported object count!: " + << objectCount << std::endl; + exit(1); + } +} + + + +////////////////////////////// +// +// MidiInPort_unsupported::close +// + +void MidiInPort_unsupported::close(void) { + if (getPortStatus() == 1) { + openQ[getPort()] = 0; + } +} + + + +////////////////////////////// +// +// MidiInPort_unsupported::closeAll +// + +void MidiInPort_unsupported::closeAll(void) { + for (int i=0; i= getNumPorts()) { + std::cerr << "Error: maximum port number is: " << getNumPorts()-1 + << ", but you tried to access port: " << aPort << std::endl; + exit(1); + } + + if (port != -1) { + portObjectCount[port]--; + } + port = aPort; + portObjectCount[port]++; +} + + + +////////////////////////////// +// +// MidiInPort_unsupported::setTrace -- if false, then don't print MIDI messages +// to the screen. +// + +int MidiInPort_unsupported::setTrace(int aState) { + int oldtrace = trace; + if (aState == 0) { + trace = 0; + } else { + trace = 1; + } + return oldtrace; +} + + + +////////////////////////////// +// +// MidiInPort_unsupported::toggleTrace -- switches the state of trace +// Returns the previous value of the trace variable. +// + +void MidiInPort_unsupported::toggleTrace(void) { + trace = !trace; +} + + + +////////////////////////////// +// +// MidiInPort_unsupported::unpause -- enables the Midi input port +// to inserting MIDI messages into the buffer after the +// port is already open. +// + +void MidiInPort_unsupported::unpause(void) { + // nothing +} + + + +/////////////////////////////////////////////////////////////////////////// +// +// Private functions +// + + + +////////////////////////////// +// +// MidiInPort_unsupported::deinitialize -- sets up storage if necessary +// This function should be called if the current object is +// the first object to be created. +// + +void MidiInPort_unsupported::deinitialize(void) { + int deviceCount = numDevices; + closeAll(); + + if (sysexBuffers != NULL) { + for (int i=0; i*[numDevices]; + + // allocate space for sysexWriteBuffer, the port open/close status + if (sysexWriteBuffer != NULL) delete [] sysexWriteBuffer; + sysexWriteBuffer = new int[numDevices]; + + // allocate space for openQ, the port open/close status + if (openQ != NULL) delete [] openQ; + openQ = new int[numDevices]; + + // allocate space for object count on each port: + if (portObjectCount != NULL) delete [] portObjectCount; + portObjectCount = new int[numDevices]; + + // allocate space for the Midi input buffers + if (midiBuffer != NULL) delete [] midiBuffer; + midiBuffer = new CircularBuffer[numDevices]; + + // initialize the static arrays + for (int i=0; i[128]; + for (int n=0; n<128; n++) { + sysexBuffers[i][n].allowGrowth(0); // shouldn't need to grow + sysexBuffers[i][n].setAllocSize(32); + sysexBuffers[i][n].setSize(0); + sysexBuffers[i][n].setGrowth(32); // in case it will ever grow + } + + } +} + + + +////////////////////////////// +// +// MidiInPort_unsupported::setPortStatus +// + +void MidiInPort_unsupported::setPortStatus(int aStatus) { + if (aStatus) { + openQ[getPort()] = 1; + } else { + openQ[getPort()] = 0; + } +} + + +// md5sum: d8b8f65af70a9b3c33e62794c2a4a91e - MidiInPort_unsupported.cpp =css= 20030102 -- cgit v1.2.1