I have a project where the SD card plays gun-shot sound effects, which may have trailing after-effects like bullet casings or a bolt/mechanism sound.
If the device fires 3-4 consecutive shots, in rapid succession, I'd like a way to layer the same sound effect starting at the beginning of each shot, and 'layered' or 'mixed' in such a way that the final output to the speaker overlaps the sounds and will retain at least the last X amount of samples. 3-4 is probably enough for me. So 3-4 shots, would cause 3-4 bullet casing sounds AFTER also playing the gunshot sounds. Currently, If I just trigger the sound it will start from the beginning and the longer sound effects/ambience is lost except of course for the very last sound playing.
I have done a little searching, and found "AudioMixer4" library, which I think will help do what i'm thinking.
"AudioMixer4 is used in File > Examples > Audio > PlayFromSketch to combine 6 memory players, so all 6 sounds can play simultaneously."
I don't want clipping as each new sound is added to the mix, how can I avoid that? As in, i'd like each sample playing to be just as loud as the other, but overlapping. I don't know if there's a way to do automatic gain or some 'unity gain mixer' for doing what I have just mentioned. Maybe some kind of normalization involved?
Is it possible to have multiple SD card files loaded or buffered so this can work only from SD sound samples? all samples for this purpose will be only 1-2 seconds max.. with the gunshot occuring in the first 200ms, and the shell casing heard at the end.
Thanks for any guidance or links to libraries/tutorials which can help me achieve my goals!
edit: I see on the audio SDWav library entry in https://www.pjrc.com/teensy/td_libs_AudioPlaySdWav.html
"TODO: how many AudioPlaySdWav and Mixer4 objects can realistically run simultaneously (eg, how many "voices" can really be played). This should be tested with good cards (eg, Sandisk Ultra) and some cheap no-name cards that lack good buffer management, even though they claim "class 10" speed."
SO it sounds like I might be able to try this out straight away, and report back here to hopefully update that "TODO" with some more info for other users?
If the device fires 3-4 consecutive shots, in rapid succession, I'd like a way to layer the same sound effect starting at the beginning of each shot, and 'layered' or 'mixed' in such a way that the final output to the speaker overlaps the sounds and will retain at least the last X amount of samples. 3-4 is probably enough for me. So 3-4 shots, would cause 3-4 bullet casing sounds AFTER also playing the gunshot sounds. Currently, If I just trigger the sound it will start from the beginning and the longer sound effects/ambience is lost except of course for the very last sound playing.
I have done a little searching, and found "AudioMixer4" library, which I think will help do what i'm thinking.
"AudioMixer4 is used in File > Examples > Audio > PlayFromSketch to combine 6 memory players, so all 6 sounds can play simultaneously."
I don't want clipping as each new sound is added to the mix, how can I avoid that? As in, i'd like each sample playing to be just as loud as the other, but overlapping. I don't know if there's a way to do automatic gain or some 'unity gain mixer' for doing what I have just mentioned. Maybe some kind of normalization involved?
Is it possible to have multiple SD card files loaded or buffered so this can work only from SD sound samples? all samples for this purpose will be only 1-2 seconds max.. with the gunshot occuring in the first 200ms, and the shell casing heard at the end.
Thanks for any guidance or links to libraries/tutorials which can help me achieve my goals!
edit: I see on the audio SDWav library entry in https://www.pjrc.com/teensy/td_libs_AudioPlaySdWav.html
"TODO: how many AudioPlaySdWav and Mixer4 objects can realistically run simultaneously (eg, how many "voices" can really be played). This should be tested with good cards (eg, Sandisk Ultra) and some cheap no-name cards that lack good buffer management, even though they claim "class 10" speed."
SO it sounds like I might be able to try this out straight away, and report back here to hopefully update that "TODO" with some more info for other users?
Last edited: