Ahhh, yes i was missing a compile! it works great now. Steven, no those were commented out. Mike this is great! you guys are the best, Thanks! Balan On Sun, Mar 16, 2008 at 4:30 PM, Michael Gogins wrote: > You could just do this in C++ and declare your buffer as > std::vector and keep pushing the ksmps buffers back onto it, > something like the following. > > I'm not sure I remember all the exact function names, but something like > this should work (for mono, anyway): > > void getSynthBuffer(std::vector &output, std::string csd, int argc, > const char **argv) > { > static bool initialized = false; > static CppSound csound; > if (!initialized) { > csound.setCSD(csd); > csound.initialize(argc, argv, 0); > initialized = true; > } > output.clear(); > csound.setCSD(csd); > csound.exportForPerformance(); > csound.compile(); > MYFLT *spout = csound.GetSpout(); while (!csound.performKsmps()) { > for (size_t j = 0, n = csound.GetSpoutSize(); ++j) { > output.push_back(spout[j]); > > } > } > } > > Hope this helps, > Mike > > ----- Original Message ----- > *From:* Balan Clockfactory > *To:* Developer discussions > *Sent:* Sunday, March 16, 2008 7:05 PM > *Subject:* Re: [Cs-dev] matlab interface > > maybe i should explain what i am trying to do. i have a concatenative > synthesis engine that uses ~40 psychoaucoustic features that matches > features extracted from input segments (note onsets) with an existing corpus > of sound, finds the closest match and substitutes it into a new sequence. I > am trying to build an evolutionary synthesis engine onto it that will find > synth parameters that minimize the distance between segment features and > synthesis features. unfortunately all of my code is in matlab and i dont > have time to write a huge collection of synthesis algorithms in matlab along > with everything else. my hope was to use synth-rich csound as part of my > objective function to iteratively generate a segment of sound based on the > current parameter set, zip that back into matlab where i could extract > features, calculate distance and tweak parameters again... ad inifinitum > (heh, hopefully not!). so, being part of my optimization loop, i just need > to specify a single note and have csound generate a buffer of data that i > can send back as quickly and noninvasively as possible. Can this be easily > done? > > Balan > > On Sun, Mar 16, 2008 at 3:39 PM, Michael Gogins > wrote: > > > You might have better luck with Csound::PerformKsmps(). You can use > > Csound::GetSpoutSize(), or calculate the size yourself as size = > > sizeof(double) (or sizeof(float)) * nchnls * ksmps. You can access the input > > buffer as Csound::GetSpin() and the output buffer as Csound::GetSpout(). > > > > Note that this is the LOW LEVEL buffer, the one opcodes actually write > > to. Not the intermediate level buffer that is sent to the sound card (that > > one's computed by PerformBuffer()). > > > > Don't ask me why we we have an intermediate level buffer at all, I think > > it is an unnecessary complication. > > > > > > ----- Original Message ----- > > > > *From:* Balan Clockfactory > > *To:* Developer discussions > > *Sent:* Sunday, March 16, 2008 6:20 PM > > *Subject:* Re: [Cs-dev] matlab interface > > > > understood, but Csound::GetOutputBufferSize() returns 0 after > > CppSound::perform() and Csound::PerformBuffer() just hangs. code attached > > > > // test app for CppSound > > #include "CppSound.hpp" > > > > int main(int argc, char* argv[]) > > { > > // cppsound object > > CppSound* cpps = new CppSound(); > > > > // create score > > cpps->addScoreLine("f 111 0 4096 10 1"); > > cpps->addScoreLine("i 100 0 1.0 20000 220 111"); > > cpps->addScoreLine("i 100 0 -1"); > > > > // create orchestra > > cpps->setOrchestra("instr 100\na1 oscil p4,p5,p6\nout a1\nendin"); > > > > // create csound command with temp orc and score > > cpps->setCommand("csound -RWdfo test.wav ./tempk.orc ./tempk.sco"); > > > > // export performance > > cpps->exportForPerformance(); > > > > // perform? > > cpps->perform(); > > // cpps->PerformBuffer() hangs > > // cpps->Perform() hangs > > > > // size check (returns a zero size) > > printf("%ld\n",cpps->GetOutputBufferSize()); > > > > // cleanup > > delete cpps; > > return 0; > > } > > > > On Sun, Mar 16, 2008 at 2:34 PM, victor > > wrote: > > > > > Csound::GetOutputBuffer()? CppSound is derived from Csound. > > > > > > ----- Original Message ----- > > > *From:* Balan Clockfactory > > > *To:* Developer discussions > > > *Sent:* Sunday, March 16, 2008 9:15 PM > > > *Subject:* Re: [Cs-dev] matlab interface > > > > > > Thanks everyone. Viktor: your comment made me go back and verify what > > > I was linking against, I had incorrectly built the csnd library. fixed. > > > ha! so my next question is: if I use CppSound::Perform() is there a > > > way to get access to the performance buffer? > > > again thanks for all of your help and patience. > > > > > > Balan > > > > > > On Sun, Mar 16, 2008 at 9:47 AM, Jonatan Liljedahl > > > wrote: > > > > > > > Rory Walsh wrote: > > > > > Balan posted the code at the end of his email. I had a quick look > > > > but > > > > > couldn't spot anything obvious. Is it Ok to call > > > > csoundScoreEvent() > > > > > before a performance has started? > > > > > > > > Yes, I do this in AlgoScore and it works fine. > > > > But I don't think it's correct to call csoundInitialize() after > > > > csoundCreate()! In AlgoScore I call csoundInitialize(0,0,0) (once) > > > > before I do anything else with csound. > > > > > > > > static naRef f_create(naContext ctx, naRef me, int argc, naRef > > > > *args) { > > > > static cs_initialized=0; > > > > HostData *data; > > > > if(!cs_initialized) { > > > > csoundInitialize(0,0,0); > > > > cs_initialized=1; > > > > } > > > > data = (HostData*)malloc(sizeof(HostData)); > > > > data->tag = NUMARG(0); > > > > data->graph_cb = naNil(); > > > > data->outvalues = naNil(); > > > > CSOUND *cs = csoundCreate((void*)data); > > > > return newCsoundGhost(ctx,cs); > > > > } > > > > > > > > > > Rory. > > > > > > > > > > > > > > > victor wrote: > > > > >> That seems correct. Can you quote your code? > > > > >> > > > > >> ----- Original Message ----- > > > > >> *From:* Balan Clockfactory > > > > >> *To:* Developer discussions > > > csound-devel@lists.sourceforge.net> > > > > >> *Sent:* Saturday, March 15, 2008 10:03 PM > > > > >> *Subject:* Re: [Cs-dev] matlab interface > > > > >> > > > > >> I hope I'm not being a nuisance but I am currently getting an > > > > error > > > > >> when I call csoundScoreEvent(). The error is "invalid > > > > instrument > > > > >> number or name". I am testing with a very simple instrument > > > > so I'm > > > > >> no > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > This SF.net email is sponsored by: Microsoft > > > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > > _______________________________________________ > > > > > Csound-devel mailing list > > > > > Csound-devel@lists.sourceforge.net > > > > > https://lists.sourceforge.net/lists/listinfo/csound-devel > > > > > > > > > > > > -- > > > > /Jonatan [ http://kymatica.com ] > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by: Microsoft > > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > _______________________________________________ > > > > Csound-devel mailing list > > > > Csound-devel@lists.sourceforge.net > > > > https://lists.sourceforge.net/lists/listinfo/csound-devel > > > > > > > > > > ------------------------------ > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Microsoft > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > > > ------------------------------ > > > > > > _______________________________________________ > > > Csound-devel mailing list > > > Csound-devel@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/csound-devel > > > > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Microsoft > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > _______________________________________________ > > > Csound-devel mailing list > > > Csound-devel@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/csound-devel > > > > > > > > ------------------------------ > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > ------------------------------ > > > > _______________________________________________ > > Csound-devel mailing list > > Csound-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/csound-devel > > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > Csound-devel mailing list > > Csound-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/csound-devel > > > > > ------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > ------------------------------ > > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > >