I have an AV installation I built using a Mega clone that reads sensor data and controls 7 meters of LED strips from adafruit using this data. Right now I'm using Max6 to control 4 mono audio channels, using serial commands to recieve the sensor data and trigger audio in sync with the LED strips.
I'd like to remove the laptop from the circuit altogether and just use the Mega clone to run everything. Even at a high baud rate, using serial to sync up the functions with Max is clunky and I'd really prefer to avoid using a laptop in this installation if I can avoid it.
I've been experimenting with a few libraries and had success with using a single 16bit mono output via Dual PWM.
Are there any libraries that support using Dual PWM for a total of 4x 16bit mono outputs? (or 2x Stereo 16bit output, though i'd like to address each speaker individually)
I'm really enjoying the Mozzi library, but it seems it is only capable of mono output.
With greater RAM and ample pins available on the Mega it seems it would be feasible to modify a library to accomodate 4 individual speakers..
I don't think you'll be able to get a Mega outputting 4 channels of audio. WaveHC maxes out at 44khz 16bit mono. I suppose if you dropped the sample rate to 22khz 8 bit and added three more buffers, you MIGHT be able to accomplish it, but for your one off project it probably wouldn't be worth the effort.
A Teensy 3.1 however would easily handle 4 channels at 44khz stereo with it's own specialized audio library. And, if you're using Neopixels, as I suspect you are, then it has a shield available for controlling those and a library that can drive up to 4000 of the things:
You can't however, do both with the same Teensy. The pinout of the Teensy's audio shield and the Neopixel sheld are incompatible. I imagine it would not be too hard to get two boards communicating with each other though with some of the unused pins, and you could run the audio board on a separate power supply so as not to have any potential issues with noise from the massive power usage of the Neopixels.
Oh wait, are you asking for 4 channel audio? As in four speakers, each with one channel? The Teensy audio library doesn't handle that I don't think. You could of course, use two boards. And you should be able to feed the audio from each sound file to only one of the stereo outputs.
Cheers. Teensy dev looks encouraging, looks a little too unstable for me at this stage.
Yes, I was hoping to explore some possibilities with 4 channels.. 4x16bit resolution is probably asking too much. More interested in exploring Wavetable synthesis than just playing samples off SD. From what I've seen with using PCM voicing is crippled and resource inefficient.
With this in mind, i'd be really surprised if the Mega isn't capable of what I'm trying to achieve here. Are there any synthesis libraries that would support 4 outputs?
As far as I know the Teensy audio and neopixel code is pretty stable. I did encounter some bugs when I used it several months back, but the developer is really fast about fixing stuff and he fixed the issues I reported within a week or so and added some features I requested to allow for looping audio seamlessly.
As for the Mega, just because the board costs a lot more and has a lot of pins and a lot of ram, doesn't mean it's much more powerful than an Uno. It's still 16mhz, still an 8 bit mega processor. The Teensy runs at up to 96mhz, is 32 bit, and has a DMA controller which greatly speeds up the transfer of data from the SD card and to the audio circuity.
And 44khz 16bit is 88K bytes per second... x4 = 352K bytes per second.
So could you do it? I don't know. There are seek times to deal with when changing files, though I think it's possible to store the index to jump straight to the file.
I didn't say it was impossible, but it's not going to be easy.
PS:
I know a fair bit about wavetable synthesis - I grew up creating MOD files on my 386, which also ran at 16mhz. It could just barely handle 4 channels of 8 bit audio at a low sample rate, and that was with highly optimized code, and a full 640K of ram to work with.
I know a fair bit about wavetable synthesis - I grew up creating MOD files on my 386, which also ran at 16mhz. It could just barely handle 4 channels of 8 bit audio at a low sample rate, and that was with highly optimized code, and a full 640K of ram to work with.
hahahah badass.. yeah i figured I was asking too much out of this hardware. I just got excited after running the Mozzi library from a single pin off a $8 Nano clone. I really like that library. Till i get a Teensy i'm going to keep explore sync'ing a few boards up and distributing the processing for this project amongst them. Cheers for your advice.
I'm afraid I misunderstood your question. I thought you wanted to read multiple audio files off an SD card at the same time and mix them.
The Mozzi library appears to synthesize effects. And I noticed you wrote in the subject line "not PCM".
You refer to wavetable synthesis though, which is the mixing of "samples", ie, an instrument recorded for a short period and looped, played back at different speeds to create the various notes.
As for whether you can get four channels of PWM audio going at the same time, I'm afraid I haven't done anything with PWM audio on the Arduino. My work with audio has been with DACs. I'm not sure how much work the PWM requires of the processor. Or how much work it has to do to generate those samples, or if it's even generating them in realtime.
I suspect my advice about it being too much for the processor though is still accurate. You may have more PWM channels available on the Mega, but I suspect that PWM audio is fairly cpu heavy and you don't get more CPU power on the Mega.