Csound Csound-dev Csound-tekno Search About

[Cs-dev] Fwd: A couple of questions, and some help with some code.

Date2011-11-09 00:01
FromJoshua Brown
Subject[Cs-dev] Fwd: A couple of questions, and some help with some code.
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

Date2011-11-09 02:18
FromSteven Yi
SubjectRe: [Cs-dev] Fwd: A couple of questions, and some help with some code.
Hi Joshua,

I've actually been working on getting Csound working on Android. I've
gotten as far as getting libcsound compiled for android armeabi
together with libsndfile.  The next steps though require getting
either the SWIG wrapper to work with Android or writing JNI code, and
also interfacing csound with OpenSL, which I have some code for from
Victor.  The next steps are a little tricky though, so it may take
some time to get it completed together with some test Android example
code.

steven


On Wed, Nov 9, 2011 at 12:01 AM, 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
>

------------------------------------------------------------------------------
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

Date2011-11-09 03:18
FromJoshua Brown
SubjectRe: [Cs-dev] Fwd: A couple of questions, and some help with some code.
On 09/11/11 02:18, Steven Yi wrote:
> Hi Joshua,
>
> I've actually been working on getting Csound working on Android. I've
> gotten as far as getting libcsound compiled for android armeabi
> together with libsndfile.  The next steps though require getting
> either the SWIG wrapper to work with Android or writing JNI code, and
> also interfacing csound with OpenSL, which I have some code for from
> Victor.  The next steps are a little tricky though, so it may take
> some time to get it completed together with some test Android example
> code.
>
> steven
>
>
> On Wed, Nov 9, 2011 at 12:01 AM, 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
>>
>>      
> ------------------------------------------------------------------------------
> 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
>
>
>    
This is encouraging to hear. Wish I knew how to help with the SWIG 
wrapper, it seems a bit beyond me.

------------------------------------------------------------------------------
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