PDA

View Full Version : Another Audio Streaming Question



mechatronic
04-12-2016, 05:58 AM
Hello PJRC, a Forum post is overdue. I am a big fan of Teensy and have followed developments for about a year now.

Is there support yet for streaming audio through Teensy + Audio Adapter/SDcard? I have recently delved into Teensy Audio, and can't quite find a clear answer to this question.

I would like to build a music suite that allows streaming audio data to individual teensy speaker units (a few dozen of them, each with a unique audio stream). Can a circular buffer be used on the Teensy to move audio data from the USB Port to the SD card while the data is being sampled?

I know the SD card could be loaded with a ton of audio files, but I would like the flexibility of putting less storage on the units themselves, and allow for continuous audio playback.

Thanks for any help!

A fellow Maker :)

Pensive
04-12-2016, 01:45 PM
No, streaming is not something that has yet been implemented.

However Frank has implemented support for MP3 / AAC / OGG(??) as well I think, so reading this from a memory chip or from a stream is very similar.

The lions share of the work is already done.



All you need to do is get a wifi chip and implement stream buffering which feeds into Frank's playback code somehow.

"all".

It should be relatively simple for a skilled coder, a challenge for someone like me, and a bit too tricky for a beginner.

But noone has done it yet, to the best of my knowledge.

PaulStoffregen
04-12-2016, 01:58 PM
I don't really understand some parts of this question....


Can a circular buffer be used on the Teensy to move audio data from the USB Port to the SD card while the data is being sampled?


I *really* don't understand how the SD card would be involved.

But I've recently begun working on integrating MickMad's prior work on USB audio streaming. This will be stereo input and output.

Similar code could perhaps be made using 4 or more channels input only. But something to consider is each channel is approx 88.2 kbytes/sec. The absolute maximum that can be moved on 12 Mbit/sec USB with isync transfers is 1023 kbytes/sec. So more than 11 channels is theoretically impossible. Even that many is probably more than any PC operating system USB host driver will likely allow bandwidth to be reserved.

You could try to do this with serial protocol instead of USB audio protocol, and code that stuffs the bytes into audio queue objects to put them into the audio library, where you can them stream to audio shields (where 4 channels is the max supported) or the DAC or PWM. But no matter what you do, you'll run into the USB absolute bandwidth limit for 12 Mbit/sec, which is approx 1.1 Mbyte/sec with the USB protocol overhead.

mechatronic
04-12-2016, 03:43 PM
Hmmm.. I didn't realize that the streaming being developed was stereo in, stereo out... but I guess that makes sense. Specifically what I am looking for is a way to move audio data from a host PC or other central memory unit to dozens of Teensy SD Cards during run-time to allow for continuous playback from all of the channels..

I guess my next question is timing. Is it feasible to load out SD cards with say 5 hours of music, and during that 5 hour playback period load the SD card with an additional 5 hours of music via Serial USB? I understand the simultaneous limitation with serial USB, but if it could be done such that channels were loaded one by one with say 5 minutes of audio data at a time, then there might be a way around that issue?

Also, I feel a little dumb asking, but how do I load the SD Cards through the Teensy's USB? I don't want to have to remove the SD Cards from the Audio adapter every time I want to load them with new audio files.

Thanks Paul for offering some of those specs, that cleared a few things up for me. Like I said, I am new to the Audio world.

MichaelMeissner
04-12-2016, 04:19 PM
Also, I feel a little dumb asking, but how do I load the SD Cards through the Teensy's USB? I don't want to have to remove the SD Cards from the Audio adapter every time I want to load them with new audio files.

I'm not sure whether Frank B's Teensy Transfer has SD support, but it at least supports flash memory that you can solder to the audio shield and the flash memory in the prop shield: https://forum.pjrc.com/threads/33859-TeensyTransfer?p=101306

Frank B
04-12-2016, 05:22 PM
I'm not sure whether Frank B's Teensy Transfer has SD support, but it at least supports flash memory that you can solder to the audio shield and the flash memory in the prop shield: https://forum.pjrc.com/threads/33859-TeensyTransfer?p=101306

SD support is comming... give me me or two weeks, or add it yourself and send me a pullrequest @ github :)
Also planned is a "callback()" function which allows to use your own devices easly. Perhaps you can use that as a kind of streaming..