Skip to content

Commit

Permalink
updated program and build script
Browse files Browse the repository at this point in the history
  • Loading branch information
vlazzarini committed Dec 24, 2017
1 parent f0a695a commit 238c2a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Bela/BelaCsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ bool setup(BelaContext *context, void *Data)
void render(BelaContext *context, void *Data)
{
if(gCsData.res == 0) {
int n,i,k,count, frmcount,blocksize,res;
int n,i,k,count, frmcount,blocksize,res = gCsData->res;
Csound *csound = gCsData.csound;
MYFLT scal = csound->Get0dBFS();
MYFLT* audioIn = csound->GetSpin();
Expand Down
9 changes: 6 additions & 3 deletions Bela/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/sh
# Build command for belacsound
c++ main.cpp -o belacsound -I/usr/local/lib -I/root/Bela/include -L/usr/local/lib -lcsound -lsndfile -L/root/Bela/lib \
-lbela -lbelaextra -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/cobalt.wrappers -Wl,@/usr/xenomai/lib/modechk.wrappers \
-L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt
c++ main.cpp -o belacsound -std=c++11 -I/usr/xenomai/include -D_GNU_SOURCE \
-D_REENTRANT -D__XENO__ -I/usr/xenomai/include/posix -I/usr/local/lib \
-I/root/Bela/include -L/usr/local/lib -lcsound -lsndfile -L/root/Bela/lib \
-lbela -lbelaextra -Wl,@/usr/xenomai/lib/posix.wrappers -L/usr/xenomai/lib \
-lpthread_rt -lxenomai -lpthread -lrt -lNE10



19 changes: 9 additions & 10 deletions Bela/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,9 @@ bool csound_setup(BelaContext *context, void *p)
{
CsData *csData = (CsData *) p;
Csound *csound;
const char *midiDev = "-Mhw:1,0,0"; /* MIDI IN device */
const char *midiOutDev = "-Qhw:1,0,0"; /* MIDI OUT device */
const char *args[] = { "csound", csdData->csdfile.c_str(), "-iadc",
const char *args[] = { "csound", csData->csdfile.c_str(), "-iadc",
"-odac", "-+rtaudio=null",
"--realtime", "--daemon",
midiDev, midiOutDev };
"--realtime", "--daemon" };
int numArgs = (int) (sizeof(args)/sizeof(char *));

if(context->audioInChannels != context->audioOutChannels) {
Expand Down Expand Up @@ -229,7 +226,7 @@ void csound_render(BelaContext *context, void *p)
{
CsData *csData = (CsData *) p;
if(csData->res == 0) {
int n,i,k,count, frmcount,blocksize,res;
int n,i,k,count, frmcount,blocksize,res = csData->res;
Csound *csound = csData->csound;
MYFLT scal = csound->Get0dBFS();
MYFLT* audioIn = csound->GetSpin();
Expand All @@ -249,6 +246,7 @@ void csound_render(BelaContext *context, void *p)
/* processing loop */
for(n = 0; n < context->audioFrames; n++, frm+=incr, count+=nchnls){
if(count == blocksize) {

/* set the channels */
for(i = 0; i < an_chns; i++) {
csound->SetChannel(channel[i].name.str().c_str(),
Expand All @@ -259,6 +257,7 @@ void csound_render(BelaContext *context, void *p)
/* run csound */
if((res = csound->PerformKsmps()) == 0) count = 0;
else break;

}
/* read/write audio data */
for(i = 0; i < chns; i++){
Expand All @@ -276,8 +275,8 @@ void csound_render(BelaContext *context, void *p)
analogWriteOnce(context,k,i,ochannel[i].samples[frmcount]);
}
}
gCsData.res = res;
gCsData.count = count;
csData->res = res;
csData->count = count;
}
}

Expand Down Expand Up @@ -370,10 +369,10 @@ int main(int argc, const char *argv[]) {
settings.render = csound_render;
settings.cleanup = csound_cleanup;
settings.highPerformanceMode = 1;
settings.interleave = 0;
settings.interleave = 1;
settings.analogOutputsPersist = 0;

while((c = Bela_getopt_long(argc, argv, "hf", opt, &settings)) >= 0) {
while((c = Bela_getopt_long(argc, (char **) argv, "hf", opt, &settings)) >= 0) {
if (c == 'h') {
usage(argv[0]);
return 1;
Expand Down

0 comments on commit 238c2a1

Please sign in to comment.