Wednesday, October 31, 2012

GIO and GStreamer: making a beep

So, a while ago, I announced that I'd try to write a game, and that I'd be restricting myself to the Gnome SDK.  The game engine -- Project Burro -- has almost nothing to show for three months of Saturdays, but, to be fair the entire GNOME stack is new to me.

The audio part is very different from other systems I've hacked.  The audio part of the Gnome SDK consists of  GStreamer, PulseAudio and Canberra. GStreamer is a multimedia framework.  PulseAudio is a lower level abstraction: receiving raw audio and shipping it to the sound card.  Canberra is a simple library that allow you to play short sounds. To be fair, Canberra would probably have been the way to go if all I wanted was a beep, but, the long range goal is to make an audio engine rather like the Game Boy Advance, and Canberra isn't really built for that.  So GStreamer or PulseAudio are the way forward.

So, step one for me -- my version of "hello world" -- is to create a PCM representation of a square wave and then play it.  I tried GStreamer first over PulseAudio for no particular reason.

GStreamer Hates You

OK. A slight exaggeration. GStreamer is complicated because it is not an audio library, it is a multimedia framework designed to encode and decode every format under the sun, apply filters, mux, demux, encode, decode, recode. It has an underlying framework that generic, extensible, and somewhat self-documenting.

To ask it to do something as trivial as playing a raw audio wave is almost beneath its dignity, and it lets you know that by requiring you to build an entire audio framework to do anything at all.

So, I've suceeded in making a beep.  I'm the greatest coder in the world, ever.  Oh, you're not impressed?  Then I'd like to see you try to extract wisdom from the unsorted pile of knowledge that are the GStreamer docs.  I used GIO to make a stream out of a memory buffer that contained my raw PCM sound data, and then streamed that to ALSA using GStreamer.

Explore my code fumblings after the jump.

Monday, October 15, 2012

Gnome 3 has a non-fallback mode, too!

I like Gnome 3, but, I've always used it in fallback mode.  On every box I've ever had, Gnome Shell dumps into fallback mode, which, if I understand correctly, is due to Clutter being unable to run because of a lack of 3D graphics power.  I've always tried to use free graphics drivers, and they don't always work well in 3D.

This week, I got a new box with a respectable graphics card.  And, much to my surprise, the fancy Gnome 3 Shell in Fedora 17 started working.  As far as I can tell, this graphics driver is a free driver.

And, rather comically, with the 'real' Gnome 3, I've been having the puzzled reaction that most people with better hardware went through last year.  Every question that I had was a question that thousands of other people had already puzzled over, argued, and flamed about.  After some searching I found answers to the common questions.
  • how to turn off the computer instead of just suspend it
  • how to delete a file, since the delete key does nothing
  • why moving the mouse to the top of the screen kept bringing up the activities menu
  • how to change the wallpaper
  • how to maximize and minimize a window
  • how to unminimize a window, since it doesn't minimize to anywhere in particular
  • what happened to workspaces
The funny thing about the nature of search engines was that a question like "how do I power off in Gnome 3" doesn't return an answer to the question, but rather people's solutions of how they solved the problem of power off not being where they thought it should be.

Anyway, after a few hours getting all that sorted, I discovered by accident that if you click on the desktop and then hit F1, it brings up a help file with all the answers I was looking for. LOL.  Why didn't I try that first?

It has been a couple of days now. I'm not a huge fan, but, that's fine.  I'm an old man, and Gnome 3 isn't looking to capitalize on the old man market.  I will say, however, that once I added Xterm and Emacs to the Activities toolbar thingie, Gnome Shell launches them like a champ.  And you kids stay off my lawn!