Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
WIP: Improve Audio #71
Create a set of improvements for the Express class’s audio features to improve performance and—later—to even volumes across the frequency range.
The existing start_tone method is slow because it generates a waveform prior to playing each tone. I propose to change this.
There is a limit of 350,000 sample points per second. So we can’t use 100 points per sample above 3,500 Hz.
This changed code generates two samples, one for each of two ranges of frequencies.
I added a square wave generator, and it’s much louder and has a much more consistent volume across the entire range (except for the several screaming resonating notes). If you run the program as is now, you’ll hear the square wave.
@tannewt mentioned a new mixer feature coming, but simpler than that (and 4.x compatible) might be to generate multiple square waveforms (just four bytes apiece since they require only 2 values each) at some number of gradations, then add a volume argument to the API. Everything can stay compatible (except that the sound will change).
Also please see my status note in https://docs.google.com/document/d/1suvCpQSY2tuw4wjyZ9G-BFId2iovcZSiA07r3W7gmrs/edit.
I think you are overdriving the on-board audio amplifier or the speaker (or both). You have maxed out the output available from the amplifier, or you are driving the speaker so hard that it is already moving to the limits of its range of motion. It's like you can't close a door any further if it's already closed.