Archive for February, 2006

Record Streaming Audio with Linux: Part I

Tuesday, February 28th, 2006

Update: For a better solution check out this newer post

I happen to enjoy listening to Glenn Beck. The problem is that I can’t receive his weekday shows where I live. Even if I could receive his weekday show over the air, I wouldn’t hear most of it because I am busy working all day.

The solution: cron and mplayer with a little help from sox.

Here’s a sample script:

BASH:
  1. #!/bin/bash
  2. # Use mplayer to capture the stream
  3. # at $STREAM to the file $FILE
  4.  
  5. DATE=`date +%d-%b-%Y`  # Save the date as DD-Mmm-YYYY
  6. YEAR=`date +%Y` # Save just the year as YYYY
  7.  
  8. # Where you want the file saved.  Leave off file extension
  9. FILE=/home/shawn/PodCasts/Glenn_Beck_Show_$DATE
  10.  
  11. # The following file should be a playlist file such as .asf or .asx
  12. # You can also create your own file with a URI and put it here
  13. STREAM=/home/shawn/bin/glenn_beck_show-6-9am
  14. DURATION=3.1h # enough to catch the show, plus a bit
  15. #DURATION=200s # a quick run, just for testing
  16.  
  17. # For the id3v2 Tags
  18. AUTHOR=“Glenn Beck”
  19. ALBUM=“104.7 WPGB-FM Pittsburgh”
  20. TITLE=“Glenn Beck Show - $DATE”
  21.  
  22. # Capture Stream
  23. /usr/bin/mplayer -really-quiet -cache 500 \
  24.     -ao pcm:file=“$FILE.wav” -vc dummy -vo null \
  25.     -playlist $STREAM &
  26. # the & turns the capture into a background job
  27. sleep $DURATION  # wait for the show to be over
  28. kill $! # kill the stream capture
  29.  
  30. # remove gaps and convert to mono
  31. sox $FILE.wav -c 1 $FILE-silenced.wav \
  32.      silence 1 -0.9 2% -1 -0.9 2% ;
  33. rm $FILE.wav ; #remove original capture
  34.  
  35. # Encode to .mp3, mono 32kHz 32kb/s, and tag the file
  36. lame -a -m m –tt “$TITLE” –ta “$AUTHOR” \
  37.      –tl “$ALBUM” –ty “$YEAR” –vbr-new -V 9 \
  38.      –resample 32 $FILE-silenced.wav $FILE.mp3 ;
  39. rm $FILE-silenced.wav # Remove the raw audio data file

Once all of the variables have been set, make this executable and make a cron job for it.
crontab -e

Here’s an example for starting at 6am every weekday:

CODE:
  1. 0 6 * * 1-5 /home/shawn/bin/glenn_beck.sh>& /dev/null

Notes

  • The basis for this script is the one found at this Linux Journal article.
  • You need at least SoX version 12.17.9 for the silence filter to work properly.
  • MPlayer should be fairly recent. Older versions have a different syntax for pcm (wav) audio output
  • This solution still requires huge amounts of disk space (~500MB/hour). I am still experimenting with using named pipes (fifos) to do all of the file processing in RAM and only output the final encoded file to the disk.

Neglecting to Choose The Right

Monday, February 27th, 2006

This was on the side of the a buiding on the walk from the S-Bahn to the Stake Center in Stuttgart. CTR is a well known LDS abbreviation for “Shoose The Right.” October 2002.

CTR Graffiti

links for 2006-02-27

Monday, February 27th, 2006

Mine is the Church of Emacs?

Sunday, February 26th, 2006

Written on the chalkboard at the beginning of Elder’s Quorum meeting was the follwing:

  • What is vi?
  • What leads to vi?
  • What are the effects of vi?
  • How do I avoid vi?
  • Do I have vi?
  • How do I get rid of vi?

Which is better, vi or emacs? That is the age old debate among *NIX users. I never thought the Church would establish any doctrine on the matter, and for a minute I was second guessing myself.

As it turns out the teacher was just being lazy and “vi” stood for “vain imaginations.” I think I like my original notion better.

Tokers on the Top Floor

Friday, February 24th, 2006

We periodically receive notes from the manager slipped through our doors informing us of upcoming events and of problems that tennants and the staff may be having with the behaviour of other tennants. Usually these are somewhat humorous. The humor is generally not found in the content of the letter, but rather in the manager’s complete disregard for spelling and language use conventions. However, this was not the case today.

Here is an excerpt from the letter we received in our doors today:

Marijuana Letter

We frequently get letters informing us that certain tennants are putting things on their balconies that are not allowed even though we have nothing on our balcony. Most of these letters are delivered to every tennant in the apartment complex, but this letter was only delivered to tennants in our building. I have never smelled the marijuana, so they must be on the other side of the building or far away. I have often heard people walking around after midnight, though. I just assumed the guy above us worked an evening shift and came home late. All I can say is that these issues haven’t bothered us at all.

Now if we can just keep people from leaving the bass turned up when they watch TV at one in the morning.

No Good Deed…

Wednesday, February 22nd, 2006

Post It NoteMy Uncle just recently moved into a different apartment complex. I won’t say that it’s new, because it’s not. I was helping him by setting up his computer for him and getting him to the point where he can get on “the intarweb.” He told me that I could park anywhere. Furthermore, he told me when we got there which parking space to park in. I was there from around 8:00pm until almost 11:00pm. The computer is really slow and they just moved in so there are boxed and things everywhere. Most of the time spent was trying to find all the components and cables and get them plugged in somewhere. After a long while I was finally able to return home. It had not been a fun experience.

As I was walking out to the car I felt a little uncomfortable, almost as if someone were watching me. When I got to the car I found a Post It note affixed to the driver’s side window which read:

You are parked in my space. Do not park here again or you will be towed.

All I have to say is, “Thank you.” I can only imagine how the rest of the night might have been had I come out to find my car gone. I only wish that I knew which car belonged to the kind soul who spared me the frustration and the $200, because I would have put a post it on their window saying:

Sorry for the inconvenience that I may have caused you by parking in your spot. Thanks for not ruining my day!

Your Friend

Rock and Suck

Tuesday, February 21st, 2006

In a blog posting at his website, rentzsch.com, Jon discusses a scanner that he recently purchased for his computer. He describes its overall quality in the following way:

It’s not rock, but it’s not suck. Apparently, nonsuck is the best the scanner market currently offers.

This is one of the most efficient descriptions of any product’s quality that I’ve ever seen.
The verbs to rock and to suck (meaning to be good or to perfom well, and to be bad or to perform poorly respectively) have been “nouned” here. Usually Nouns get “verbed” in English, but here we see the opposite. A more standard rendering of this sentence would be: “It doesn’t rock, but it doesn’t suck.”

Flash and History Don’t Mix

Thursday, February 16th, 2006

I am taking a History class that has an online component and is taught in a computer lab with Internet access. The teacher lectures while everyone looks at myspace, checks their email and basically does anything to avoid actually learning. This can be distracting, but is bearable.

Enter Flash games.

Imagine the sound of a spacebar being hammered between ten and twenty times a second followed by hushed jubilation in the form of, “Yes!” and, “All right!” Next, picture this happening every thirty seconds for ten seconds at a time. Now picture this going on for five minutes with no obvious signs of stopping! Something had to be done.

I tried for three of these attempts to give him the crook eye, but he wasn’t looking in my direction. He was too busy concentrating on irritating me to notice me staring at him. By this point I noticed the student next to me shaking his head incredulously. Knowing that I wasn’t the only perterbed pupil in the classroom boosted my confidence. It was at the precise moment that I felt this surge of assertiveness that keyboard crusher happened to glance in my general direction. Without any conscious thought I let loose with a crook-eyed head shake with shoulders hunched and palms turned upward immediately joined by mouthing the words, “What are you doing?”

The student to my left that had once shared in my frustrated head-shaking immediately went stiff and almost magically removed himself from the situation. It was his reaction that started my paranoia. Had I overdone it? The kid in the row behind me didn’t look amused by my harsh reproof. He was sitting next to at least one good friend who had seemed to be enjoying his role as spectator until I ruined it for him. I began to feel ill. I only knew one other person in the class, and she was nowhere near me at the time, so I emailed her. I was hoping she might check it, see my dilemma and offer backup in case of emergency. She was too busy learning to find my plea for help.

The hammering of the keyboard had stopped, but the hammering in my head was just beginning. I thought I had met my objective, but I was still not able to concentrate and learn. I waited until class was over and pretended to be working on an assignment at the computer. I was fearing eye contact as I worried that that may act as a catalyst for the punks who saught my suffering. I waited five long minutes. I mustered the courage to chance a look back; they were gone.

I packed up my belongings and was on my way. I watched my back during the long walk across campus and to my car. I will see them again on Thursday. I only hope that they don’t remember me.

I am considering starting a petition requesting the removal of Flash plugins from all lab computers.

Trip to the Zoo

Saturday, February 11th, 2006

My Dad, my half-brother Matthew, Krissy, and I went to the San Diego Zoo today. I hadn’t been there since I was in grade school. That was when our school got banned from returning because some kids got caught stealing stuff in one of the gift shops. The thing I remember most from that day was spitting from the Skyfari and trying to hit the tiger pen. We were mad that the designers of the tiger’s enclosure had made the most comfortable spot for the tiger to rest as for away from the viewing glass as possible and he was out of view the entire time we were there.

Today was better, although the food was disappointing. It tasted like school cafeteria food, but cost as much as a pretty good restaurant. I know that was imitation cheese, you guys. Why be so cheap?

There were enough interesting things to see that it was worth it. There was the peacock that wasn’t in its cage, the amazing floating trashcan lid, and the monkey that would never stop moving. There were also a couple of huge snakes, but all I could a get a picture of was the glare off the glass on the cage.

If I go again, I’ll bring my own food. It was a lot of fun, and even though it’s a bit pricey at least I know I’m helping to keep the place running. Living so close to attractions like this is great, and I take it for granted too often.

Krissy’s New Glasses

Thursday, February 9th, 2006

Krissy finally got her new glasses after almost a month of waiting for the factory to get done making the lenses for them.  They are a new type of lens apparently based on technology developed for laser eye surgery.  There is a device that measures the irregularities of your retina and then lenses are made that correct for these unique differences.  The brand name is iZon and there are only a few optometrists around the country that are using this technology.

Of course, I know that what you really want to know is, “What does she look like in glasses?”  Well… something like this!

I like it.