Browse Source

Add getName to MidiOutput devices

tags/2021-05-28
hogliux 9 years ago
parent
commit
c89f476127
5 changed files with 20 additions and 10 deletions
  1. +3
    -2
      modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp
  2. +5
    -1
      modules/juce_audio_devices/midi_io/juce_MidiOutput.h
  3. +2
    -2
      modules/juce_audio_devices/native/juce_linux_Midi.cpp
  4. +3
    -2
      modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp
  5. +7
    -3
      modules/juce_audio_devices/native/juce_win32_Midi.cpp

+ 3
- 2
modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp View File

@@ -32,10 +32,11 @@ struct MidiOutput::PendingMessage
PendingMessage* next;
};
MidiOutput::MidiOutput()
MidiOutput::MidiOutput(const String& midiName)
: Thread ("midi out"),
internal (nullptr),
firstMessage (nullptr)
firstMessage (nullptr),
name (midiName)
{
}


+ 5
- 1
modules/juce_audio_devices/midi_io/juce_MidiOutput.h View File

@@ -84,6 +84,9 @@ public:
/** Destructor. */
~MidiOutput();
/** Returns the name of this device. */
const String& getName() const noexcept { return name; }
/** Makes this device output a midi message.
@see MidiMessage
*/
@@ -131,8 +134,9 @@ private:
CriticalSection lock;
struct PendingMessage;
PendingMessage* firstMessage;
String name;
MidiOutput(); // These objects are created with the openDevice() method.
MidiOutput(const String& midiName); // These objects are created with the openDevice() method.
void run() override;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiOutput)


+ 2
- 2
modules/juce_audio_devices/native/juce_linux_Midi.cpp View File

@@ -497,7 +497,7 @@ MidiOutput* MidiOutput::openDevice (int deviceIndex)
if (port.isValid())
{
newDevice = new MidiOutput();
newDevice = new MidiOutput (devices [deviceIndex]);
newDevice->internal = new MidiOutputDevice (newDevice, port);
}
@@ -512,7 +512,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)
if (port.isValid())
{
newDevice = new MidiOutput();
newDevice = new MidiOutput (deviceName);
newDevice->internal = new MidiOutputDevice (newDevice, port);
}


+ 3
- 2
modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp View File

@@ -332,10 +332,11 @@ MidiOutput* MidiOutput::openDevice (int index)
{
MIDIClientRef client = CoreMidiHelpers::getGlobalMidiClient();
MIDIPortRef port;
String deviceName = CoreMidiHelpers::getConnectedEndpointName (endPoint);
if (client != 0 && CHECK_ERROR (MIDIOutputPortCreate (client, pname.cfString, &port)))
{
mo = new MidiOutput();
mo = new MidiOutput (deviceName);
mo->internal = new CoreMidiHelpers::MidiPortAndEndpoint (port, endPoint);
}
}
@@ -354,7 +355,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)
if (client != 0 && CHECK_ERROR (MIDISourceCreate (client, name.cfString, &endPoint)))
{
MidiOutput* mo = new MidiOutput();
MidiOutput* mo = new MidiOutput (deviceName);
mo->internal = new CoreMidiHelpers::MidiPortAndEndpoint (0, endPoint);
return mo;
}


+ 7
- 3
modules/juce_audio_devices/native/juce_win32_Midi.cpp View File

@@ -362,6 +362,7 @@ MidiOutput* MidiOutput::openDevice (int index)
UINT deviceId = MIDI_MAPPER;
const UINT num = midiOutGetNumDevs();
int n = 0;
String deviceName;
for (UINT i = 0; i < num; ++i)
{
@@ -369,13 +370,16 @@ MidiOutput* MidiOutput::openDevice (int index)
if (midiOutGetDevCaps (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR)
{
String name = String (mc.szPname, sizeof (mc.szPname));
// use the microsoft sw synth as a default - best not to allow deviceId
// to be MIDI_MAPPER, or else device sharing breaks
if (String (mc.szPname, sizeof (mc.szPname)).containsIgnoreCase ("microsoft"))
if (name.containsIgnoreCase ("microsoft"))
deviceId = i;
if (index == n)
{
deviceName = name;
deviceId = i;
break;
}
@@ -392,7 +396,7 @@ MidiOutput* MidiOutput::openDevice (int index)
{
han->refCount++;
MidiOutput* const out = new MidiOutput();
MidiOutput* const out = new MidiOutput (deviceName);
out->internal = han;
return out;
}
@@ -411,7 +415,7 @@ MidiOutput* MidiOutput::openDevice (int index)
han->handle = h;
MidiOutHandle::activeHandles.add (han);
MidiOutput* const out = new MidiOutput();
MidiOutput* const out = new MidiOutput (deviceName);
out->internal = han;
return out;
}


Loading…
Cancel
Save