Friday, January 30, 2009

How To: MPD/MPC with Ubuntu

For a few months now I wanted to try mpd mainly out of curiosity. Music Player Daemon (mpd) is a music server and mpc will be the client used to interact with the server. This how to will look at a localhost server of mpd.

Prereqs: Enable universal repositores in /etc/apt/sources.list

Installing & Configuring Software:
In terminal:
sudo apt-get install mpd mpc paprefs
Next we need to set up Pulse Audio.
Go to System->Preferences->Pulse Audio Preferences
Check "enable network access to local sound device" & "Don't require authentication"
Set up mpd.conf (use your favorite text editor)
sudo gedit /etc/mpd.conf
Add the following to the config file:
audio_output {
type "pulse"
name "Local MPD Output"
In the mpd.conf file, look for "music_directory" and change the corresponding path to your music directory.

Next, we shall build the database. In terminal, type:
sudo mpd --create-db
Finally, restart mpd by:
sudo /etc/init.d/mpd restart
Using mpc: mpd/mpc is higly scriptable so I recommend create some bash files for yourself. You will find the manual to mpc here:

Example: Add Radiohead to current playlist
mpc search artist Radiohead | mpc add
mpc play
Good luck

Further Reading:

Friday, January 16, 2009

MATLAB: Set working path at startup

Many times when MATLAB is started there is a certain program that you want to work on. In order to work on this program, the current directory or path of that program must be changed or set.  This little script here will prompt the user for the module to work on and then add that directory to the path listing. When MATLAB is terminated, that path will not be saved.
% startup.m

% Set Production Directory

% Prompt user for module name
module=input('What module do you want to work on? ','s');

% If module is set, add to top of path. Otherwise don't add
if ~isempty(module)
Place the startup.m in your MATLAB work directory.

Thursday, January 15, 2009

Plotting in MATLAB / Making Plots Look Pretty

Alright, well, here's the scoop. Ditto wanted a v2.0 remake of a post that we started late last year. And, well, I give him whatever he wants. So, without further ado, here's Pretty Plots in Matlab, v2.0.

Using MATLAB to crank through some calculations, but having trouble making the plots pretty? Here's an example that should make a nice looking plot that's ready to be inserted into a report.

X=[1 2 3 4 5 6 7 8 9 10];


set(gcf, 'PaperSize', [8. 6.],'PaperPositionMode', 'auto');
xlabel('my $x$ label','Interpreter','latex','fontsize',16);
ylabel('my $y$ label','Interpreter','latex','fontsize',16)
AXIS([xmin xmax ymin ymax])

Copy, paste, and run, and you should get this (in the directory your current directory):

Alright, a quick rundown.

1. The 'figure' command is letting MATLAB know that we're making a picture with all the following attributes.
2. The 'set gca' command is setting the axes, which have the default handle 'gca', to have a font size of 14 here. This will control the size of the numbering on the axes, as well as the size of the font in the legend.
3. The 'set gcf' command is setting the paper size to 8" by 6", a size I find works well with the default figure output of MATLAB. This will prevent you from having to crop the plot later in a third-party photo editor.
4. The 'plot' command lists the X and Y arrays youd like to plot, 'k^' plots black upward facing triangles in a 'marker size' of 10pt, and filled red.
The 'legend' command puts in your legend, one entry per pair of vectors being plotted, in the northwest position.
5. The 'xlabel' and 'ylabel' commands are pretty straightforward, but the interpretter command displays the labels in the default LaTeX font instead of the MATLAB font. You can use the '$$' pairing to put in maths (the x and y).
6. The 'axis' command sets the range for x and y, just comment this out if you like what MATLAB does.
7. The 'print' command will save your figure as .pdf with the filename you specify in the current directory (where your .m file is). Here, you can always specficy a path if you'd like to save figures in a different folder.

Still to come, using str2num and num2str to automatically number plots that are part of a for loop, or to name output graphs based on input data.

Friday, January 9, 2009

Woah, October 10, 2010

Today I had a mind blowing realisation that any geek would appreciate. Not sure if its well known but it soon will be. The number 42, which in case you didn't know, is the answer to everything, the universe and life, referring to The Hitchhiker's Guide to the Galaxy (see here).

Next year, October 10, 2010 will be here and it can be written as 10/10/10. Or removing the slashes, 101010 which converting from binary to decimal form is 42. Woah. Yeah, woah. Will the answer to life appear on October 10, 2010. I dont know, but someone will make mad money making t-shirts.

I think the meaning will come from the web comic In case you did not know, the ordinal values of xkcd add up to 42.

Get your tinfoil hat ready.

Sarah Palin Pwns the Media Elite




Wednesday, January 7, 2009

The Music of Four Loves Four - 2008

As the 2008 comes to a close, here are the top ten artists that the author's of Four Loves Four listened to.

Ditto's Top Ten
  1. Radiohead
  2. Coldplay
  3. Van Morrison
  4. Pearl Jam
  5. Death Cab for Cutie
  6. Kanye West
  7. Mat Kearney
  8. Counting Crows
  9. The Decemberists
  10. Incubus
Doodah's Top Ten
  1. Tokyo Police Club
  2. Say Anything
  3. Owen
  4. Sufjan Stevens
  5. Someone Still Loves You Boris Yeltsin
  6. Vampire Weekend
  7. Royksopp
  8. The Appleseed Cast
  9. Pompeii
  10. Nada Surf
Mig's Top Ten
  1. Radiohead
  2. Death Cab for Cutie
  3. Christopher O'Riley
  4. Dave Matthew Band 
  5. Broken Social Scene
  6. Snow Patrol
  7. Jack Johnson
  8. Feist
  9. Van Morrison
  10. The Decemberists
A look at the musical tastes of the people who drive this site.
Thanks to all who subscribe.

Monday, January 5, 2009

I'm Boycotting the Progressive Insurance Commercial Girl...

...and so should you. Flo is bothering me just like Joe Buck did in 2004. We all know what happened there. (To refresh your memory)

Just so I know what I'm working against, I did a little detective work. Her name is Stephanie Courtney and here is a list of films and works I will not be watching until Progressive takes my demands suriously and ends these commercials.

Join my Cause.

-migs out

btw, I will be entertaining myself at the Nova/Seton Hall game tomorrow night at the ROCK and then watching the premier of Scrubs on ABC.