Forum Replies Created
-
AuthorPosts
-
PhotoflashParticipant
Well, that is disappointing.
Thanks anyway…
PhotoflashParticipantThanks for the tip… I changed echoDelay to
unsigned long echoDelay;
and now have a 4 second delay maximum.Do you have any thoughts on how I can reach the 8.6 second maximum, as in the documentation?
PhotoflashParticipantI have the DJ Shield (unassembled, unfortunately) so I’ll put that together and try using a pot with the echo example. Hopefully, I’ll get to it this weekend.
PhotoflashParticipantChanging the echoDelay value seems to have no audible effect at all. I’ve tried many different values from around 300 to 48000 (all divisible by 3), and I can’t hear, or measure with a stopwatch, any significant change in the delay, which is consistently around 2 sec.
But when I use a very high value, such as 90000, it produces a lot of feedback-like noise, so there definitely is a maximum limit.
I’m not using any pots, but just changing the value in the code and uploading to the Audio Hacker to test it out.
PhotoflashParticipantHere’s the code:
#include <AudioHacker.h> #define DEBUG unsigned int playbackBuf; unsigned int sampleRate; unsigned int readBuf[2]; unsigned int writeBuf; boolean evenCycle = true; unsigned int timer1Start; volatile unsigned int timer1EndEven; volatile unsigned int timer1EndOdd; unsigned long lastDebugPrint = 0; volatile long address = 0; unsigned int echoDelay; boolean echoWrapped = false; void setup() { #ifdef DEBUG Serial.begin(115200); // connect to the serial port #endif playbackBuf = 2048; sampleRate = DEFAULT_RECORDING_SAMPLE_RATE; timer1Start = UINT16_MAX - (F_CPU / sampleRate); AudioHacker.begin(); #ifdef DEBUG Serial.print("sample rate = "); Serial.print(sampleRate); Serial.print(" Hz"); Serial.println(); #endif } void 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. echoDelay = 24000; #ifdef DEBUG if ((millis() - lastDebugPrint) >= 1000) { lastDebugPrint = millis(); //each 3 echoDelay2 is 2 samples. unsigned int delayMillis = (float)(((float)((echoDelay * 2) / 3)) / (float)(sampleRate/1000.0)); Serial.print("echo delay = "); Serial.print(delayMillis); Serial.print(" ms even cycles remaining = "); Serial.print(UINT16_MAX - timer1EndEven); Serial.print(" odd cycles remaining = "); Serial.print(UINT16_MAX - timer1EndOdd); Serial.println(); } } #endif ISR(TIMER1_OVF_vect) { TCNT1 = timer1Start; unsigned int signal; unsigned int echo; int mix; AudioHacker.writeDAC(playbackBuf); // Read ADC signal = AudioHacker.readADC(); if (evenCycle) { long echoAddress = address - echoDelay; if (echoAddress < 0) { echoAddress += MAX_ADDR; } AudioHacker.readSRAMPacked(0, echoAddress, readBuf); if ((!echoWrapped) && (echoAddress > address)) { // avoid reading from unwritten memory echo = 2048; readBuf[1] = 2048; } else { echo = readBuf[0]; } } else { echo = readBuf[1]; } if (echoDelay == 0) { echo = 2048; } if (evenCycle) { writeBuf = signal; } else { AudioHacker.writeSRAMPacked(0, address, writeBuf, signal); address += 3; if (address > MAX_ADDR) { address = 0; echoWrapped = true; } } playbackBuf = echo; #ifdef DEBUG if (evenCycle) { timer1EndEven = TCNT1; } else { timer1EndOdd = TCNT1; } #endif evenCycle = !evenCycle; }
PhotoflashParticipantHowdy, Michael —
I’m still having a bit of trouble changing the length of the delay to more than the 2 seconds it produced originally.
I change
echoDelay = 24000
but that has no effect. Is there another delay modification that I’m not finding?Any help would be appreciated.
Thanks, Charles
-
AuthorPosts