mirror of
https://github.com/le-studio-5/MachineInfernale.git
synced 2025-04-02 15:59:38 +02:00
Last codes
salut PM, les derniers codes en vrac, tu peux les renomer avec le bon numéro de module... j'ai plus en tête :)
This commit is contained in:
parent
eff8841ed8
commit
0c914a4436
|
@ -19,16 +19,26 @@ int16_t granularMemory[GRANULAR_MEMORY_SIZE];
|
|||
USBHost usbHost1;
|
||||
USBHIDParser usbHid1( usbHost1 );
|
||||
JoystickController stick( usbHost1 );
|
||||
#include <FastLED.h>
|
||||
CRGB leds[3];
|
||||
bool freeze = 0;
|
||||
bool bouton[13];
|
||||
bool buttonFlag[3] = {0};
|
||||
|
||||
void setup( ) {
|
||||
Serial.begin(9600);
|
||||
AudioMemory(30);
|
||||
usbHost1.begin();
|
||||
bitcrusher1.bits(16); /////////////////
|
||||
bitcrusher1.sampleRate(44100);
|
||||
granular1.begin(granularMemory, GRANULAR_MEMORY_SIZE);
|
||||
//granular1.beginPitchShift(25);
|
||||
FastLED.addLeds<WS2812B, 0, GRB>(leds, 3);
|
||||
// for (int i = 0; 1 < 3; i++) {
|
||||
// leds[i].r = 255;
|
||||
// leds[i].g = 0;
|
||||
// }
|
||||
// FastLED.show();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -38,8 +48,10 @@ void loop() {
|
|||
int Zjoy = stick.getAxis( 5 );
|
||||
int Cross = stick.getAxis( 9 );
|
||||
uint32_t buttons = stick.getButtons();
|
||||
Serial.println("top");
|
||||
for (int i = 1; i < 13; i++) { ///////////////////à tester...
|
||||
bouton[i] = (buttons >> (i - 1)) & 1;
|
||||
Serial.println( bouton[i]);
|
||||
}
|
||||
if (bouton[2]) bitcrusher1.bits(1);
|
||||
else if (bouton[3]) bitcrusher1.bits(2);
|
||||
|
@ -50,8 +62,7 @@ void loop() {
|
|||
///////// fin à tester
|
||||
long SR = sq(1023 - Yjoy) / 40;
|
||||
//Serial.print( buttons, BIN);
|
||||
Serial.print( Zjoy);
|
||||
Serial.println();
|
||||
|
||||
bitcrusher1.sampleRate(SR);
|
||||
if (bouton[1] == 1 && freeze == 0) {
|
||||
freeze = 1;
|
||||
|
@ -62,26 +73,62 @@ void loop() {
|
|||
freeze = 0;
|
||||
granular1.stop();
|
||||
}
|
||||
if (bouton[12]==1 ) {
|
||||
|
||||
if (bouton[7] == 1 && buttonFlag[0] == 0) { //Boutton 7 effet 1 ON
|
||||
buttonFlag[0] = 1;
|
||||
leds[0].r = 0;
|
||||
leds[0].g = 200;
|
||||
FastLED.show();
|
||||
|
||||
}
|
||||
if (bouton[8] == 1 && buttonFlag[0] == 1) { //Boutton 8 effet 1 OFF
|
||||
buttonFlag[0] = 0;
|
||||
leds[0].r = 255;
|
||||
leds[0].g = 0;
|
||||
FastLED.show();
|
||||
}
|
||||
if (bouton[9] == 1 && buttonFlag[1] == 0) { //Boutton 9 effet 2 ON
|
||||
buttonFlag[1] = 1;
|
||||
leds[1].r = 0;
|
||||
leds[1].g = 200;
|
||||
FastLED.show();
|
||||
|
||||
}
|
||||
if (bouton[10] == 1 && buttonFlag[1] == 1) { //Boutton 10 effet 2 OFF
|
||||
buttonFlag[1] = 0;
|
||||
leds[1].r = 255;
|
||||
leds[1].g = 0;
|
||||
FastLED.show();
|
||||
}
|
||||
if (bouton[11] == 1 && buttonFlag[2] == 0) { //Boutton 11 effet 3 ON
|
||||
buttonFlag[2] = 1;
|
||||
leds[2].r = 0;
|
||||
leds[2].g = 200;
|
||||
FastLED.show();
|
||||
granular1.beginPitchShift(10);
|
||||
}
|
||||
//
|
||||
if(freeze==1){
|
||||
float ratio;
|
||||
if (Zjoy >= 0 && Zjoy < 32) ratio = 0.25;
|
||||
if (Zjoy >= 32 && Zjoy < 96) ratio = 0.5;
|
||||
if (Zjoy >= 96 && Zjoy < 160) ratio = 1.0;
|
||||
if (Zjoy >= 160 && Zjoy < 224) ratio = 2.0;
|
||||
if (Zjoy >= 224 && Zjoy < 256) ratio = 4.0;
|
||||
//ratio = powf(2.0, (Zjoy)/255.0 * 2.0 - 1.0); // 0.5 to 2.0
|
||||
//ratio = powf(2.0, knobA2 * 6.0 - 3.0); // 0.125 to 8.0 -- uncomment for far too much range!
|
||||
granular1.setSpeed(ratio);
|
||||
if (bouton[12] == 1 && buttonFlag[2] == 1) { //Boutton 12 effet 3 OFF
|
||||
buttonFlag[2] = 0;
|
||||
leds[2].r = 255;
|
||||
leds[2].g = 0;
|
||||
FastLED.show();
|
||||
granular1.stop();
|
||||
}
|
||||
//
|
||||
if (freeze == 1) {
|
||||
float ratio;
|
||||
if (Zjoy >= 0 && Zjoy < 32) ratio = 0.25;
|
||||
if (Zjoy >= 32 && Zjoy < 96) ratio = 0.5;
|
||||
if (Zjoy >= 96 && Zjoy < 160) ratio = 1.0;
|
||||
if (Zjoy >= 160 && Zjoy < 224) ratio = 2.0;
|
||||
if (Zjoy >= 224 && Zjoy < 256) ratio = 4.0;
|
||||
//ratio = powf(2.0, (Zjoy)/255.0 * 2.0 - 1.0); // 0.5 to 2.0
|
||||
//ratio = powf(2.0, knobA2 * 6.0 - 3.0); // 0.125 to 8.0 -- uncomment for far too much range!
|
||||
granular1.setSpeed(ratio);
|
||||
}
|
||||
else {
|
||||
float pitch = Xjoy / 1024.0;
|
||||
pitch = map(pitch, 0.0, 1.0, 0.75, 1.25);
|
||||
granular1.setSpeed(pitch);
|
||||
}
|
||||
else{
|
||||
float pitch = Xjoy/1024.0;
|
||||
pitch=map(pitch, 0.0, 1.0, 0.75, 1.25);
|
||||
granular1.setSpeed(pitch);
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
#include <Audio.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
#include <SerialFlash.h>
|
||||
|
||||
// GUItool: begin automatically generated code
|
||||
AudioPlaySdRaw playSdRaw0; //xy=69,20
|
||||
AudioPlaySdRaw playSdRaw1; //xy=69,78
|
||||
AudioPlaySdRaw playSdRaw2; //xy=69,150
|
||||
AudioPlaySdRaw playSdRaw3; //xy=69,218
|
||||
AudioPlaySdRaw playSdRaw4; //xy=69,287
|
||||
AudioPlaySdRaw playSdRaw5; //xy=69,356
|
||||
AudioPlaySdRaw playSdRaw6; //xy=69,424
|
||||
AudioFilterStateVariable filter0; //xy=237,27.5
|
||||
AudioFilterStateVariable filter2; //xy=243,154
|
||||
AudioFilterStateVariable filter6; //xy=242,426
|
||||
AudioFilterStateVariable filter4; //xy=243,289
|
||||
AudioFilterStateVariable filter1; //xy=244,87
|
||||
AudioFilterStateVariable filter3; //xy=245,218
|
||||
AudioFilterStateVariable filter5; //xy=245,359
|
||||
AudioMixer4 mixer1; //xy=399,103
|
||||
AudioMixer4 mixer2; //xy=480,201
|
||||
AudioEffectGranular granular; //xy=614,202
|
||||
AudioEffectBitcrusher bitcrusher; //xy=748,200
|
||||
AudioOutputAnalogStereo dacs; //xy=885,198
|
||||
AudioConnection patchCord1(playSdRaw0, 0, filter0, 0);
|
||||
AudioConnection patchCord2(playSdRaw1, 0, filter1, 0);
|
||||
AudioConnection patchCord3(playSdRaw2, 0, filter2, 0);
|
||||
AudioConnection patchCord4(playSdRaw3, 0, filter3, 0);
|
||||
AudioConnection patchCord5(playSdRaw4, 0, filter4, 0);
|
||||
AudioConnection patchCord6(playSdRaw5, 0, filter5, 0);
|
||||
AudioConnection patchCord7(playSdRaw6, 0, filter6, 0);
|
||||
AudioConnection patchCord8(filter0, 0, mixer1, 0);
|
||||
AudioConnection patchCord9(filter2, 0, mixer1, 2);
|
||||
AudioConnection patchCord10(filter6, 0, mixer2, 2);
|
||||
AudioConnection patchCord11(filter4, 0, mixer2, 0);
|
||||
AudioConnection patchCord12(filter1, 0, mixer1, 1);
|
||||
AudioConnection patchCord13(filter3, 0, mixer1, 3);
|
||||
AudioConnection patchCord14(filter5, 0, mixer2, 1);
|
||||
AudioConnection patchCord15(mixer1, 0, mixer2, 3);
|
||||
AudioConnection patchCord16(mixer2, granular);
|
||||
AudioConnection patchCord17(granular, bitcrusher);
|
||||
AudioConnection patchCord18(bitcrusher, 0, dacs, 0);
|
||||
AudioConnection patchCord19(bitcrusher, 0, dacs, 1);
|
||||
// GUItool: end automatically generated code
|
||||
AudioPlaySdRaw *sdRaw[7] = {
|
||||
&playSdRaw0, &playSdRaw1, &playSdRaw2, &playSdRaw3, &playSdRaw4, &playSdRaw5, &playSdRaw6
|
||||
};
|
||||
AudioFilterStateVariable *filter[7] = {
|
||||
&filter0, &filter1, &filter2, &filter3, &filter4, &filter5, &filter6
|
||||
};
|
||||
// Use these with the Teensy 3.5 & 3.6 SD card
|
||||
#define SDCARD_CS_PIN BUILTIN_SDCARD
|
||||
#define SDCARD_MOSI_PIN 11 // not actually used
|
||||
#define SDCARD_SCK_PIN 13 // not actually used
|
||||
//uint8_t pinBouton[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
#define GRANULAR_MEMORY_SIZE 12800 // enough for 290 ms at 44.1 kHz
|
||||
float ratio;
|
||||
int16_t granularMemory[GRANULAR_MEMORY_SIZE];
|
||||
float level = 0.25;
|
||||
//float sawFreq[7] = {110, 178, 288, 466, 754, 1220, 1973.62};
|
||||
byte pinTouch[11] = {15, 16, 17, 18, 19, 22, 23, 0, 1, 29, 30};
|
||||
int touchAver[7] = {0};
|
||||
float touch[7];
|
||||
float smooth = 0.5;
|
||||
float res = 1.8;
|
||||
char sample[7][7] = { "s0.raw", "s1.raw", "s2.raw", "s3.raw", "s4.raw", "s5.raw", "s6.raw",};// 10 is the length of the longest string + 1 ( for the '\0' at the end )
|
||||
|
||||
//#define DEBUG 1
|
||||
|
||||
void setup() {
|
||||
#ifdef DEBUG
|
||||
delay(500);
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
;
|
||||
}
|
||||
#endif
|
||||
AudioMemory(60);
|
||||
pinMode(13, OUTPUT);
|
||||
|
||||
SPI.setMOSI(SDCARD_MOSI_PIN);
|
||||
SPI.setSCK(SDCARD_SCK_PIN);
|
||||
while (!(SD.begin(SDCARD_CS_PIN))) {
|
||||
digitalWrite(13, LOW);
|
||||
delay (100);
|
||||
digitalWrite(13, HIGH);
|
||||
delay (100);
|
||||
}
|
||||
digitalWrite(13, HIGH);
|
||||
delay(100);
|
||||
mixer1.gain(0, level);
|
||||
mixer1.gain(1, level);
|
||||
mixer1.gain(2, level);
|
||||
mixer1.gain(3, level);
|
||||
mixer2.gain(0, level);
|
||||
mixer2.gain(1, level);
|
||||
mixer2.gain(2, level);
|
||||
mixer2.gain(3, 1.0);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
filter[i]->resonance(res);
|
||||
filter[i]->frequency(500);
|
||||
}
|
||||
granular.begin(granularMemory, GRANULAR_MEMORY_SIZE);
|
||||
bitcrusher.bits(16);
|
||||
bitcrusher.sampleRate(44000);
|
||||
//granular.beginPitchShift(20);
|
||||
for (int h = 0; h < 100; h++) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
touchAver[i] = touchAver[i] + touchRead(pinTouch[i]);
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 7; i++) {
|
||||
touchAver[i] = touchAver[i] / 100;
|
||||
}
|
||||
|
||||
}
|
||||
void loop() {
|
||||
|
||||
// ++ deux potentiomètres => bitcrusher / stutter /
|
||||
// float knobA8 = (float)analogRead(A8) / 1023.0;
|
||||
// float knobA9 = (float)analogRead(A9) / 1023.0;
|
||||
//bitcrusher.bits(12);
|
||||
// int bitres = 2 + sq((float)analogRead(A8)) / 100000.0;
|
||||
// bitcrusher.bits(bitres);
|
||||
// bitcrusher.sampleRate(50 + sq((float)analogRead(A8)) / 24.0);
|
||||
// int knobA9 = analogRead(A9);
|
||||
// if (knobA9 <= 512) {
|
||||
// ratio = map((float)knobA9, 0, 512, 0.25, 1.0);
|
||||
// }
|
||||
// if (knobA9 > 512) {
|
||||
// ratio = map((float)knobA9, 512, 1023, 1.0, 4.0);
|
||||
// }
|
||||
// if (ratio < 1.05 && ratio > 0.95) granular.stop();
|
||||
// else {
|
||||
// granular.beginPitchShift(20); granular.setSpeed(ratio);
|
||||
// }
|
||||
for (int i = 0; i < 7; i++) {
|
||||
touch[i] = smooth * touch[i] + (1.0 - smooth) * (touchRead(pinTouch[i]) - touchAver[i]);
|
||||
float freqCut = (sq(touch[i]) - 10000) / 100;
|
||||
freqCut = constrain(freqCut, 0, 20000);
|
||||
filter[i]->frequency(freqCut);
|
||||
#ifdef DEBUG
|
||||
Serial.println(touch[i]);//Serial.print( buttons, BIN);//Serial.println(analogRead(A8));// Serial.println(cutoff);
|
||||
#endif
|
||||
if ( sdRaw[i]->isPlaying() == 0 && touch[i] > 100) {
|
||||
sdRaw[i]->play(sample[i]);
|
||||
}
|
||||
else if (touch[i] < 90) {
|
||||
sdRaw[i]->stop();
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
|
||||
}
|
189
ArduinoTeensyCodes/t36Synth13Keys3Pots/t36Synth13Keys3Pots.ino
Normal file
189
ArduinoTeensyCodes/t36Synth13Keys3Pots/t36Synth13Keys3Pots.ino
Normal file
|
@ -0,0 +1,189 @@
|
|||
#include <Audio.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
#include <SerialFlash.h>
|
||||
|
||||
// GUItool: begin automatically generated code
|
||||
AudioSynthNoisePink pink11; //xy=57,707
|
||||
AudioSynthNoisePink pink1; //xy=63,66
|
||||
AudioSynthNoisePink pink3; //xy=63,220
|
||||
AudioSynthNoisePink pink10; //xy=62,655
|
||||
AudioSynthNoisePink pink13; //xy=62,799
|
||||
AudioSynthNoisePink pink2; //xy=65,147
|
||||
AudioSynthNoisePink pink6; //xy=65,398
|
||||
AudioSynthNoisePink pink12; //xy=64,757
|
||||
AudioSynthNoisePink pink8; //xy=66,544
|
||||
AudioSynthNoisePink pink5; //xy=67,343
|
||||
AudioSynthNoisePink pink9; //xy=66,604
|
||||
AudioSynthNoisePink pink7; //xy=67,471
|
||||
AudioSynthNoisePink pink4; //xy=68,286
|
||||
AudioSynthWaveformModulated waveformMod6; //xy=221,405
|
||||
AudioSynthWaveformModulated waveformMod7; //xy=223,478
|
||||
AudioSynthWaveformModulated waveformMod5; //xy=227,350
|
||||
AudioSynthWaveformModulated waveformMod1; //xy=230,70
|
||||
AudioSynthWaveformModulated waveformMod2; //xy=230,148
|
||||
AudioSynthWaveformModulated waveformMod3; //xy=233,224
|
||||
AudioSynthWaveformModulated waveformMod4; //xy=233,293
|
||||
AudioSynthWaveformModulated waveformMod8; //xy=236,546
|
||||
AudioSynthWaveformModulated waveformMod9; //xy=238,607
|
||||
AudioSynthWaveformModulated waveformMod13; //xy=242,810
|
||||
AudioSynthWaveformModulated waveformMod12; //xy=243,763
|
||||
AudioSynthWaveformModulated waveformMod10; //xy=247,658
|
||||
AudioSynthWaveformModulated waveformMod11; //xy=247,709
|
||||
AudioEffectEnvelope envelope2; //xy=401,144
|
||||
AudioEffectEnvelope envelope4; //xy=403,293
|
||||
AudioEffectEnvelope envelope7; //xy=405,485
|
||||
AudioEffectEnvelope envelope1; //xy=409,83
|
||||
AudioEffectEnvelope envelope3; //xy=410,214
|
||||
AudioEffectEnvelope envelope6; //xy=412,406
|
||||
AudioEffectEnvelope envelope8; //xy=413,548
|
||||
AudioEffectEnvelope envelope9; //xy=413,602
|
||||
AudioEffectEnvelope envelope5; //xy=423,352
|
||||
AudioEffectEnvelope envelope12; //xy=423,761
|
||||
AudioEffectEnvelope envelope10; //xy=426,650
|
||||
AudioEffectEnvelope envelope13; //xy=427,806
|
||||
AudioEffectEnvelope envelope11; //xy=428,705
|
||||
AudioMixer4 mixer1; //xy=568,184
|
||||
AudioMixer4 mixer2; //xy=606,424
|
||||
AudioMixer4 mixer3; //xy=620,662
|
||||
AudioSynthWaveformSine sine1; //xy=771,402
|
||||
AudioMixer4 mixer4; //xy=784,317
|
||||
AudioFilterStateVariable filter1; //xy=919,404
|
||||
AudioOutputAnalogStereo dacs; //xy=942,305
|
||||
AudioConnection patchCord1(pink11, 0, waveformMod11, 0);
|
||||
AudioConnection patchCord2(pink1, 0, waveformMod1, 0);
|
||||
AudioConnection patchCord3(pink3, 0, waveformMod3, 0);
|
||||
AudioConnection patchCord4(pink10, 0, waveformMod10, 0);
|
||||
AudioConnection patchCord5(pink13, 0, waveformMod13, 0);
|
||||
AudioConnection patchCord6(pink2, 0, waveformMod2, 0);
|
||||
AudioConnection patchCord7(pink6, 0, waveformMod6, 0);
|
||||
AudioConnection patchCord8(pink12, 0, waveformMod12, 0);
|
||||
AudioConnection patchCord9(pink8, 0, waveformMod8, 0);
|
||||
AudioConnection patchCord10(pink5, 0, waveformMod5, 0);
|
||||
AudioConnection patchCord11(pink9, 0, waveformMod9, 0);
|
||||
AudioConnection patchCord12(pink7, 0, waveformMod7, 0);
|
||||
AudioConnection patchCord13(pink4, 0, waveformMod4, 0);
|
||||
AudioConnection patchCord14(waveformMod6, envelope6);
|
||||
AudioConnection patchCord15(waveformMod7, envelope7);
|
||||
AudioConnection patchCord16(waveformMod5, envelope5);
|
||||
AudioConnection patchCord17(waveformMod1, envelope1);
|
||||
AudioConnection patchCord18(waveformMod2, envelope2);
|
||||
AudioConnection patchCord19(waveformMod3, envelope3);
|
||||
AudioConnection patchCord20(waveformMod4, envelope4);
|
||||
AudioConnection patchCord21(waveformMod8, envelope8);
|
||||
AudioConnection patchCord22(waveformMod9, envelope9);
|
||||
AudioConnection patchCord23(waveformMod13, envelope13);
|
||||
AudioConnection patchCord24(waveformMod12, envelope12);
|
||||
AudioConnection patchCord25(waveformMod10, envelope10);
|
||||
AudioConnection patchCord26(waveformMod11, envelope11);
|
||||
AudioConnection patchCord27(envelope2, 0, mixer1, 1);
|
||||
AudioConnection patchCord28(envelope4, 0, mixer1, 3);
|
||||
AudioConnection patchCord29(envelope7, 0, mixer2, 2);
|
||||
AudioConnection patchCord30(envelope1, 0, mixer1, 0);
|
||||
AudioConnection patchCord31(envelope3, 0, mixer1, 2);
|
||||
AudioConnection patchCord32(envelope6, 0, mixer2, 1);
|
||||
AudioConnection patchCord33(envelope8, 0, mixer2, 3);
|
||||
AudioConnection patchCord34(envelope9, 0, mixer3, 0);
|
||||
AudioConnection patchCord35(envelope5, 0, mixer2, 0);
|
||||
AudioConnection patchCord36(envelope12, 0, mixer3, 3);
|
||||
AudioConnection patchCord37(envelope10, 0, mixer3, 1);
|
||||
AudioConnection patchCord38(envelope13, 0, mixer4, 3);
|
||||
AudioConnection patchCord39(envelope11, 0, mixer3, 2);
|
||||
AudioConnection patchCord40(mixer1, 0, mixer4, 0);
|
||||
AudioConnection patchCord41(mixer2, 0, mixer4, 1);
|
||||
AudioConnection patchCord42(mixer3, 0, mixer4, 2);
|
||||
AudioConnection patchCord43(sine1, 0, filter1, 1);
|
||||
AudioConnection patchCord44(mixer4, 0, filter1, 0);
|
||||
AudioConnection patchCord45(filter1, 0, dacs, 0);
|
||||
AudioConnection patchCord46(filter1, 0, dacs, 1);
|
||||
// GUItool: end automatically generated code
|
||||
AudioSynthNoisePink *pink[13] = {
|
||||
&pink1, &pink2, &pink3, &pink4, &pink5, &pink6, &pink7, &pink8, &pink9, &pink10, &pink11, &pink12, &pink13
|
||||
};
|
||||
AudioSynthWaveformModulated *osc[13] = {
|
||||
&waveformMod1, &waveformMod2, &waveformMod3, &waveformMod4, &waveformMod5, &waveformMod6, &waveformMod7, &waveformMod8, &waveformMod9, &waveformMod10, &waveformMod11, &waveformMod12, &waveformMod13
|
||||
};
|
||||
AudioEffectEnvelope *env[13] = {
|
||||
&envelope1, &envelope2, &envelope3, &envelope4, &envelope5, &envelope6, &envelope7, &envelope8, &envelope9, &envelope10, &envelope11, &envelope12, &envelope13
|
||||
};
|
||||
|
||||
#include <Bounce.h>
|
||||
int debT = 5;
|
||||
Bounce b0 = Bounce(0, debT); Bounce b1 = Bounce(1, debT); Bounce b2 = Bounce(2, debT); Bounce b3 = Bounce(3, debT); Bounce b4 = Bounce(4, debT); Bounce b5 = Bounce(5, debT);
|
||||
Bounce b6 = Bounce(6, debT); Bounce b7 = Bounce(7, debT); Bounce b8 = Bounce(8, debT); Bounce b9 = Bounce(9, debT); Bounce b10 = Bounce(10, debT); Bounce b11 = Bounce(11, debT); Bounce b12 = Bounce(12, debT);
|
||||
Bounce *b[13] = {
|
||||
&b0, &b1, &b2, &b3, &b4, &b5, &b6, &b7, &b8, &b9, &b10, &b11, &b12
|
||||
};
|
||||
|
||||
float sawFreq[13] = {261.6256, 277.1826, 293.6648, 311.1270, 329.6276, 349.2282 , 369.9944, 391.9954, 415.3047, 440.0000, 466.1638, 493.8833, 523.2511};
|
||||
//byte pinKey[13] = {18, 23, 17, 22, 16, 19, 15};
|
||||
float pinkLevel = 0.01;
|
||||
float sawLevel = 0.25;
|
||||
float smooth = 0.5;
|
||||
float freqCut = 200;
|
||||
float res = 2.8;
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
|
||||
void setup() {
|
||||
#ifdef DEBUG
|
||||
delay(500);
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
;
|
||||
}
|
||||
#endif
|
||||
analogReadRes(12);
|
||||
for (int i = 0; i < 13; i++) {
|
||||
pinMode(i, INPUT_PULLUP);
|
||||
}
|
||||
AudioMemory(30);
|
||||
pink1.amplitude(pinkLevel); pink2.amplitude(pinkLevel); pink3.amplitude(pinkLevel); pink4.amplitude(pinkLevel); pink5.amplitude(pinkLevel); pink6.amplitude(pinkLevel); pink7.amplitude(pinkLevel);
|
||||
//waveformMod1. waveformMod2.begin(WAVEFORM_SAWTOOTH); waveformMod3.begin(WAVEFORM_SAWTOOTH); waveformMod4.begin(WAVEFORM_SAWTOOTH); waveformMod5.begin(WAVEFORM_SAWTOOTH); waveformMod6.begin(WAVEFORM_SAWTOOTH); waveformMod7.begin(WAVEFORM_SAWTOOTH);
|
||||
// waveformMod1.amplitude(sawLevel); waveformMod2.amplitude(sawLevel); waveformMod3.amplitude(sawLevel); waveformMod4.amplitude(sawLevel); waveformMod5.amplitude(sawLevel); waveformMod6.amplitude(sawLevel); waveformMod7.amplitude(sawLevel);
|
||||
//waveformMod1.frequency(sawFreq[0]); waveformMod2.frequency(sawFreq[1]); waveformMod3.frequency(sawFreq[2]); waveformMod4.frequency(sawFreq[3]); waveformMod5.frequency(sawFreq[4]); waveformMod6.frequency(sawFreq[5]); waveformMod7.frequency(sawFreq[6]);
|
||||
//waveformMod8.frequency(sawFreq[7]); waveformMod9.frequency(sawFreq[8]); waveformMod10.frequency(sawFreq[9]); waveformMod11.frequency(sawFreq[10]); waveformMod12.frequency(sawFreq[11]); waveformMod13.frequency(sawFreq[12]);
|
||||
|
||||
for (int i = 0; i < 13; i++) {
|
||||
osc[i]->begin(WAVEFORM_SAWTOOTH);
|
||||
osc[i]->amplitude(sawLevel);
|
||||
osc[i]->frequency(sawFreq[i]);
|
||||
env[i]->attack(119.2);
|
||||
env[i]->hold(2.1);
|
||||
env[i]->decay(31.4);
|
||||
env[i]->sustain(0.6);
|
||||
env[i]->release(384.5);
|
||||
|
||||
}
|
||||
filter1.resonance(res);
|
||||
filter1.frequency(freqCut);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
#ifdef DEBUG
|
||||
|
||||
Serial.println();
|
||||
#endif
|
||||
freqCut = sq(analogRead(A5)) / 4096.0;
|
||||
filter1.frequency(freqCut);
|
||||
float pinkLvl = sq(analogRead(A7) / 4096.0);
|
||||
float sineLvl = constrain(50*sq(analogRead(A6) / 4096.0),0.0 ,1.0);
|
||||
sine1.amplitude(sineLvl);
|
||||
float sineFreq = sq(analogRead(A6) / 4096.0)*100.0;
|
||||
sine1.frequency(sineFreq);
|
||||
for (int i = 0; i < 13; i++) {
|
||||
b[i]->update();
|
||||
if (b[i]->fallingEdge()) {
|
||||
env[i]->noteOn();
|
||||
}
|
||||
if (b[i]->risingEdge()) {
|
||||
env[i]->noteOff();
|
||||
}
|
||||
pink[i]->amplitude(pinkLvl);
|
||||
}
|
||||
|
||||
|
||||
//delay(20);
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
#include <Audio.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
#include <SerialFlash.h>
|
||||
|
||||
// GUItool: begin automatically generated code
|
||||
AudioSynthNoisePink pink1; //xy=63,66
|
||||
AudioSynthNoisePink pink3; //xy=63,220
|
||||
AudioSynthNoisePink pink2; //xy=65,147
|
||||
AudioSynthNoisePink pink6; //xy=65,398
|
||||
AudioSynthNoisePink pink5; //xy=67,343
|
||||
AudioSynthNoisePink pink7; //xy=67,471
|
||||
AudioSynthNoisePink pink4; //xy=68,286
|
||||
AudioSynthWaveformModulated waveformMod6; //xy=221,405
|
||||
AudioSynthWaveformModulated waveformMod7; //xy=223,478
|
||||
AudioSynthWaveformModulated waveformMod5; //xy=227,350
|
||||
AudioSynthWaveformModulated waveformMod1; //xy=230,70
|
||||
AudioSynthWaveformModulated waveformMod2; //xy=230,148
|
||||
AudioSynthWaveformModulated waveformMod3; //xy=233,224
|
||||
AudioSynthWaveformModulated waveformMod4; //xy=233,293
|
||||
AudioFilterStateVariable filter3; //xy=377,230
|
||||
AudioFilterStateVariable filter2; //xy=382,153
|
||||
AudioFilterStateVariable filter1; //xy=385,77
|
||||
AudioFilterStateVariable filter4; //xy=411,291
|
||||
AudioFilterStateVariable filter7; //xy=417,482
|
||||
AudioFilterStateVariable filter6; //xy=420,410
|
||||
AudioFilterStateVariable filter5; //xy=422,351
|
||||
AudioMixer4 mixer1; //xy=538,127
|
||||
AudioMixer4 mixer2; //xy=636,219
|
||||
AudioEffectFreeverb freeverb; //xy=654,289
|
||||
AudioOutputAnalogStereo dacs; //xy=693,353
|
||||
AudioConnection patchCord1(pink1, 0, waveformMod1, 0);
|
||||
AudioConnection patchCord2(pink3, 0, waveformMod3, 0);
|
||||
AudioConnection patchCord3(pink2, 0, waveformMod2, 0);
|
||||
AudioConnection patchCord4(pink6, 0, waveformMod6, 0);
|
||||
AudioConnection patchCord5(pink5, 0, waveformMod5, 0);
|
||||
AudioConnection patchCord6(pink7, 0, waveformMod7, 0);
|
||||
AudioConnection patchCord7(pink4, 0, waveformMod4, 0);
|
||||
AudioConnection patchCord8(waveformMod6, 0, filter6, 0);
|
||||
AudioConnection patchCord9(waveformMod7, 0, filter7, 0);
|
||||
AudioConnection patchCord10(waveformMod5, 0, filter5, 0);
|
||||
AudioConnection patchCord11(waveformMod1, 0, filter1, 0);
|
||||
AudioConnection patchCord12(waveformMod2, 0, filter2, 0);
|
||||
AudioConnection patchCord13(waveformMod3, 0, filter3, 0);
|
||||
AudioConnection patchCord14(waveformMod4, 0, filter4, 0);
|
||||
AudioConnection patchCord15(filter3, 0, mixer1, 2);
|
||||
AudioConnection patchCord16(filter2, 0, mixer1, 1);
|
||||
AudioConnection patchCord17(filter1, 0, mixer1, 0);
|
||||
AudioConnection patchCord18(filter4, 0, mixer1, 3);
|
||||
AudioConnection patchCord19(filter7, 0, mixer2, 3);
|
||||
AudioConnection patchCord20(filter6, 0, mixer2, 2);
|
||||
AudioConnection patchCord21(filter5, 0, mixer2, 1);
|
||||
AudioConnection patchCord22(mixer1, 0, mixer2, 0);
|
||||
AudioConnection patchCord23(mixer2, freeverb);
|
||||
AudioConnection patchCord24(freeverb, 0, dacs, 0);
|
||||
AudioConnection patchCord25(freeverb, 0, dacs, 1);
|
||||
// GUItool: end automatically generated code
|
||||
float pinkLevel = 0.01;
|
||||
float sawLevel = 0.5;
|
||||
float sawFreq[7] = {110, 178, 288, 466, 754, 1220, 1973.62};
|
||||
byte pinTouch[7] = {18, 23, 17, 22, 16, 19, 15};
|
||||
int touchAver[7] = {0};
|
||||
float touch[7];
|
||||
float smooth = 0.5;
|
||||
float freqCut[7];
|
||||
float res = 1.8;
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
|
||||
void setup() {
|
||||
#ifdef DEBUG
|
||||
delay(500);
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
;
|
||||
}
|
||||
#endif
|
||||
AudioMemory(30);
|
||||
pink1.amplitude(pinkLevel); pink2.amplitude(pinkLevel); pink3.amplitude(pinkLevel); pink4.amplitude(pinkLevel); pink5.amplitude(pinkLevel); pink6.amplitude(pinkLevel); pink7.amplitude(pinkLevel);
|
||||
waveformMod1.begin(WAVEFORM_SAWTOOTH); waveformMod2.begin(WAVEFORM_SAWTOOTH); waveformMod3.begin(WAVEFORM_SAWTOOTH); waveformMod4.begin(WAVEFORM_SAWTOOTH); waveformMod5.begin(WAVEFORM_SAWTOOTH); waveformMod6.begin(WAVEFORM_SAWTOOTH); waveformMod7.begin(WAVEFORM_SAWTOOTH);
|
||||
waveformMod1.amplitude(sawLevel); waveformMod2.amplitude(sawLevel); waveformMod3.amplitude(sawLevel); waveformMod4.amplitude(sawLevel); waveformMod5.amplitude(sawLevel); waveformMod6.amplitude(sawLevel); waveformMod7.amplitude(sawLevel);
|
||||
waveformMod1.frequency(sawFreq[0]); waveformMod2.frequency(sawFreq[1]); waveformMod3.frequency(sawFreq[2]); waveformMod4.frequency(sawFreq[3]); waveformMod5.frequency(sawFreq[4]); waveformMod6.frequency(sawFreq[5]); waveformMod7.frequency(sawFreq[6]);
|
||||
filter1.resonance(res);filter2.resonance(res);filter3.resonance(res);filter4.resonance(res);filter5.resonance(res);filter6.resonance(res);filter7.resonance(res);
|
||||
//filter1.frequency(0);filter2.frequency(0);filter3.frequency(0);filter4.frequency(0);filter5.frequency(0);filter6.frequency(0);filter7.frequency(0);
|
||||
freeverb.roomsize(0.01);
|
||||
freeverb.damping(0.01);
|
||||
for (int h = 0; h < 100; h++) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
touchAver[i] = touchAver[i] + touchRead(pinTouch[i]);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 7; i++) {
|
||||
touchAver[i] = touchAver[i] / 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
#ifdef DEBUG
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Serial.print(touchRead(pinTouch[i]) - touchAver[i]);
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
#endif
|
||||
for (int i = 0; i < 7; i++) {
|
||||
touch[i] = smooth * touch[i] + (1.0 - smooth) * (touchRead(pinTouch[i]) - touchAver[i]);
|
||||
freqCut[i] = (sq(touch[i])-10000)/100;
|
||||
freqCut[i] = constrain(freqCut[i],0,20000);
|
||||
}
|
||||
filter1.frequency( freqCut[0]); filter2.frequency(freqCut[1]); filter3.frequency(freqCut[2]); filter4.frequency(freqCut[3]); filter5.frequency(freqCut[4]); filter6.frequency(freqCut[5]); filter7.frequency(freqCut[6]);
|
||||
delay(20);
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
#define bounceTime 20
|
||||
#include <FastLED.h>
|
||||
CRGB leds[8];
|
||||
#include <Audio.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
#include <SerialFlash.h>
|
||||
|
||||
// GUItool: begin automatically generated code
|
||||
AudioPlaySdRaw playSdRaw0; //xy=69,93
|
||||
AudioPlaySdRaw playSdRaw1; //xy=106,124
|
||||
AudioPlaySdRaw playSdRaw2; //xy=135,154
|
||||
AudioPlaySdRaw playSdRaw3; //xy=161,185
|
||||
AudioMixer4 mixer1; //xy=402,138
|
||||
AudioOutputAnalogStereo dacs; //xy=625,143
|
||||
AudioConnection patchCord1(playSdRaw0, 0, mixer1, 0);
|
||||
AudioConnection patchCord2(playSdRaw1, 0, mixer1, 1);
|
||||
AudioConnection patchCord3(playSdRaw2, 0, mixer1, 2);
|
||||
AudioConnection patchCord4(playSdRaw3, 0, mixer1, 3);
|
||||
AudioConnection patchCord5(mixer1, 0, dacs, 0);
|
||||
AudioConnection patchCord6(mixer1, 0, dacs, 1);
|
||||
// GUItool: end automatically generated code
|
||||
#define SDCARD_CS_PIN BUILTIN_SDCARD
|
||||
#define SDCARD_MOSI_PIN 11 // not actually used
|
||||
#define SDCARD_SCK_PIN 13 // not actually used
|
||||
uint8_t pinStep[8] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
uint8_t pinLine[4] = {8, 9, 10, 11};
|
||||
uint8_t Step = 0;
|
||||
unsigned long previousMillis;
|
||||
int tInt;
|
||||
|
||||
void setup() {
|
||||
FastLED.addLeds<WS2812B, 22, GRB>(leds, 8);
|
||||
AudioMemory(20);
|
||||
pinMode(13, OUTPUT);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
pinMode(pinStep[i], OUTPUT);
|
||||
digitalWrite(pinStep[i], HIGH);
|
||||
}
|
||||
digitalWrite(pinStep[0], LOW);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pinMode(pinLine[i], INPUT_PULLUP);
|
||||
|
||||
}
|
||||
SPI.setMOSI(SDCARD_MOSI_PIN);
|
||||
SPI.setSCK(SDCARD_SCK_PIN);
|
||||
while (!(SD.begin(SDCARD_CS_PIN))) {
|
||||
digitalWrite(13, LOW);
|
||||
delay (100);
|
||||
digitalWrite(13, HIGH);
|
||||
delay (100);
|
||||
}
|
||||
digitalWrite(13, HIGH);
|
||||
delay(100);
|
||||
mixer1.gain(0, 0.7);
|
||||
mixer1.gain(1, 0.7);
|
||||
mixer1.gain(2, 0.7);
|
||||
mixer1.gain(3, 0.7);
|
||||
}
|
||||
void loop() {
|
||||
tInt = map(analogRead(A9), 0, 1023, 64, 1000);
|
||||
if (millis() >= previousMillis + tInt*0.33) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
leds[i] = 0;
|
||||
}
|
||||
FastLED.show();
|
||||
}
|
||||
if (millis() >= previousMillis + tInt) {
|
||||
previousMillis = millis();
|
||||
if (!digitalRead(pinLine[0])) {
|
||||
playSdRaw0.play("s0.raw");
|
||||
}
|
||||
if (!digitalRead(pinLine[1])) {
|
||||
playSdRaw1.play("s1.raw");
|
||||
}
|
||||
if (!digitalRead(pinLine[2])) {
|
||||
playSdRaw2.play("s2.raw");
|
||||
}
|
||||
if (!digitalRead(pinLine[3]) ) {
|
||||
playSdRaw3.play("s3.raw");
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
pinMode(pinStep[i], OUTPUT);
|
||||
digitalWrite(pinStep[i], HIGH);
|
||||
leds[i] = 0;
|
||||
}
|
||||
leds[7-Step].r = 255;
|
||||
leds[7-Step].b = 128;
|
||||
FastLED.show();
|
||||
Step = (Step + 1) % 8;
|
||||
digitalWrite(pinStep[Step], LOW);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user