Lightbluehue
Member
Hi all,
I'm using 2 x waveforms going into a mixer & trying to map/constrain each so that one acts as an LFO and one acts as an audible range oscillator.
Having a strange issue where knob2/4 are mapping/constraining correctly, but knob6/7 does not seem to read the potentiometer whatsoever and stays at the same rate, regardless of the pot value unless map/constrain is done after the following line:
Meaning that the mapping/constraining of the values is done after the frequency is set. So obviously does nothing.
In the commented code, you can see how I tried to do this initially.
I could not figure out how to do that way, by mapping/constraining waveform1.frequency, etc.
I do not have access to an oscilloscope until next week, but I was wondering what the maximum/minimum frequency of the waveform object is?
My guess was 20Hz-20kHz, hence 1.023 = 20Hz & 1023.0 = 20kHz...
Any clarification on this would be much appreciated.
I'm using 2 x waveforms going into a mixer & trying to map/constrain each so that one acts as an LFO and one acts as an audible range oscillator.
Having a strange issue where knob2/4 are mapping/constraining correctly, but knob6/7 does not seem to read the potentiometer whatsoever and stays at the same rate, regardless of the pot value unless map/constrain is done after the following line:
Code:
waveform3.frequency(360 * knob6 + 0.25);
Meaning that the mapping/constraining of the values is done after the frequency is set. So obviously does nothing.
In the commented code, you can see how I tried to do this initially.
I could not figure out how to do that way, by mapping/constraining waveform1.frequency, etc.
I do not have access to an oscilloscope until next week, but I was wondering what the maximum/minimum frequency of the waveform object is?
My guess was 20Hz-20kHz, hence 1.023 = 20Hz & 1023.0 = 20kHz...
Code:
// use the knobs to adjust parameters
//float knob1 = (float)analogRead(A1) / 1023.0;
float knob2 = (float)analogRead(A2) / 1023.0;
knob2 = map(knob2, 0.0, 1023.0, 0.0, 1.023);
knob2 = constrain(knob2, 0.0, 1.023);
waveform1.frequency(360 * knob2 + 0.25);
float knob3 = (float)analogRead(A3) / 1023.0;
sine_fm1.frequency(knob3 * 1500 + 50);
float knob6 = (float)analogRead(A18) / 1023.0;
waveform3.frequency(360 * knob6 + 0.25);
knob6 = map(knob6, 0.0, 1023.0, 1.023, 1023.0);
knob6 = constrain(knob6, 1.023, 1023.0);
//map(waveform1.frequency, 0.0, 20000.0, 0.0, 20.0);
//constrain(waveform1.frequency, 0.0, 20.0);
//map(waveform3.frequency, 0.0, 20000.0, 20.0, 20000.0);
//constrain(waveform3.frequency, 20.0, 20000.0);
float knob4 = (float)analogRead(A6) / 1023.0;
knob4 = map(knob4, 0.0, 1023.0, 0.0, 1.023);
knob4 = constrain(knob4, 0.0, 1.023);
waveform2.frequency(360 * knob4 + 0.25);
float knob5 = (float)analogRead(A7) / 1023.0;
sine_fm2.frequency(knob5 * 1500 + 50);
float knob7 = (float)analogRead(A20) / 1023.0;
waveform4.frequency(360 * knob7 + 0.25);
knob7 = map(knob7, 0.0, 1023.0, 1.023, 1023.0);
knob7 = constrain(knob7, 1.023, 1023.0);
//map(waveform1.frequency, 0.0, 20000.0, 0.0, 20.0);
//constrain(waveform1.frequency, 0.0, 20.0);
//map(waveform3.frequency, 0.0, 20000.0, 20.0, 20000.0);
//constrain(waveform3.frequency, 20.0, 20000.0);
Any clarification on this would be much appreciated.