Skip to content

History

project-owner edited this page Oct 17, 2018 · 6 revisions

The main driving force for this plugin was PeppyMeter - the UI application which shows volume level in a form of traditional VU Meter. For a long time this application was relying on the file ALSA plugin which can send PCM signal either to a file or named pipe. The file plugin was sending PCM data to the named pipe and PeppyMeter was reading that data from another end of the pipe and it was displaying the current audio volume level in UI.

Here is the example of ALSA configuration (.asoundrc) for the file plugin:

pcm.!default {
    type file
    slave.pcm "hw:0,0"
    file /home/pi/myfifo
    format raw
}

This configuration makes ALSA system to output signal to the sound card (hw:0,0) and to the named pipe (/home/pi/myfifo) at the same time.

Unfortunately file ALSA plugin has some issues which made problematic the usage of the PeppyMeter with such players and VLC and MPLAYER. The only player which was reliably working with a named pipe was MPD. This is because MPD provides its own implementation of the file plugin. So if that MPD implementation was used instead of ALSA implementation then PeppyMeter was working fine.

Here are the issues of the ALSA file plugin:

  • If you start player (e.g. VLC) which is using file plugin and there is no any app consuming the data on the other end of the named pipe then your player will be blocked and no audio will be output to the sound card. This happens because the file plugin opens named pipe in a blocking mode. In this mode the plugin waits until any app connects to a named pipe and starts reading data. This issue dictates the order of bringing up the player and the app which consumes the data. First should be started the consumer and then player.
  • Another issue is the fact that ALSA file plugin outputs signal in the same format as input signal. That means that the application reading data from the named pipe should be able to detect signal format which makes that app more complicated.

The above-mentioned issues made problematic the usage of any players other than MPD with PeppyMeter. There was a long discussion about possible solutions on diyaudio.com forum.

The ideal solution should be able to send the signal to a named pipe which should be opened in a non-blocking mode. This could allow to use the current VU Meter implementation of the PeppyMeter as it's based on a named pipe. Also the solution should not depend on the input signal format. It should handle all of them.

The custom ALSA plugin ameter was considered as one of the possible solutions. That plugin in turn is based on obscure ALSA plugin - meter. That plugin makes the most of the magic by handling signals in different format and providing API for consuming volume levels. ameter outputs volume level to UI based on SDL library. For the solution required by PeppyMeter the part which outputs signal to the UI should be replaced by the one which sends signal to a named pipe.

While searching for the solutions of the issues another custom ALSA plugin was found - pivumeter. This is open source project which was created for the commercial products sold by Pimoroni company. The company leverages pivumeter plugin in such products as:

pivumeter plugin is reusing the ameter code but instead of showing Volume level in UI they send it to the Pimoroni devices via I2C interface. This is almost exactly what was needed for PeppyMeter. Therefore pivumeter plugin was taken as a base for peppyalsa plugin. The I2C output was replaced by the code which sends signal to a named pipe. Also Spectrum Analyzer functionality was borrowed from the pivumeter plugin. As a result peppyalsa plugin sends volume data to one named pipe and spectrum data to the other.

<<Previous | Next>>