[SOLVED] Matrix Voice speaker outs

Hey, this seems to be a fairly recurring topic but I couldn’t get a sense if it’s supposed to work or not. I get audio out from the 3.5mm port on Matrix Voice via ALSA hw:2,1, but I can’t get the same to work via the audio amp speaker ports. What am I doing wrong?

Intresting, I will follow this because I might need in the future.

You could try this:

In here: https://github.com/matrix-io/matrix-creator-hal/blob/master/cpp/driver/audio_output.h
you can read:

enum OutputSelector : uint16_t {
  kHeadPhone = 0x0001,
  kSpeaker = 0x0000


In here: https://github.com/matrix-io/matrix-creator-hal/blob/master/cpp/driver/audio_output.cpp you can read that the default is headphone:
: mute_status_(kUnMute),
PCM_sampling_frequency_(44100) {

Maybe in your code do a:

bus_->Write(kConfBaseAddress + 11, output_selector);

as per the function:

bool AudioOutput::SetOutputSelector(OutputSelector output_selector) {
  if (!bus_) return false;
  bus_->Write(kConfBaseAddress + 11, output_selector);
  selector_hp_nspk_ = output_selector;
  return true;

Thanks! I’m not using HAL, but the kernel modules. However, that did point me out in the approximate direction. The ALSA driver is hardcoded for headphones out, and since it doesn’t expose any mixer settings, there’s no user space method for swapping this. It’s been a decade since I last wrote any kernel driver code…

static uint16_t matrixio_headphone(void)
	uint16_t headphone = 0x0001;

	return matrixio_write(ms->mio, MATRIXIO_CONF_BASE + 11,
			      sizeof(uint16_t), &headphone);

Yep, this swaps to speaker amps. Very noisy out at these settings, and obviously it should be both alsamixer controllable as well as jack autodetect.

diff --git a/src/matrixio-playback.c b/src/matrixio-playback.c
index b828144..03e4c11 100644
--- a/src/matrixio-playback.c
+++ b/src/matrixio-playback.c
@@ -86,12 +86,12 @@ static uint16_t matrixio_fifo_status(void)
        return kFIFOSize - read_pointer + write_pointer;
-static uint16_t matrixio_headphone(void)
+static uint16_t matrixio_select_output(int headphone)
-       uint16_t headphone = 0x0001;
+       uint16_t config = headphone ? 0x0001 : 0x0000;
        return matrixio_write(ms->mio, MATRIXIO_CONF_BASE + 11,
-                             sizeof(uint16_t), &headphone);
+                             sizeof(uint16_t), &config);
 static uint16_t matrixio_flush(void)
@@ -177,6 +177,8 @@ static int matrixio_playback_open(struct snd_pcm_substream *substream)
+       matrixio_select_output(0); // for speaker out hack
        sema_init(&sem, 1);

Maybe it is easy to hardcode the speaker and build the kernel modules from src?

that’d be easy and nasty. I went through the trouble of making the output controllable from alsamixer.


Good work, did you manage to get it working?

Where did you get those speakers and connectors?
I have finally made progress in my audio streamer, which now can receive wave messages from MQTT and play over headphones.
It still needs work, but I’d rather output is over the speaker instead of having to plug in a jack

Sure, it works fine. Pull request was accepted yesterday so you don’t even need to patch - just update your kernel drivers.

The speakers and connectors are from Aliexpress. Basic 3W/4ohm pair and JST PH 1.25 wiring.


Nice work @osma with the pull request. Note that it been on master , it means is included in the unstable package and no yet in the main package. We are making some tests to put it on a official release so it goes to main.

To get the unstable:

echo "deb https://apt.matrix.one/raspbian $(lsb_release -sc) unstable" | sudo tee /etc/apt/sources.list.d/matrixlabs.list

to get the main package after release is done:

echo "deb https://apt.matrix.one/raspbian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/matrixlabs.list

After this :

sudo apt-get update
sudo apt-get upgrade