This example shows you how to read from the extra audio channels of the audio expander capelet.
#include <cmath>
float gPhase[10] = {0};
float gFreq[10];
float inAcc[10] = {0};
unsigned int inAccCount[10] = {0};
{
float baseFreq = 123;
gFreq[ch] = baseFreq * (1 + ch);
return true;
}
{
{
{
inAcc[ch] += in;
++inAccCount[ch];
float out = 0.4f * sinf(gPhase[ch]);
if(gPhase[ch] > M_PI)
gPhase[ch] -= 2.f * (float)M_PI;
}
}
{
{
inAcc[idx] += in;
++inAccCount[idx];
float out = 0.4f * sinf(gPhase[idx]);
if(gPhase[idx] > (float)M_PI)
gPhase[idx] -= 2.f * (float)M_PI;
}
}
static int count = 0;
{
count += 1;
{
rt_printf("Average input:\n");
for(unsigned int n = 0; n < 10; ++n)
{
rt_printf("[%d]:\t%.3f\t", n, inAcc[n]/inAccCount[n]);
if(n % 2 == 1)
rt_printf("\n");
}
}
}
}
{
}
static float audioRead(BelaContext *context, int frame, int channel)
Read an audio input, specifying the frame number (when to read) and the channel.
Definition Bela.h:1458
static float analogRead(BelaContext *context, int frame, int channel)
Read an analog input, specifying the frame number (when to read) and the channel.
Definition Bela.h:1480
static void audioWrite(BelaContext *context, int frame, int channel, float value)
Write an audio output, specifying the frame number (when to write) and the channel.
Definition Bela.h:1469
static void analogWriteOnce(BelaContext *context, int frame, int channel, float value)
Write an analog output, specifying the frame number (when to write) and the channel.
Definition Bela.h:1491
void render(BelaContext *context, void *userData)
User-defined callback function to process audio and sensor data.
Definition render.cpp:68
bool setup(BelaContext *context, void *userData)
User-defined initialisation function which runs before audio rendering begins.
Definition render.cpp:51
void cleanup(BelaContext *context, void *userData)
User-defined cleanup function which runs when the program finishes.
Definition render.cpp:96
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition Bela.h:231
const uint32_t audioOutChannels
The number of audio output channels.
Definition Bela.h:326
const uint32_t audioFrames
The number of audio frames per block.
Definition Bela.h:322
const float audioSampleRate
The audio sample rate in Hz (currently always 44100.0).
Definition Bela.h:328
const uint32_t analogFrames
The number of analog frames per block.
Definition Bela.h:341
const uint32_t analogOutChannels
The number of analog output channels.
Definition Bela.h:351
const uint32_t analogInChannels
The number of analog input channels.
Definition Bela.h:346
const float analogSampleRate
Analog sample rate in Hz.
Definition Bela.h:362