| Joshua,
your code looks correct, however the CSDs you showed maybe the
problem. They use 16K as SR and diskin does not do SR conversion, so
if your file is not 16K (quite an unusual sr these days). It would
sound funny alright.
Victor
On 8 Nov 2011, at 23:53, Joshua Brown wrote:
> Hello, I have a couple of questions:
>
> 1) Where can I find the source code for the libcsound API (& if
> possible, build instructions)? I am interested in porting it to
> android.
>
> 2) I have attempted to modify some C++ code which uses libcsound
> written
> by Victor Lazzarini, so that it will run in C. The modified code
> 'works'
> but sounds funny. I can't spot what I'm doing wrong:
>
> ====================
>
> #include
> #include
>
> int main(int argc, char **argv){
>
> // sender, receiver instances
> CSOUND *sender, *receiver;
> MYFLT *psend, *precv;
> char sar[20], kar[20];
> int res,i,ksmps;
>
> // set sender argvs
> char ** senderargv = malloc(sizeof(char)*(10+2));
> senderargv[1] = "sender.csd";
> senderargv[2] = "-n";
>
> // create instances
> sender = csoundCreate(NULL);
> receiver = csoundCreate(NULL);
>
> // compile sender
> // retrieve kr & sr
> csoundPreCompile(sender); //NOTE: Returns CSOUND_SUCCESS on success,
> and
> CSOUND_ERROR or CSOUND_MEMORY if an error occured.
> csoundCompile(sender, 3, senderargv);
> sprintf(sar, "--sample-rate=%d", (int)csoundGetSr(sender));
> sprintf(kar, "--control-rate=%d", (int)csoundGetKr(sender));
>
> // set receiver argvs
> char ** receiverargv = malloc(sizeof(char)*12+sizeof(kar)
> +sizeof(sar));
> receiverargv[1] = "receiver.csd";
> receiverargv[2] = kar;
> receiverargv[3] = sar;
>
> // compile receiver
> // force kr & sr
> csoundPreCompile(receiver); //NOTE: Returns CSOUND_SUCCESS on success,
> and CSOUND_ERROR or CSOUND_MEMORY if an error occured.
> csoundCompile(receiver, 4, receiverargv);
>
> // get send and receive buffers
> psend = csoundGetSpout(sender);
> precv = csoundGetSpin(receiver);
> ksmps = csoundGetKsmps(sender);
>
> // fill first ksmps vector
> res = csoundPerformKsmps(sender);
> while(!res){
> // copy sender output to receiver input
> for(i=0; i < ksmps; i++) precv[i] = psend[i];
> // process ksmps vectors
> res = csoundPerformKsmps(receiver);
> if(!res) res = csoundPerformKsmps(sender);
> }
>
> csoundDestroy(sender);
> csoundDestroy(receiver);
>
> }
>
> =======================
> sender.csd
>
>
>
>
> -d
>
>
> sr=16000
> ksmps=64
> nchnls=1
>
> instr 1
>
> asig diskin "clar.wav", 1, 0, 1
> out asig
>
> endin
>
>
>
> i1 0 60
> e
>
>
>
> ========================
> receiver.csd
>
>
>
>
> -W -owhoo.wav -b1024 -d
>
>
> sr=16000
> ksmps=64
> nchnls=1
>
> instr 1
> aout in
> out aout
>
> endin
>
>
>
> i1 0 60
> e
>
>
>
> =======================
>
> Link to clar.wav: http://labrosa.ee.columbia.edu/matlab/sinemodel/clar.wav
>
>
> Hope I'm sending this message to the correct place. Any help, very
> much
> appreciated,
>
> Josh
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> 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
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |