Csound Csound-dev Csound-tekno Search About

[Cs-dev] Same problem, just slightly different.

Date2012-01-17 20:47
FromJoshua Brown
Subject[Cs-dev] Same problem, just slightly different.
Hello, I am trying to use spin and spout unsuccessfully. I've changed 
diskin to diskin2 on my sender csd, so the sample rate shouldn't matter 
too much. Upon running the program, I get a high pitched ringing and I 
still can't find out what it is! Any help appreciated. :)

#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 *) * 3);
senderargv[0] = malloc(sizeof(char)*6);
senderargv[0] = "csound";
senderargv[1] = malloc(sizeof(char)*10);
senderargv[1] = "sender.csd";
senderargv[2] = malloc(sizeof(char)*2);
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 *) * 4);;
receiverargv[0] = malloc(sizeof(char)*6);
receiverargv[0] = "csound";
receiverargv[1] = malloc(sizeof(char)*12);
receiverargv[1] = "receiver.csd";
receiverargv[2] = malloc(sizeof(kar));
receiverargv[2] = kar;
receiverargv[3] = malloc(sizeof(sar));
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
ksmps = csoundGetKsmps(sender);
psend = malloc(sizeof(MYFLT)*ksmps);
precv = malloc(sizeof(MYFLT)*ksmps);
psend = csoundGetSpout(sender);
precv = csoundGetSpin(receiver);

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



-d



sr     = 44100
kr     = 4410
ksmps  = 10
nchnls = 1
0dbfs = 1
instr 1

a1     diskin2 "clar.wav", 1, 0, 1, 0, 32
        out a1


endin



i 1 0 15
e



========================================= RECEIVER===



-+rtaudio=pulse -odac


sr=44100
nchnls=1
0dbfs=1
ksmps=10

instr 1
a2 in
out a2

endin



i1 0 15
e



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-01-18 02:23
FromJoshua Brown
SubjectRe: [Cs-dev] Same problem, just slightly different.
On 17/01/12 20:47, Joshua Brown wrote:
> Hello, I am trying to use spin and spout unsuccessfully. I've changed
> diskin to diskin2 on my sender csd, so the sample rate shouldn't matter
> too much. Upon running the program, I get a high pitched ringing and I
> still can't find out what it is! Any help appreciated. :)
>
> #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 *) * 3);
> senderargv[0] = malloc(sizeof(char)*6);
> senderargv[0] = "csound";
> senderargv[1] = malloc(sizeof(char)*10);
> senderargv[1] = "sender.csd";
> senderargv[2] = malloc(sizeof(char)*2);
> 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 *) * 4);;
> receiverargv[0] = malloc(sizeof(char)*6);
> receiverargv[0] = "csound";
> receiverargv[1] = malloc(sizeof(char)*12);
> receiverargv[1] = "receiver.csd";
> receiverargv[2] = malloc(sizeof(kar));
> receiverargv[2] = kar;
> receiverargv[3] = malloc(sizeof(sar));
> 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
> ksmps = csoundGetKsmps(sender);
> psend = malloc(sizeof(MYFLT)*ksmps);
> precv = malloc(sizeof(MYFLT)*ksmps);
> psend = csoundGetSpout(sender);
> precv = csoundGetSpin(receiver);
>
> // 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===
>
> 
> 
> -d
> 
> 
>
> sr     = 44100
> kr     = 4410
> ksmps  = 10
> nchnls = 1
> 0dbfs = 1
> instr 1
>
> a1     diskin2 "clar.wav", 1, 0, 1, 0, 32
>          out a1
>
>
> endin
>
> 
> 
> i 1 0 15
> e
> 
> 
>
> ========================================= RECEIVER===
>
> 
> 
> -+rtaudio=pulse -odac
> 
> 
> sr=44100
> nchnls=1
> 0dbfs=1
> ksmps=10
>
> instr 1
> a2 in
> out a2
>
> endin
>
> 
> 
> i1 0 15
> e
> 
> 
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>    
Found the problem, I'm using csound64 so I just replaced MYFLT with 
double and it worked okay.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net