Store › Forums › Audio Hacker › Discussion and Project Ideas › Audio Delay line
Tagged: audio delay
- This topic has 5 replies, 3 voices, and was last updated 7 years, 9 months ago by Michael.
-
AuthorPosts
-
September 27, 2014 at 12:03 am #720DaveedMember
I want to build a simple delay line. I figure I would repurpose the sketch for the Echo Effect http://nootropicdesign.com/projectlab/2013/07/05/echo-effect/
I just need to get rid of the direct signal (dry) and the echos.
I tried commenting the following block.
// mix = signal-2048;<br /> // echo = echo >> 1; // attenuate echo<br /> mix += (echo - 1024); // since we are dividing echo by 2, decrement by 1024<br /> // if (mix < -2048) {<br /> // mix = -2048;<br /> // } else {<br /> // if (mix > 2047) {<br /> // mix = 2047;<br /> // }<br /> // }<br /> playbackBuf = mix + 2048;
It gets rid of the dry signal but I still get the echos. How can I get rid of the echos?
Also:
Can I assign the buttons on S1, S2 on the shield to change the echo delay in ms, How?
And the last step is, I would like to output the delay value in milliseconds to a LCD display, any help with any of this item would be very much appreciated.
- This topic was modified 8 years ago by Michael. Reason: fixed link
September 29, 2014 at 8:55 pm #2039MichaelKeymasterWhen you say you hear “echoes” (plural), what do you mean? There is the original signal in realtime and it is mixed with the delay read from memory (this is variable “echo”). I think you just want to hear the delay.
You should replace this code:
mix = signal-2048;
echo = echo >> 1; // attenuate echo
mix += (echo - 1024); // since we are dividing echo by 2, decrement by 1024
if (mix < -2048) {
mix = -2048;
} else {
if (mix > 2047) {
mix = 2047;
}
}
playbackBuf = mix + 2048;with this simple code:
playbackBuf = echo;As for using the switches to set the delay, yes, it’s easy to use Arduino digitalRead(pin) to read whether a button is pressed or not. You could use one button to increase the delay, and another to decrease.
setup() {
...
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
}
...
loop() {
if (digitalRead(5) == LOW) {
delay++;
}
if (digitalRead(6) == LOW) {
delay--;
}
...
}
You probably are not going to be able to drive an LCD while processing audio. The timing of the audio processing must be precise, and peripheral communication using interrupts will mess it up.
October 2, 2014 at 2:32 am #2046DaveedMemberWow, that is perfect, thanks.
That code seems pretty straight forward and does what I want, a simple echo.When I tried this code for the buttons to increment the delay:
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
}
...
loop() {
if (digitalRead(5) == LOW) {
delay++;
}
if (digitalRead(6) == LOW) {
delay--;
}
...
}I get:
“error: ISO C++ forbids incrementing a pointer of type ‘void (*)(long unsigned int)'”
but I changed to:
Global variable
int a = 25; // make a variable I can control with buttons and ++
setup() {
...
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
}
...
loop()
delay(300);
// echoDelay is number of memory slots back into the past to read for the echo.
// must be a factor of 3 because we pack 2 samples into each 3-byte sequence of SRAM.
int delayValue = 3 * a; //mulyply by 3 for 3-byte SRAM
echoDelay = analogRead(0) * delayValue;
{
if (digitalRead(5) == LOW) {
a++;
}
if (digitalRead(6) == LOW) {
a--;
}
// code for two buttons press at the same tim
if (digitalRead(5) == LOW && digitalRead(6) == LOW){
Serial.println();
Serial.print("BOTH SWITCHES");
Serial.println();
}
}
and that works well.
Although I am sure they are more elegant ways to do that.Do you think is possible just to query the system to get the delay value to the LCD ? Pressing both buttons, for example, just to send the data to the LCD once, without affecting the the delay too much
October 2, 2014 at 1:29 pm #2047MichaelKeymasterOk, sounds like you have your delay working.
I haven’t ever interfaced with an LCD and don’t have one, so I can’t comment on how well it would work. I think it would work, but you need lots of pins. The Audio Hacker uses pins 5-13, so you have pins 2,3,4 and the analog pins A0-A5 which can be used as digital pins if you refer to them as 14-19. Have a look at this:
http://arduino.cc/en/Tutorial/LiquidCrystalFebruary 9, 2017 at 4:02 am #8777jlastParticipantI need an audio delay line; read audio input and send it to the output with a programmable delay (up to 1 sec). Can I do this with a sampling rate of 16 kHz?
February 9, 2017 at 8:08 pm #8779MichaelKeymasterYes, you should be able to record and then playback delayed at 16KHz.
-
AuthorPosts
- You must be logged in to reply to this topic.