OpenShot Library | libopenshot-audio  0.2.0
juce::MidiOutput Class Referencefinal

Controls a physical MIDI output device. More...

#include <juce_MidiOutput.h>

+ Inheritance diagram for juce::MidiOutput:

Classes

struct  PendingMessage
 

Public Member Functions

 ~MidiOutput () override
 Destructor. More...
 
const StringgetName () const noexcept
 Returns the name of this device. More...
 
void sendMessageNow (const MidiMessage &message)
 Sends out a MIDI message immediately. More...
 
void sendBlockOfMessagesNow (const MidiBuffer &buffer)
 Sends out a sequence of MIDI messages immediately. More...
 
void sendBlockOfMessages (const MidiBuffer &buffer, double millisecondCounterToStartAt, double samplesPerSecondForBuffer)
 This lets you supply a block of messages that will be sent out at some point in the future. More...
 
void clearAllPendingMessages ()
 Gets rid of any midi messages that had been added by sendBlockOfMessages(). More...
 
void startBackgroundThread ()
 Starts up a background thread so that the device can send blocks of data. More...
 
void stopBackgroundThread ()
 Stops the background thread, and clears any pending midi events. More...
 

Static Public Member Functions

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

Detailed Description

Controls a physical MIDI output device.

To create one of these, use the static getDevices() method to get a list of the available output devices, then use the openDevice() method to try to open one.

See also
MidiInput

Definition at line 41 of file juce_MidiOutput.h.

Constructor & Destructor Documentation

◆ ~MidiOutput()

juce::MidiOutput::~MidiOutput ( )
override

Destructor.

Member Function Documentation

◆ getDevices()

static StringArray juce::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

Referenced by juce::AudioDeviceManager::setDefaultMidiOutput().

◆ getDefaultDeviceIndex()

static int juce::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().

◆ openDevice()

static MidiOutput* juce::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
deviceIndexthe index of a device from the list returned by getDevices()
See also
getDevices

Referenced by juce::AudioDeviceManager::setDefaultMidiOutput().

◆ createNewDevice()

static MidiOutput* juce::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 nullptr if a device can't be created.

Parameters
deviceNamethe name to use for the new device

◆ getName()

const String& juce::MidiOutput::getName ( ) const
inlinenoexcept

Returns the name of this device.

Definition at line 91 of file juce_MidiOutput.h.

◆ sendMessageNow()

void juce::MidiOutput::sendMessageNow ( const MidiMessage message)

Sends out a MIDI message immediately.

Referenced by sendBlockOfMessagesNow(), and stopBackgroundThread().

◆ sendBlockOfMessagesNow()

void juce::MidiOutput::sendBlockOfMessagesNow ( const MidiBuffer buffer)

Sends out a sequence of MIDI messages immediately.

Definition at line 41 of file juce_MidiOutput.cpp.

References juce::MidiBuffer::Iterator::getNextEvent(), and sendMessageNow().

◆ sendBlockOfMessages()

void juce::MidiOutput::sendBlockOfMessages ( const MidiBuffer buffer,
double  millisecondCounterToStartAt,
double  samplesPerSecondForBuffer 
)

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 specified, 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.

Definition at line 51 of file juce_MidiOutput.cpp.

References juce::MidiBuffer::Iterator::getNextEvent(), juce::Thread::isThreadRunning(), and juce::Thread::notify().

◆ clearAllPendingMessages()

void juce::MidiOutput::clearAllPendingMessages ( )

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

Definition at line 93 of file juce_MidiOutput.cpp.

Referenced by stopBackgroundThread().

◆ startBackgroundThread()

void juce::MidiOutput::startBackgroundThread ( )

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

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

Definition at line 105 of file juce_MidiOutput.cpp.

References juce::Thread::startThread().

◆ stopBackgroundThread()

void juce::MidiOutput::stopBackgroundThread ( )

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