/*
 *  Copyright 2008 Markus Prinz
 *  Released unter an MIT licence
 *
 */

#include <ruby.h>
#include <CoreMIDI/CoreMIDI.h>


VALUE callback_proc = Qnil;

MIDIPortRef inPort = NULL;
MIDIClientRef client = NULL;

static void RbMIDIReadProc(const MIDIPacketList* packetList, void* readProcRefCon, void* srcConnRefCon)
{
    
}

static VALUE t_sources(VALUE self)
{    
    int number_of_sources = MIDIGetNumberOfSources();
    
    VALUE source_ary = rb_ary_new2(number_of_sources);
    
    for(int idx = 0; idx < number_of_sources; ++idx)
    {
        MIDIEndpointRef src = MIDIGetSource(idx);
        CFStringRef pname;
        char name[64];
        
        MIDIObjectGetStringProperty(src, kMIDIPropertyName, pname);
        CFStringGetCString(pname, name, sizeof(name), 0);
        CFRelease(pname);
        
        rb_ary_push(source_ary, rb_str_new2(name));
    }
    
    return source_ary;
}

void Init_rbcoremidi (void)
{
  // Add the initialization code of your module here.
}

/*
 *  Copyright 2008 Markus Prinz
 *  Released unter an MIT licence
 *
 */

#include <ruby.h>
#include <CoreMIDI/CoreMIDI.h>


VALUE callback_proc = Qnil;

MIDIPortRef inPort = NULL;
MIDIClientRef client = NULL;

static void RbMIDIReadProc(const MIDIPacketList* packetList, void* readProcRefCon, void* srcConnRefCon)
{
    
}

void Init_rbcoremidi (void)
{
  // Add the initialization code of your module here.
}

--- 
+++ 
@@ -18,6 +18,28 @@
     
 }
 
+static VALUE t_sources(VALUE self)
+{    
+    int number_of_sources = MIDIGetNumberOfSources();
+    
+    VALUE source_ary = rb_ary_new2(number_of_sources);
+    
+    for(int idx = 0; idx < number_of_sources; ++idx)
+    {
+        MIDIEndpointRef src = MIDIGetSource(idx);
+        CFStringRef pname;
+        char name[64];
+        
+        MIDIObjectGetStringProperty(src, kMIDIPropertyName, pname);
+        CFStringGetCString(pname, name, sizeof(name), 0);
+        CFRelease(pname);
+        
+        rb_ary_push(source_ary, rb_str_new2(name));
+    }
+    
+    return source_ary;
+}
+
 void Init_rbcoremidi (void)
 {
   // Add the initialization code of your module here.
Add best guess at a method that returns an array with the names of all sources
