5

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.

  • 3
    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. – Chris Stratton May 17 '13 at 14:48
  • 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. – Chris Stratton May 17 '13 at 14:50
  • 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. – John U May 17 '13 at 15:34
  • 1
    ...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. – John U May 17 '13 at 15:35

1 Answers1

1

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.

squarewav
  • 1,440
  • 1
  • 14
  • 33