bool initialise_aux_tasks() { if((gChangeCoeffTask = Bela_createAuxiliaryTask(&check_coeff, 90, "bela-check-coeff")) == 0) return false; if((gInputTask = Bela_createAuxiliaryTask(&read_input, 50, "bela-read-input")) == 0) return false; rt_printf("Cut-off frequency: %f\n", gCutFreq); rt_printf("Press 'a' <enter> to start playing the sample, 's' to stop\n"); rt_printf(" 'z' <enter> to low down cut-off freq by 100 Hz, 'x' to raise it\n"); rt_printf("Press 'q' <enter> or ctrl-C to quit\n"); return true; }
bool setup(BelaContext *context, void *userData) { updatePll=Bela_createAuxiliaryTask(&updatePllFunction, 91, "update PLL"); for(int n=0; n<delayLength; n++){ delay[n]=0; } return true; }
bool initialise_trigger() { if((gTriggerSamplesTask = Bela_createAuxiliaryTask(&trigger_samples, 50, "bela-trigger-samples")) == 0) return false; rt_printf("Press 'a' <enter> to trigger sample,\n" " 's' <enter> to stop the current playing sample\n" " 'q' <enter> or ctrl-C to quit\n"); return true; }
bool setup(BelaContext *context, void *userData) { // Check that we have the same number of inputs and outputs. if(context->audioInChannels != context->audioOutChannels || context->analogInChannels != context-> analogOutChannels){ printf("Error: for this project, you need the same number of input and output channels.\n"); return false; } updatePll=Bela_createAuxiliaryTask(&updatePllFunction, 91, "update PLL"); for(int n=0; n<delayLength; n++){ delay[n]=0; } Bela_scheduleAuxiliaryTask(updatePll); return true; }
// setup() is called once before the audio rendering starts. // Use it to perform any initialisation and allocation which is dependent // on the period size or sample rate. // // userData holds an opaque pointer to a data structure that was passed // in from the call to initAudio(). // // Return true on success; returning false halts the program. bool setup(BelaContext *context, void *userData) { srandom(time(NULL)); if(context->audioOutChannels != 2) { rt_printf("Error: this example needs stereo audio enabled\n"); return false; } // Initialise the sine wavetable if(posix_memalign((void **)&gWavetable, 8, (gWavetableLength + 1) * sizeof(float))) { rt_printf("Error allocating wavetable\n"); return false; } for(int n = 0; n < gWavetableLength + 1; n++) gWavetable[n] = sinf(2.0 * M_PI * (float)n / (float)gWavetableLength); // Allocate the other buffers if(posix_memalign((void **)&gPhases, 16, gNumOscillators * sizeof(float))) { rt_printf("Error allocating phase buffer\n"); return false; } if(posix_memalign((void **)&gFrequencies, 16, gNumOscillators * sizeof(float))) { rt_printf("Error allocating frequency buffer\n"); return false; } if(posix_memalign((void **)&gAmplitudes, 16, gNumOscillators * sizeof(float))) { rt_printf("Error allocating amplitude buffer\n"); return false; } if(posix_memalign((void **)&gDFrequencies, 16, gNumOscillators * sizeof(float))) { rt_printf("Error allocating frequency derivative buffer\n"); return false; } if(posix_memalign((void **)&gDAmplitudes, 16, gNumOscillators * sizeof(float))) { rt_printf("Error allocating amplitude derivative buffer\n"); return false; } // Initialise buffer contents float freq = kMinimumFrequency; float increment = (kMaximumFrequency - kMinimumFrequency) / (float)gNumOscillators; for(int n = 0; n < gNumOscillators; n++) { gPhases[n] = 0.0; if(context->analogFrames == 0) { // Random frequencies when used without matrix gFrequencies[n] = kMinimumFrequency + (kMaximumFrequency - kMinimumFrequency) * ((float)random() / (float)RAND_MAX); } else { // Constant spread of frequencies when used with matrix gFrequencies[n] = freq; freq += increment; } // For efficiency, frequency is expressed in change in wavetable position per sample, not Hz or radians gFrequencies[n] *= (float)gWavetableLength / context->audioSampleRate; gAmplitudes[n] = ((float)random() / (float)RAND_MAX) / (float)gNumOscillators; gDFrequencies[n] = gDAmplitudes[n] = 0.0; } increment = 0; freq = 440.0; for(int n = 0; n < gNumOscillators; n++) { // Update the frequencies to a regular spread, plus a small amount of randomness // to avoid weird phase effects float randScale = 0.99 + .02 * (float)random() / (float)RAND_MAX; float newFreq = freq * randScale; // For efficiency, frequency is expressed in change in wavetable position per sample, not Hz or radians gFrequencies[n] = newFreq * (float)gWavetableLength / context->audioSampleRate; freq += increment; } // Initialise auxiliary tasks if((gFrequencyUpdateTask = Bela_createAuxiliaryTask(&recalculate_frequencies, 85, "bela-update-frequencies")) == 0) return false; //for(int n = 0; n < gNumOscillators; n++) // rt_printf("%f\n", gFrequencies[n]); gAudioSampleRate = context->audioSampleRate; gSampleCount = 0; return true; }
void OSCClient::createAuxTasks(){ char name [30]; sprintf (name, "OSCSendTask %i", port); OSCSendTask = Bela_createAuxiliaryTask(sendQueue, BELA_AUDIO_PRIORITY-5, name, this, true); }
void Midi::staticConstructor(){ staticConstructed = true; midiInputTask = Bela_createAuxiliaryTask(Midi::midiInputLoop, 50, "MidiInput"); midiOutputTask = Bela_createAuxiliaryTask(Midi::midiOutputLoop, 50, "MidiOutupt"); }