Hi Team,
Ive got a smal test project going on, and its not quite clear to me, on how to handle the behavior that its giving me (or the results, and that has more to do with my skills than the teensy )
what i try to achieve is a audio mixer with left input and right input (audio) aswel as a L&R audio output. seperated from eachother.
with button1 i trigger the left side to active, as for button2 the right. this works fine with no specialties.
but i wanted to make the left side overruling the right side, so if i press button1, the right side should remain off (or silent or low, bassicly do nothing because the left side is active).
the question is : how to go forward from here? and what to learn or take further notice of?
ive tried allot, and this code is the most basic version that works like a normal mixer with no specials or extra's.
ive tryed bouncing the buttons, worked with millis, even made the leftinput to a interrupt that it must be the master channel. but not getting the correct result and leads to no audio, or crackling audio of both sides,
to simplify its purpose of function : if button1 is pressed > turn on mixer1 and turn on led1(leftoutput)
if button2 is pressed > turn on mixer2 and turn on led2(Rightoutput)
but if button1 is active turn mixer2 en Led2(rightoutput) low (off) even if button2 is pressed.
Thnx in advance
Yours
Danny
Ive got a smal test project going on, and its not quite clear to me, on how to handle the behavior that its giving me (or the results, and that has more to do with my skills than the teensy )
what i try to achieve is a audio mixer with left input and right input (audio) aswel as a L&R audio output. seperated from eachother.
with button1 i trigger the left side to active, as for button2 the right. this works fine with no specialties.
but i wanted to make the left side overruling the right side, so if i press button1, the right side should remain off (or silent or low, bassicly do nothing because the left side is active).
the question is : how to go forward from here? and what to learn or take further notice of?
ive tried allot, and this code is the most basic version that works like a normal mixer with no specials or extra's.
ive tryed bouncing the buttons, worked with millis, even made the leftinput to a interrupt that it must be the master channel. but not getting the correct result and leads to no audio, or crackling audio of both sides,
to simplify its purpose of function : if button1 is pressed > turn on mixer1 and turn on led1(leftoutput)
if button2 is pressed > turn on mixer2 and turn on led2(Rightoutput)
but if button1 is active turn mixer2 en Led2(rightoutput) low (off) even if button2 is pressed.
Thnx in advance
Yours
Danny
Code:
#include <Audio.h>
#include <Wire.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=299,207
AudioMixer4 mixer2; //xy=503,273
AudioMixer4 mixer1; //xy=504,130
AudioOutputI2S i2s2; //xy=676,193
AudioConnection patchCord1(i2s1, 0, mixer1, 0);
AudioConnection patchCord2(i2s1, 1, mixer2, 0);
AudioConnection patchCord3(mixer2, 0, i2s2, 1);
AudioConnection patchCord4(mixer1, 0, i2s2, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=745,489
// GUItool: end automatically generated code
const int ledPin = LED_BUILTIN;// the number of the LED pin
int ledState3 = LOW; // ledState used to set the LED
unsigned long previousMillis3 = 0; // will store last time LED was updated
const long interval = 1000; // interval at which to blink (milliseconds)
const int leftInput = 0; //pinout op de Teensy
const int leftOutput = 1; //pinout op de Teensy
const int rightInput = 2; //pinout op de Teensy
const int rightOutput = 3; //pinout op de Teensy
void setup() {
pinMode(ledPin, OUTPUT);
pinMode (leftInput, INPUT_PULLUP);
pinMode (leftOutput, OUTPUT);
pinMode (rightInput, INPUT_PULLUP);
pinMode (rightOutput, OUTPUT);
digitalWrite(leftOutput, LOW);
digitalWrite(rightOutput, LOW);
AudioMemory(10);
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
mixer1.gain(0, 0.0); //audio input 1
mixer2.gain(0, 0.0); //audio input 3
delay(500);
}
///////////////////////////////////////////////////////////////////////////////////////////////
void controleLed () {
unsigned long currentMillis3 = millis();
if (currentMillis3 - previousMillis3 >= interval) {
previousMillis3 = currentMillis3;
if (ledState3 == LOW) {
ledState3 = HIGH;
} else {
ledState3 = LOW;
}
digitalWrite(ledPin, ledState3);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
controleLed ();
if (digitalRead(leftInput) == LOW) {
digitalWrite(leftOutput, HIGH);
mixer1.gain(0, 0.6); //audio input 1
}
if (digitalRead(leftInput) == HIGH) {
digitalWrite(leftOutput, LOW);
mixer1.gain(0, 0.0); //audio input 1
}
if (digitalRead(rightInput) == LOW) {
digitalWrite(rightOutput, HIGH);
mixer2.gain(0, 0.6); //audio input 1
}
if (digitalRead(rightInput) == HIGH) {
digitalWrite(rightOutput, LOW);
mixer2.gain(0, 0.0); //audio input 1
}
}