csound / csound

Main repository for Csound
https://csound.com
GNU Lesser General Public License v2.1
1.24k stars 191 forks source link

csoundGetMIDIDevList - return clients also with jack module #775

Closed tarmoj closed 7 years ago

tarmoj commented 7 years ago

Enhancement:

Getting cliets list with csoundGetMIDIDevList for jack is not implemented yet. Hopefully in future!

Code for testing:

// compile gcc -DUSE_DOUBLE -o cs-test cs-test.c -lcsound64 

#include <csound/csound.h>
#include <stdio.h>

void getMidiNames(const char *module) {
    CSOUND *cs = csoundCreate(NULL);
    csoundSetMIDIModule(cs, module);
    int i,newn, n = csoundGetMIDIDevList(cs,NULL,0);
    CS_MIDIDEVICE *devs = (CS_MIDIDEVICE *) malloc(n*sizeof(CS_MIDIDEVICE));
    newn = csoundGetMIDIDevList(cs,devs,0);

    printf("Module %s %i devices found\n", module, newn);
    for (i = 0; i < n; i++) {
            printf("Device no %d: name: %s interfacename: %s\n", i, devs[i].device_name, devs[i].interface_name);
    }
    free(devs);
    csoundDestroy(cs);
}

int main(int argc, char **argv)
{
  getMidiNames("alsaseq");
  getMidiNames("jack");
  return 0;
}
vlazzarini commented 7 years ago

Implemented now.

tarmoj commented 7 years ago

Thanks!

I pulled, I can see changes in rtjack.c, rebuilt but the code below code return still 0 devices for jack (alsa works as expected):


void getMidiNames(const char module) { CSOUND cs = csoundCreate(NULL); csoundSetMIDIModule(cs, module); int i,newn, n = csoundGetMIDIDevList(cs,NULL,0); CS_MIDIDEVICE devs = (CS_MIDIDEVICE ) malloc(n*sizeof(CS_MIDIDEVICE)); newn = csoundGetMIDIDevList(cs,devs,0);

printf("Module %s %i devices found\n", module, newn);
for (i = 0; i < n; i++) {
        printf("Device no %d: name: %s interfacename: %s\n", i,

devs[i].device_name, devs[i].interface_name); } free(devs); csoundDestroy(cs);

}

int main(int argc, char **argv) { getMidiNames("alsaseq"); getMidiNames("jack"); return 0; }

tarmo


2017-05-11 10:51 GMT+03:00 vlazzarini notifications@github.com:

Closed #775 https://github.com/csound/csound/issues/775.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/775#event-1077745039, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVCU7MeiWpGEENZaT0-vsn4YfSJC0ljks5r4r3pgaJpZM4M0lpT .

vlazzarini commented 7 years ago

Well, it works here. Tested with

csound -+rtmidi=jack -+rtaudio=jack --midi-devices

When I first run it, I got 0 devices, but then I realised I had to turn MIDI on in jack. I got this printout then:

ligeti:debug victor$ ./csound -+rtmidi=jack -+rtaudio=jack --midi-devices  
time resolution is 1000.000 ns
virtual_keyboard real time MIDI plugin for Csound
WARNING: STK opcodes not available: define environment variable RAWWAVE_PATH
(points to rawwaves directory) to use STK opcodes.
0dBFS level = 32768.0
--Csound version 6.09 beta (double samples) May  9 2017 
[commit: 3b74104b032c17a5d01d82b97ca9ba1bd3b2268c]
libsndfile-1.0.25
WARNING: STK opcodes not available: define environment variable RAWWAVE_PATH
(points to rawwaves directory) to use STK opcodes.
rtaudio: JACK module enabled
rtmidi: JACK module enabled
4 MIDI input devices 
 0: 0 (system_midi:capture_1)
 1: 1 (system_midi:capture_2)
 2: 2 (system_midi:capture_3)
 3: 3 (system_midi:capture_4)
4 MIDI output devices 
 0: 0 (system_midi:playback_1)
 1: 1 (system_midi:playback_2)
 2: 2 (system_midi:playback_3)
 3: 3 (system_midi:playback_4)

This is what happens if I run jack without asking for MIDI

ligeti:debug victor$ ./csound -+rtmidi=jack -+rtaudio=jack --midi-devices  
time resolution is 1000.000 ns
virtual_keyboard real time MIDI plugin for Csound
WARNING: STK opcodes not available: define environment variable RAWWAVE_PATH
(points to rawwaves directory) to use STK opcodes.
0dBFS level = 32768.0
--Csound version 6.09 beta (double samples) May  9 2017 
[commit: 3b74104b032c17a5d01d82b97ca9ba1bd3b2268c]
libsndfile-1.0.25
WARNING: STK opcodes not available: define environment variable RAWWAVE_PATH
(points to rawwaves directory) to use STK opcodes.
rtaudio: JACK module enabled
rtmidi: JACK module enabled
0 MIDI input devices 
0 MIDI output devices 
WARNING: could not open library './libwebsocketIO.dylib' (-1)
end of score.          overall amps:      0.0
       overall samples out of range:        0
0 errors in performance
Elapsed time at end of performance: real: 0.176s, CPU: 0.091s
tarmoj commented 7 years ago

Oh, right, - the Csound options!

When I added these lines to code: CSOUND *cs = csoundCreate(NULL); csoundSetOption(cs,"-odac"); csoundSetOption(cs,"-+rtaudio=jack"); csoundSetOption(cs,"-+rtmidi=jack"); csoundSetMIDIModule(cs, module);

it worked fine.

2017-05-11 21:41 GMT+03:00 vlazzarini notifications@github.com:

Well, it works here. Tested with

csound -+rtmidi=jack -+rtaudio=jack --midi-devices

When I first run it, I got 0 devices, but then I realised I had to turn MIDI on in jack. I got this printout then:

ligeti:debug victor$ ./csound -+rtmidi=jack -+rtaudio=jack --midi-devices time resolution is 1000.000 ns virtual_keyboard real time MIDI plugin for Csound WARNING: STK opcodes not available: define environment variable RAWWAVE_PATH (points to rawwaves directory) to use STK opcodes. 0dBFS level = 32768.0 --Csound version 6.09 beta (double samples) May 9 2017 [commit: 3b74104b032c17a5d01d82b97ca9ba1bd3b2268c] libsndfile-1.0.25 WARNING: STK opcodes not available: define environment variable RAWWAVE_PATH (points to rawwaves directory) to use STK opcodes. rtaudio: JACK module enabled rtmidi: JACK module enabled 4 MIDI input devices 0: 0 (system_midi:capture_1) 1: 1 (system_midi:capture_2) 2: 2 (system_midi:capture_3) 3: 3 (system_midi:capture_4) 4 MIDI output devices 0: 0 (system_midi:playback_1) 1: 1 (system_midi:playback_2) 2: 2 (system_midi:playback_3) 3: 3 (system_midi:playback_4)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/775#issuecomment-300880548, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVCU3JL7EBkrobAxbBhRUSugoEiaYbOks5r41ZJgaJpZM4M0lpT .