[Csnd] No audio output from API
Date | 2013-10-29 20:12 |
From | mark |
Subject | [Csnd] No audio output from API |
After creating a working orchestra + score file (and confirming that it produces sound) I set to work creating a program to use the API to control the orchestra in realtime. Everything runs without errors (all 0's returned), but I don't hear any sound. Any help is appreciated. Here is the code - sorry, it's in Forth, hopefully it's still legible. Console output below. -- View this message in context: http://csound.1045644.n5.nabble.com/No-audio-output-from-API-tp5728851.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-10-29 20:16 |
From | mark |
Subject | [Csnd] Re: No audio output from API |
Oh .. I'm such an idiot. I realized that my commandline options aren't in the orchestra file. Now I just need to configure audio output to dac in the API. Unfortunately it's impossible to send argv as a char array with SwiftForth's FFI, so could someone point me at the right function(s) to do this without commandline options? -- View this message in context: http://csound.1045644.n5.nabble.com/No-audio-output-from-API-tp5728851p5728853.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-10-29 20:41 |
From | Steven Yi |
Subject | Re: [Csnd] Re: No audio output from API |
Hi Roger, I didn't see anything posted, but generally with Csound 6 it's easiest to use the csoundSetOption function (or just SetOption on a Csound object, depends if you're calling into the C or C++ API's from Forth). You should set one set of flags at a time, such as: csoundSetOption(csound, "-odac"); csoundSetOption(csound, "-m127"); (Not sure what the Forth equivalent is, I haven't played around much with postfix languages.) Hope that helps! steven On Tue, Oct 29, 2013 at 4:16 PM, mark |
Date | 2013-10-29 20:48 |
From | mark |
Subject | [Csnd] Re: No audio output from API |
It's visible on the forum but not in the mailing list. Don't know why. Thank you for the function, hopefully that's what I need - so longer as it lets me pass a pointer to the string rather than the string itself I should be good to go. Sifting through the csound.h file is a bit nerve-testing at times. Oh, and the equivalent would be: csound z" -odac" csoundSetOption ;)
On Tue, Oct 29, 2013 at 4:42 PM, Steven Yi [via Csound] <[hidden email]> wrote:
View this message in context: Re: No audio output from API Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-10-29 20:52 |
From | Steven Yi |
Subject | Re: [Csnd] Re: No audio output from API |
Hope that works out! Perhaps I can persuade you to write a translation of the API examples in Forth if you have a chance? :) It looked to me that Swiftforth is a commercial application. Would you know if gforth would be compatible? On Tue, Oct 29, 2013 at 4:48 PM, mark |
Date | 2013-10-29 21:00 |
From | mark |
Subject | [Csnd] Re: No audio output from API |
I believe that GForth and SwiftForth are largely compatible, except for the FFI. Unfortunately that's not standardized - the binding syntax is likely different and parameter order could be reversed.
SwiftForth does have a free version that is only missing executable export. You can run source files (treating them as scripts) by setting SwiftForth to open source files when double-clicked or configuring your text editor to run them with a hotkey. I can share my source once I have things running. Not sure which API examples you're referring to - I've been using this old pdf I found by Rory Walsh as my guide. The link to the API docs on csound was broken.
On Tue, Oct 29, 2013 at 4:53 PM, Steven Yi [via Csound] <[hidden email]> wrote:
View this message in context: Re: No audio output from API Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-10-29 21:04 |
From | Steven Yi |
Subject | Re: [Csnd] Re: No audio output from API |
Ah, I just published API examples at: https://github.com/kunstmusik/csoundAPI_examples It's mentioned in another email thread here, but I'm looking to have these examples translated into multiple languages from the Python ones. I got Swiftforth installed here now. I'd certainly like to see your source when you're ready. Thanks! steven On Tue, Oct 29, 2013 at 5:00 PM, mark |
Date | 2013-10-29 21:15 |
From | mark |
Subject | [Csnd] Re: No audio output from API |
Thanks for the link Steven. Looking at Python example #1, I already see an obstacle - I don't know how to compile .csd files without passing the path of one to csoundCompile via argc/argv, which I can't do. I'd enjoy translating these examples (partly for the educational value) but I think I'd need your help to overcome obstacles like this one.
On Tue, Oct 29, 2013 at 5:09 PM, Steven Yi [via Csound] <[hidden email]> wrote:
View this message in context: Re: No audio output from API Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-10-29 21:21 |
From | Dave Seidel |
Subject | Re: [Csnd] Re: No audio output from API |
Mark, if you looks at any of the other examples, you'll see that none of them (at least, none of the ones I've seen) compile a CSD from the flesystem. That was just showing how one would do that. It's extremely easy to compile ORC and SCO data from strings.
On Tue, Oct 29, 2013 at 5:15 PM, mark <roger.levy@gmail.com> wrote:
|
Date | 2013-10-29 21:42 |
From | Steven Yi |
Subject | Re: [Csnd] Re: No audio output from API |
I did a quick search for information about the FFI in SwiftForth but didn't see anything in the docs folder or online. Could you direct me to some info? Also, if you post what you got so far here, I can take a look. Maybe once we get past the initial hurdle, the rest will fall into place. On Tue, Oct 29, 2013 at 5:15 PM, mark |
Date | 2013-10-29 22:16 |
From | mark |
Subject | [Csnd] Re: No audio output from API |
I replied in email to Dave ... but it didn't post here. Sorry, I'm still getting the hang of this. FFI info is in the manual, sorry it might not be referred to there by that specific term. OK it's in section 8.2 in the win32 version. Here's what I (thought I) posted via email ... Ah, great. Well I guess we can work around that problem for example 1. I've got things working now. Since [Steven] requested, I'm including my test-bed source. Try this out for size. (Just replace the filenames with your own - also, warning, no way is provided to stop playback without closing the swiftforth window ) library csound64.dll function: csoundCreate ( options -- csound ) function: csoundCompile ( csound argc argv -- result ) function: csoundPerformKsmps ( csound -- result ) function: csoundStart ( csound -- int ) function: csoundDestroy ( csound -- ) function: csoundCreateThread ( routine[ptr--ptr] userdata -- ) function: csoundScoreEvent ( csound type pfields count -- ) function: csoundGetChannelPtr ( CSOUND >pointervar *name type -- n ) \ maybe not safe function: csoundGetAudioChannel ( csound *name *samples -- ) function: csoundSetAudioChannel ( csound *name *samples -- ) function: csoundSetControlChannel ( csound *name floatval -- ) function: csoundGetKsmps ( csound -- n ) \ # of samples per control frame function: csoundSetScorePending ( csound flag -- ) \ used to stop further score events (may not be needed) function: csoundScoreEvent ( csound type *float-pfields long-numfields -- ) \ used to update function tables (waveforms) function: csoundTableCopyIn ( csound table# *floats -- ) \ direct alternative way (non-generative, non-normalizing) function: csoundPerform ( csound -- int ) function: csoundReadScore ( csound *code -- int ) function: csoundSetOption ( csound *option -- int ) \ both can be called during performance... function: csoundCompileOrc ( csound *code -- int ) function: csoundEvalCode ( csound *code -- flt ) \ may be useful - allows return values dir 0 csoundCreate value csound cr : file, R/O open-file throw >r here r@ file-size 2drop dup allot 0 c, r@ read-file throw drop r> close-file throw ; csound z" -B256" csoundSetOption . csound z" -odac" csoundSetOption . create orc " vgc-1.0.orc" file, csound orc csoundCompileOrc . create sco " vgc-1.0.sco" file, csound sco csoundReadScore . csound csoundStart . :noname begin csound csoundPerformKsmps dup . until ; execute -- View this message in context: http://csound.1045644.n5.nabble.com/No-audio-output-from-API-tp5728851p5728866.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-10-29 22:26 |
From | Dave Seidel |
Subject | Re: [Csnd] Re: No audio output from API |
I did't get your email, but it seems like you are getting things sorted. Enjoy! On Tue, Oct 29, 2013 at 6:16 PM, mark <roger.levy@gmail.com> wrote: I replied in email to Dave ... but it didn't post here. Sorry, I'm still |
Date | 2013-10-29 22:54 |
From | mark |
Subject | [Csnd] Re: No audio output from API |
Ah, great. Well I guess we can work around that problem for example 1. I've got things working now. Since you requested, I'm including my test-bed source. Try this out for size. (Just replace the filenames with your own - also, warning, no way is provided to stop playback without closing the swiftforth window ) library csound64.dll function: csoundCreate ( options -- csound ) function: csoundCompile ( csound argc argv -- result ) function: csoundPerformKsmps ( csound -- result )
function: csoundStart ( csound -- int ) function: csoundDestroy ( csound -- ) function: csoundCreateThread ( routine[ptr--ptr] userdata -- ) function: csoundScoreEvent ( csound type pfields count -- )
function: csoundGetChannelPtr ( CSOUND >pointervar *name type -- n ) \ maybe not safe function: csoundGetAudioChannel ( csound *name *samples -- ) function: csoundSetAudioChannel ( csound *name *samples -- )
function: csoundSetControlChannel ( csound *name floatval -- ) function: csoundGetKsmps ( csound -- n ) \ # of samples per control frame function: csoundSetScorePending ( csound flag -- ) \ used to stop further score events (may not be needed)
function: csoundScoreEvent ( csound type *float-pfields long-numfields -- ) \ used to update function tables (waveforms) function: csoundTableCopyIn ( csound table# *floats -- ) \ direct alternative way (non-generative, non-normalizing)
function: csoundPerform ( csound -- int ) function: csoundReadScore ( csound *code -- int ) function: csoundSetOption ( csound *option -- int ) \ both can be called during performance...
function: csoundCompileOrc ( csound *code -- int ) function: csoundEvalCode ( csound *code -- flt ) \ may be useful - allows return values dir 0 csoundCreate value csound
cr : file, R/O open-file throw >r here r@ file-size 2drop dup allot 0 c, r@ read-file throw drop
r> close-file throw ; csound z" -B256" csoundSetOption . csound z" -odac" csoundSetOption . create orc " vgc-1.0.orc" file,
csound orc csoundCompileOrc . create sco " vgc-1.0.sco" file, csound sco csoundReadScore . csound csoundStart . :noname
begin csound csoundPerformKsmps dup . until ; execute On Tue, Oct 29, 2013 at 5:22 PM, Dave Seidel [via Csound] <[hidden email]> wrote:
View this message in context: Re: No audio output from API Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-10-30 01:03 |
From | Steven Yi |
Subject | Re: [Csnd] Re: No audio output from API |
Attachments | example1.fs |
Thanks for that, I did find the information in 8.2 of the manual here. I spent a little time and figured out how to create a string array to use with csoundCompile. I got the following to work as example1.fs. The code is: 0 csoundCreate value csound create myargs z" csound", z" test1.csd", csound z" -B256" csoundSetOption . csound z" -odac" csoundSetOption . csound 2 myargs csoundCompile . csound csoundStart . csound csoundPerform . csound csoundStop . I've attached the complete example here, and have committed it to a forth folder in the examples git repo. I think the FFI stuff could be moved to a separate .fs file. The FFI stuff looks about what I'd expect, and I'm wondering if we couldn't just generate a csound.fs file from the Python API, using the introspection into the objects to write out the .fs. That'd be sort of neat. :) Otherwise, good luck with the rest of your work! steven On Tue, Oct 29, 2013 at 6:16 PM, mark |