Home Entertainment Linux MP3 Player
Of all MP3 player programs available for Linux, only mp3blaster has a user interface nice enough for easy control of directories and files to be played. The program supports multiple groups and can interactively select among directories. I decided to use both features. All albums are stored in separate groups, and at any time, I can toggle to directory browsing and select albums hierarchically. The prerecorded voice files are good guides for where you are and what you are doing (see Speech Synthesis).
Given that all your MP3 files reside in some hierarchical directory structure, say at /home/mp3, you need to set the environment variable MP3_ROOT to it. That way, the player will know where the files are, and during the directory browse, it will not allow you to accidentally change directories to one above it. (Remember, we are physically too far from the keyboard and display to fix any mishap.)
The mp3blaster is invoked with the option -x which I added to activate all the remote features.
In order to get full use of the groups features of mp3blaster, you need to manually set the current working directory to the MP3_ROOT directory (where your music hierarchy starts), start mp3blaster and press the F1, F5 keys. The F5 function key will add all directories as groups, thus effectively listing all your albums. Then, you can save the list by pressing the F6 key. So now, you would start mp3blaster with the following syntax:
You can run the program from the init script if you wish, or from an idle console; it doesn't matter, since it will connect to the remote control unit and perform its function in the background. Now, using your remote controller, you are able to browse the directories and play songs. As you will see, the speech synthesis is also coded in to give you feedback.
mp3blaster has two modes of operation: group and file. The group mode of operation accepts the following remote controller keys:
Channel +: selects next album (group). Voice will announce album name.
Channel -: selects previous album (group). Voice will announce album name.
Play/Enter: plays the whole album.
A*B: this key toggles between group and file selection modes.
The file selection mode is more complicated, as we are allowed to traverse directory structure and play arbitrary albums. The remote keys accepted in this mode are:
Channel +: selects next subdirectory. Voice will say its name.
Channel -: selects previous subdirectory. Voice will say its name.
A*B: this key toggles between group and file selection modes.
POWER: switch to groups mode.
Play/Enter: enter the subdirectory and play all mp3 files there.
Shift: step back one directory level.
Play: continue playing after a pause.
Stop: stop playing, return to the mode where we initiated playing.
Pause: temporarily stop playing.
Volume +: increase volume.
Volume -: decrease volume.
Rew: play previous song.
FF: play next song.
Looking at the code, the process of inserting actions into the input loop of mp3blaster can be viewed as somewhat hacky, but most codes are just inserted as keys that would be pressed for an equivalent action from the keyboard anyway. The number of changes is rather large to be printed here, so please see the file src/main.cc for details.
When wanting to browse your mp3 music albums with no computer monitor to guide you, the natural substitute for vision is the voice. I decided to use festival, an excellent speech synthesis package. It is not only a current research development project that is growing and improving daily, but one you can actually use as soon as you install it.
festival can generate speech on the fly, as you type any text interactively, or you can pipe in a text file and it will synthesize it. None of these real-time approaches seems to be fast enough for interactive menu selection. I needed immediate voice response, and generation on the fly introduced a delay proportional to the length of the album names, noticeable and annoyingly long for normal use. The solution was to create a subdirectory containing all voice files to be used during the browsing. This way, the MP3 player program does not have to call festival to generate each album name as we browse it, but can use wave files cached in that specific directory. A drawback to this approach is the disk space taken up for the voice files, but that space is negligible in comparison to the actual MP3 files which amount to 50 to 60MB per album.
Once you generate voice files using the festival program, you can test each of them by simply piping them to /dev/audio. Also, you may want to change diphone for some albums (I found the Spanish diphone to make much better pronunciation for the groups of International albums). Alternatively, you could manually record all your voice files, thus eliminating the need for a speech synthesis program.
The Perl script in Listing 2 is used to traverse all the subdirectories under the MP3 files root directory and in creating all necessary voice files used by the mp3blaster player.
In order to generate necessary voice files, you would run this script every time you add an album or change the directory structure. You can run the script with the option -clean to ensure all old files are deleted before creating a new set.
All voice files are stored in your root mp3 directory under the subdirectory .vocals. They are vocalized interpretations of all subsequent subdirectories, and thus all the album names as well (they are just subdirectories at some terminal node, and they contain only MP3 files).
The Perl script first creates text files (original subdirectory name with the extension .txt). They contain a slightly modified name stripped of all non-alpha characters. This is done to help the speech synthesis program generate more precise sounds. Lastly, the u-law audio files are created based on the content of those files. If you are not satisfied with how it sounds, you can change the phonetics inside the text files, delete the voice file and rerun the script in order to get the optimal pronunciation.
|Hacking a Safe with Bash||Jul 28, 2015|
|KDE Reveals Plasma Mobile||Jul 28, 2015|
|Huge Package Overhaul for Debian and Ubuntu||Jul 23, 2015|
|diff -u: What's New in Kernel Development||Jul 22, 2015|
|Shashlik - a Tasty New Android Simulator||Jul 21, 2015|
|Embed Linux in Monitoring and Control Systems||Jul 20, 2015|
- Hacking a Safe with Bash
- KDE Reveals Plasma Mobile
- Huge Package Overhaul for Debian and Ubuntu
- The Controversy Behind Canonical's Intellectual Property Policy
- Shashlik - a Tasty New Android Simulator
- Home Automation with Raspberry Pi
- diff -u: What's New in Kernel Development
- Embed Linux in Monitoring and Control Systems
- General Relativity in Python
- One Port to Rule Them All!