I've done a lot of stuff with speakers in my projects, trying to get the most out of small and large speakers.
There's several things you'll want to pay attention to.
First there's the audio file itself. Have you maximized the peaks? Run it through a compressor? You can double the volume this way.
Next, there's the impedance. If you've got a little 3W amplifier running on 5V, then a 4 ohm speaker (or two 8 ohm speakers in parallel) is going to allow twice the current to flow, and you will get twice the power out of it.
Then there's the sensitivity. All other things being equal, the sensitivity, measured in decibels, is how efficient the speaker is at converting power into volume. A 6db increase is a doubling in volume.
But the sensitivity does you no good if the speaker isn't good at reproducing the tones you want. Look at the datasheet for the speaker if you can find one for a graph. Or at the very least, there should be a range for frequencies the speaker can reproduce. You can hear between 20Hz-20kHz, so you want as wide a range as possible. For a tiny speaker, if it can go down to 300Hz then that's great. But make sure it isn't limited to something like 8Hz on the high end if you want the best audio quality.
Finally, there's the size of the speaker. You'd think the other factors above would tell the whole story but in my tests, that doesn't seem to be the case. A 3" speaker is going to sound a hell of a lot louder than a 1x2" speaker, even if the latter is listed as having a higher sensitivity, and has half the impedance. Perhaps this is partly due to the larger speaker's ability to play lower frequency sounds, but it seems like it's across the board that a larger speaker will be louder with the same power input.
Unfortunately if you're buying your speakers on Ebay instead of a site like Digikey or Mouser, then you're not really going to have much of this data to base your decision on, and you can't really trust what's there anyway.
So, I'd suggest getting a speaker from Digikey and paying close attention to the specs, or else it's just going to be pot luck what you get. That said... the 5pc auction looks like that would be the louder speaker. But neither looks like a very good speaker. Not a fan of the mylar.
I made him using a Teensy 3.0 + audio shield, an ultrasonic sensor, a 3W amplifier, a TLC59711 breakout, and a regulated 5V wall adapter.
This is more a proof of concept than a final product, as the kits I mention will actually use a new board I'm designing which will be based on the Arduino Pro and Wave Shield. That board is being designed as part of a commission, but I figured since it was perfect for talking paintings like this, (it will be long and thin and have the controls and SD card slot and power jack all along the bottom and have an amplifier and LED driver and DC motor controller built in) that I might as well sell a few spares. I needed something to demonstrate the concept to potential buyers though, and I had the Teensy already, so I based the prototype on that. I'll probably set up a Kickstarter in a couple weeks to take preorders once the design of the new board has been nailed down. It's not going to be marketed as a Vigo circuit, but as a generic Halloween prop controller. And , since it's based on the Arduino Pro it will be programmable by the end user in the IDE using an FTDI or ISP programmer.
The code for Vigo is actually somewhat sophisticated.
I didn't want him to repeat the same audio file every time he started up, so I seed the random number generator with the time and distance at which he first detects something blocking the sensor.
I also will have limited ram to work with when I switch to a 328, so I needed a way to select a file to play back that didn't require me to store all the filenames or indexes in ram, since there are over a hundred phrases. So I count the number of files on startup, and then choose a random index and just read the directory again until I've read that many files.
To prevent him from repeating the same phrase several times which the random number generator alone was wont to do, I keep a running history of the last 10 indices played in a ring buffer and compare new selections to that before playing them.
Vigo also does not trigger the instant you step in front of the sensor, but waits for the opportune moment to startle the unsuspecting victim... between 3..5 seconds. If the user walks away before that time elapses he won't trigger. And after he has spoken, he will wait a longer period before he begins pinging for victims again.
As for his glowing eyes, those work by detecting the maximum amplitude of the waveform since the last check, and he performs this check 30 times a second. The brightness is squared to make the fade linear, and I multiply the peak value by 4 because the volume of the audio files is at half to begin with and I wanted even softly spoken lines to light the eyes at almost full brightness.
You could add the modified wiring.c to the sketch folder. I just ran a quick test to confirm it gets compiled and linked OK. I haven't tested making any change to the file to prove that the definitions in this copy take precedence over the ones in the standard wiring.c, but I think they probably do.
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.
And modify the line in the wiring.c function in the Arduino program files hardware\arduino\cores\arduino\wiring.c : #define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(1 * 510))
My question is, can I just throw that #define in my main program after my includes, possibly #undef -ing it first, and have the compiler use that new definition everywhere, or am I going to have to alter wiring.c, which I'd prefer not to do because the modification will affect other projects and will inevitably be lost and forgotten when I back up my project folder?
I'm aware there are other timers I could use, but Timer 1 is in use by the audio library, and both Timer 1 and Timer 2 share pins with the SPI interface, and I want to drive a motor controller with PWM and that means I need two PWM pins for forward and reverse control, and if I used pins from two different timers then both have to be set to the higher PWM speed, and I'm sure I'd regret that decision later if I need Timer 2 for something else.
It's more than fast enough but where did you get the 20khz PWM spec ? That's not an arduino PWM frequency so where is it from ?
20khz is a typical PWM speed when controlling motors. It's fast enough that the PWM won't cause the motor to buzz at an audible frequency. While it's true that the default PWM speed on the Arduino is 490hz you can change a few registers to get much higher PWM speeds.
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.
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.
Not sure what I should be looking for on the timing specs, but the worst number I see there is 800ns which I think means the switching speed can be faster than 1mhz.
Seems like a nice chip. Might have to be careful in motor selection even if it will work though. I notice one motor I just checked has a stall current of 2A. It would be bad if the part were to blow if the motor was prevented from turning.
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.
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.
Daisy-chained power isn't a series connection. Hmm... if you have ever done house wiring, outlets are daisy-chained.
So you mean parallel then, but are asking if I have a single 5V rail which the amplifier and LEDs are branching off of.
Not exactly. I have a 5V plane on top, and a ground plane on the bottom which are broken up by traces, and the analog portion of the circuit is isolated from these except at a single point about a quarter of an inch from where power is siphoned off for the LEDs.
Anyway. Yes, you'll have to use a large bypass capacitor with a low value resistor on power running to your audio circuits.
These boards are the size of a credit card. They have to be small to fit where they need to fit. I can't stick a giant 4700uF capacitor on there, and that seems like a horribly inelegant solution anyway.