Skip to content

Commit

Permalink
Update instructions and build to work with the Pimoroni Speaker PHAT
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarev0k committed Feb 5, 2018
1 parent 5900119 commit d32d17c
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ SRC := $(shell pwd)
all: devicetree
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules

modules_install: devicetree
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
install: devicetree
cp hifimems-soundcard.dtbo /boot/overlays/
cp hifimems-codec.ko /lib/modules/$(shell uname -r)
cp hifimems-soundcard.ko /lib/modules/$(shell uname -r)
depmod -a

clean: clean-local
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) clean
Expand Down
50 changes: 44 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
# AoSC Driver Simple I2S Hifiberry and ICS43432 MEMS

> Use Hifiberry-dac / Adafruit Speaker Bonnet and ICS43432 / SPH0645 I2S MEMS Mic simultaneously
> Use Hifiberry-dac and ICS43432 simultaneously
Tested with:
- [Adafruit I2S MEMS Microphone Breakout](https://www.adafruit.com/product/3421)
- [Adafruit I2S 3W Stereo Speaker Bonnet for Raspberry Pi](https://www.adafruit.com/product/3346)
- [Adafruit I2S MEMS Microphone Breakout](https://www.adafruit.com/product/3421) and [Pimoroni Speaker PHAT for Raspberry Pi Zero](https://www.adafruit.com/product/3401)
- [Adafruit I2S MEMS Microphone Breakout](https://www.adafruit.com/product/3421) and [Adafruit I2S 3W Class D Amplifier Breakout](https://www.adafruit.com/product/3006)

Based on googlevoicehat-{codec,soundcard}.c by Peter Malkin.

## Install

This was installed successfully on Linux 4.9.35+ on a Raspberry Pi Zero W
This was installed successfully on Linux 4.9.59+ on a Raspberry Pi Zero W

```sh
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install raspberrypi-kernel-headers

git clone https://github.com/GothAck/hifimems-kmod
git clone https://github.com/Sarev0k/hifimems-kmod
cd hifimems-kmod

make KERNEL_SRC=/lib/modules/$(uname -r)/build all
sudo make KERNEL_SRC=/lib/modules/$(uname -r)/build modules_install
sudo make KERNEL_SRC=/lib/modules/$(uname -r)/build install
```

## Boot Config Setup
```sh
sudo sed -i "/^#dtparam=i2s=on$/ s|#||" /boot/config.txt
sudo sed -i "/^dtparam=audio=on$/ s|^|#|" /boot/config.txt
echo "dtoverlay=hifimems-soundcard" | sudo tee -a /boot/config.txt
```

## Audio Config Setup
```sh
sudo cp asound.conf /etc/asound.conf


# Reduce speaker pops and crackles
sudo apt-get install pulseaudio

sudo sed -i "s/^.ifexists module-udev-detect.so\b/&.ignore/" /etc/pulse/default.pa
sudo sed -i "s/^load-module module-native-protocol-unix\b/& auth-anonymous=1 socket=\/tmp\/pulseaudio.socket/" /etc/pulse/default.pa
sudo sed -i "/^#load-module module-native-protocol-tcp$/ s|#||" /etc/pulse/default.pa
sudo sed -i "s/^load-module module-native-protocol-tcp\b/& auth-ip-acl=127.0.0.1/" /etc/pulse/default.pa
sudo sed -i "s/^load-module module-suspend-on-idle\b/& timeout=604800/" /etc/pulse/default.pa

echo "autospawn = no" | sudo tee -a /etc/pulse/client.conf
echo "default-server = unix:/tmp/pulseaudio.socket" | sudo tee -a /etc/pulse/client.conf

echo "exit-idle-time = -1" | sudo tee -a /etc/pulse/daemon.conf
echo "resample-method = ffmpeg" | sudo tee -a /etc/pulse/daemon.conf
echo "enable-remixing = yes" | sudo tee -a /etc/pulse/daemon.conf
echo "flat-volumes = no" | sudo tee -a /etc/pulse/daemon.conf
echo "default-sample-rate = 48000" | sudo tee -a /etc/pulse/daemon.conf

sudo cp pulseaudio.service /etc/systemd/system/pulseaudio.service
sudo systemctl daemon-reload
sudo systemctl enable pulseaudio
sudo reboot
```
43 changes: 43 additions & 0 deletions asound.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pcm.!default {
type asym
playback.pcm "playback"
capture.pcm "capture"
}

pcm.playback {
type plug
slave.pcm "dmixer"
}

pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave.pcm "speaker"
bindings {
0 0
1 1
}
}

ctl.dmixer {
type hw
card sndrpihifimemss
}

pcm.speaker {
type hw
card sndrpihifimemss
}

pcm.capture {
type plug
slave.pcm "microphone"
}

pcm.microphone {
type hw
card sndrpihifimemss
channels 2
format S32_LE
}
14 changes: 14 additions & 0 deletions pulseaudio.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=PulseAudio Daemon
After=sound.target network.target
Requires=sound.target

[Install]
WantedBy=default.target

[Service]
Restart=always
Type=simple
PrivateTmp=false
ExecStart=/usr/bin/pulseaudio --realtime --disallow-exit --no-cpu-limit --log-target=syslog
ExecStop=/usr/bin/pulseaudio --kill

0 comments on commit d32d17c

Please sign in to comment.