MidiOutput Class Reference

Represents a midi output device. More...

Inherits Thread.

List of all members.

Classes

struct  PendingMessage

Public Member Functions

virtual ~MidiOutput ()
 Destructor.
virtual void sendMessageNow (const MidiMessage &message)
 Makes this device output a midi message.
virtual void reset ()
 Sends a midi reset to the device.
virtual bool getVolume (float &leftVol, float &rightVol)
 Returns the current volume setting for this device.
virtual void setVolume (float leftVol, float rightVol)
 Changes the overall volume for this device.
virtual void sendBlockOfMessages (const MidiBuffer &buffer, const double millisecondCounterToStartAt, double samplesPerSecondForBuffer) throw ()
 This lets you supply a block of messages that will be sent out at some point in the future.
virtual void clearAllPendingMessages () throw ()
 Gets rid of any midi messages that had been added by sendBlockOfMessages().
virtual void startBackgroundThread () throw ()
 Starts up a background thread so that the device can send blocks of data.
virtual void stopBackgroundThread () throw ()
 Stops the background thread, and clears any pending midi events.

Static Public Member Functions

static const StringArray getDevices ()
 Returns a list of the available midi output devices.
static int getDefaultDeviceIndex ()
 Returns the index of the default midi output device to use.
static MidiOutputopenDevice (int deviceIndex)
 Tries to open one of the midi output devices.
static MidiOutputcreateNewDevice (const String &deviceName)
 This will try to create a new midi output device (Not available on Windows).

Protected Member Functions

 MidiOutput () throw ()
 MidiOutput (const MidiOutput &)
void run ()
 Must be implemented to perform the thread's actual code.

Protected Attributes

void * internal
CriticalSection lock
PendingMessagefirstMessage


Detailed Description

Represents a midi output device.

To create one of these, use the static getDevices() method to find out what outputs are available, then use the openDevice() method to try to open one.

See also:
MidiInput

Constructor & Destructor Documentation

virtual MidiOutput::~MidiOutput (  )  [virtual]

Destructor.

MidiOutput::MidiOutput (  )  throw () [protected]

MidiOutput::MidiOutput ( const MidiOutput  )  [protected]


Member Function Documentation

static const StringArray MidiOutput::getDevices (  )  [static]

Returns a list of the available midi output devices.

You can open one of the devices by passing its index into the openDevice() method.

See also:
getDefaultDeviceIndex, openDevice

static int MidiOutput::getDefaultDeviceIndex (  )  [static]

Returns the index of the default midi output device to use.

This refers to the index in the list returned by getDevices().

static MidiOutput* MidiOutput::openDevice ( int  deviceIndex  )  [static]

Tries to open one of the midi output devices.

This will return a MidiOutput object if it manages to open it. You can then send messages to this device, and delete it when no longer needed.

If the device can't be opened, this will return a null pointer.

Parameters:
deviceIndex the index of a device from the list returned by getDevices()
See also:
getDevices

static MidiOutput* MidiOutput::createNewDevice ( const String deviceName  )  [static]

This will try to create a new midi output device (Not available on Windows).

This will attempt to create a new midi output device that other apps can connect to and use as their midi input.

Returns 0 if a device can't be created.

Parameters:
deviceName the name to use for the new device

virtual void MidiOutput::sendMessageNow ( const MidiMessage message  )  [virtual]

Makes this device output a midi message.

See also:
MidiMessage

virtual void MidiOutput::reset (  )  [virtual]

Sends a midi reset to the device.

virtual bool MidiOutput::getVolume ( float &  leftVol,
float &  rightVol 
) [virtual]

Returns the current volume setting for this device.

virtual void MidiOutput::setVolume ( float  leftVol,
float  rightVol 
) [virtual]

Changes the overall volume for this device.

virtual void MidiOutput::sendBlockOfMessages ( const MidiBuffer buffer,
const double  millisecondCounterToStartAt,
double  samplesPerSecondForBuffer 
) throw () [virtual]

This lets you supply a block of messages that will be sent out at some point in the future.

The MidiOutput class has an internal thread that can send out timestamped messages - this appends a set of messages to its internal buffer, ready for sending.

This will only work if you've already started the thread with startBackgroundThread().

A time is supplied, at which the block of messages should be sent. This time uses the same time base as Time::getMillisecondCounter(), and must be in the future.

The samplesPerSecondForBuffer parameter indicates the number of samples per second used by the MidiBuffer. Each event in a MidiBuffer has a sample position, and the samplesPerSecondForBuffer value is needed to convert this sample position to a real time.

virtual void MidiOutput::clearAllPendingMessages (  )  throw () [virtual]

Gets rid of any midi messages that had been added by sendBlockOfMessages().

virtual void MidiOutput::startBackgroundThread (  )  throw () [virtual]

Starts up a background thread so that the device can send blocks of data.

Call this to get the device ready, before using sendBlockOfMessages().

virtual void MidiOutput::stopBackgroundThread (  )  throw () [virtual]

Stops the background thread, and clears any pending midi events.

See also:
startBackgroundThread

void MidiOutput::run (  )  [protected, virtual]

Must be implemented to perform the thread's actual code.

Remember that the thread must regularly check the threadShouldExit() method whilst running, and if this returns true it should return from the run() method as soon as possible to avoid being forcibly killed.

See also:
threadShouldExit, startThread

Implements Thread.


Member Data Documentation

void* MidiOutput::internal [protected]


The documentation for this class was generated from the following file:

Generated on Fri Nov 20 12:00:45 2009 for JUCE by  doxygen 1.5.9