This project sonifies the readings from the different channels of Trill craft using a bank of oscillators.
The capacitve channels of the Trill device are scanned on an auxiliary task running parallel to the audio thread and stored in a global variable.
The reading from each channel on Trill craft are used to control the amplitudes of a bank of quasi-harmonically-tuned oscillators. You can hear the effect by running your finger across each pad of the Trill device.
Try changing the cutoff frequency of the smoothing filter which is applied to the Trill readings to change the response of this example. try filterCutoff = 50;
#include <libraries/Trill/Trill.h>
#include <libraries/Biquad/Biquad.h>
#include <libraries/Oscillator/Oscillator.h>
#include <vector>
#include <cstring>
#include <cmath>
#define NUM_CAP_CHANNELS 30
std::vector<Oscillator> gOscBank;
std::vector<Biquad> gFilters;
float gSensorReading[NUM_CAP_CHANNELS] = { 0.0 };
unsigned int gTaskSleepTime = 12000;
void loop(void*)
{
{
for(unsigned int i = 0; i < NUM_CAP_CHANNELS; i++)
gSensorReading[i] = touchSensor.
rawData[i];
usleep(gTaskSleepTime);
}
}
{
fprintf(stderr, "Unable to initialise Trill Craft\n");
return false;
}
float filterCutoff = 10;
gFilters.resize(NUM_CAP_CHANNELS,
Biquad::Settings({.fs = context->
audioSampleRate, .type = Biquad::lowpass, .cutoff = filterCutoff, .q = 0.707, .peakGainDb = 0}));
gOscBank.resize(NUM_CAP_CHANNELS, {context->
audioSampleRate, Oscillator::sine});
float fundFreq = 50;
for(unsigned int n = 0; n < gOscBank.size(); n++) {
float freq = fundFreq * powf(1.0 + n, 1.002);
gOscBank[n].setFrequency(freq);
}
return true;
}
{
for(
unsigned int n = 0; n < context->
audioFrames; ++n){
float out = 0;
for(unsigned int o = 0; o < gOscBank.size(); ++o) {
float amplitude = gFilters[o].process(gSensorReading[o]);
out += gOscBank[o].process() * amplitude * amplitude / 6.f;
}
}
}
{
}