Exemple #1
0
// Create a new source endpoint
static VALUE t_create_source(VALUE self, VALUE client_instance, VALUE source_name)
{
    MIDIEndpointRef source;
    
    RbMIDIClient* client;
    Data_Get_Struct(client_instance, RbMIDIClient, client);
    
    CFStringRef source_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(source_name)->ptr, kCFStringEncodingASCII);

    MIDISourceCreate(client->client, source_str, &source);

    VALUE source_instance = rb_class_new_instance(0, 0, cEndpoint);
    if( source_instance == Qnil )
    {
        free_objects();
        rb_fatal("Couldn't create an instance of Endpoint!");
    }
    
    RbEndpoint* endpoint_struct;
    Data_Get_Struct(source_instance, RbEndpoint, endpoint_struct);
    
    endpoint_struct->endpoint = source;
    
    return source_instance;
}
Exemple #2
0
void CoreMidiManager::InitializeMIDI()
{
  midimsg_attempt(MIDIClientCreate
		  (CFStringCreateWithCString(NULL, "Manta", kCFStringEncodingASCII), 
		   NULL, NULL, &m_midiclient), "creating OS-X MIDI client object.");
  
  midimsg_attempt(MIDISourceCreate
		  (m_midiclient, 
		   CFStringCreateWithCString(NULL, "Manta", kCFStringEncodingASCII), 
		   &m_midiendpoint), "creating OS-X virtual MIDI source.");
}
Exemple #3
0
//------------------------------------------------------------------------
bool TJackSynchro::Open()
{
    OSStatus err;

    if ((fClient = jack_client_new("JackSynchro")) == 0) {
        fprintf (stderr, "jack server not running?\n");
        return false;
    }

    jack_set_process_callback(fClient, Process, this);
    jack_set_sync_callback(fClient, SyncCallback, this);
    jack_on_shutdown(fClient, Shutdown, 0);

    if (jack_activate(fClient)) {
        fprintf (stderr, "cannot activate client");
        return false;
    }

    DBUG(("MIDIClientCreate \n"));
    err = MIDIClientCreate(CFSTR("JAS Sync"), NotifyProc, NULL, &fMidiClient);
    if (!fClient) {
        printf("Can not open Midi client\n");
        goto error;
    }

    err = MIDIDestinationCreate(fMidiClient, CFSTR("Jack Sync In"), ReadSyncProc, this, &fDestination);
    if (!fDestination) {
        printf("Can not open create destination \n");
        goto error;
    }
    DBUG(("MIDIDestinationCreate OK\n"));

    DBUG(("MIDISourceCreate \n"));
    err = MIDISourceCreate(fMidiClient, CFSTR("Jack Sync Out"), &fSource);
    if (!fSource) {
        printf("Can not open create source \n");
        goto error;
    }
    return true;

error:
    Close();
    return false;
}
Exemple #4
0
//------------------------------------------------------------------------
bool TJackSynchro::AddMidiBus(int i)
{
    OSStatus err;
    MIDIEndpointRef input = NULL;
    MIDIEndpointRef output = NULL;
    char inputStr [64];
    char outputStr [64];

    // Up to MAX_MIDI_BUS busses
    if (i >= MAX_MIDI_BUS)
        return false;

    sprintf(outputStr, "Jack MIDI In%ld", i);
    sprintf(inputStr, "Jack MIDI Out%ld", i);

    CFStringRef coutputStr = CFStringCreateWithCString(NULL, outputStr, CFStringGetSystemEncoding());
    CFStringRef cinputStr = CFStringCreateWithCString(NULL, inputStr, CFStringGetSystemEncoding());

    err = MIDIDestinationCreate(fMidiClient, coutputStr, fReadProc[i - 1], this, &output);
    if (!output) {
        printf("Can not open create destination \n");
        goto error;
    }

    err = MIDISourceCreate(fMidiClient, cinputStr, &input);
    if (!input) {
        printf("Can not open create source \n");
        goto error;
    }

    fMidiInput.push_back(input);
    fMidiOuput.push_back(output);
    CFRelease(coutputStr);
    CFRelease(cinputStr);
    return true;

error:
    if (input)
        MIDIEndpointDispose(input);
    if (output)
        MIDIEndpointDispose(output);
    return false;
}