[Cs-dev] Getting Audio and MIDI Device lists from API
Date | 2013-08-15 00:36 |
From | Steven Yi |
Subject | [Cs-dev] Getting Audio and MIDI Device lists from API |
Attachments | None None |
Hi All,
I was experimenting with getting audio and midi device lists from Csound through the API (both Python and Java via Clojure). I'm not sure it's really possible to use it from outside C/C++. Could someone tell me if this is correct?
If so, I'm wondering if we should add methods to csound.hpp doing the appropriate C code so that it'll get wrapped to return an array of CS_AUDIODEVICE and CS_MIDIDEVICE? Also, does someone have example C code for using the related Csound API functions? Thanks! steven |
Date | 2013-08-15 00:45 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Getting Audio and MIDI Device lists from API |
Attachments | None None |
Hi, I'm not sure if these functions are available outside the C/C++ API, but this is what the code in CsoundQt looks like: QList<QPair<QString, QString> > deviceList; #ifdef CSOUND6 CSOUND *cs = csoundCreate(NULL); csoundSetRTAudioModule(cs, module.toLatin1().data()); int i,newn, n = csoundGetAudioDevList(cs,NULL,0); CS_AUDIODEVICE *devs = (CS_AUDIODEVICE *) malloc(n*sizeof(CS_AUDIODEVICE)); newn = csoundGetAudioDevList(cs,devs,0); if (newn != n) { qDebug() << "ConfigLists::getAudioInputDevices Device number changed"; return deviceList; } for (i = 0; i < n; i++) { // qDebug() << devs[i].device_name; deviceList.append(QPair<QString,QString>(devs[i].device_name, QString(devs[i].device_id))); } free(devs); #else You first need to query the available modules with something like: CSOUND *csound = csoundCreate(NULL); char *name, *type; int n = 0; while(!csoundGetModule(csound, n++, &name, &type)) { if (strcmp(type, "audio") == 0) { rtAudioNames << name; // printf("Module %d: %s (%s) \n", n, name, type); } } rtAudioNames << "null"; // add also none (-+rtaudio=null) n = 0; while(!csoundGetModule(csound, n++, &name, &type)) { if (strcmp(type, "midi") == 0) { rtMidiNames << name; // printf("MIDI Module %d: %s (%s) \n", n, name, type); } } rtMidiNames << "virtual" << "none"; Cheers, Andrés On Wed, Aug 14, 2013 at 4:36 PM, Steven Yi <stevenyi@gmail.com> wrote:
|
Date | 2013-08-15 08:38 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Getting Audio and MIDI Device lists from API |
I think you might be right. I think the way ahead is not to touch cound.hpp but add some interfaces to it either in the SWIG interface file or as separate helper classes. Csound.hpp needs to continue to be a thin layer. Victor On 15 Aug 2013, at 00:36, Steven Yi wrote: > Hi All, > > I was experimenting with getting audio and midi device lists from Csound through the API (both Python and Java via Clojure). I'm not sure it's really possible to use it from outside C/C++. Could someone tell me if this is correct? > > If so, I'm wondering if we should add methods to csound.hpp doing the appropriate C code so that it'll get wrapped to return an array of CS_AUDIODEVICE and CS_MIDIDEVICE? > > Also, does someone have example C code for using the related Csound API functions? > > Thanks! > steven > ------------------------------------------------------------------------------ > Get 100% visibility into Java/.NET code with AppDynamics Lite! > It's a free troubleshooting tool designed for production. > Get down to code-level detail for bottlenecks, with <2% overhead. > Download for free and get started troubleshooting in minutes. > http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk_______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2013-08-19 00:47 |
From | Steven Yi |
Subject | Re: [Cs-dev] Getting Audio and MIDI Device lists from API |
Thanks for this. I think that generally it's better to have ** for array types rather than just * which usually gets mapped as just a reference to an object. As it is, I don't think the C code can be automatically wrapped with SWIG, so intermediary code would need to be introduced. Not sure of path forward, but at least the problem is identified. On Wed, Aug 14, 2013 at 7:45 PM, Andres Cabrera |
Date | 2013-08-19 16:17 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Getting Audio and MIDI Device lists from API |
Attachments | None None |
Hmm... It's a shame we didn't identify this before the release... So I think the solution is some intermediary code for SWIG. Do you think there is a way to write a code that can be shared by all language bindings? Cheers, Andrés On Sun, Aug 18, 2013 at 4:47 PM, Steven Yi <stevenyi@gmail.com> wrote: Thanks for this. I think that generally it's better to have ** for |
Date | 2013-08-19 16:59 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Getting Audio and MIDI Device lists from API |
Attachments | None None |
Yes, don't expose sructs, return everything by value. On Aug 19, 2013 11:18 AM, "Andres Cabrera" <mantaraya36@gmail.com> wrote:
|
Date | 2013-08-19 23:11 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Getting Audio and MIDI Device lists from API |
Attachments | None None |
The current system doesn't pass the original structs directly, but copies them to a preallocated array. Thinking back it might have been better to take a **pointer and allocate it in the Csound API... Cheers,Andrés On Mon, Aug 19, 2013 at 8:59 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
|