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

#include <juce_MidiDevices.h>

Inheritance diagram for juce::MidiOutput:
juce::Thread

Classes

struct  PendingMessage
class  Pimpl

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< MidiDeviceInfogetAvailableDevices ()
static MidiDeviceInfo getDefaultDevice ()
static std::unique_ptr< MidiOutputopenDevice (const String &deviceIdentifier)
static StringArray getDevices ()
static int getDefaultDeviceIndex ()
static std::unique_ptr< MidiOutputopenDevice (int)

Private Member Functions

 MidiOutput (const String &, const String &)
void run () override
Private Member Functions inherited from juce::Thread
 Thread (const String &threadName, size_t threadStackSize=0)
virtual ~Thread ()
void startThread ()
void startThread (int priority)
bool stopThread (int timeOutMilliseconds)
bool isThreadRunning () const
void signalThreadShouldExit ()
bool threadShouldExit () const
bool waitForThreadToExit (int timeOutMilliseconds) const
void addListener (Listener *)
void removeListener (Listener *)
bool setPriority (int priority)
void setAffinityMask (uint32 affinityMask)
bool wait (int timeOutMilliseconds) const
void notify () const
ThreadID getThreadId () const noexcept
const StringgetThreadName () const noexcept

Private Attributes

MidiDeviceInfo deviceInfo
std::unique_ptr< Pimplinternal
CriticalSection lock
PendingMessagefirstMessage = nullptr

Additional Inherited Members

Private Types inherited from juce::Thread
enum  { realtimeAudioPriority = -1 }
using ThreadID = void*
Static Private Member Functions inherited from juce::Thread
static void launch (std::function< void()> functionToRun)
static bool currentThreadShouldExit ()
static bool setCurrentThreadPriority (int priority)
static void JUCE_CALLTYPE setCurrentThreadAffinityMask (uint32 affinityMask)
static void JUCE_CALLTYPE sleep (int milliseconds)
static void JUCE_CALLTYPE yield ()
static ThreadID JUCE_CALLTYPE getCurrentThreadId ()
static Thread *JUCE_CALLTYPE getCurrentThread ()
static void JUCE_CALLTYPE setCurrentThreadName (const String &newThreadName)

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

@tags{Audio}

Constructor & Destructor Documentation

◆ ~MidiOutput()

juce::MidiOutput::~MidiOutput ( )
overridedefault

Destructor.

◆ MidiOutput()

juce::MidiOutput::MidiOutput ( const String & deviceName,
const String & deviceIdentifier )
explicitprivate

Member Function Documentation

◆ clearAllPendingMessages()

void juce::MidiOutput::clearAllPendingMessages ( )

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

◆ 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.

◆ getDefaultDeviceIndex()

int juce::MidiOutput::getDefaultDeviceIndex ( )
static

◆ getDeviceInfo()

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

Returns the MidiDeviceInfo struct containing some information about this device.

◆ getDevices()

StringArray juce::MidiOutput::getDevices ( )
static

◆ getIdentifier()

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

Returns the identifier of this device.

◆ getName()

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

Returns the name of this device.

◆ isBackgroundThreadRunning()

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

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

See also
startBackgroundThread, stopBackgroundThread

◆ openDevice() [1/2]

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
deviceIdentifierthe ID of the device to open - use the getAvailableDevices() method to find the available devices that can be opened
See also
getDevices

◆ openDevice() [2/2]

std::unique_ptr< MidiOutput > juce::MidiOutput::openDevice ( int index)
static

◆ run()

void juce::MidiOutput::run ( )
overrideprivatevirtual

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 juce::Thread.

◆ 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.

◆ sendBlockOfMessagesNow()

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

Sends out a sequence of MIDI messages immediately.

◆ sendMessageNow()

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

Sends out a MIDI message immediately.

◆ setName()

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

Sets a custom name for the device.

◆ 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().

◆ stopBackgroundThread()

void juce::MidiOutput::stopBackgroundThread ( )

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

See also
startBackgroundThread

Member Data Documentation

◆ deviceInfo

MidiDeviceInfo juce::MidiOutput::deviceInfo
private

◆ firstMessage

PendingMessage* juce::MidiOutput::firstMessage = nullptr
private

◆ internal

std::unique_ptr<Pimpl> juce::MidiOutput::internal
private

◆ lock

CriticalSection juce::MidiOutput::lock
private

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