billgrahammusic
New member
I'm a beginner, working on a project converting an old set of organ pedals into a standalone bass synth. Between the audio design tool and looking around at other projects (I found Notes and Volts videos particularly helpful,) I've managed to crib together most of the code I need. I have just a couple of questions. I'm using the oscillator from the design tool. I'd like to know how to control the pitch from the switches built into the pedals wired into 13 digital pins, and also use 2 more switches on digital pins to change the states of mixer inputs off and on (0 and 1.) Here's the code I have so far, any help would be much appreciated.
Thanks very much!
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform sawtooth; //xy=62,41
AudioEffectEnvelope envelope3_(long release); //xy=162,154
AudioEffectEnvelope envelope1_(gate); //xy=165,84
AudioEffectEnvelope envelope2_(string bass); //xy=165,119
AudioMixer4 saw_envelope switcher; //xy=233,220
AudioFilterLadder ladder1; //xy=268,318
AudioMixer4 Osc_plus thump mixer; //xy=539,535
AudioSynthNoiseWhite noise_(thump); //xy=558,31
AudioFilterLadder ladder2; //xy=590,126
AudioEffectEnvelope envelope4; //xy=620,72
AudioOutputI2S i2s1; //xy=738,558
AudioConnection patchCord1(sawtooth, envelope1_(gate));
AudioConnection patchCord2(sawtooth, envelope2_(string bass));
AudioConnection patchCord3(sawtooth, envelope3_(long release));
AudioConnection patchCord4(envelope3_(long release), 0, saw_envelope switcher, 2);
AudioConnection patchCord5(envelope1_(gate), 0, saw_envelope switcher, 0);
AudioConnection patchCord6(envelope2_(string bass), 0, saw_envelope switcher, 1);
AudioConnection patchCord7(saw_envelope switcher, 0, ladder1, 0);
AudioConnection patchCord8(ladder1, 0, Osc_plus thump mixer, 1);
AudioConnection patchCord9(Osc_plus thump mixer, 0, i2s1, 0);
AudioConnection patchCord10(noise_(thump), envelope4);
AudioConnection patchCord11(ladder2, 0, Osc_plus thump mixer, 0);
AudioConnection patchCord12(envelope4, 0, ladder2, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=129,608
// GUItool: end automatically generated code
const float noteFreqs[128] = {8.176, 8.662, 9.177, 9.723, 10.301, 10.913, 11.562, 12.25, 12.978, 13.75, 14.568, 15.434, 16.352, 17.324, 18.354, 19.445, 20.602, 21.827, 23.125, 24.5, 25.957, 27.5, 29.135, 30.868, 32.703, 34.648, 36.708, 38.891, 41.203, 43.654, 46.249, 48.999, 51.913, 55, 58.27, 61.735, 65.406, 69.296, 73.416, 77.782, 82.407, 87.307, 92.499, 97.999, 103.826, 110, 116.541, 123.471, 130.813, 138.591, 146.832, 155.563, 164.814, 174.614, 184.997, 195.998, 207.652, 220, 233.082, 246.942, 261.626, 277.183, 293.665, 311.127, 329.628, 349.228, 369.994, 391.995, 415.305, 440, 466.164, 493.883, 523.251, 554.365, 587.33, 622.254, 659.255, 698.456, 739.989, 783.991, 830.609, 880, 932.328, 987.767, 1046.502, 1108.731, 1174.659, 1244.508, 1318.51, 1396.913, 1479.978, 1567.982, 1661.219, 1760, 1864.655, 1975.533, 2093.005, 2217.461, 2349.318, 2489.016, 2637.02, 2793.826, 2959.955, 3135.963, 3322.438, 3520, 3729.31, 3951.066, 4186.009, 4434.922, 4698.636, 4978.032, 5274.041, 5587.652, 5919.911, 6271.927, 6644.875, 7040, 7458.62, 7902.133, 8372.018, 8869.844, 9397.273, 9956.063, 10548.08, 11175.3, 11839.82, 12543.85};
void setup() {
// put your setup code here, to run once:
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(0.32);
waveform1.begin(WAVEFORM_SAWTOOTH);
waveform1.amplitude(0.75);
waveform1.frequency(32.70);
waveform1.pulseWidth(0.15);
envelope1.attack(0);
envelope1.decay(0);
envelope1.sustain(1);
envelope1.release(0);
envelope2.attack(0);
envelope2.decay(150);
envelope2.sustain(.25);
envelope2.release(500);
envelope3.attack(0);
envelope3.decay(0);
envelope3.sustain(1);
envelope3.release(800);
ladder1.frequency(600)
ladder1.resonance(0)
mixer4.gain(0, 1.0);
mixer4.gain(1, 0);
mixer4.gain(2, 0);
noise1.amplitude(0.75)
envelope4.attack(0);
envelope4.decay(100);
envelope4.sustain(.05);
envelope4.release(0);
ladder2.frequency(300)
ladder2.resonance(0)
mixer3.gain(0, 1.0);
mixer3.gain(1, 0.25);
}
void loop() {
// put your main code here, to run repeatedly:
}
Thanks very much!
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform sawtooth; //xy=62,41
AudioEffectEnvelope envelope3_(long release); //xy=162,154
AudioEffectEnvelope envelope1_(gate); //xy=165,84
AudioEffectEnvelope envelope2_(string bass); //xy=165,119
AudioMixer4 saw_envelope switcher; //xy=233,220
AudioFilterLadder ladder1; //xy=268,318
AudioMixer4 Osc_plus thump mixer; //xy=539,535
AudioSynthNoiseWhite noise_(thump); //xy=558,31
AudioFilterLadder ladder2; //xy=590,126
AudioEffectEnvelope envelope4; //xy=620,72
AudioOutputI2S i2s1; //xy=738,558
AudioConnection patchCord1(sawtooth, envelope1_(gate));
AudioConnection patchCord2(sawtooth, envelope2_(string bass));
AudioConnection patchCord3(sawtooth, envelope3_(long release));
AudioConnection patchCord4(envelope3_(long release), 0, saw_envelope switcher, 2);
AudioConnection patchCord5(envelope1_(gate), 0, saw_envelope switcher, 0);
AudioConnection patchCord6(envelope2_(string bass), 0, saw_envelope switcher, 1);
AudioConnection patchCord7(saw_envelope switcher, 0, ladder1, 0);
AudioConnection patchCord8(ladder1, 0, Osc_plus thump mixer, 1);
AudioConnection patchCord9(Osc_plus thump mixer, 0, i2s1, 0);
AudioConnection patchCord10(noise_(thump), envelope4);
AudioConnection patchCord11(ladder2, 0, Osc_plus thump mixer, 0);
AudioConnection patchCord12(envelope4, 0, ladder2, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=129,608
// GUItool: end automatically generated code
const float noteFreqs[128] = {8.176, 8.662, 9.177, 9.723, 10.301, 10.913, 11.562, 12.25, 12.978, 13.75, 14.568, 15.434, 16.352, 17.324, 18.354, 19.445, 20.602, 21.827, 23.125, 24.5, 25.957, 27.5, 29.135, 30.868, 32.703, 34.648, 36.708, 38.891, 41.203, 43.654, 46.249, 48.999, 51.913, 55, 58.27, 61.735, 65.406, 69.296, 73.416, 77.782, 82.407, 87.307, 92.499, 97.999, 103.826, 110, 116.541, 123.471, 130.813, 138.591, 146.832, 155.563, 164.814, 174.614, 184.997, 195.998, 207.652, 220, 233.082, 246.942, 261.626, 277.183, 293.665, 311.127, 329.628, 349.228, 369.994, 391.995, 415.305, 440, 466.164, 493.883, 523.251, 554.365, 587.33, 622.254, 659.255, 698.456, 739.989, 783.991, 830.609, 880, 932.328, 987.767, 1046.502, 1108.731, 1174.659, 1244.508, 1318.51, 1396.913, 1479.978, 1567.982, 1661.219, 1760, 1864.655, 1975.533, 2093.005, 2217.461, 2349.318, 2489.016, 2637.02, 2793.826, 2959.955, 3135.963, 3322.438, 3520, 3729.31, 3951.066, 4186.009, 4434.922, 4698.636, 4978.032, 5274.041, 5587.652, 5919.911, 6271.927, 6644.875, 7040, 7458.62, 7902.133, 8372.018, 8869.844, 9397.273, 9956.063, 10548.08, 11175.3, 11839.82, 12543.85};
void setup() {
// put your setup code here, to run once:
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(0.32);
waveform1.begin(WAVEFORM_SAWTOOTH);
waveform1.amplitude(0.75);
waveform1.frequency(32.70);
waveform1.pulseWidth(0.15);
envelope1.attack(0);
envelope1.decay(0);
envelope1.sustain(1);
envelope1.release(0);
envelope2.attack(0);
envelope2.decay(150);
envelope2.sustain(.25);
envelope2.release(500);
envelope3.attack(0);
envelope3.decay(0);
envelope3.sustain(1);
envelope3.release(800);
ladder1.frequency(600)
ladder1.resonance(0)
mixer4.gain(0, 1.0);
mixer4.gain(1, 0);
mixer4.gain(2, 0);
noise1.amplitude(0.75)
envelope4.attack(0);
envelope4.decay(100);
envelope4.sustain(.05);
envelope4.release(0);
ladder2.frequency(300)
ladder2.resonance(0)
mixer3.gain(0, 1.0);
mixer3.gain(1, 0.25);
}
void loop() {
// put your main code here, to run repeatedly:
}