Tuesday, June 7, 2011

Record sound currently playing to file using ALSA

I've been wondering for a long time about how to record sound which is currently being played on the computer. I know the ALSA framework is powerful enough to do that, and today just proved me so (at least to some extent). It turns out that it's pretty trivial using the file PCM plugin; all you need is a stanza like this in your $HOME/.asoundrc file:

pcm.save {
    type file
    format wav
    slave.pcm front 
    # my main PCM is called front
    file output.wav
}

Afterwards, you can use this save PCM with the tools that understand it, such as aplay or mplayer:

~ aplay -Dsave stuff.wav
~ mplayer -ao alsa:device=save stuff.wav

(for xine users, you may want to have a look at the audio.device.alsa_front_device configuration element).

Funnier, though, is the possibility to use it with programs that don't provide such an easy way to change that, (say, the flash player in a browser ?) via the use of the default PCM specification in $HOME/.asoundrc:

pcm.!default save

After that, all programs using the default PCM will save the sound they play as a save.wav file in their current directory - but nothing stops you from specifiying an absolute directory. Better yet, you may apparently use pipes in stead of the file name, à la popen.

Simply impressive...

... that's what I think of the work of the FTP Team. Three uploads to NEW in one day, all of which processed in less than half a day. Truly impressive !

Many thanks to them !

Tuesday, April 26, 2011

Newer xorg, missing mouse features and xinput

Recent versions of xorg have seen changes in defaults for the behaviour of mice/touchpads, such as third button emulation or edge scrolling suddenly not working anymore. What is worse now is that the corresponding entries in the xorg.conf are now ignored... Wait, wait, don't go flaming the Xorg maintainers, but keep on looking rather. This is where I found out about xinput, the new way to customize/parametrize input devices for the X server. And, lets face it, it beats any customization that could have been done in xorg.conf ! Here's how to use it.

First, you'll have to install it from its own package (xinput), as it doesn't come bundled with standard X clients. Second, you can find out about the devices connected to your X server using:

~ xinput --list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=12   [slave  pointer  (2)]

It is easy to find the device you're interested in (here, say the touchpad entry). Then, you list the properties you can set/get using:

~ xinput --list-props "SynPS/2 Synaptics TouchPad"
[...]
        Synaptics Edge Scrolling (269): 0, 0, 0
 

The list is quite impressive, so I have only shown the one I'm interested in. You see here everything is 0, which probably explains why edge scrolling is disable (I don't have a clue what the actual numbers mean). You can finally change the properties this way:

xinput --set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Edge Scrolling"  6 6 6

This gave me back edge scrolling. I used a similar approach to enable again the third button emulation... What is neat here is that the property names are readable enough, and there's a lot of them to play with. Great !

Tuesday, March 29, 2011

Call for testers: pmount finally supports mounting image files

I've finally come up with a decent way for pmount to support mounting image files using loop devices. This has required a little more work than I thought, since I had to add support for configuration files for pmount, as loopback mounting is by essence insecure, so the support for it had to be user-configurable. I have tried hard to make the loopback mounting as secure as possible, for instance by ensuring that a user cannot bypass file permissions with it, but of course lookback mount still means that a user has read-write access to a mounted FS which can be used to exploit potential weaknesses in the kernel...

I have uploaded a new version of pmount to experimental. Comments, bug reports, exploits are welcome !

Monday, March 7, 2011

Installing a Canon Pixma MP250

I recently acquired a Pixma MP 250 printer, and as I had some difficulties with setting it up, I wanted to share this here. The printer isn't supported as such by CUPS, so I had to dig a little bit. After quite some time, I found debian packages on the Canon website there. Don't fear the mention of i386, amd64 packages are included too. This link is likely to break when the software is upgraded, you should try your luck in the drivers search page should that happen (or for other models). After installing that, CUPS find the connected printer and proposes the PPD for it. The scanner works out of the box with xsane

As a side note, Canon also provides source for the debian packages (the packaged was ITPed ages ago). However, there are some binary-only blobs and I didn't manage to get it to compile from source.

Saturday, February 26, 2011

A praise for TikZ

I have been using xfig for ages to draw figures, and I appreciate it, especially combined with a small script I wrote based on an original idea by Seb Desreux at H&K, fig2ps, that allows painless integration of LaTeX code inside xfig figures.

But recently, it seems that I've hit limitations in xfig. Mainly, if it is great when you want to produce sober figures, whenever you want to do something fancier, including shadings and the like, frustration comes in quickly (since it is purely impossible). I've spent a while looking for a decent alternative, until I had a look again at pgf, which since turned into TikZ. That was amazing. It integrates painlessly within LaTeX and is simply great to work with. Drawing complex diagrams with noes and complex relations between them is trivial. It handles moving the nodes very gracefully, and styling can be done in a CSS-like fashion (though it definitely isn't CSS), which means you can first concentrate on structure and then turn your graph into something nice, while for all the other programs I know, you have to handle both structural and stylistic aspects at the same time.

Sure enough, you need to like the command-driven approach, as mice won't come in too useful here... As a side note, I wanted to express my admiration of Till Tantau's (TikZ's author) mastery of (La)TeX: TikZ can be seen as an interpreter of a simple graphical language written in pure TeX, which is, according to my humble experience with dirty trick in TeX, is simply amazing. Many thanks, Till !

Sunday, February 6, 2011

Doxygen for Ruby, first working draft !

Quite some time ago, I complained about the lack of support of Ruby in doxygen, the ultimate code documentation generator (at least for me). Time has passed, and I had some time and motivation to look into it and write a patch. The code is now reasonably mature to be used, altough it still lacks many features, and, most importantly, testing.

That's why I pushed my git-svn private repository to github today, in order to get enough testing to integrate it into mainstream doxygen. It's current features:

  • Code structure parsing is complete in principle, it should extract all the classes/method definitions. If not, please use the tracker at github, posting a full example showing the problem.
  • It features a rdoc compatibility mode (on by default), in which it parses all comments (outside method definitions) and interprets most of rdoc's markup.
  • The inner code parsing and cross-linking is very ineffective for now; most cross-links are currently not performed. This is one thing on which I'd like to work some day... Although you're welcome to have a go at it if you wish !

You can get an opinion of how it looks on the code of ctioga2. The doxygen configuration file can be found there.