h1

Time allocation

2009-10-07

Here’s how I spent my day:

3pm-5pm
Tutoring introductory algebra. Subtract that from both sides. No not divide, subtract. Ok, now divide both sides… y = mx + b is slope-intercept form.

5pm-9pm
Installing a 32-bit chroot on Arch Linux in order to compile and use nsis on a 64-bit platform. Shell scripts and aliases are your friends. Linux32 seems to provide a transparent way to make it work.

9pm-12:30am
Troubleshooting software installation on Vista. Spent the first 2-3 hours trying various manifest and packaging options and instructing the user to uninstall and install various versions of the Visual C++ 2005 Redistributable file from Microsoft. The only thing that fixed it was using Visual C++ 2008 SP1 in VirtualBox on my MacBook to compile the software, and point to the newer Redistributable. Seriously Microsoft, it shouldn’t be this complicated.

h1

Sweet home West Virginia

2009-10-03

Having been entrusted with yet another infrastructure deployment project, I purchased a SuperMicro barebones system from Newegg along with a Xeon X3220 processor, 8 GB of RAM, and two WD 320 GB SATA-II hard disks. Installing Arch Linux was (as always) a walk in the park, but care had to be taken to set up the RAID properly. The latest version of Arch allows the admin to set up the array, and then write the output of mdadm to mdadm.conf, and doesn’t require kernel parameters– mdadm.conf is loaded immediately during initrd so that no kernel parameters are needed to reload the array.

I was very pleased when the server came online in WV without needing operator assistance. I attribute this to carefully configuring the rc.conf to have the correct IP settings and making sure iptables allowed only SSH access into the machine. Arch Linux isn’t difficult to configure in regard to TCP/IP settings, but it does require some know-how. It isn’t obvious from looking at rc.conf that the gateway settings need to be provided in terms that the route command can directly understand. I referred to my previous work to make sure I had it down cold.

Now that it’s online, I’m spending time tuning and tweaking the system for optimal performance. I realized that some of the code I had written before was very suboptimal, mainly because every page referred to a gigantic >1000 line monstrosity of a PHP class that contained everything needed for the entire management site. I decided to peel layers away from it piece by piece, and I’ve now ended up with several smaller files that are dynamically loaded when they are needed. The common functions live in their own file, and each database table gets its own file to handle validation and presentation. The average load time has dropped significantly as a result.

h1

Pattern Recognition is schooling me in math all over again

2009-09-27

Discriminant functions:

g(x) = x⃗ᵗ W⃗ᵢ x⃗ + w⃗ᵢx⃗ + wᵢ₀

the first is the product of a 1×2 row vector, 2×2 matrix, and 2×1 column vector. This should return a scalar. Leaving x⃗ as an independent variable (e.g. x⃗ = {{x₁},{x₂}}), yields a quadratic equation such as Ax₁² + Bx₂² + (C+D)x₁x₂. The second part gives Ex₁ + Fx₂, and the last part is just a scalar with no variable coefficient attached.

I’ve been using Numpy within Python with Matplotlib and a bit of Scipy in order to do my homework for this class. In creating my functions to take data and crunch it, I’m being very general with the dimensionality of the data set. I have a function that can take in the W⃗ matrix and the w⃗ vector, and produce as its output a list of coefficients of the resulting quadratic, using the size of the list and the order of its elements to encode the independent variables x₁² x₂² x₁x₂ x₁ x₂ and so on.

h1

Windows 7 + memory upgrade

2009-08-25

Didn’t change a thing. Same issues.

Here’s another link about the problems people are having.

But I’m not complaining about the performance increase in Windows XP Pro 32-bit. Using the /3GB switch in boot.ini enables XP to allocate up to 3 GB of memory to an application, instead of its default behavior of splitting the entire RAM between system and applications 50/50. Since my motherboard doesn’t support running memory at 1066 MHz, I’ve been forced to leave my clock settings alone. It seems as though I can tweak my timings to 4-4-4-12 if I increase the voltage to at least 2.0V, but I’d rather have stability at 1.8V running with 5-5-5-15 timings. With a new motherboard, I could take advantage of syncing the memory to the processor at 1066 MHz, but I’ll probably hold off and spend money on a whole new setup since this one performs decently.

One thing I hate is blue screens of death… I’ve gotten a few in the process of tweaking my settings… all of them a stop 0×50 error: PAGE_FAULT_IN_NONPAGED_AREA. I’ve also upgraded my BIOS and made sure my chipset drivers are up-to-date.

h1

Nyquist

2009-08-21

I’ve spent the last 90 minutes reading a bunch of DSP geeks arguing about whether 192 kHz audio is worthwhile at
dsprelated.com. Here are a few references for context:
Nyquist-Shannon sampling theorem, pulse-code modulation.

Many argue that since most humans can’t perceive sounds greater than 20-22 kHz, it doesn’t make sense to encode at a higher rate than twice that; CD audio is defined as 44.1 kHz. While Nyquist states that twice the audible threshold is sufficient to encode audio, he is careful to note that it is sufficient assuming ideal components for reproduction of said audio. Bandlimiting must be ideal during the ADC process to avoid aliasing, and the DAC’s output must use ideal sinc functions and impulses to avoid interpolation error. Increasing the sample rate mitigates the error caused by unideal conversion processes.

There’s certainly a reason that many prefer the sound of vinyl compared to that of a CD, and the term most people use to describe the difference is “warmth”. Because of the way a CD’s audio is encoded, frequencies in the mid range (200-800 Hz) can end up sounding muddy. While a CD is producing a piecewise staircase pattern (one with smoothed step corners under circumstances involving high-end DACs), the information stored on vinyl is a continuous analog curve. To put it in simple terms, the more samples there are, the closer to analog a digital recording becomes – visualize it as the steps being less steep and closer together; more intermediate steps.

The middle frequencies get muddied up because it takes a series of numbers to represent any one frequency, and at any given time in a piece of music, many frequencies must be reproduced simultaneously. Picturing a histogram provides a clear example of what is going on: there are only so many bins that can be defined in the result of a Fourier transform. If a frequency ends up being a non-integer-divisible numerator over the sample rate, the frequency will end up falling into multiple bins of adjacent integer frequencies – quantization error I believe it’s called. By increasing the sample rate, more frequency bins are available, allowing for finer frequency resolution and cleaner reproduction of music, especially music that involves non-equal-temperament tunings.

Another fine example of reduced audio quality is that of the result of MP3 compression. Some may argue that an analysis of the frequency response is identical to that of uncompressed audio, but IMHO it’s not a very good argument. One only has to crunch audio down to a lower bitrate to understand the horrors of MP3 compression and what it does to the signal. That weird tinny sound in the upper frequency range is the result, and can be avoided by destroying (bandlimiting) data in the higher frequency range for better results, but clearly MP3 compression is lossy so any further discussion to the contrary is absurd. MP3 compression “gets rid” of “things we normally can’t hear” by reducing the frequency resolution through Fourier transformation and further quantization.

Ultimately I think it boils down to what people enjoy. Personally I think there’s room for more research in sampling. Not that Nyquist was wrong, but just that most people take for granted the part about things needing to be “ideal”. Multi-channel audio is certainly better than monophonic or stereophonic audio, and I think it’d be nice to see an audio format that stores multiple frequency ranges in different channels – like the subwoofer channel on a DVD… let’s have four channels for four ranges of frequencies: lo-lomid-midhi-hi, and two sets of those to make stereo, or maybe just channel one for the lowest frequencies since directionality is less perceptible at those rates, for a total of seven channels. Or even crazier, what if we separated the channels by odd/even frequencies?

One last thought about the issue of higher resolution: Digitized audio is the sum of periodic functions. Not too long ago I set about to improve my sub-frequency sinewave samples for use in music production. When generating sinewaves at low frequencies in equal temperament, I ran into the issue of period variance. Each sample had to be trimmed differently because the zero-crossings varied. Like a continued fraction or irrational number, some frequencies simply cannot be represented by a finite series of digits.

Some argued that it’s all about the money and taking money from naive consumers, and I think that’s an unfair remark. Yes, the record industry is in fact out to make a profit, and I disagree heavily with some of the legal tactics they’ve undertaken to achieve that goal, but offering higher-resolution sampled audio data isn’t dishonest in the least. For now, analog ultimately wins the quality battle, and one can only hope that more research will be undertaken by those who care equally about empirical quality and listener satisfaction.

h1

Windows 7 RC

2009-08-20

Things I like about Windows 7 include the fact that it tends to load applications and websites quickly, and that it continues to support XP applications.

What I hate about Windows 7 the fact that for music production, it’s horrible. And honestly, the main reason I would consider purchasing Windows 7 is to get more out of my PC’s music making ability. What’s so horrible about it you ask? ASIO inefficiency!

I posted a frank complaint about this inefficiency in detail on Microsoft’s official QnA forum regarding 7 RC, linked here. Basically I have to double my soundcard’s latency in order to get the same reliability. In XP Pro 32-bit, I can easily run 4ms latency on my Firepod without stuttering, although the more samples I load, the harder it has to try to push audio to the device because of memory constraints, soon to be addressed by a 4GB memory upgrade but I digress… In Windows 7 x64, I have to set my latency to 8ms just for it to eek out a sound without stuttering. And what’s worse, is that the CPU idles between 30% and 50%, sometimes even peaking at 70%, when Ableton isn’t even playing anything back! On XP Pro, it typically idles between 2% and 5%. Clearly, something is wrong with this picture. I achieved the same results between Ableton Live 7 and 8 running on Windows 7 x64.

Do I want a shiny new OS that can run Ableton Live on a PC? Yes, yes in fact I do. Would I be willing to pay Microsoft for it? Yeah, I’d do that. Is Windows 7 such an OS? It sure doesn’t seem to be!

I’ll report back when I’ve upgraded my ram from 2GB @800MHz CAS-4 to 4GB @ (hopefully) 1066MHz CAS-5.

h1

Radio station work

2009-08-11

At the radio station, my job is to make sure audio programs are moved into on-air servers. Doing this manually would be inefficient because of the sheer quantity of files, and existing software isn’t customizable enough for my taste. I had run into a brick wall with my existing system of manually updating shell scripts for each download, with each file producing a separate run-log (generated by piping stdout and stderr to a file at runtime), and all this being managed using a bash prompt over ssh.

The first thing I did was create a unifying bash script called mp3dl which would execute the redundant actions given input pertaining to the program to be downloaded, the actions being: using wget/curl/ncftp, converting, copying to on-air server, updating the file’s modification time, and finally removing the temporary download file. Input varies from site to site, as not everyone uses the same file nomenclature, and not all programs get downloaded everyday. Once this was complete, I set it up to be called by many of my shell scripts. It got more comfortable than before, but I felt as though it was still nebulous.

Every executive/manager needs a dashboard/heads-up-display. There existed a heads-up-display, but only a limited dashboard, and by that I mean that, although I could see the file times, and move in files that had already been downloaded or ripped from CD, but I was not able to easily look at log files, query the program’s usual download times, or make changes to the program’s download information. A database solution seemed the only way to go forward from here, since the dynamic nature of the information would be horrendous to manage with plain-text files and local variables defined in scripts.

In the process of building the database, questions naturally arose, some of which had not been given much thought beforehand. This rendered the newer software even more valuable, with unanticipated features such as the system’s ability to determine when a program should be run based on cron-like syntax, eliminating the need to run “sudo crontab -e nobody” each time a change needed to be made to the program’s download schedule. It only made sense to proceed in PHP, because shell scripting quote-escaping syntax gets really tedious after a while, whereas in php commands can be issued simply by using a `backtick operator`.

The development of this project has also had the consequence of teaching me to develop more generic methods. Instead of hard-coding things, I’m using more variables, creating more functions, etc… This has the added benefit of giving me reusable code.

What I haven’t done so much is object-orienting the whole thing, although in a sense I have by creative use of object-structures and arrays. PHP doesn’t care if you cast an array as an object, or blatantly violate scoping by adding a new member-variable to an object. It’s like “hey, no problem man”. Not to get down on Perl, but I find PHP simpler for most things because I learned it earlier. I still think Perl is an amazing language, but I find its syntax and huge symbol-vocabulary a bit daunting.

Oh also, It’s worth mentioning:

#!/usr/bin/php

h1

ejabberd stuff

2009-07-28

I had to invoke a variation on this series of commands today:

openssl req -newkey rsa:1024 -keyout ejabberd.pem -nodes -x509 -days 3650 -out ejabberd.cer
echo "" >> ejabberd.pem
cat ejabberd.cer >> ejabberd.pem
sudo cp ejabberd.pem /etc/ejabberd/ejabberd.pem
sudo chown ejabberd:ejabberd /etc/ejabberd/ejabberd.pem
sudo chmod 400 /etc/ejabberd/ejabberd.pem

h1

OpenStreetMap

2009-07-27

It’s a project worth looking into. http://www.openstreetmap.org is home to the initiative to generate a publicly available and editable map source, not unlike Wikipedia except for maps.

The problem with this project is that it is currently lacking in participants in the USA, and the maps that have been uploaded from census data are very inaccurate. I live in North Carolina so I’ve taken up the task of correcting the roads that I travel to the best of my abilities.

I also bought a BU-353 GPS receiver, which can work with Linux, Mac, or Windows systems. On Mac OS X I’m using the macports-installed distribution of gpsd to interface between the receiver and navit.

Navit has a patch available created by yours-truly which enables showing distances in miles in the user interface (this project too is mostly european supported).

http://navit.sourceforge.net/

h1

Wake-on-LAN

2009-06-12

Having installed my Alix board successfully as the Ethernet router (yeah, still working on the Wifi aspect), and wanting to save some energy and lower the noise threshold in my room, I decided to implement WoL.

Windows XP can be awakened via WoL magic packets, or any packets. It’s like the difference between a heavy sleeper who needs not only an alarm clock but also a knock on the door to wake up, and a light sleeper who will wake up upon hearing footsteps. The heavy sleeper (using magic packets) is what I want because it will stay asleep until I tell it explicitly to wake up. I’ll be putting the computer into standby when I’m not here, dropping my concurrent wattage from 125W to 5W. It may only be a monthly savings of about 5 bucks, but every bit helps.

Using Voyage Linux on the Alix, etherwake can be installed easily using:

apt-get install etherwake

It seems important to specify which interface to send the magic packet, so naturally I created a shell script at /usr/local/sbin/awaken. It looks something like this:

#!/bin/bash

etherwake -i eth1 machine

Now when I need to log into my system at home remotely I can now fire it up from elsewhere.