From now on I will be posting my thoughts and deeds to bytopia.org. This blog remains as is with all its content and can be safely linked to.
Thanks and see you again in Bytopia!
One of the greatest features of GNU/Linux is that it shares the Unix amaziness of having lots of small tools which are easily combined together via stdin/stdout. Today we are going to explore the possibilities of playing MP3 files with these little tools.
The simplest command to produce sounds is aplay. Prior to ALSA there was a device called /dev/dsp to which you could redirect any file and it would “play” it. Now aplay acts similarly. Try executing this:
cat /path/to/wav/file | aplay
You can also send to aplay something that is formally not music at all. Consider an example:
cat /bin/bash | aplay # Sounds a bit like dubstep at the beginning!
As you can see aplay will play any binary stream you pass it.
This tools is a free (and less buggy) version of mpg123 which is a dead simple MP3 player. First of all you can provide it with a list of files to play:
mpg321 one.mp3 two.mp3
You can also supply the call with a playlist (which is a simple list of files to play):
find *.mp3 > 1.pls # Will scan the current dir for MP3 files and write their names to 1.pls mpg321 -@ 1.pls
mpg321 also supports playing from the stdin and writing output to the stdout.
Right now you have a working MP3 player that you can pause (by pressing Ctrl-Z in the terminal. To bring it back type fg %1), play next track (by pressing Ctrl-C once. Pressing Ctrl-C twice in a rapid succession will stop the playback).
We hadn’t seen anything cool so far. OK, a poor man’s “player” controllable from shell. Can you do with it anything at all? Well, perhaps there are things you can. For example, streaming the songs directly to another computer via ssh!
cat /path/to/mp3 | mpg321 -w - - | ssh firstname.lastname@example.org aplay
-w – option to mpg321 means that it would output the wav file to the stdout. The second – tells it that it should take output from stdin. The output from mpg321 is then passed via ssh to the aplay command which would play the stream on the remote machine.
Nothing stops you from translating a series of tracks. Actually MP3 files are excellently concatenable with mere cat:
cat *.mp3 | mpg321 -w - - | ssh email@example.com aplay
This kind of “translation” has its weakness – you can’t stop it from the target machine unless putting down sshd or sound system (Did I say weakness?:)). To achieve some better feeling of an Internet radio you can use netcat:
cat *.mp3 | mpg321 -w - - | nc -l -p 9999
From the other machine just type the following:
nc first.machine.ip.address 9999 | aplay
Voila! You have an Internet music radio going directly to your audio device. How more awesome can this be? Well, there are certain limitations of the approach: it doesn’t support multiple connections and doesn’t restart listening the port after the client disconnects. These issues are fixable but are probably close to rewriting icecast:).
Here’s the command to make our Radio “Netcat” a bit more spicy:
find -name "*.mp3" | sort -R | sed -E 's/(.+)/"\1"/' | xargs cat | mpg321 -w - - | nc -L -p 9999
If you execute it from the root of your music folder it will find all MP3 files, shuffle them, wrap names into quotes (this is done to fight a xargs issue) and stream it to our 9999 port.
The final neat feature
If you can redirect anything to aplay why can’t you send it… your own voice! It is as simple as this:
arecord | ssh firstname.lastname@example.org aplay
arecord will record the input from the microphone and send it via pipe directly to the sound output of the target computer. Execute the same command from the second computer (with first computer’s IP address respectively) and you’ll have a super-secured overly-hipster voice connection (still with a couple of seconds lag:)). Who needs that crappy Skype anyway?
I covered a little bit of examples of what you can do provided a certain knowledge of Linux tools and a certain amount of stupidity. Hope this proves useful to somebody and remember – I was using this before it was cool!
Good evening to everyone. Today I want to guide you step-by-step through the process of writing a game of Tetris in Clojure. My goal was not to write the shortest version possible but the concisest one and the one that would use idiomatic Clojure techniques (like relying on the sequence processing functions and making a clear distinction between purely functional and side-effect code). The result I got is about 300 lines of code in size but it is very comprehensible and simple. If you are interested then fire up your editor_of_choice and let’s get our hands dirty.
The whole code is available here.
Recently I stuck with a problem that had no solution around the Internet. Raidcall, a voice chat program exclusively for Windows, refused to start under Wine referring to the absent (or wrong) library dnsapi.dll. I found out that there is such library in ./wine/drive_c/windows/system32/ folder. Replacing this file with original dnsapi.dll taken from Windows distribution didn’t help. So after that I opened winecfg, switched to Libraries, found dnsapi.dll (native) in the list and just removed it (Remove button is on the right). Then, after applying the changes, Raidcall finally started.
Hope this would help somebody.
Being a proud owner of WM8505 mini netbook I spent a lot of time tinkering with it. This little noname machines ship with preinstalled WinCE that is very close to useless, so as soon as I got the netbook I installed this Debian distribution on it. And since I don’t want my time to be utterly wasted I decided to start a series of post concering different aspects of using Linux on WM8505 netbooks. In this very entry I would talk about different browsers available for this installation, from the simplest to the most functional. So, let’s start.
Note: most of the information here should be also relevant for VT8500 netbooks.
This is still another widget to make awesome users’ life easier. This widget parses your Emacs org-mode files and shows you a pretty to-do list and a calendar. Here are listed its features:
- shows on-demand calendar with marked schedules and deadlines
- shows schedules and deadlines ordered by date
- supports multiple org-files
If you are interested visit this link for further information about installation and usage.
After switching from Gnome\KDE many Awesome newcomers feel the lack of mouse-operated controls (like desktop icons or quick launch shortcuts). This widget tries to satisfy their needs providing an ability to put iconed shortcuts on the taskbar.
Widget uses *.desktop files for specifying the shortcuts, so you don’t have to edit your configuration file in order to add another shortcut. Also, you can just give the widget your Desktop folder as the folder for shortcuts, and they all will appear at the taskbar without any additional efforts.
For information about widget configuration and for the widget itself visit https://awesome.naquadah.org/wiki/Quick_launch_bar_widget