Pages: [1]   Go Down
Author Topic: Is this even possible? (~7 second audio delay)  (Read 1385 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm affiliated with a rather poor non-profit radio station. In our main studio, we have a digital 7 second broadcast delay setup, so that if anyone drops profanity on the air, we can hit a dump button and keep either the last 3.5 or 7 seconds from being broadcast. In our remote studio a half mile away, however, we don't have any sort of trigger for that system, so essentially we would have to have someone sitting near the dump button back at the main studio all times. We don't have the manpower, nor the time to do that. What I'm wondering is if there is a way with an arduino (or multiple arduinos) or similar setup to input a 80hz-14khz audio signal, buffer it for 7 seconds, and then output it. The only things it would need to have other than that would be a button that took the signal buffer and dumped it from memory, and then started buffering the delay again. The reason I'm asking is the CHEAPEST I can find a digital, professionally-made, dedicated delay setup is around $700. Our budget doesn't cover that kind of expense, especially after having 3 of our 4 $300 Marantz reporter-recorders "walk off" on us in the last several months.  :'(

Could I do this with several boards?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Time for a bit of math.  According to Nyquist, you'll need 14,000 * 2 samples per second = 28,000 samples per second.  About the lowest resolution you'd want to consider is 12 bits per sample which gives us 336,000 bits per second or 42,000 bytes per second.  I believe the maximum memory available on an AVR processor is 64K.  You may be able to buffer 1.5 seconds.  So, you'll have to consider a solution with external memory.  

You'll need an external DAC (available as a shield) and may need an external ADC.

Still interested?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The first thing you would need to do is figure out what sampling rate you want to use to record the incoming signal. Then, determine if the ADC on the Arduino is fast enough to collect that number of samples. For any reasonable level of accuracy for sampling audio data, it is not.

Then, you need to determine how much space it will take to store 7 seconds of samples. For any reasonable level of accuracy for sampling audio data, that's a lot of samples. Far more than the poor little Arduino can hold in memory at one time. Even the Mega 2560 only has 8K of SRAM for all global variables, constants, and stack space.

Then, you need to convert the sampled/stored input data into some useful format.

If you want to chop 3.5 seconds out of the data being streamed out, that leaves you with 3.5 seconds of data. If you chop another 3.5 seconds, you are no longer storing anything. How do commercial devices handle this?

Break the legs on the last one you have, so it doesn't walk off, too.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am willing to deal with external memory, and I was already considering The DAC and ADC idea. The way I was thinking was this: 3 Arduinos, mainly to share the load of the processing this is probably going to take:

SOUND SOURCE -> Arduino with analog to digital converter -> Arduino with external flash memory -> Arduino with digital to analog converter -> SOUND OUTPUT

Does this work like this? Sending a data signal from one arduino to another?
« Last Edit: November 11, 2010, 04:19:02 pm by dannywilson » Logged

Sofia, Bulgaria
Offline Offline
Full Member
***
Karma: 0
Posts: 237
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here you can find some audio effects implemented on a ATTiny26 with external RAM:
http://elm-chan.org/works/vp/report.html
As the tiny is a lot less powerful than an atmega I think this is a good base to build upon. On the other hand, as it was mentioned before - what audio quality do you want to record. If it is a phone audio, it might do the job, but if you want to buffer high quality audio it might not.
What about using a PC for that?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 168
Posts: 12428
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Time for a bit of math.
Is the signal Stereo or Mono?  This doubles the amount of bits calculated by Coding Badly.

Just another thought:
Imagine an Arduino handling the button in the Main studio (just add a relay or so). Let that same Arduino have an ethenetshield and a  built in ethernet/web server that provides a virtual button.  This virtual button can be "pressed" by another Arduino that also has an ethernetshield and client software and an real switch.

switch@remote) ---->[arduino remote] ====> (over the internet)  =====> Arduino remote]  can see if  [Arduino main]  is alive & kicking ...

Is this a valid alternative?

« Last Edit: November 11, 2010, 05:05:11 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
SOUND SOURCE -> Arduino with analog to digital converter -> Arduino with external flash memory -> Arduino with digital to analog converter -> SOUND OUTPUT
Does this work like this? Sending a data signal from one arduino to another?
You can do that but it adds considerable complexity to the system.  You only want to add more Arduinos if you absolutely have to.  If you are at the point where you need more processing power, you should consider a single more powerful processor.

Right now, you need to decide the audio quality (bits per sample; samples per second).  That will drive many of the other decisions.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Coding Badly: Hmm. So I believe it would have to be 28000 Hz, 16 bit stereo, as that is the maximum our main 7 second box runs, and there's no point in running a massive quality stream out just to be re-compressed for radio again. What would a more powerful processor be? The reason I had the 3 arduinos serially laid out is so that each could do one specific job, and that job only.

mircho: It's FM broadcast compression when it finally goes out. And what you linked me is more of an effects processor than a dedicated delay, but thanks, I kinda wanna play with that on another project of mine.

robtillaart: This is a kinda good idea, especially because I just built a corded "Big Red Button" remote for the main studio, and implementing it wouldn't be too hard with the exception of getting permission from the university's IT dept.

Logged

Sofia, Bulgaria
Offline Offline
Full Member
***
Karma: 0
Posts: 237
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well Chan describes in the list of effects the most basic one - delay. Which does what you want, I think - it delays the input. Of course in the context of his article it is about sound effects.
I think that a cheap (old, off ebay) laptop with Linux can do the job, after some time spent configuring some software. There are plenty of options: http://en.wikipedia.org/wiki/List_of_Linux_audio_software
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What would a more powerful processor be?
http://www.logicsupply.com/products/artigo_a1000
 smiley
I actually don't know.  Someone else will have to guide you on something between an Arduino and a Pentium.

Quote
The reason I had the 3 arduinos serially laid out is so that each could do one specific job, and that job only.
I understand.  But first you need to determine if it's even necessary to have more than one Arduino involved.

Quote
stereo
One Arduino per channel with the kill button wired to both.

Quote
Coding Badly: Hmm. So I believe it would have to be 28000 Hz, 16 bit stereo, as that is the maximum our main 7 second box runs, and there's no point in running a massive quality stream out just to be re-compressed for radio again.
That means an external ADC and an external DAC (per channel).

  (((28000*2))*16)/8 = 112,000 bytes per second (per channel)

    * 7 seconds = 784,000 bytes of storage (per channel)

  16000000 / 112000 = ~142 machine instructions per sample (per channel)

A run-down of what needs to be done...

- Get a new sample from the ADC
- Record the new sample to a circular buffer
- Read an old sample from the other side of the circular buffer
- Send the old sample to the DAC
- Check for a button press

I suspect that can be done in 142 machine instructions but you will very likely have to avoid the Arduino API (instead of digitalRead, read the PIN register; instead of using the SPI library, access the SPI registers directly).  You will probably have to turn off the millis interrupt and setup a timer to provide synchronization.
Logged

0
Offline Offline
Shannon Member
****
Karma: 160
Posts: 10416
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've used microSD card and not managed much faster than 3--4ms per block (512 bytes) through the hardware SPI interface at 4MHz clock, which is about 140kB/s, fast enough to read enough samples to drive a DAC, but the DAC would not be able to share hardware SPI - perhaps 8 bit parallel by directly writing to the AVR ports...

But if you want to write as well that's slower, perhaps 6ms to write, 3ms to read. overall throughput 56kB/s, not really enough - and that's not including any overhead for doing any interfacing to ADC/DAC or other Arduinos

So I'd say it would be very difficult without more powerful hardware, specifically something with enough fast RAM on the system bus to do the buffering (1MB ought to do it), then you only have to write the interrupt handlers and interface suitable DAC and ADC.  A DSP based board is likely to be far better bet...  Anyone know an open DSP board?
Logged

[ I won't respond to messages, use the forum please ]

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 168
Posts: 12428
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
implementing it wouldn't be too hard with the exception of getting permission from the university's IT dept.

Its easier to ask forgiveness than to ask permission smiley
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Right Here!
Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As someone once said:
"If I be goin' there I be-n't start by here"

For what the OP describes you don't need any processing at all, just A/D -> memory -> D/A with a simple clock and counter to step through the memory. The read needs to be 1 tick ahead of the write.

So its:
step, read, write, step, read, write ... etc.

Your delay is the memory size (in words) / clock rate.
Logged

Pages: [1]   Go Up
Jump to: