Skip to content

Commit

Permalink
Dynamically getting sample rate from Bela backend
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliomoro committed Oct 19, 2020
1 parent dce192d commit 50f9e31
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/scsynth/SC_Bela.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ SC_BelaDriver::~SC_BelaDriver() {
mBelaDriverInstance = 0;
}

static float gBelaSampleRate;
// Return true on success; returning false halts the program.
bool sc_belaSetup(BelaContext* belaContext, void* userData) {
// cast void pointer
// SC_BelaDriver *belaDriver = (SC_BelaDriver*) userData;
gBelaSampleRate = belaContext->audioSampleRate;
return true;
}

Expand Down Expand Up @@ -454,7 +456,7 @@ bool SC_BelaDriver::DriverSetup(int* outNumSamples, double* outSampleRate) {
}

*outNumSamples = settings->periodSize;
*outSampleRate = 44100.0; // This is fixed in Bela at the moment
*outSampleRate = gBelaSampleRate;
Bela_InitSettings_free(settings);

// Set up interrupt handler to catch Control-C and SIGTERM
Expand Down

0 comments on commit 50f9e31

Please sign in to comment.