Post by sleeptotem on Jan 31, 2021 12:18:25 GMT
Hello everyone,
So ive finally succumbed to the allure of diy stuff and well, here is my first ever diy electronics thingie project.
Its a simple Sample Player using the Teensy 4.0.
What it does atm:
- Has 6 samples which are stored in the internal memory
- Samples can be played simultaneously
- 6 cv ins which trigger each sample individually
- 3 choke togglable groups which pair 2 sounds that will choke each other (1 <=> 4, 2 <=> 5, 3 <=> 6)
- Choke groups are saved in memory so if you turn it on and of your choke group settings remain
- 3 LEDs which show the state of each choke group
- Global Voulme Control Knob
- LPF Control Knob
Future implementation:
- Loading samples somehow?
- Have a volume control which can toggle from global to each individual sample volume
- Improve sound quality
- Power with ae 5v voltage instead of usb
Heres a video showcasing the module function with all of the above (the choke groups are: Kick and Clap, Snare and Voice, Closed HH and Open HH).
One thing that I have been unable to do is powering the Teensy without usb, using only the AE 5v/gnd, any help here would be highly appreciated.
And here is the code for anyone interested. Bear in mind this is my first time ever coding on arduino/teensy so im sure theres a lot to improve, feedback is highly appreaciated.
Anyways let me know what you guys think!
So ive finally succumbed to the allure of diy stuff and well, here is my first ever diy electronics thingie project.
Its a simple Sample Player using the Teensy 4.0.
What it does atm:
- Has 6 samples which are stored in the internal memory
- Samples can be played simultaneously
- 6 cv ins which trigger each sample individually
- 3 choke togglable groups which pair 2 sounds that will choke each other (1 <=> 4, 2 <=> 5, 3 <=> 6)
- Choke groups are saved in memory so if you turn it on and of your choke group settings remain
- 3 LEDs which show the state of each choke group
- Global Voulme Control Knob
- LPF Control Knob
Future implementation:
- Loading samples somehow?
- Have a volume control which can toggle from global to each individual sample volume
- Improve sound quality
- Power with ae 5v voltage instead of usb
Heres a video showcasing the module function with all of the above (the choke groups are: Kick and Clap, Snare and Voice, Closed HH and Open HH).
One thing that I have been unable to do is powering the Teensy without usb, using only the AE 5v/gnd, any help here would be highly appreciated.
And here is the code for anyone interested. Bear in mind this is my first time ever coding on arduino/teensy so im sure theres a lot to improve, feedback is highly appreaciated.
Anyways let me know what you guys think!
#include <EEPROM.h>
#include <Audio.h>
#include <SerialFlash.h>
#include <Bounce.h>
#include "AudioSampleBdlin.h" // Kick
#include "AudioSampleChlin.h" // Closed Hat
#include "AudioSampleCl.h" // Clap
#include "AudioSampleOhl.h" // Open Hat
#include "AudioSampleSdl.h" // Snare
#include "AudioSampleSsl.h" // Stick
#include "AudioSampleNow.h" // Vocal
AudioPlayMemory sound0;
AudioPlayMemory sound1; // six memory players, so we can play
AudioPlayMemory sound2; // all six sounds simultaneously
AudioPlayMemory sound3;
AudioPlayMemory sound4;
AudioPlayMemory sound5;
AudioMixer4 mix1;
AudioMixer4 mix2;
AudioMixer4 mix3;
AudioMixer4 mix4;
AudioFilterStateVariable filter0; //xy=127,349
AudioFilterStateVariable filter1; //xy=127,349
AudioFilterStateVariable filter2; //xy=127,349
AudioOutputMQS mqs1; //xy=1000,150
// Create Audio connections between the components
//
AudioConnection c1(sound0, 0, mix1, 0); /// First sound group
AudioConnection c2(sound1, 0, mix1, 1);
AudioConnection c3(sound2, 0, mix1, 2);
AudioConnection c4(sound3, 0, mix2, 0); /// Second sound group
AudioConnection c5(sound4, 0, mix2, 1);
AudioConnection c6(sound5, 0, mix2, 2);
AudioConnection c7(mix1, 0, mix3, 0); /// Main mixer
AudioConnection c8(mix2, 0, mix3, 1);
AudioConnection c9(mix3, 0, filter0, 0); /// Low pass noise cutoff
AudioConnection c10(filter0, 0, filter1, 0); /// High pass noise cutoff
AudioConnection c11(filter1, 2, filter2, 0); /// Controlable Filter
AudioConnection c12(filter2, 0, mix4, 0); /// Controllable Volume Mixer
AudioConnection c13(mix4, 0, mqs1, 0); /// Main outs
AudioConnection c14(mix4, 0, mqs1, 1);
int led = 13;
int chokeLed0 = 11;
int chokeLed1 = 9;
int chokeLed2 = 8;
int potIn0 = 23;
int potOut1 = 22;
int potIn1 = 21;
int buttonOut0 = 20;
int buttonIn0 = 19;
Bounce button0 = Bounce(buttonIn0, 10);
int buttonOut1 = 18;
int buttonIn1 = 17;
Bounce button1 = Bounce(buttonIn1, 10);
int buttonOut2 = 16;
int buttonIn2 = 15;
Bounce button2 = Bounce(buttonIn2, 10);
int topoIn0 = 0;
int topoIn1 = 1;
int topoIn2 = 2;
int topoIn3 = 5;
int topoIn4 = 6;
int topoIn5 = 7;
int topoState0;
int topoState1;
int topoState2;
int topoState3;
int topoState4;
int topoState5;
int potState0;
int potState1;
int cutoff;
byte chokeState0;
byte chokeState1;
byte chokeState2;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
analogWrite(led, 10);
pinMode(chokeLed0, OUTPUT);
pinMode(chokeLed1, OUTPUT);
pinMode(chokeLed2, OUTPUT);
pinMode(potIn0, INPUT);
pinMode(potOut1, OUTPUT);
digitalWrite(potOut1, HIGH);
pinMode(potIn1, INPUT);
pinMode(topoIn0, INPUT);
digitalWrite(topoIn0, LOW);
pinMode(topoIn1, INPUT);
digitalWrite(topoIn1, LOW);
pinMode(topoIn2, INPUT);
digitalWrite(topoIn2, LOW);
pinMode(topoIn3, INPUT);
digitalWrite(topoIn3, LOW);
pinMode(topoIn4, INPUT);
digitalWrite(topoIn4, LOW);
pinMode(topoIn5, INPUT);
digitalWrite(topoIn5, LOW);
pinMode(buttonOut0, OUTPUT);
digitalWrite(buttonOut0, HIGH);
pinMode(buttonIn0, INPUT_PULLUP);
digitalWrite(buttonIn0, LOW);
pinMode(buttonOut1, OUTPUT);
digitalWrite(buttonOut1, HIGH);
pinMode(buttonIn1, INPUT_PULLUP);
digitalWrite(buttonIn1, LOW);
pinMode(buttonOut2, OUTPUT);
digitalWrite(buttonOut2, HIGH);
pinMode(buttonIn2, INPUT_PULLUP);
digitalWrite(buttonIn2, LOW);
AudioMemory(6);
filter0.frequency(11000);
filter1.frequency(40);
mix1.gain(0, 0.4);
mix1.gain(1, 0.4);
mix1.gain(2, 0.4);
mix2.gain(0, 0.4);
mix2.gain(1, 0.4);
mix2.gain(2, 0.4);
delay(500);
chokeState0 = EEPROM.read(0);
chokeState1 = EEPROM.read(1);
chokeState2 = EEPROM.read(2);
}
void loop() {
digitalWrite(chokeLed0, chokeState0);
digitalWrite(chokeLed1, chokeState1);
digitalWrite(chokeLed2, chokeState2);
topoState0 = digitalRead(topoIn0);
topoState1 = digitalRead(topoIn1);
topoState2 = digitalRead(topoIn2);
topoState3 = digitalRead(topoIn3);
topoState4 = digitalRead(topoIn4);
topoState5 = digitalRead(topoIn5);
potState1 = analogRead(potIn1);
float vol = (float)analogRead(potIn0)/1024.0;
mix4.gain(0, vol);
cutoff = analogRead(potIn1) * 9;
cutoff = cutoff < 200 ? 200 : cutoff;
filter2.frequency(cutoff);
if(button0.update() && button0.fallingEdge()) {
chokeState0 = !chokeState0;
EEPROM.write(0, chokeState0);
}
if(button1.update() && button1.fallingEdge()) {
chokeState1 = !chokeState1;
EEPROM.write(1, chokeState1);
}
if(button2.update() && button2.fallingEdge()) {
chokeState2 = !chokeState2;
EEPROM.write(2, chokeState2);
}
if(topoState0 == 1){
if(!!chokeState0) sound3.stop();
sound0.play(AudioSampleBdlin);
}
if(topoState1 == 1){
if(!!chokeState1) sound4.stop();
sound1.play(AudioSampleSdl);
}
if(topoState2 == 1){
if(!!chokeState2) sound5.stop();
sound2.play(AudioSampleChlin);
}
if(topoState3 == 1){
if(!!chokeState0) sound0.stop();
sound3.play(AudioSampleCl);
}
if(topoState4 == 1){
if(!!chokeState1) sound1.stop();
sound4.play(AudioSampleNow);
}
if(topoState5 == 1){
if(!!chokeState2) sound2.stop();
sound5.play(AudioSampleOhl);
}
}