Loading...
Searching...
No Matches
juce::MidiOutput Class Referencefinal

`#include <juce_MidiDevices.h>`

Inheritance diagram for juce::MidiOutput:

## Public Member Functions

| ~MidiOutput () override
MidiDeviceInfo | getDeviceInfo () const noexcept
String | getIdentifier () const noexcept
String | getName () const noexcept
void | setName (const String &newName) noexcept
void | sendMessageNow (const MidiMessage &message)
void | sendBlockOfMessagesNow (const MidiBuffer &buffer)
void | sendBlockOfMessages (const MidiBuffer &buffer, double millisecondCounterToStartAt, double samplesPerSecondForBuffer)
void | clearAllPendingMessages ()
void | startBackgroundThread ()
void | stopBackgroundThread ()
bool | isBackgroundThreadRunning () const noexcept

## Static Public Member Functions

static Array< MidiDeviceInfo > | getAvailableDevices ()
static MidiDeviceInfo | getDefaultDevice ()
static std::unique_ptr< MidiOutput > | openDevice (const String &deviceIdentifier)
static StringArray | getDevices ()
static int | getDefaultDeviceIndex ()
static std::unique_ptr< MidiOutput > | openDevice (int)

## Detailed Description

Represents a midi output device.

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

See also
  MidiInput

Definition at line 324 of file juce_MidiDevices.h.

## Constructor & Destructor Documentation

## ~MidiOutput()

juce::MidiOutput::~MidiOutput | ( |  | ) |

override

Destructor.

## Member Function Documentation

## clearAllPendingMessages()

void juce::MidiOutput::clearAllPendingMessages | ( |  | ) |

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

Definition at line 157 of file juce_MidiDevices.cpp.

Referenced by sendMessageNow().

## getAvailableDevices()

Array< MidiDeviceInfo > juce::MidiOutput::getAvailableDevices | ( |  | ) |

static

Returns a list of the available midi output devices.

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

See also
  MidiDeviceInfo, getDevices, getDefaultDeviceIndex, openDevice

## getDefaultDevice()

MidiDeviceInfo juce::MidiOutput::getDefaultDevice | ( |  | ) |

static

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

## getDeviceInfo()

MidiDeviceInfo juce::MidiOutput::getDeviceInfo | ( |  | ) | const

inline noexcept

Returns the MidiDeviceInfo struct containing some information about this device.

Definition at line 373 of file juce_MidiDevices.h.

## getIdentifier()

String juce::MidiOutput::getIdentifier | ( |  | ) | const

inline noexcept

Returns the identifier of this device.

Definition at line 376 of file juce_MidiDevices.h.

## getName()

String juce::MidiOutput::getName | ( |  | ) | const

inline noexcept

Returns the name of this device.

Definition at line 379 of file juce_MidiDevices.h.

## isBackgroundThreadRunning()

bool juce::MidiOutput::isBackgroundThreadRunning | ( |  | ) | const

inline noexcept

Returns true if the background thread used to send blocks of data is running.

See also
  startBackgroundThread, stopBackgroundThread

Definition at line 428 of file juce_MidiDevices.h.

## openDevice()

std::unique_ptr< MidiOutput > juce::MidiOutput::openDevice | ( | const String & | deviceIdentifier | ) |

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.

If the device can't be opened, this will return an empty object.

Parameters

  deviceIdentifier | the ID of the device to open - use the getAvailableDevices() method to find the available devices that can be opened

See also
  getDevices

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

## 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 118 of file juce_MidiDevices.cpp.

Referenced by sendMessageNow().

## sendBlockOfMessagesNow()

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

Sends out a sequence of MIDI messages immediately.

Definition at line 112 of file juce_MidiDevices.cpp.

Referenced by sendMessageNow().

## sendMessageNow()

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

Sends out a MIDI message immediately.

Referenced by sendBlockOfMessagesNow().

## setName()

void juce::MidiOutput::setName | ( | const String & | newName | ) |

inline noexcept

Sets a custom name for the device.

Definition at line 382 of file juce_MidiDevices.h.

## 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 169 of file juce_MidiDevices.cpp.

Referenced by sendMessageNow().

## stopBackgroundThread()

void juce::MidiOutput::stopBackgroundThread | ( |  | ) |

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

See also
  startBackgroundThread

Definition at line 174 of file juce_MidiDevices.cpp.

Referenced by sendMessageNow().

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

- juce_MidiDevices.h
- juce_MidiDevices.cpp