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/MidiOutPort_unsupported.cpp | 402 +++++++++++++++++++++++++++++ 1 file changed, 402 insertions(+) create mode 100644 src/midiio/src/MidiOutPort_unsupported.cpp (limited to 'src/midiio/src/MidiOutPort_unsupported.cpp') diff --git a/src/midiio/src/MidiOutPort_unsupported.cpp b/src/midiio/src/MidiOutPort_unsupported.cpp new file mode 100644 index 0000000..f4b8c28 --- /dev/null +++ b/src/midiio/src/MidiOutPort_unsupported.cpp @@ -0,0 +1,402 @@ +// +// Programmer: Craig Stuart Sapp +// Creation Date: Mon Jan 12 21:40:35 GMT-0800 1998 +// Last Modified: Mon Jan 12 21:40:39 GMT-0800 1998 +// Filename: ...sig/code/control/MidiOutPort/unsupported/MidiOutPort_unsupported.cpp +// Web Address: http://www-ccrma.stanford.edu/~craig/improv/src/MidiOutPort_unsupported.cpp +// Syntax: C++ +// +// Description: Operating-System specific interface for basic MIDI output +// capabilities in an unknown operating system. Privately +// inherited by the MidiOutPort class. Used for compiling +// and running MIDI programs on a computer with no +// MIDI output. +// + +#include "MidiOutPort_unsupported.h" + +#include +#include +#include +#include + +// initialized static variables +int MidiOutPort_unsupported::numDevices = 0; +int MidiOutPort_unsupported::objectCount = 0; +int* MidiOutPort_unsupported::openQ = NULL; +int* MidiOutPort_unsupported::portObjectCount = NULL; +int MidiOutPort_unsupported::channelOffset = 0; + + +////////////////////////////// +// +// MidiOutPort_unsupported::MidiOutPort_unsupported +// default values: autoOpen = 1 +// + + +MidiOutPort_unsupported::MidiOutPort_unsupported(void) { + if (objectCount == 0) { + initialize(); + } + objectCount++; + + port = -1; + setPort(0); +} + + +MidiOutPort_unsupported::MidiOutPort_unsupported(int aPort, int autoOpen) { + if (objectCount == 0) { + initialize(); + } + objectCount++; + + port = -1; + setPort(aPort); + if (autoOpen) { + open(); + } +} + + + +////////////////////////////// +// +// MidiOutPort_unsupported::~MidiOutPort_unsupported +// + +MidiOutPort_unsupported::~MidiOutPort_unsupported() { + objectCount--; + if (objectCount == 0) { + deinitialize(); + } else if (objectCount < 0) { + std::cerr << "Error: bad MidiOutPort object count!: " << objectCount << std::endl; + exit(1); + } +} + + + +////////////////////////////// +// +// MidiOutPort_unsupported::close +// + +void MidiOutPort_unsupported::close(void) { + if (getPortStatus() == 1) { + setPortStatus(0); + } +} + + + +////////////////////////////// +// +// MidiOutPort_unsupported::closeAll +// + +void MidiOutPort_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]++; +} + + + +////////////////////////////// +// +// MidiOutPort_unsupported::setTrace -- if false, then won't print +// Midi messages to standard output. +// + +int MidiOutPort_unsupported::setTrace(int aState) { + int oldtrace = trace; + if (aState == 0) { + trace = 0; + } else { + trace = 1; + } + return oldtrace; +} + + + +////////////////////////////// +// +// MidiOutPort_unsupported::sysex -- +// + +int MidiOutPort_unsupported::sysex(uchar* array, int size) { + return 1; +} + + + +////////////////////////////// +// +// MidiOutPort_unsupported::toggleTrace -- +// + +void MidiOutPort_unsupported::toggleTrace(void) { + trace = !trace; +} + + + +/////////////////////////////////////////////////////////////////////////// +// +// Private functions +// + + + +////////////////////////////// +// +// MidiOutPort_unsupported::deinitialize -- sets up storage if necessary +// This function should be called if the current object is +// the first object to be created. +// + +void MidiOutPort_unsupported::deinitialize(void) { + closeAll(); + if (openQ != NULL) delete [] openQ; + openQ = NULL; + if (portObjectCount != NULL) delete [] portObjectCount; + portObjectCount = NULL; +} + + + +////////////////////////////// +// +// MidiOutPort_unsupported::initialize -- sets up storage if necessary +// This function should be called if the current object is +// the first object to be created. +// + +void MidiOutPort_unsupported::initialize(void) { + // get the number of ports + numDevices = 16; + if (getNumPorts() <= 0) { + std::cerr << "Error: no MIDI output devices" << std::endl; + exit(1); + } + + + // 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]; + + + // initialize the static arrays + for (int i=0; i