Tuesday, September 24, 2013

Math, for fun!

My recent attempts at programming have inspired me to try to get better at it. This is by no means new, but I've been working at solving the problems in Project Euler. It's a collection of math problems which you typically have to write some sort of program to solve. After you complete a problem you get access to a forum where people are discussing the problem. In the ones I've seen so far, there's a bunch of people discussing various ways to code the problem and some math genius who solved it just with math theorems. I'm up to problem 5.

Thursday, September 19, 2013

Revisiting Photo Prep for Digital Frames

Previously, I made a Matlab script that  automatically detected the faces in a photo then cropped and resized the photo centered around the faces. Portrait photos were formatted for an 800x600 frame and landscape photos were formatted for a 1920x1080 frame. The script also had the option to disable face detection and use the center of the uncropped image as the center of the center point. I had about 700 photos I wanted to process so I ran the script both with and without face detection enabled. About 70% of the images looked ok with the face detected results, 15% with the image centered results, and 15% with neither.

All in all, however, manually picking out the images from the face-detected and image-centered sets was more work than I wanted to do. There's probably a better process I could come up with, maybe a script that shows both images and lets you pick one, but I don't think I'll ever process that many images in a single time again. The question is what do I do about the 100 or so photos that I have to crop and resize by hand. My solution is the following Matlab script. It borrows heavily from the face-detection version but instead of running the face-detection scheme the user selects a point manually. It took about a minute to process approximately 100 images. I suspect I will just use this version in the future.

% Manually selects central point to crop images for frames
%
% Last modified: 09/10/13
% Aaron Potter

clear all
close all

% set input and output subdirectories
InDir = 'Input';                             % Input subdirectory name
OutDir = 'Output';                           % Output subdirectory name
FilePattern = fullfile(InDir, '*.jpg');
jpgFiles = dir(FilePattern);

% load an example image (single file mode
%File = uigetfile('*.jpg');              % Returns file name as a string 
%InImage = imread(File);                % Reads image file into variable
%img = rgb2gray(InImage);               % Converts to grayscale

for k=1:length(jpgFiles)

% Read in image file
%
% file = 'test.jpg'                     % test file (skips file selection)
% InImage = imread(file);               % Reads test image file into variable

    BaseFileName = jpgFiles(k).name;
    File = fullfile(InDir,BaseFileName);
    InImage = imread(File);                 % Reads image file into variable
    img = rgb2gray(InImage);               % Converts to grayscale

% Determine if image file is Portrait or Landscape
%
% Height = InSize(1,1);
% Width = InSize(1,2);

    InSize = size(img);
    if InSize(1,1) > InSize(1,2)
        InType = 1;                         % Portrait
    elseif InSize(1,1) < InSize(1,2)
        InType = 2;                         % Landscape
    else
        InType = 3;                         % Square
    end

% display the image
imagesc(img)
colormap gray
axis image
axis off

% select point in image
CenterPoint = ginput(1);
close

% testing
%
% display(CenterPoint);
 
% Scale photos depending on type
%
% Portrait photos to 800 width
% Landscape photos to 1920 width
% square photos to 800 width
% crop rectangle defined as [xmin ymin width height]
            if InType==1                                        % Portrait
                OutImage = imresize(InImage, [NaN 800]);
                ScaleFactor = InSize(1,2)/800;
                ScaledHeight = InSize(1,1)/ScaleFactor;
                ScaledCenter = round(CenterPoint/ScaleFactor);
                % shift crop region if cropped region using faces center 
                % would extend past the edge of the image (i.e. images
                % would be too small
                Offset = ScaledHeight-(ScaledCenter(1,2)+300);
                 if ScaledCenter(1,2)+300 > ScaledHeight
                     CropRect = [0 ScaledCenter(1,2)-300+Offset 800 599];
                     %display('option1');
                 elseif ScaledCenter(1,2)-300 < 0
                     CropRect = [0 ScaledCenter(1,2)-300+Offset 800 599];
                     %display('option2');
                 else
                     CropRect = [0 ScaledCenter(1,2)-300 800 599];
                     %display('option3');
                end                
            elseif InType==2                                     % Landscape
                OutImage = imresize(InImage, [NaN 1920]);
                ScaleFactor = InSize(1,2)/1920;
                ScaledHeight = InSize(1,1)/ScaleFactor;
                ScaledCenter = round(CenterPoint/ScaleFactor);
                % shift crop region if cropped region using faces center 
                % would extend past the edge of the image (i.e. images
                % would be too small
                Offset = ScaledHeight-(ScaledCenter(1,2)+540);         
                 if ScaledCenter(1,2)+540 > ScaledHeight
                     CropRect = [0 ScaledCenter(1,2)-540+Offset 1920 1079];
                     %display('option1');
                 elseif ScaledCenter(1,2)-540 < 0
                     CropRect = [0 ScaledCenter(1,2)-540+Offset 1920 1079];
                     %display('option2');
                 else
                     CropRect = [0 ScaledCenter(1,2)-540 1920 1079];
                     %display('option3');
                end
            elseif InType==3                                     % Square
                OutImage = imresize(InImage, [800 800]);
                ScaleFactor = InSize(1,2)/800;
                ScaledHeight = InSize(1,1)/ScaleFactor;
                ScaledCenter = round(CenterPoint/ScaleFactor);
                CropRect = [0 ScaledCenter(1,2)-300 800 600];
                % shift crop region if cropped region using faces center 
                % would extend past the edge of the image (i.e. images
                % would be too small
                Offset = ScaledHeight-(ScaledCenter(1,2)+300);
                  if ScaledCenter(1,2)+300 > ScaledHeight
                     CropRect = [0 ScaledCenter(1,2)-300+Offset 800 599];
                     %display('option1');
                 elseif ScaledCenter(1,2)-300 < 0
                     CropRect = [0 ScaledCenter(1,2)-300+Offset 800 599];
                     %display('option2');
                 else
                     CropRect = [0 ScaledCenter(1,2)-300 800 599];
                     %display('option3');
                end 
            end

% Write resized image to file in output subdirectory
    CropImage = imcrop(OutImage,CropRect);
    InFilename = strtok(File,'.');
    OutFilename = strcat(InFilename,'_f.jpg');
    FullOutFilename = strrep(OutFilename, InDir, OutDir);
    imwrite(CropImage,FullOutFilename,'jpg');           
               
end

Wednesday, September 11, 2013

Audiophile Raspberry Pi

Lifehacker has a post on a audiophile Raspberry Pi distribution. I'm hardly an audiophile but this might be a good way to add audio nodes, possibly of better quality to my Airplay based whole house audio system. The key would be to integrate RAOP, which is reverse engineered Airplay. The same Lifehacker author has an earlier post on using Raspberry pi as an Airplay receiver, but it looks like it's based around XBMC. As is, I'm not sure how well it will work headless.

Another option might be a TP-LINK TL-WR703N Router based solution. It looks like it is possible to add the OpenWRT based firmware with Airplay implemented either yourself, for as a commenter mentioned, an already built system is available for sale for about half the price of a new Airport Express.

Update (9/11/13): A commenter on the Lifehacker post says the RaspyFi distro supports Airplay out of the box. I didn't see any documentation that supports this, but the RaspyFi forum seems to suggest this is true.

Thursday, August 22, 2013

Photo Formatting Program (Updated)

As I mentioned previously, I wanted a program that would automatically format my photos to be used on my digital frames. I'm pretty sure this would be trivial for an actual programmer, but I'll post it anyway.  I have two frames, one is a standard 7" digital frame with 800x600 resolution and the second is a converted 19" LCD monitor operating at 1920×1080 (i.e. 1080p). I don't like the black borders around photos with the wrong resolution so I would like to resize and crop the photos for their intended frame. In this program, portrait photos are resized and cropped for the 800x600 frame and landscape photos are resized and cropped for the 1920x1080 frame. The program finds the faces in the photo, determines the mid point between them, and uses that as the center of the cropped region.

I tested the program in Matlab 2012b (32bit) in Windows. It requires the fdlibmex library for face detection, which should go in the same directory as the Matlab *.m file. As written the program looks for jpg photo files in the Input subdirectory and writes the output files to the Output subdirectory.

Update (8/28/13):
Fixed several bugs and tested on a larger sample size.
  • Images without faces detected are processed, the code crops the middle section of the image.
  • The code now checks that cropped region won't exceed the size of the image, resulting in a cropped image that is too small. There is also an option to disable face detection altogether.

Wednesday, August 7, 2013

Work In Progress: Photo Formatting Program

Because I don't have enough things I'm concurrently working on (and none of this stuff obviously has a deadline), I thought I would work on a program that would prepare my digital photos for my two digital frames. I have a little programming experience, I took some classes in college and have done a little over the years though grad school and work, but I'm so out of practice and do it so infrequently, I might as well be a beginner. Hopefully if I give myself software projects I can improve my skills a little, as well as automate some of the digital grunt work in my life.

I have two frames, one is a standard 7" digital frame with 800x600 resolution and the second is a converted 19" LCD monitor operating at 1920×1080 (i.e. 1080p). I don't like it when portrait photographs are displayed on the frames leaving dark margins on the edges. I tried using the smaller frame in portrait mode, but I don't like how it looks. If I were to use it this way, it still wouldn't be labor free since the as far as I can tell the frame doesn't have a setting to automatically rotate each image. I would have to manually rotate them. Digital camera photos tend to have a 1.33 aspect ratio while my converted monitor has a 1.78 aspect ratio. Previously I prepared photos for this frame by resizing the photos to a width of 1920 pixels then cropping out a section1080 pixels high. For a few photos I cropped out a 1920x1080 section without resizing, but this tends to look too big. My plan is to take the landscape photos and resize and crop them for the larger frame and take the portrait photos and resize and crop out a 800x600 portrait section for the smaller frame.

Here's what I would like the program to do:
  • Decide if a photo is portrait or landscape, and sort them into different directory
  • Resize the images to the appropriate size
  • Find the faces in the images
  • Find the centroid of the faces and put it in the top 1/3 line of the crop region, making sure that nobody is cut off.
  • crop and save the images.
We'll see how my automated cropping plan works.  If it doesn't work out I'll have it pop open a selection window to manually choose a crop region with the defined size. As a feasibility exercise, I was able to get this face detection function working in Matlab. Ideally, I'd ultimately like to have a standalone program rather than Matlab, but that may take considerably longer.

Tuesday, August 6, 2013

Ideas?

Here are some things that I have around that I would like to find a use for. I'm open to suggestions.

Monday, August 5, 2013

To Do List

Last Updated: August 5, 2013

Theater HTPC

Get Blu Ray disc playback working
Set up external programs (Netflix, Hulu, etc)
Choose a remote control setup and configure Eventghost
Get better front speakers
Move noisy AV equipment into the garage (Xbox, HTPC)
Fix screen velvet border
New decor design (curtains, carpet, sofa covers, wall paint)

Den HTPC
Finish setting up external programs (Netflix, Skype, etc)
Find way to return to XBMC easily from external programs
Configure Xbox controller
Install and configure game emulators
AV cabinet for Den

Whole House Audio
Add screen controls for volume
Configure kitchen PC for optional "headless" operation with a "headless" mode button
Add IR control to kitchen PC 
Add more standalone audio nodes
Improve audio node speakers/amplifiers
Configure Airfoil Speakers on HTPCs
Add scanner to kitchen PC

Other Projects
Add bluetooth input to the other car
Garage door open/closed notifier
Rec Room open/closed notifier or motion detector


Friday, August 2, 2013

Kitchen PC: Software Configuration

If there is one thing I've learned about my family computing projects over the years is the software makes or breaks the whole project. It can't take more than a few actions for PC to perform it's task, otherwise it isn't going to be used. My goal for the kitchen PC is for me or my wife to wake the thing up and have it playing music in one click. I don't think I'm there yet, but I'm on my way.

The Guts

As I mentioned in the hardware post for the kitchen PC, with an iOS device you can stream to a single Airport Express, the advantage to using a PC (or a Mac, for that matter) is it is possible to stream to multiple Airport Expresses simultaneously. The most straightforward way to do this is to use iTunes. Of course, using iTunes isn't exactly the most well regarded music software, and using it to stream will limit you to only music you can import or get from iTunes. My preferred technique is to run Rogue Amoeba's Airfoil, which allows you to stream audio from any program to multiple Airport Express units. It largely runs in the background, although you need to open it up if you want to change which Airport Expresses you want to broadcast to, or which application you're broadcasting from. I recommend enabling Airfoil's Instant On feature which can eliminate having to restart the applications to capture the audio in Airfoil.

The weak point with Airfoil, in my opinion, is you need to open it up and switch sources. One way around this is to stick to a single source. I'm trying to only use Chrome-web apps to keep to a single source. Opening a page in app mode eliminates the toolbars and tab markers, so the page looks like a standalone app. So far it looks promising, but I'm not 100% sold on the Spotify web app. Also, I haven't decided what to do with my local music, but I will probably use Google Music once I get it all properly tagged, right now my Google Music is a mess.

To open a page in Chrome app mode create a shortcut with the following (using TuneIn as an example)
c:\Program Files\Google\Chrome\Application --app=http://tunein.com



 The User-Interface

Here's what I'm starting with

I imagine the user-interface for this project will evolve. To start off, I put the start menu at the top of the screen. It looks OSX-esque from an earlier attempt to see if I could make a mock-Macintosh and I can't remember how to undo it. There are also a few desktop icons. Once things are running smoothly I may hide the start menu and task bar and remove the icons. At the bottom of the screen I have Rocketdock running. I have the dock set to always be on top and to not autohide.  I also turned off, minimize to the dock. For icons, I got free Rocketdock compatible icons from Icon Database. I'm using the ICS Optics set by lostintortola.

In the middle of the dock I put the music apps, I think I will primarily use, on the left side I put video apps, I may occasionally use, and on the right side I put miscellaneous other apps. Here they are in order from left to right.
  • YouTube: I have this set to the YouTube Leanback TV-friendly interface.
  • Live-TV application: I have an old HD Homerun on my network, this starts the QuickTV application that will play broadcast TV via an antenna in my attic. It seems like the computer isn't quite fast enough to playback the mpeg2 video stream, but since other video files run decently, that could also be that I had bad reception at when I was testing it. I used CCCP to install an mpeg2 compatible codec.
  • Video Files: This opens a grid stack docklet that shows the contents of a video folder on my NAS.
  • Music: Currently this opens another stack docklet that points to my music folder, but the plan is to have this point to Google Music.
  • TuneIn: This site collects internet-broadcasting terrestrial radio stations. I set up favorites for the local stations we tend to listen to.
  • Spotify: The subscription music service. There is both a web app and desktop app, The desktop app seems to perform better, and gives you more options, but I am going to try the web app again, to see if I get used to it.
  • Skype: This opens the chat program in it's standard window. I don't foresee broadcasting this over the whole house. That might be a little quickly.
  • Chrome: Opens a standard Chrome browser window
  • Airfoil: Opens the Airfoil App
  • Recycling Bin: I'll probably get rid of this as soon as I figure out how to put it somewhere else.
Remote Control

Having the tablet screen is nice, but it's also nice to be able to control music playback remotely. I've installed Remoteless for Spotify on our iPhones to do that, at least with Spotify. Remoteless also has a version only for Airfoil, but so far I primarily use Spotify on this machine and Airfoil control is baked into that version as well.

Tidbits

A few odds and ends to make the system work better.
  • Autohotkey: This project is actually my first experience with this Windows scripting program. On startup, the screen is upside down relative to the user (it's actually right side up relative to the keyboard). I have a one line script that sends Ctrl + Alt + Up Arrow to rotate the screen. I believe this is particular to this tablet. Occasionally I'll do something that will cause the screen to rotate back (so it is upside down to me). I put a shortcut on the desktop and in the quickrun toolbar that will execute this hotkey. I am going to try Hybernate Trigger to try to run this script when the computer wakes up.
  • Standby at night: I set up a batch file (from this source) in the task scheduler so the computer will go into Standby mode at night.
  • TightVNC: It is much easier to configure things on another PC while I sit on my couch rather than trying to use the stylus and a mini-wireless keyboard in the kitchen.
  • Rainmeter: I'm playing around with the desktop customization program, Rainmeter. I'd like to put a clock, weather, and maybe a music player on the desktop. I haven't used Rainmeter before. Years ago I used Samurize, which is similar.
Upgrade Ideas

Software wise, I suspect it's going to take a while to converge on the right user interface. Ideally, I wouldn't have to open up Airfoil. Also, I'd like to set up the desktop to display useful information like the weather.

If you missed it, see my take on the kitchen PC hardware, here.

Tuesday, July 30, 2013

Extending Your Wifi Network with an Old Router

Here's some timely information from Lifehacker. A couple of months ago, the unreliability of the aging Airport express I was using as a wireless access point in my detached garage pushed me into action. Ok, I'm exagerating a little here. I had been annoyed by this for a while, but it was fairly low on the priority list.

I use a wired gateway/router provided by my ISP as the router for my network, then I have two wireless access points, one for the house and one for the garage. In the house I have an Asus RT-N66U (I realize I don't need a router here, but I wanted the option to use it as one in the future). This replaced a Linksys WRT610n, which is a fairly new router, but gave me enough problems that I wasn't happy with it. However, when I set up the Linksys router as an access point in the garage, it works like a champ.

The Lifehacker article primarily deals with setting up an old router as a wifi repeater. Since I ran an Ethernet cable under the house  to each of the access points (fun, let me tell you) I didn't need this functionality. There isn't much to do technically. Go into the setup for each access point using a browser, to make life easier, I recommend connecting to the access point directly using an Ethernet cable. Set it to act as an access point instead of a router and set each access point to broadcast the same wireless network. I have 802.11g and 802.11n 5GHz networks broadcasting, for 802.11g, you want to make sure they are operating on different channels with minimal overlap. For two access points, use channels 1 and 11. I haven't played around the 802.11n settings yet, both access points are set to their automatic values. Generally, my understanding is that there is much less interference possible in this band. I may come back to this in the future.

Monday, July 29, 2013

Kitchen PC: The Hardware


Part of the reason I decided to resurrect this blog was I had a cabinet full of old computers, internet appliances, and AV equipment that I wasn't using, but they work well enough that I really didn't want to dump them in the e-waste.  A couple weeks ago or so, I decided to adapt an old tablet computer to be an under-the-counter kitchen PC. My goal is to have a PC in the kitchen that I can use to control a whole-house music system. I suspect with this project the software is going to change more frequently than the hardware so I am going to divide posts on this project along those lines. I'll talk about the my generation one hardware configuration here, and my first stab at a software configuration in a later post.

This isn't my first attempt at a whole house audio system. I have had some of the music nodes active, at least I have played around with them previously, but in order to play anything I had to go to sneak into the den where the general use computer resides. This is decidedly a low WAF technique. For a while I was using a remote control app on my phone to control the music on my den PC, but this was annoying for me, especially since that computer was often tied up doing other things. I could stream directly from my phone to a single music node, but in order to stream from your phone to multiple nodes, at least using an Airplay based system, you need a PC committed to the task. When I started brainstorming this project, I thought I would hide a PC in the laundry room, pantry, or on top of the kitchen cabinets, but since I was planning on adapting a tablet I thought it might be useful to try to take advantage of the screen rather than hide it and mount it underneath the cabinets and actually use it as a kitchen PC. The spot next to the refrigerator was good since I wasn't exactly sure how this would look and that spot is normally a mess anyway.

Starting materials

The tablet PC I am using is an HP TC4200. I bought this PC of Ebay for about $100 several years ago, when it was already obsolete, for my wife to use for her lectures when she started teaching. I spent another $50 or so on more memory, a new hard drive and (I think) a new battery. She used it for a year or two before she was able to get a new tablet PC. It hasn't done much since then except be my guinea pig.  

From PC Magazine (this tablet PC was quite expensive, back in the day)

The audio nodes are based around first generation Airport Express units. As I mentioned before, I have a few of these. I used them as both a router and an access point over the years as well as units to just serve as Airplay nodes, but recently they found themselves in the future e-waste cabinet. For reasons that aren't clear to me, they seem to develop problems working as a wireless router or access point. It turns out that even when these units are no longer ideal as a reliable access point, they can still work fine as an Airplay output node, especially if you operate them wired into the ethernet network. I've been trying them out in this capacity. Streaming from one of our i-devices to an Airport Express set up in the kitchen.

From Gdgt

For each audio node I would like to have a decent amplifier and speakers. For the amplifiers I'm planning on using T-class units. I already have 2, a Dayton Audio DTA-1 and a Lepai LP-A68. For the speakers I am planning on using pairs of Dayton B652. I have two pairs of these already one of which I am using and the other I am planning on swapping out from another location. I purchased these all from Parts Express. For future nodes my plan is to use Lepai-2020A+ for the amplifier, although I may swap out the amplifier attached to the PC with a higher quality USB soundcard/amp, perhaps a Topping TP30. I'll also try to find smaller, higher quality speakers. I think I may swap out the Polk RM6751 speakers in my theater for something else (thinking Pioneer SP-BS22-LR) and use them around the house.

Initial placement

As I mentioned before, placed the tablet PC underneath the cabinet, next to the refrigerator. The nice part about this arrangement, besides being out of the way, is that when the screen is fully closed, the pc is almost totally hidden from view. Initially I mounted the computer under the cabinet similar to this Lifehacker inspired post using two coat hangers held in place by two shelving screws, but this prevented the screen from folding up all the way, which I didn't like. For my second attempt I used four pieces of 4"x2" industrial strength Velcro, to hold the computer in place, two on each side of the computer. Before attaching the Velcro pieces to the computer I cut them along the access panel seams, in the unlikely event I want to change out the hard disk or the battery. At first I was concerned the PC would fall down during the 24 hours it takes for the adhesive to take hold, so I tried to use some fishing wire tied around the leftover screws to strain relief the velcro. It turned out this wasn't necessary and the Velcro adhesive worked fine without any additional support.


The power brick plugs into the PC in the front, on the side toward the user so I had to reposition the computer on the velcro to make room for the cable and the backside of the lower lip of the cabinet front. I put the power brick on top of the refrigerator underneath the cabinet so it is out of view and plugged it into the outlet behind the refrigerator. I used some masking tape to keep the power cord out of view, but I will probably come back to this with a better solution. The audio amplifier and speakers are top of the cabinet. They are mostly hidden from view but from some vantage points you can see the speakers (part of the reason I'd like to replace them with smaller speakers). I drilled holes through the bottom and top of the cabinet over the refrigerator and routed a power and audio cable to the top of the cabinet. The audio input of the PC is a 3.5mm mini connector (like a headphone jack) and the amplifier has left and right RCA inputs, so I used a long mini-to-mini cable, a mini stereo union, and 3.5mm mini-to-RCA Y-cable to connect the two, although if I had a long enough Y-cable around I would have used only that. The 3.5mm jack is on the side of the computer away from the refrigerator so I routed the cable along the back of the cabinet and again held it in place with tape. I'm still playing around with the best way to do this. I want to keep the cable hidden but it keeps getting in the way of the latch when I try to open the folded-up screen. I may try to route it around the front of the PC as well.

Here's the alcove with the kitchen PC with the screen closed. I should really clean this area up.

Here's the kitchen PC screen open.

That's the starting hardware configuration. I'll talk about the software configuration in a later post. Maybe I'll clean up the pile of paperwork too!

Upgrade ideas
1.  Better speakers.
2.  Integrated USB sound card and amplifier combo.
3.  IR receiver to control with a traditional (i.e. non-iPhone remote).
4.  USB notifier light, something like this. I'm not sure exactly what I would want it to tell me, but I think this would be straightforward to do.
5. Integrate with a motion activated camera to log who comes to the front/back doors.
6. I wonder if I could use this PC as a bluetooth speaker phone?
7. USB thermometer and/or humidity sensor to display or track indoor temperate.
8. Wireless USB thermometer or weather station to display and track outdoor weather info.

Update! (8/2/13)
My first take on the software configuration for the kitchen PC is here.

Monday, July 22, 2013

Airplay in my car (Updated!)

I was inspired by this recent Lifehacker post by Ben Novakovic to try to assemble an Airplay receiver for my car. My car doesn't have a bluetooth receiver while I could probably put something together that used bluetooth, but I liked the idea of using wifi based Airplay better. In Ben's post, he converted a new 2nd generation Airport Express to run off a 5V USB power supply.  I already have several 1st generation Airport Express units, a few of which I wasn't using. Assuming they can also be run of a 5V USB power supply, I would like to use one of them instead. I should note that while this worked great in my garage, I encountered audio problems, probably due to the wifi connection, as I was driving around town.

Hardware Setup

A Google search revealed that power supply failure on the 1st generation Airport Express units was fairly common and there were a few useful posts on converting them to run off USB. Like the 2nd generation unit, the 1st generation Airport Express runs off 3.3V and 5V. The previous posts, used a card reader board to step down the voltage, my plan was to use the step down converter, Ben specified in his post.


 
 The 1st generation Airport Express, with the case ready to be opened. 

As you'd expect from an Apple product, the 1st generation Airport Express is a pain to open. The two plastic halves of the unit are melted together. Rather than use a saw, I used a small screwdriver to break the plastic seam and pry the unit open. Once open the power supply can easily be removed with a single screw.

The open Airport Express, The top half is the power supply.

 The power supply half of the Airport Express with the power supply removed

There are six wires coming out of the Airport Express controller going to a socket connector. Three black (ground), two orange (3.3V) and one red (5V). I wanted to preserve the connector on the  Airport Express controller in the event I wanted to reassemble the Airport to it's original state so I constructed a pin connector that would mate to it. I shorted the same color wire pins together and soldered a couple inches of wire off the black (ground), orange (3.3V) and red (5V) leads. For the USB connector, I sacrificed a USB cable then soldered the red (5V) and black (ground) to the matching pin connector cable. My soldering skills aren't that great, so I soldered a few inches of wire onto the step-down converter leads, black (ground), red (VIN, i.e. voltage input 5V), orange (OUT, i.e. voltage output, 3.3V).  Finally, I soldered connector/USB wires to the appropriate wire lead on the step down converter. I secured the step-down transformer and strain-relieved the wires using kapton tape. There is probably a better way to do this, but I am used to clugeing things with kapton tape.




The wiring harness I assembled. The step-down transformer is on the right the connections to the controller half of the Airport Express are on the left..

The wiring harness secured to the empty half of the Airport Express with kapton tape.

It powers up!


I put the Airport Express back together with white vinyl tape that I had. I also strain-relieved the USB cable.

Software Configuration

The process for configuring the 1st generation Airport Express is similar to the process outlined in the Lifehacker article, although with fewer options. The important point is to set the Airport Express to create a wireless network and to enable the Airplay. I gave my wireless network a clever name.  To set the Airport Express create a wireless network, open up the Airport Utility (I used the Windows version) and click "manual setup". You should be in the "Airport" configuration section. On the Base Station tab, give the Airport Express a name and a password. On the wireless tab, change the wireless mode to create a wireless network. Give your network whatever level of security you feel will make your network safe as you zoom around town. I don't think the radio mode matters, but if you are attempting to do this with an 802.11n capable 1st generation unit (Gen 1.5) you should make sure your network is 802.11g compatible. Next go to the Music configuration section and enable Airplay. Finally save your configuration.

Your phone, or other Airplay transmitting device should be configured as described in the Lifehacker article, but I'll summarize them here. The goal is to connect to the airport express wireless network for music but use your phone's cellular network connection for data. You can set this up in advance either before you start or using a USB auto (12V) power adapter. Directions for an iPhone, summarized from the Lifehacker article are as follows: Go to the wifi settings then press the arrow next to your car's wifi network name to view the setup options.  Change the IP address type to static and enter 10.0.1.4 for the  IP address and 255.255.0.0 for the Subnet Mask. Leave Router, DNS, and Search Domains blank. After some initial road testing I played around with the settings some more. I'll explain them in more detail below. 


Car Integration!

I want to keep my Airport Express hidden in my glove box. I'm not really a car guy, but I figured I could wire some USB ports into the glove box. I also wanted to run a hidden audio cable from the stereo head unit to the glove box where it would connect to my hidden Airport express. Fortunately in my car, the fuse box is right next to the glove box. I used an Add-a-circuit fuse tap and an appropriate fuse to add a circuit and connected it to this 12v-to-5V Step-down voltage converter with two USB ports. there is also a single USB version. I should note that I was pretty nervous about violating my "don't break the car" spousal pledge. This post on a similar car to mine gave me the courage to try.


The wiring harness to convert 12v power from the car to two 5v USB connections

The USB power supply wired into the car. I'm close to violating my "Don't break the car" pledge

For the audio cable, my car's stock stereo has an auxilary input jack near in the center console near the shifter. When I started out on this project, I was prepared to run a moderately visible mini cable (i.e. headphone jack) from this port into the glovebox. It turns out there is an inexpensive cable that plugs into the back of the head unit, replacing the console port with a mini cable that I can run to the glovebox. I imagine there may be similar cables available for other cars.  The stock head unit has the capability to connect satellite radio that isn't being used. In my ideal world, I would tie into that port on the head unit and re-enable the console Aux port. I couldn't figure out how to easily do that, so I may come back to it later. I was also thinking I might open up the stereo again and add a line from the unused console Aux port to the glovebox. Then if I wanted to re-enable the console port, I could swap it easily. If I was really inspired, I could add a switch.

Mazda doesn't make this simple. It's a miracle I didn't lose any screws.

Once everything was connected I tried to hide it in the glove box as much as possible. I mounted the USB power transformer to the side of the glovebox with mounting tape, and the Airport Express on top of a plastic piece in the middle of the box. I also used a few pieces of electrical tape to hold the audio mini cable in place.

Everything connected and hidden away.

When I start the car it takes 30 seconds or so for the Car wifi network to come up. One issue, is my phone can still access my normal home wifi network in the garage. So I have to either switch it manually or start the music playing after I drive off.

 The end result!


Road Testing
In my garage, everything works perfectly, but taking it out for a drive it there seems to be a fairly severe audio skip problem. Doing some searching online revealed that this is a fairly common problem with Airplay through Airport Express Gen1 units, although I've never had a problem with this at home. I suspect driving around town you encounter a range of different 2.4GHz enviroments. I tried a few things to rectify this, and have seen some improvements. First I went into the Airport Express configuration application and into wireless settings. I clicked the Wireless Options button and did the following:
1. Set the wireless channel to 11
2. Set the multicast rate to 24Mbs
2. Enabled Interface Robustness
3. Enabled WPA security (previously, I used an open network)

Some more things to try:
1 It looks like because of car alarms, I might have better luck with channel 1.
2. I might try decreasing the broadcast power.
3. I'll try turning off the bluetooth on my phone. Although I have future plans for this.

If all else fails...
I have a bluetooth USB audio dongle. I'll swap out the Airport for this. Sad panda.

Update
I tried the things on my list and there are still audio dropouts. I ended up swapping the Airport Express out for a USB to 3.5mm bluetooth dongle. The nice thing is it is all still hidden in my glove box. I used this particular dongle with a 12V auto adapter and had all kinds of problems. It works so smoothly now, I think the problem was the power port I was using.

Upgrade ideas: 
1. Tie into the Satellite connection on the head unit and re-enable the front panel Aux input.
2. If option 1 isn't possible, run a line from the front panel Aux input to the glovebox and integrate a switch.
3. I'd like to get a remote control, such as this one, secured to the steering wheel.

Thursday, July 18, 2013

Great moments in home theater computing

I just promised the babysitter that there would be sound for the TV the next time she came over.

I should note that this is my secondary system, not my theater, that we basically only use for the kids or video calls with the grandparents.

Tuesday, July 16, 2013

Work in Progress: In-car Airplay

This is an example of low WAF

There's just some tidying up left to do on this project, and it was a lot of fun. I'll try to write it up soon.

Friday, July 12, 2013

Work in Progress: Kitchen PC


Caution: Work in progress! I'm repurposing an old tablet PC as an under-cabinet kitchen PC. Hopefully when it's done, it will be the brains behind a home brew poor man's whole house audio system a la Sonos. When it's more mature, I'll do a bigger post with links.

Wednesday, July 10, 2013

"New" Phone

This past month my wife and I were finally able to get in sync with our phone contracts. To mark this happy occasion I purchased us both iPhone 5 phones. Of course this means that Apple with come out with a new phone next month. After some soul searching I decided I was ok with this.

Tuesday, July 9, 2013

Back From the Dead

I started this blog to chronicle my, often unsuccessful, attempts to make a family friendly home theater PC sort of AV setup. Unfortunately, through a move and another baby I let the blog slide into the abyss. A few days ago, however, I happened to check the Blogger dashboard and it seems that my measly comatose blog actually gets a few hits now and then. You know what? I still work on a number of projects that might be interesting to someone and let's be honest, an AV setup is never really finished. I'm going to try to bring the blog back!

For the hell of it, let's take a look at the todo list from 2010 and see what still applies. In future posts I'll elaborate on the things that are still applicable.