Use default software mixer in own mixer



as mentioned before, I wrote a mixer for TPA2016D2. However, the volume range is very limited. Especially the lowest volume is still loud. Thus I want to extend my mixer so it also uses the default software mixer. It seems that I only need mixer_ref:

to do things like mixer_ref.set_volume(volume).

However, I don’t know who calls the corresponding setup function. It is not part of the mixer class:

Is the softwaremixer somehow special or can I also create the setup function to get mixer_ref?

$ grep "setup\("
121:                extension.setup(registry)
403:        core.setup().get()
128:    def setup(self, registry):
134:            def setup(self, registry):

154:    def setup(self, element, mixer_ref):
156:        self._mixer.setup(mixer_ref)


However I’m confused by
If you just want to make it positive then use abs(), this isn’t C. But doesn’t this code just prevent you from writing negative gain values? I don’t see how you could hope to use the quieter settings.


I’m sending the data via I2C. And the gain is coded within the first 6 bits. Therefore, I have to convert 8bit negative numbers.
But it is along time since a wrote the code. I will check if everything is correct, as I was always wondering why the volume range is quite small.

So it seems that the softwaremixer is a special instance compared to other extensions. I will check how to get the reference also in conventional extensions.


I was just comparing your code to the adafruit sample library and they just do normal 8bit writes in the range -28 to 30. It’s fine if you need to convert to a 6-bit signed number, I don’t know anything about this board so maybe that’s correct. I’d imagine it would be very obvious as you decreased the volume that it suddenly jumped back up!