Close

Level up - Mixer with wav files brings polyphonic playback

A project log for Adventures in Bleep Bloops with CircuitPython

Experiments with polyphonic pythonic tone playing

foamyguyfoamyguy 01/26/2020 at 20:060 Comments

I played with for a while with AudioOut trying to get multiple sounds playing at once. Eventually I found the Mixer object. This seemed like just the thing I needed to get it working. The sample code uses wav files, but I was able to modify it to work with the RawSample objects from before. It took a fair bit of tinkering but I did get it working and had the correct notes getting played when the correct buttons were pressed. However polyphonic playback still eluded me. When I attempted to play two samples at the same time on different voices the audio went quiet, only returning when I dropped back to playing a single sample only. There was also some extra clicking and other errant sounds that can be heard that ideally we'll want to minimize. 

Not dissuaded by the first failed attempt I decided to take a short field trip through wav file land. After all the mixer example code is using wav files, not RawSamples, perhaps that is part of my issue. This led me to the ABC sound board learn guide which loads up tons of wav files and plays them back when buttons are pressed. I was able to modify this example to use the Mixer object and to my delight I was eventually able to get it to play multiple wav files on top of each other. Armed with this knowledge and modified sample code I headed back to switch the basic synth program to use pre-created wav files instead of RawSamples generated by CircuitPython code. 

Discussions