JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::MidiInput Class Referencefinal

Represents a midi input device. More...

#include <juce_MidiInput.h>

Collaboration diagram for juce::MidiInput:

Public Member Functions

 ~MidiInput ()
 Destructor. More...
 
const StringgetName () const noexcept
 Returns the name of this device. More...
 
void setName (const String &newName) noexcept
 Allows you to set a custom name for the device, in case you don't like the name it was given when created. More...
 
void start ()
 Starts the device running. More...
 
void stop ()
 Stops the device running. More...
 

Static Public Member Functions

static MidiInputcreateNewDevice (const String &deviceName, MidiInputCallback *callback)
 This will try to create a new midi input device (Not available on Windows). More...
 
static int getDefaultDeviceIndex ()
 Returns the index of the default midi input device to use. More...
 
static StringArray getDevices ()
 Returns a list of the available midi input devices. More...
 
static MidiInputopenDevice (int deviceIndex, MidiInputCallback *callback)
 Tries to open one of the midi input devices. More...
 

Private Member Functions

 MidiInput (const String &)
 

Private Attributes

void * internal = nullptr
 
String name
 

Detailed Description

Represents a midi input device.

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

See also
MidiOutput

{Audio}

Constructor & Destructor Documentation

◆ ~MidiInput()

juce::MidiInput::~MidiInput ( )

Destructor.

◆ MidiInput()

juce::MidiInput::MidiInput ( const String )
explicitprivate

Member Function Documentation

◆ createNewDevice()

static MidiInput* juce::MidiInput::createNewDevice ( const String deviceName,
MidiInputCallback callback 
)
static

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

This will attempt to create a new midi input device with the specified name, for other apps to connect to.

Returns nullptr if a device can't be created.

Parameters
deviceNamethe name to use for the new device
callbackthe object that will receive the midi messages from this device.

◆ getDefaultDeviceIndex()

static int juce::MidiInput::getDefaultDeviceIndex ( )
static

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

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

◆ getDevices()

static StringArray juce::MidiInput::getDevices ( )
static

Returns a list of the available midi input devices.

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

See also
getDefaultDeviceIndex, openDevice

Referenced by juce::StandalonePluginHolder::timerCallback().

◆ getName()

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

Returns the name of this device.

◆ openDevice()

static MidiInput* juce::MidiInput::openDevice ( int  deviceIndex,
MidiInputCallback callback 
)
static

Tries to open one of the midi input devices.

This will return a MidiInput object if it manages to open it. You can then call start() and stop() on 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()
callbackthe object that will receive the midi messages from this device.
See also
MidiInputCallback, getDevices

◆ setName()

void juce::MidiInput::setName ( const String newName)
inlinenoexcept

Allows you to set a custom name for the device, in case you don't like the name it was given when created.

◆ start()

void juce::MidiInput::start ( )

Starts the device running.

After calling this, the device will start sending midi messages to the MidiInputCallback object that was specified when the openDevice() method was called.

See also
stop

◆ stop()

void juce::MidiInput::stop ( )

Stops the device running.

See also
start

Member Data Documentation

◆ internal

void* juce::MidiInput::internal = nullptr
private

◆ name

String juce::MidiInput::name
private

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