-
Notifications
You must be signed in to change notification settings - Fork 6
How It Works
There are several ways to make inter-process communication. One of the easiest ways is a named pipe. This type of pipe is very similar to the anonymous pipe. The main difference is the file descriptor. That descriptor allows to get the reference to the particular named pipe. Even though the named pipe has a file descriptor it doesn't use a file system for communication. It's using memory buffer instead. This is especially useful on the platforms where file system is based on a flash memory with a finite number of the read-write cycles (e.g. Raspberry Pi).
PeppyMeter leverages named pipes for receiving volume signal from the audio player. The communication over named pipe doesn't need any additional library. That makes PeppyMeter a simple and slim application. peppyalsa ALSA plugin should be installed to make PeppyMeter functional. That plugin outputs volume level signal to the named pipe. PeppyMeter reads that signal from another end of the named pipe.
The image below shows the data flow in PeppyMeter.
There is a separate thread in PeppyMeter which reads volume data from the named pipe, splits it into two channels and places data for each channel into the dedicated queue. On the other end of each channel queue animation thread picks up that data and feeds UI with new volume level.
There are two algorithms used to convert stereo signal volume levels to mono volume level.
- Average. This is default algorithm. It creates the value by calculating average between two channels: (L + R)/2, where L- PCM value of the left channel, R - PCM value of the right channel.
- Maximum. To create mono volume level this algorithm picks up the maximum value between the left and right channels.