Hi
I am playing around with some of the example code. The hardware I have are three home made stretch sensors. I’m getting decent values from them and are mapping them to better ranges.
I’m don’t know heaps about programming. Currently I am not getting sound out. I don’t really understand the two for loops in the audio callback. At first I thought the for loop was just used in the example to automate it. But now I get that it’s inside this for loop where I need to put the sound.
I’m currently getting no sound out from channel 1. The sensors are working as they react in the serial monitor. I think that it’s either that I have the output set up wrong. or that the parameters I am setting for bit crush are wrong. Is there somewhere that I can find out the max and min values for the bitDepth and crushRate?
here is my altered bitcrush example code:
#include "DaisyDuino.h"
DaisyHardware hw;
size_t num_channels;
static Oscillator osc, lfo;
static Bitcrush bitcrush;
static Metro metro;
uint8_t depth;
uint8_t string1;
uint8_t string2;
uint8_t string3;
float harpL;
float harpM;
float harpR;
void MyCallback(float **in, float **out, size_t size) {
float sig;
Serial.print("string1: ");
Serial.println(analogRead(string1));
harpL = map(analogRead(string1), 910, 1023, 200, 22000);
harpM = map(analogRead(string2), 910, 1023, 1, 8);
harpR = map(analogRead(string3), 710, 1023, 1000, 2000);
for (size_t i = 0; i < size; i++) {
sig = osc.Process();
osc.SetFreq(harpL);
bitcrush.SetBitDepth(harpM);
bitcrush.SetCrushRate(harpR);
sig = bitcrush.Process(sig);
for (size_t chn = 0; chn < num_channels; chn++) {
out[chn][i] = sig;
}
}
}
void setup() {
Serial.begin(9600);
float sample_rate;
// Initialize for Daisy pod at 48kHz
hw = DAISY.init(DAISY_SEED, AUDIO_SR_48K);
num_channels = hw.num_channels;
sample_rate = DAISY.get_samplerate();
depth = 1;
string1 = A6;
string2 = A5;
string3 = A4;//r
pinMode(string1, INPUT);
pinMode(string2, INPUT);
pinMode(string3, INPUT);
osc.Init(sample_rate);
bitcrush.Init(sample_rate);
metro.Init(1.0f, sample_rate);
// Set parameters for oscillator
osc.SetWaveform(osc.WAVE_SIN);
osc.SetFreq(440);
osc.SetAmp(0.25);
// set parameters for bitcrusher
bitcrush.SetBitDepth(6);
bitcrush.SetCrushRate(10000);
DAISY.begin(MyCallback);
}
void loop() {}
I’ve checked the output with a different sketch and the sound out is working so it’s not the cable.
Any help or feedback appreciated. Thanks