Vuo  2.0.0
VuoInputEditorMidiOutputDevice.cc
Go to the documentation of this file.
1 
11 
12 extern "C"
13 {
14  #include "VuoMidi.h"
15 }
16 
17 #include<CoreMIDI/CoreMIDI.h>
18 #include "VuoOsStatus.h"
19 
24 static void __attribute__((constructor)) VuoInputEditorMidiOutputDevice_init()
25 {
26  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
27  MIDIClientRef client;
28  OSStatus result = MIDIClientCreate( CFStringCreateWithCString( NULL, "blah", kCFStringEncodingASCII ), NULL, NULL, &client);
29  if (result != noErr)
30  VUserLog("Warning: Apple CoreMIDI initialization failed: %s", VuoOsStatus_getText(result));
31  });
32 }
33 
38 {
39  return new VuoInputEditorMidiOutputDevice();
40 }
41 
46 {
47  VuoInputEditorMenuItem *optionsTree = new VuoInputEditorMenuItem("root");
48 
49  optionsTree->addItem(new VuoInputEditorMenuItem("First available device", NULL));
50  optionsTree->addSeparator();
51  optionsTree->addItem(new VuoInputEditorMenuItem("Specific device", NULL, NULL, false));
52 
54  unsigned long deviceCount = VuoListGetCount_VuoMidiOutputDevice(devices);
55 
56  if (deviceCount)
57  for (unsigned long i = 1; i <= deviceCount; ++i)
58  {
60  device.id = -1;
61  optionsTree->addItem(new VuoInputEditorMenuItem(VuoText_format(" %s", device.name), VuoMidiOutputDevice_getJson(device)));
62  }
63  else
64  optionsTree->addItem(new VuoInputEditorMenuItem(" (no devices found)", NULL, NULL, false));
65 
66 
67  return optionsTree;
68 }