Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Audio.h>
- #include <Wire.h>
- #include <SPI.h>
- #include <SD.h>
- #include <SerialFlash.h>
- #include <Bounce.h>
- #include <ResponsiveAnalogRead.h>
- #include <CD74HC4067.h>
- CD74HC4067 my_mux(0, 1, 2, 3); // create a new CD74HC4067 object with its four control pins
- const int g_common_pin = A1; // select a pin to share with the 16 channels of the CD74HC4067
- ResponsiveAnalogRead analog(g_common_pin, true);
- // GUItool: begin automatically generated code
- AudioSynthWaveform waveform1; //xy=110,164
- AudioSynthWaveformModulated waveformMod1; //xy=307,171
- AudioEffectWaveshaper waveshape1; //xy=485,209
- AudioEffectFade fade1; //xy=594,281
- AudioMixer4 mixer3; //xy=743,257
- AudioEffectDelay delay1; //xy=753,408
- AudioMixer4 mixer2; //xy=921,200
- AudioOutputI2S i2s1; //xy=1116,197
- AudioConnection patchCord1(waveform1, 0, waveformMod1, 0);
- AudioConnection patchCord2(waveformMod1, 0, mixer2, 0);
- AudioConnection patchCord3(waveformMod1, 0, mixer3, 0);
- //AudioConnection patchCord4(waveshape1, fade1);
- //AudioConnection patchCord5(fade1, 0, mixer3, 0);
- AudioConnection patchCord6(mixer3, delay1);
- AudioConnection patchCord7(delay1, 0, mixer2, 1);
- AudioConnection patchCord8(delay1, 0, mixer3, 1);
- AudioConnection patchCord9(mixer2, 0, i2s1, 0);
- AudioConnection patchCord10(mixer2, 0, i2s1, 1);
- AudioControlSGTL5000 sgtl5000_1; //xy=289,433
- // GUItool: end automatically generated code
- int aread[10];
- int areadNew[10];
- int cycles[10];
- int mincycles = 2;
- int average[10][4];
- int window = 2;
- void setup()
- {
- Serial.begin(9600);
- pinMode(g_common_pin, INPUT);
- pinMode(4, INPUT_PULLUP);
- pinMode(5, INPUT_PULLUP);
- pinMode(6, INPUT_PULLUP);
- pinMode(9, INPUT_PULLUP);
- delay(300);
- Serial.println("horst hrubsesch");
- // Audio connections require memory to work. For more
- // detailed information, see the MemoryAndCpuUsage example
- AudioMemory(200);
- // Comment these out if not using the audio adaptor board.
- sgtl5000_1.enable();
- sgtl5000_1.volume(0.5); // caution: very loud - use oscilloscope only!
- sgtl5000_1.lineOutLevel(23);
- waveformMod1.amplitude(1.0);
- waveformMod1.frequency(400);
- waveformMod1.frequencyModulation(4);
- waveform1.amplitude(0.0);
- waveform1.frequency(1);
- waveformMod1.begin(1);
- waveform1.begin(WAVEFORM_SINE);
- mixer2.gain(0, 1);
- delay1.delay(0, 330);
- mixer3.gain(0, 1);
- mixer3.gain(1, 0.5); //feedback
- mixer2.gain(1, 1); // wet mix
- Serial.println("setup");
- }
- void readpots()
- {
- for (int i = 0; i < 10; i++) {
- my_mux.channel(i);
- analogRead(g_common_pin);
- delayMicroseconds(1500);
- areadNew[i] = analogRead(g_common_pin);
- if (areadNew[i] != aread[i]) {
- //average[i][cycles[i]] = areadNew[i];
- cycles[i]++;
- }
- else cycles[i] = 0;
- if (cycles[i] >= mincycles) {
- cycles[i] = 0;
- //areadNew[i] = (average[i][0] + average[i][1] + average[i][2] + average[i][3]) >> 2;
- if ((areadNew[i] < aread[i] - window) || (areadNew[i] > aread[i] + window)) {
- aread[i] = (aread[i] + areadNew[i]) >> 1;
- if (aread[i] < 3) {
- aread[i] = 0;
- }
- if (aread[i] > 1020) {
- aread[i] = 1023;
- }
- }
- }
- Serial.print(aread[i]);
- Serial.print(" - ");
- }
- Serial.println();
- }
- void loop()
- {
- readpots();
- if (!digitalRead(4)) {
- Serial.println("fire");
- mixer2.gain(0, 1);
- mixer3.gain(0, 1);
- }
- else {
- Serial.println("no");
- mixer2.gain(0, 0);
- mixer3.gain(0, 0);
- }
- waveform1.amplitude((float)aread[8] / 1023);
- waveform1.frequency((float)aread[9] / 50);
- mixer2.gain(1, (float)aread[4] / 1023); //delay wet
- mixer3.gain(1, (float)aread[5] / 512); //delay feedback
- delay1.delay(0, (aread[6] >> 2) + 50); //delay time
- waveformMod1.amplitude((float) aread[2] / 1023); //main vol
- waveformMod1.frequency((aread[0] << 2) + 40); // vco freq
- //Serial.println("x");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement