Ok - Our ongoing quest to get a 4051 working with gen~ continues. The current state is that I have a breadboard with a 4051 setup to a single pot that works perfectly with a C++ program but does not work with what I think is the identical setup using oopsy.
As far as I can see I have got everything correct. I know the wiring is correct as the C++ example works correctly reading the pot thru the mux. I know that the gen~ environment is working as I can download and run the default patch and it works ok when I use knob1 (note that on the breadboard I do have a pot connected as knob1 as if this was a pod). But when I try to use knob3 defined as a the mux knob in the pod.json file I just get a noisy tone and no knob affect at all.
I can’t think of anything else to try. It feels like under oopsy that the mux is not being initialised and I am getting noise on the pin. We are using the bootloader_additions version of oopsy and I updated it just today. Any help or suggestions would be hugely appreciated.
Here is an image of the breadboard setup.
and this the c++ code that works perfectly.
#include "daisysp.h"
#include "daisy_seed.h"
using namespace daisysp;
using namespace daisy;
static DaisySeed hw;
static Oscillator osc;
int v1;
static void AudioCallback(AudioHandle::InterleavingInputBuffer in,
AudioHandle::InterleavingOutputBuffer out,
size_t size)
{
float sig;
for(size_t i = 0; i < size; i += 2)
{
// osc.SetFreq(hw.adc.GetMux(0,0));
osc.SetFreq( mtof(hw.adc.GetMuxFloat(0,0) * 127));
sig = osc.Process();
// left out
out[i] = sig;
// right out
out[i + 1] = sig;
}
}
int main(void)
{
// initialize seed hardware and oscillator daisysp module
float sample_rate;
hw.Configure();
hw.Init();
hw.SetAudioBlockSize(4);
sample_rate = hw.AudioSampleRate();
/** Configure the ADC
*
* One channel configured for 8 inputs via CD4051 mux.
*
*/
AdcChannelConfig adc_cfg;
adc_cfg.InitMux(seed::A1, 8, seed::D7, seed::D8, seed::D9);
/** Initialize the ADC with our configuration */
hw.adc.Init(&adc_cfg, 1);
osc.Init(sample_rate);
// Set parameters for oscillator
osc.SetWaveform(osc.WAVE_SIN);
osc.SetFreq(440);
osc.SetAmp(0.5);
/** Start the ADC conversions in the background */
hw.adc.Start();
/** Startup the USB Serial port */
hw.StartLog(true);
hw.PrintLine( "We are connected");
// start callback
hw.StartAudio(AudioCallback);
while(1) {
float f = hw.adc.GetMuxFloat(0,0);
hw.PrintLine( "Input Mux 1: " FLT_FMT(3), FLT_VAR(3,f));
System::Delay(100);
}
}
This is the pod.json file modified to have the 4051 mux and knob3 defined
{
"name": "pod",
"som": "seed",
"defines": {
"OOPSY_TARGET_POD": 1,
"OOPSY_TARGET_HAS_MIDI_INPUT": 1,
"OOPSY_HAS_ENCODER": 1
},
"max_apps": 8,
"display": {},
"audio": {
"channels": 2
},
"parents": {
"pot_mux": {
"component": "CD4051",
"mux_count": 8,
"pin": {
"adc": 16,
"sel0": 7,
"sel1": 8,
"sel2": 9
}
}
},
"components": {
"sw1": {
"component": "Switch",
"pin": 27
},
"sw2": {
"component": "Switch",
"pin": 28
},
"knob1": {
"component": "AnalogControl",
"pin": 21
},
"knob2": {
"component": "AnalogControl",
"pin": 15
},
"knob3": {
"component": "CD4051AnalogControl",
"index": 0,
"parent": "pot_mux"
},
"encoder": {
"component": "Encoder",
"pin": {
"a": 26,
"b": 25,
"click": 13
}
},
"led1": {
"component": "RgbLed",
"pin": {
"r": 20,
"g": 19,
"b": 18
}
},
"led2": {
"component": "RgbLed",
"pin": {
"r": 17,
"g": 24,
"b": 23
}
}
},
"aliases": {
"switch": "sw1",
"button": "sw1",
"switch1": "sw1",
"button1": "sw1",
"switch2": "sw2",
"button2": "sw2",
"encswitch": "encoder_rise",
"enp": "encoder_press",
"press": "encoder_press",
"knob": "knob1",
"ctrl": "knob1",
"ctrl1": "knob1",
"ctrl2": "knob2",
"led": "led1"
}
}
and finally the gen~ patch