5
\$\begingroup\$

Say, you have an arduino uno + audio shield, a speaker and a jog-wheel (or mouse scroll-wheel).

And you want to play some audio-file tied to the movement of the wheel, just like you move vinyl disc. For example, you scroll forward(fast enough) — the audio plays forward(fast enough), you scroll back(slowly) — audio play backwards(same slow).

How do you do it? Is it possible anyhow? i hope i`ve made it clear.

\$\endgroup\$
  • 3
    \$\begingroup\$ This will actually be pretty challenging. The plausible scratch distance of a record is a fair fraction of a second, which is far more audio data than you can hold in the on-chip ram of an Arduino, so you'll have to go and pull it from the SD card or whatever in real time to respond to the movement. That aspect of the project would be much easier with something such as a Raspberry Pi, where you could hold the entire track (at full CD quality) in RAM. \$\endgroup\$ – Chris Stratton May 17 '13 at 14:48
  • \$\begingroup\$ However if using the Pi's audio output stack you would probably need to do a variable sample rate conversion instead of just delivering the samples at an adjusted rate to a comparatively "dumb" DAC or PWM output. This is do-able (there are available libraries), another option could be to use something like the audio shield connected to the Pi or see if it has a PWM output you could use. \$\endgroup\$ – Chris Stratton May 17 '13 at 14:50
  • \$\begingroup\$ Pioneer do it on their CDJ cd/dvd/mp3 turntables, and it seems on the surface like a fairly easy task (I've considered similar projects myself) but I'm willing to bet the devil is in the detail. There are also other DJ solutions where software tracks an actual vinyl "reference" record and plays back an MP3 matched/scratched with the speed of the reference. \$\endgroup\$ – John U May 17 '13 at 15:34
  • 1
    \$\begingroup\$ ...I'd be looking for some sort of micro (probably with external RAM on a proper bus, probably 32-bit) that can hold & instantly access enough data to playback an uncompressed stereo audio file. \$\endgroup\$ – John U May 17 '13 at 15:35
1
\$\begingroup\$

I have no experience with this particular type of application but my guess would be that it all depends on your available RAM and what sort of features the codec has for directing it to the buffered data in RAM. So when you scroll forward your code would tell the codec to skip some buffers in RAM. But meanwhile your code would have to anticipate what buffers will be needed and pull them from the SD card. So you need a good algorithm that can anticipate what parts of the sound file will be needed. To play backwards you would just need to reverse the data in each buffer. To play slow, it might be as simple as changing the bitrate of the CODEC to be too fast and thus the audio will sound slow.

But the first thing you would need to do is identify the chip on the audio shield used to actually convert the sound file to digital audio and carefully study what sort of control you have over how you feed it data. It might have a routine that can access a file on the SD card directly but of course that would be of no use to you. It probably has lower level routines that work on buffers. You would need to explicitly tell it to play individual buffers in RAM. Then it's all about getting the right buffers in RAM.

You might not have enough RAM to do this actually. Before you get carried away, you should figure that out.

\$\endgroup\$
  • \$\begingroup\$ 2K of RAM on an Arduino, a bit more on a mega. \$\endgroup\$ – Chris Stratton May 17 '13 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.