This a module for the MagicMirror. It can play WAV sounds through your Pi when triggered by other modules.
This can only play WAV files.
Although this has been developed for the Raspbian operating system, any system that uses alsa
would likely work too.
- Read this to configure sound output for your Raspberry Pi
- Make sure
alsa
is installed on your Pi:sudo apt-get install alsa-base alsa-utils
- Adjust your volume output, try 100% first with:
alsamixer
- Optional, test your speaker output:
speaker-test -t sine -f 440 -c 2 -s 1
- Navigate into your MagicMirror's
modules
folder and executegit clone https://github.com/jc21/MMM-Sounds.git
- Execute
cd MMM-Sounds && npm install
to install the node dependencies. - Optional, test the alsa player with a wav file:
aplay sounds/woop-woop.wav
- Add config to your magic mirror config file
To use this module, add it to the modules array in the config/config.js
file:
modules: [
{
module: 'MMM-Sounds',
config: {
startupSound: 'wobble.wav',
quietTimeStart: '23:00', // 11pm
quietTimeEnd: '07:00' // 7am
}
}
]
The following properties can be configured:
Option | Description |
---|---|
startupSound |
The sound to play after module startup Possible values: string
Default value: null
|
defaultDelay |
The default delay before playing the file in milliseconds Possible values: integer
Default value: 10
|
quietTimeStart |
The 24 hour and minute start of Quiet time Possible values: string
Default value: null
|
quietTimeEnd |
The 24 hour and minute end of Quiet time Possible values: string
Default value: null
|
debug |
Enable to display more debug messages in console Possible values: bool
Default value: false
|
This module supports not playing sounds during a quiet time, if BOTH the quietTimeStart
and quietTimeEnd
config
options are specified.
The values for these times are HH:mm and must be in 24 hour format. Examples:
00:30
- 12:30am06:30
- 6:30am14:11
- 2:11pm23:30
- 11:30pm
From another module you can tell this module to play a sound in 2 ways:
In your module:
this.sendNotification('PLAY_SOUND', 'wobble.wav');
or also specifying a delay:
this.sendNotification('PLAY_SOUND', {sound: 'wobble.wav', delay: 1000}); // 1 second delay
buzz.wav
sonar.wav
ta-ting.wav
twip.wav
wobble.wav
woop-woop.wav
Just put your WAV files in modules/MMM-Sounds/sounds/
and reference those files in your other modules.