Sunday, February 27, 2011

open sound control using touchOSC

Open Sound Control is a very cool technology, sort of an updated MIDI. With TouchOSC, you can send OSC messages over the network via WIFI to control OSC-aware softwares, like music recording software. I'm controlling the GForce Oddity software synth within Reaper in the video below.

Recording the audio/video from the mac to Cinelerra on my Linux box was a bit of a pain and took some work:
1) on mac: esd -public -promiscuous -bind mac -trust -tcp
2) on mac: esdrec -s mac | esdcat -s ogre
3) on linux:
gnome-sound-settings: hw
analog stereo output + digital stereo input
digital stereo output + digital stereo input (best for recording)
-input from microphone line in (for voice only) on Mackie Alt3-4
-input from mac monitor of m-audio digital stereo (null device)
-both if both are on Mackie Alt3-4

Alt 3-4 -> ch1/ch2 line in on M-Audio MobilePre

pavucontrol dialog settings
-output device: MobilePre analog speakers
-playback: null device from esound server created above
-record monitor (once Audacity/Cinelerra record monitor enabled):

If you'd like to download the Oddity layout and the Osculator settings, here they are:
Oddity Ipad Touch OSC Layout
Osculator Settings for the Above

More detail on ESD/PulseAudio here:

Wednesday, February 23, 2011

PulseAudio: streaming iTunes from the mac to linux

After beating my head against a wall for the past three days, I finally overcame my mental block and was able to get audio streaming from iTunes to my Linux box. This was to help facilitate the production of a video that will be the subject of my next post.

For this project though, I had to jump through a good number of hoops to get the streaming going. The side benefit was that the project allowed me to educate myself on the benefits of PulseAudio, which I had previously believed to be a piece of crap that only served to bollucks your workstation's audio. Now that I have a better understanding of PulseAudio, I've changed my mind.

Here's an article on why you might want to care about PulseAudio.

Still, the implementation of audio streaming over the network using PulseAudio is somewhat programmer-centric and thus, it is not easy. The faint of heart might choose to simplify their lives and buy one of these Apple AirPort Express with Air Tunes.

This post will give an overview of the tools used to stream audio from a Mac running the Enlightment Sound Daemon (ESD) sound server to any PC running PulseAudio. I'll include links to the more detailed resources, rather than repeating information already available on the web.

Here's an overly simplified signal chain of what's happening to make this work.

On the Mac
iTunes -> Soundflower audio driver -> eSound daemon -> Linux box

On the Linux box
audio stream from Mac -> PulseAudio -> ALSA -> PC's audio interface -> speakers

It's a bit of a funky setup, over-explained semi-coherently here:
and here:

The Process
On the Mac
Prerequisites: iTunes and esound macport
1) install Soundflower, the audio driver that ESD will use
2) setup an ESD sound server using ESD and open a network connection for the Linux box
3) format and forward the sound onto the Linux box

On the Linux box
Prerequisites: pulseaudio, paprefs(pa prefs), pavucontrol(pa volume control), pulseaudio-utils
4) make sure paprefs is setup properly
5) start pulseaudio
6) verify that data is being sent over the network

Detailed Steps
On the Mac
1) install Soundflower and select Soundflower 2ch as your System Prefs -> Sound -> Output and Input
Best explained here:

For debugging purposes, enter the commands below in separate terminals. In both cases, if the commands execute correctly, the command prompt should not return to you.

2) setup an audio server using the Enlightment Sound daemon (ESD) and open a port for your Linux box to connect to. To do this, open a terminal and run a command similar to this:
mac:~ sodo$ esd -tcp -bind [mac]:16001 -public -promiscuous -trust
- accepting connections on port 16001

3) format and forward the sound to the Linux box (make sure PA is running on the Linux box first):
esdrec -s [mac]:16001 esdcat -s [linux]

On the Linux box
4) make sure paprefs is setup properly
There's more detail at this link, but here are the prefs you want to set:

5) start (or kill and restart) pulseaudio
[sodo@ogre ~]$ pulseaudio -k
[sodo@ogre ~]$ pulseaudio --start
[sodo@ogre ~]$ ps -ef grep pulse
sodo 3860 1 0 00:06 ? 00:00:01 /usr/bin/pulseaudio --start --log-target=syslog
sodo 3862 3860 0 00:06 ? 00:00:00 /usr/libexec/pulse/gconf-helper
sodo 5298 5045 0 00:09 pts/4 00:00:00 grep pulse

Here are some other notes regarding pacmd, the command line interface to PulseAudio.

pacmd list-modules
>>> [sodo@ogre ~]$ pacmd list-modules
Welcome to PulseAudio! Use "help" for usage information.
>>> 23 module(s) loaded.
index: 4
used: 1
load once: no
properties: = "Lennart Poettering"
module.description = "ALSA Card"
module.version = "0.9.21"

pacmd list-sinks
[sodo@ogre ~]$ pacmd list-sinks
Welcome to PulseAudio! Use "help" for usage information.
>>> 1 sink(s) available.
* index: 0
state: RUNNING

Once you've verified the daemon is up, look for a sound source in the PulseAudio Volume Control app, Playback tab:

I'm not sure why the stream from the mac is listed as null.

6) verify that data is being sent over the network
First, I look at netstat. Netstat is telling me that my Linux box (.8) on port 16001 has an established connection to my Mac (.12) on port 62356:
[sodo@ogre ~]$ netstat -na grep \.12

Most likely, the Linux box initiated the connection from 16001 and the Mac responded back by opening port 62356. I am not sure how ESD works in this regard either, as the ports identified on the ESD command line would suggest that the Mac should have port 16001 open and not the Linux box. Weirdness.

And make sure access to port 16001 is not disabled on the bloody firewall, either local on each box or a remote firewall between the machines!  I use an exclamation point here because this got me twice when I was setting this whole thing up:

Also, I use iptraf to show me the volume of my network traffic. Here we see the lion's share of data is coming from .12 (my Mac) and .8 (my Linux box) is shuttling a lot less data. Observed over time, I see that the Linux box sends about 1% of the audio stream's data quantity simply to manage the connection:

Lastly, you could take a look at the files PulseAudio keeps open by looking at TCP port 16001:
[sodo@ogre ~]$ lsof -i TCP:16001
pulseaudi 3860 sfrase 30u IPv6 48581 0t0 TCP *:16001 (LISTEN)
pulseaudi 3860 sfrase 31u IPv4 48582 0t0 TCP *:16001 (LISTEN)
pulseaudi 3860 sfrase 36u IPv4 49374 0t0 TCP ogre:16001->mac:50314 (ESTABLISHED)

PulseAudio is quite cool. I think it works a bit more consistently if you have two machines with PulseAudio on both ends. I've tried this and it works very well. Here's an article on how to stream music between two computers using only PulseAudio:

Of course, I needed to stream from the Mac and there is no port of PulseAudio for the Mac. Still good stuff this PulseAudio, once you understand more about it.

Example of this working

Update 2012/12/03
After upgrading both my Fedora box from F15 to F17 and upgrading my Mac from Leopard to Lion, pulseaudio streaming broke.  I had to do the following:
1) on the mac, download and install the latest version of SoundFlower (reboot necessary)
2) on the linux box, download and install pulseaudio-module-zeroconf (above and beyond the normal pulseaudio installation)
3) on the linux box, make sure iptables is turned off (just for testing purposes..reenable with an exception for port 16001).  On Fedora 17, this would be:
systemctl stop iptables.service

Updated Process
Also, I streamlined my process for getting this to work.  Try the below steps in this same order:
1) on the mac, make sure both input and output is set to SoundFlower (2CH)
2) on the mac, stream eSound to a public port, like so:
esd -tcp -bind ::0
3) on linux, make sure pulseaudio is running and that paprefs is set (as above)
4) on the mac, open an eSound stream to the Linux box
esdrec -s ::0 | esdcat -s
5) you should then see a nice volume control named "null" appear under the Playback tab in the PulseAudio volume control (pavucontrol)

Good luck!

Other References
PulseAudio Sink, Streams, Clients

How to: AirTunes without AirPort

network audio between mac and linux 1&2

Remote sound playback through a Nokia 770

Using the PulseAudio sink

PulseAudio Wiki

Linux: exporting audio and video

burning an iso to cd using cdrecord

The past few years, as Linux distributions get larger, I've been burning more DVDs than CDs. So my CD burning chops have lapsed. I recently wanted to fire up a Live version of Fedora 14 for some PulseAudio experiments, so I downloaded the ISO which came CD-sized.

*** Update 3/4/2013 ***
I used Brasero on my Fedora 17 and that burned a copy of Clonezilla quite nicely.  Hooray!  Of course, my clone didn't work, but that's another story.
*** end update ***

First, for convenience sake, I burned the first F12 Live CD using my Macbook's Disk Utility. But when I plopped the CD into my desktop, the boot never finished and the DVD player kept humming for about 45 minutes. Something definitely wrong there. Testing on a second PC yielded the same result.

Researching Google, I found that other people had similar problems if the application they burned the CD with burned the CD at too fast a rate. This causes the laser in the DVDs to have difficulty reading the source data. Guess I'll have to reburn that bad boy. I tossed that CD out and thought I'd give Linux tools a try. I didn't know this next stage was going to turn into a two-hour extravaganza.

Burning an ISO in Linux is Easy, No?
Starting from scratch on my Fedora 12 box, I popped in a blank CD and good old Nautilus CD/DVD creator pops up:

I dragged and dropped the ISO onto the blank CD:

Selected "Burn contents"

And POOF..nautilus immediately craps out with a buffer error in dmesg:
[ 78.116252] Buffer I/O error on device sr0, logical block 0

OK, so I guess I won't use that. Next, I try Brasero:

Same result. OK. So let me try cdrecord, from the CDR toolset. Things seems to go well and then ba-BANG:
wodim: Cannot fixate disk

What the? Thinking the media was bad, I yanked it out and put a new CD in the drive. Same result. OK, this is getting tiresome. Time to Google:

Surfing around does not yield much usable information; however, one post hinted at a drive or BIOS issue. I rebooted and checked the BIOS..nothing far from standard there. So I figured I'd run cdrecord again using the -dummy switch that means "do everything the burn will do, except turn off the laser." So I did this, again using another CD. If you're counting, that's three.

I first ran a scanbus:
[sodo@computer ~]$ cdrecord -scanbus
200) 'HL-DT-ST' 'DVD+-RW GH50N ' 'B103' Removable CD-ROM
201) *
202) *
203) *
204) *
205) *
206) *
207) *

Then I ran cdrecord with the dummy parameter:
[sodo@computer ~]$ cdrecord -v -tao driveropts=burnfree -dummy -dev=2,0,0 Downloads/Fedora-14-i686-Live-Desktop.iso
TOC Type: 1 = CD-ROM

wodim: Operation not permitted.
Warning: Cannot raise RLIMIT_MEMLOCK limits.

scsidev: '2,0,0'

scsibus: 2 target: 0 lun: 0

WARNING: the deprecated pseudo SCSI syntax found as device specification.

Support for that may cease in the future versions of wodim. For now,
the device will be mapped to a block device file where possible.
Run "wodim --devices" for details.
Linux sg driver version: 3.5.27

Wodim version: 1.1.11
Driveropts: 'burnfree'
SCSI buffer size: 64512
Device type : Removable CD-ROM

Version : 5
Response Format: 2

Capabilities :
Vendor_info : 'HL-DT-ST'
Identification : 'DVD+-RW GH50N '

Revision : 'B103'

Device seems to be: Generic mmc2 DVD-R/DVD-RW.

Current: 0x0009 (CD-R)

Profile: 0x0012 (DVD-RAM)

Profile: 0x0011 (DVD-R sequential recording)
Profile: 0x0015 (DVD-R/DL sequential recording)
Profile: 0x0016 (DVD-R/DL layer jump recording)

Profile: 0x0014 (DVD-RW sequential recording)
Profile: 0x0013 (DVD-RW restricted overwrite)
Profile: 0x001A (DVD+RW)
Profile: 0x001B (DVD+R)
Profile: 0x002B (DVD+R/DL)
Profile: 0x0010 (DVD-ROM)
Profile: 0x0009 (CD-R) (current)
Profile: 0x000A (CD-RW) Profile: 0x0008 (CD-ROM)
Profile: 0x0002 (Removable disk)

Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).


Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R96R

Drive buf size : 1053696 = 1029 KB

Beginning DMA speed test. Set CDR_NODMATEST environment variable if device
communication breaks or freezes immediately after that.
Drive DMA Speed: 16168 kB/s 91x CD 11x DVD

FIFO size : 4194304 = 4096 KB

Track 01: data 686 MB

Total size: 787 MB (78:03.12) = 351234 sectors

Lout start: 788 MB (78:05/09) = 351234 sectors
Current Secsize: 2048

ATIP info from disk:

Indicated writing power: 5 Is not unrestricted Is not erasable Disk sub type: Medium Type A, high Beta category (A+) (3) ATIP start of lead in: -11634 (97:26/66)
ATIP start of lead out: 359846 (79:59/71)
Disk type: Short strategy type (Phthalocyanine or similar)

Manuf. index: 3

Manufacturer: CMC Magnetics Corporation

Blocks total: 359846 Blocks current: 359846 Blocks remaining: 8612
Speed set to 8468 KB/s

Starting to write CD/DVD at speed 48.0 in dummy TAO mode for single session.

Last chance to quit, starting dummy write in 0 seconds. Operation starts.

Waiting for reader process to fill input buffer ... input buffer ready.

Starting new track at sector: 0

Track 01: 686 of 686 MB written (fifo 100%) [buf 91%] 49.9x.

Track 01: Total bytes read/written: 719323136/719323136 (351232 sectors).
Writing time: 143.394s

Average write speed 32.7x.
Min drive buffer fill was 87%


WARNING: Some drives don't like fixation in dummy mode.

Fixating time: 22.123s

wodim: fifo had 11331 puts and 11331 gets.

wodim: fifo was 0 times empty and 6563 times full, min fill was 85%

OK! So this time, the "fake" burn worked! That's promising. I then ran the "real" burn (same command without the -dummy parameter) and prayed that it would work:
[sodo@computer ~]$ cdrecord -v -tao driveropts=burnfree -dev=2,0,0 Downloads/Fedora-14-i686-Live-Desktop.iso
Starting to write CD/DVD at speed 48.0 in real TAO mode for single session.

Last chance to quit, starting real write in 0 seconds. Operation starts.
Waiting for reader process to fill input buffer ... input buffer ready.

Performing OPC...

Starting new track at sector: 0

Track 01: 686 of 686 MB written (fifo 100%) [buf 91%] 49.7x.

Track 01: Total bytes read/written: 719323136/719323136 (351232 sectors).

Writing time: 149.247s

Average write speed 31.4x.
Min drive buffer fill was 87%


Fixating time: 22.165s

wodim: fifo had 11331 puts and 11331 gets.

wodim: fifo was 0 times empty and 6552 times full, min fill was 84%.

Ho HO! It worked!! Fabulous. But why?

It seems I made two changes that could have an effect:
1) I rebooted the computer
2) I used a different disc

My bet is on #2. But if you think differently, let me know. I'm just glad to having a working process for burning ISOs to a CD!


Tuesday, February 08, 2011

fun (?) with Enlightenment window manager

As much as I'm used to it, I've finally bored of Metacity, the default window manager in Fedora. Metacity is very nice if you live in the Windows world from 9-5 like I do..the keybindings are very similar. So I decided to upgrade..

For the past three days, I've spent a good amount of time with Enlightenment, a visually striking, light(-er)weight window manager for Linux (and other OSs). The initial install was simple, as Enlightenment is in Fedora's repos:
[sodo@computer ~]$ sudo yum info enlightenment
[sudo] password for sodo:
Loaded plugins: presto, refresh-packagekit
Installed Packages
Name : enlightenment
Arch : x86_64
Version : 0.16.999.050
Release : 5.fc12
Size : 10 M
Repo : installed
From repo : fedora
Summary : Highly optimized and extensible desktop shell
License : MIT
Description : Enlightenment 0.17 is desktop shell based on Enlightenment Foundation
: Libraries. It's highly optimized and provides extensive theming capabilities.
: A Desktop shell means it's a window manager plus a file manager, plus
: configuration utilitys all in one. It works reasonably fast even on old and low
: range computers, providing eye-candy environment.

As a new user, I've found the documentation and resources for Enlightenment to be difficult to navigate. The best source for a new user is to visit the Wiki and choose "User Guides":

Module Installation
Also, module installation is buried in the Wiki:

Update 2011/02/12
I've since installed from source to give me the latest and greatest. The source install was relatively painless downloading the latest E packages from here:

Install the sources in this order:

For each of the sources, after extracting the source code via "tar xvfz ", run:
sudo make install

The only occasional problem that I had was a missing library here and there, like liblua. I resolved this by installing the -devel package. A second problem I encountered was that I needed to set:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
***end update***

Enlightenment is very cool, very pretty, but it takes quite a bit of getting used to especially if you're coming from the world of Metacity.

I think I like it, but the jury is out due to all the configuration I've had to do.

A battle, as always
So here are a few of the problems I encountered, and some workarounds:
1) ALT-PrntScreen didn't work

I had to rebind the PrtScn key to gnome-screenshot, the default Gnome screen capture program.

Binding keys
The key bindings interface in Enlightenment is a little funky. You get there by clicking on the desktop, go to Settings, Settings Panel, Input category, Key Bindings:

The left part of the screen is the key and the right hand side shows the Action you want to perform. In my case, ALT+Print was not in the list, so I first had to Add Binding. Then I needed to bind the key to an action, which was to Launch a Command:
/usr/bin/gnome-screenshot -w

The -w parameter screencaps a single window. If you leave off the -w parameter, your entire desktop will be screencapped to a PNG file. Once I created this key binding, all was well and I was able to capture screens again.

2) ALT-space to maximize/restore windows was not bound to anything

Again, I had to bind this command to a Window:State:

The nice thing about the Maximize window state is that it toggles between Maximize and Restore (or Unmaximize in the Enlightenment world).

3) Icons for some of the programs I selected for my Icon Bar were missing:

I had to go and find individual icons by right-clicking on the space in the icon bar, select Change Icon Properties, select Icon, and navigate to the following directory:

You can also find icons in any of the sized directories; for example:

I had to do this for Google Chrome, gnome-terminal, vmware player and my nvidia settings. I'm surprised that Enlightenment did not automatically find these for some of the more popular programs.

4) the Shelf's icon bar seems to start programs in their own environment separate from your user environment

I found this out because when I started Google Chrome in Enlightenment, Google Chrome no longer respected any of my proxy settings. The workaround was to create a simple shell script that exports my proxy environment variables and starts Chrome:
[sodo@computer ~]$ cat
export http_proxy=http://http-proxy:8080/
export https_proxy=http://http-proxy:8080/
export no_proxy=localhost,
/opt/google/chrome/google-chrome &

I then put that script in the Executable section of the icon. Don't forget the ampersand on the end of the command. If you don't have it, you may see an Enlightenment dialog popup saying something like "Enlightenment was unable to run the application..the app failed to start" when exiting out of the app.

5) The "Remember" feature: remember size, position and settings of a windowed program (in this case, gnome-terminal) plain ol' just doesn't work. Haven't got a workaround for this yet.

Other bothersome things I have yet to fix
1) it is meant as a convenience, but it is irritating when the cursor jumps to the Save dialog
* this was corrected via Settings -> Settings Panel -> Windows -> Window Focus -> Advanced -> uncheck "Slide pointer to a new focused window"

2) desktop switches to the adjacent one when your mouse is next to a desktop's far edge
* this was corrected via Settings -> Settings Panel -> Input -> Edge Bindings and removing the binding for the Right Edge. Erg!!

3) ctrl-shift left or right does not select text, it brings you to the adjacent desktop
* ARGH..still no fix

4) clicking on an application does not make the applications in front of the clicked application disappear..erg!
* this was corrected via Settings -> Settings Panel -> Windows -> Window Focus -> "Click Window to Focus".

5) I miss the GNOME system monitor panel widget. Weep.

It's always a tough row to hoe in the Linux world..nothing great or tasty or beautiful comes without some work.

Keep you posted..

E User Guide
good info on features and keybindings of Metacity:

Tuesday, February 01, 2011

projectM visualizer

I've been looking for a decent visualization software for Linux for quite some time. In my search, I stumbled upon this neat gadget, essentially a visualizer in a box:

I didn't really need all that. But further reading and a hop onto the forums of the Milkymist site gave me a lead. One of the folks on the user boards kindly turned me onto projectM, a visualizer modeled off of MilkDrop.

The good news is that I got projectM running and it seems to work very well:

Of course, the install wasn't without its difficulties. I had a few hurdles, the primary one self-imposed because I didn't want to spend time building from source. I was in luck: my current version of Fedora (12, x86-64) had the projectM libs in the updates repo:
[sodo@ogre ~]$ rpm -qa | grep projectM*

The next limitation was that the audio apps that projectM works with that utilize libvisual were limited in my repository: XMMS and Amarok only. And the XMMS in my repo did not have the projectM-xmms build. Thus Amarok was my only choice.

Once I got Amarok installed, I needed to reconfigure it to send its audio through Pulse and not plain ALSA. I already had alsa-plugins-pulseaudio installed, but I had no way to control Pulseaudio, so I had to install pavucontrol. Once that was done, good to go man! Running my favorite tunes with visuals! I have yet to customize it, but some nice features seem to be possible:

And I am impressed with Amarok. Really fast search, easy to create and navigate playlists, search playlists and configurable interface:

Start projectM

Controls for projectM
m - brings up a menu
f - toggles fullscreen on/off
l - "locks" to a particular preset
y - toggles shuffle mode
n - next preset
p - previous preset
r - selects random preset

F1 - Help menu
F2 - Toggles song title on/off (doesn't work in libvisual or pulseaudio as far as I can tell)
F3 - Toggle preset name on/off
F4 - Toggel rendering info on/off
F5 - Shows fps

Feel free to drop me a line or ask me a question.