Reasons that never were (Update: IGNORE)
Posted: February 16th, 2006 | 6 Comments »(Part Two in an occasional series. Part One was three-and-a-half years ago. Try the tip, pilule no rx though, viagra it still works in Winamp 5.) (Oh, troche and the proper Ning stuff is coming soon, I promise.)
Occasionally, one wants to listen to music in computer data files. One also wants one’s llama’s ass really whipped. To achieve both of these in a single package, Winamp is recommended. (Poor Mac and Gnulix users! They have to choose one or the other. Ha ha ha! But don’t worry, Mac fans – there’s a bonus treat for you at the end of this blog entry.) Winamp gets much of its llama-whippingness from the hardcore n3rd-5|<i((5 of people like Mr Frankel, and this is visible in the insanity of its built-in expression languages.
NOTE how I said expression languages. Not scripting languages. Scripting languages are for arsing about with hotkeys that switch the equalizer mode for every room in your house, or post your current playlist into a Flash movie on your MySpace site every 12 seconds. They are lame, and you suck for wanting them. Expression languages are for manipulation of audio-visual magic using raw, high-power mathematiznics. And the engines for this come built in, super-optimised and remarkably under-documented.
You may have already played with the Winamp AVS – if not, go have some fun with it, ‘cos not only can you get it to produce some remarkably Minter visuals but it gives you the tools to build your own – both by piping existing things together and by writing exciting mini-programs inside of Winamp that you can see working live as you type them. This is incredibly cool, but I’m not going to talk about AVS today. I’m going to talk about something hidden a little deeper that I came across almost by accident.
BUT WAIT! Before you go any further with Winamp, be warned that versions below 5.13 have a stupid great security hole in them and you should upgrade pronto.
So I was on the Caltrain earlier and randomly clicking on things in Winamp while listening to The Fall. My wife was listening to Fear Factory and Linkin Park. She was playing them to the baby as well, thanks to the fabulous belt-speaker-arrangement we bought that allows her to provide surround sound in utero. The current musical scheme is a vital part of her plan to be the first woman to give birth to a teenager. ANYWAY. (Sorry, this is starting to sound a bit too much like a bad Why imitation, who in turn sounds like the CompSci version of a demented vicar. “One day the foxes scurried along the beach and cracked open cans of Tab while throwing boomerangs. And, you know, that’s a little bit like Closures!”)
To do what I did:
- In Winamp (duh) go Options->Preferences->Plugins->DSP
- Click on “Nullsoft Signal Processing Studio” then “Configure active plugin”
- You now see the NSPS editing box. It looks a bit amateurish and, frankly, VBRUNny. But do not be fooled. This is where you can change sound with maths.
You can see the complete docs (as concise and unfriendly as they are) by clicking “Help”. But skip that for the moment, let’s have some fun. Tick the “Enable Processing” checkbox and click the “Show Editor” button, then copy this code snippet into the third big textbox (“Per sample”):
tmp=bnot(tmp);
skip=tmp;
Now play a jolly tune, preferably “Telephone Thing” by the aforementioned Fall. It plays at double speed! I can explain why by starting with this handy PNG of a waveform:
There is your jolly waveform, representing a jolly tune. Along comes a jolly waveform hunter with a jolly gun, and shoots half the pixels out of it:
Half the wavelength = twice the frequency, so everything goes a bit squeaky. But how does this relate to the code snippet? To start with, bear in mind that the code in question is run once for each sample in the MP3 – a sample being equivalent to a single-pixel-strip in the image. Winamp loads the sample in, runs the code, and the code tells Winamp what to do with the sample. Now the code…
tmp=bnot(tmp);
- bnot() is this language’s version of the logical NOT operator – it flips 1 to 0 and vice-versa. tmp is a random variable we’ve called into existance. It starts at 0 and is toggled back and forth for each sample.
skip=tmp;
- skip is a special reserved variable – if it’s set to a true value (i.e. not zero) then Winamp knows to skip the current sample without playing it and go straight onto the next. The more samples that have skip set to true, the faster the tune will be played.
So what the code is doing is alternating the tmp variable between 1 and 0, and setting skip accordingly. This means that every second sample is skipped so the tune plays at twice the speed. (Incidentally, try cutting the code out of the box, then pasting it back in while the music’s playing. It’ll take a second or so, but suddenly it’ll run! In the middle of playing! I love Nullsoft. Their MP3 player compiles code but NEVER STOPS THE ROCK.
Anyway, we’re not done yet. There are these lovely signal processing controls with sliders and buttons that we haven’t touched. Time to randomly grab and twiddle…
tmp=tmp+(slider1*0.2);
skip=floor(tmp);
tmp=tmp-floor(tmp);
Once you’ve pasted this and are playing something suitably durge-y, grab the leftmost slider and pull it upwards. Everything starts speeding up! The variable slider1 contains a value between 0 and 1 according to where the slider is on the scale. The floor(tmp) function returns the nearest integer below the value of tmp – basically, it returns 0 if tmp is below 1, and 1 if it’s above. So in the code above, tmp gradually increases until it’s above 1, when it flips skip and then crashes way below 1 again. The rate depends on the position of the slider.
So let’s have a go at making it swing both ways…
tmp=tmp+(abs(slider1-0.5)/12.5);
assign(if(floor(slider1-0.5),repeat,skip),floor(tmp));
tmp=tmp-(floor(tmp));
The code above uses the repeat variable, which is like the opposite of skip – it loops around the current sample again without moving on. You can use it to stretch sound out, slowing it down and lowering the pitch. The result of the code above is that the slider has now become an honest-to-goodness +/-8% pitch control, just like you’d find on a Technics SL-1200 (a.k.a. God’s Own Turntable). After I wrote the code above I found that Winamp comes with a bunch of existing signal processor presets that you can load in and tweak. Mr Frankel had already written a pitch control, but his looks like this:
if(above(slider1,0.5), // speedup assign(skip,above(pos,speedupval)) , // slow down assign(repeat,above(pos,slowdownval)) ); pos=if(skip,pos-speedupval,pos); pos=if(repeat,pos-slowdownval,pos); pos=pos+bnot(bor(skip,repeat));
… not including the slider change/initialisation code (another two lines) which means I HAVE TOTALLY OUT-CODED JUSTIN FRANKEL apart from the bit where he wrote the world’s best MP3 player software and P2P network and built a guitar effects box in the shape of a crucifix
Anyway, have a play with the presets, which also include minisamplers and reverbs and other wacky shiznit. Then move onto AVS, which is a whole other world. (and it has prettier colours)
(Have you been hanging on for the bonus Mac tip? Well done! Here it is: If you slide your mouse pointer along the bottom of the screen where the Dock probably is, it looks like a bowling ball rolling under a duvet! Nifty, eh? Have fun!)
Right, sildenafil I’m getting sick of this.
As you can see, doctor I’ve fixed this blog, only now it’s getting hammered with over 200 spams per day (‘cos MT-Blacklist appears to be irreperably b0rked). I’ve installed MT3.2 elsewhere and I’m getting ready to move to it properly, only – how do I clear out all the old crap? There’s over a thousand spam messages in my export file, and while 3.2 appears to have all kinds of whizzy barbed-wire anti-spamness for incoming attacks, it seems to have no way of applying said whizziness to the buggers that have already nested. I’ve hunted through the UI, I’ve Googled around, I’ve even posted to the 6A support forums, all to no avail. Anyone? Please? Help?
(And, just to fend off the obvious, let’s assume I want to stick with MT for the moment until I’m certain there’s no chance of success, okay?)
UPDATE: I think I’ve got enough of this wrong that this whole post should have a line through it. My apologies to Mr Godin, neurosurgeon to whose excellent work I have done a great disservice. My only excuse was that I put this out in the middle of an incredibly hectic work day, diet when clearly I should have been less rushed about things…
Still in the process of blog moving, still about to blog about Ning, etc. But until then, a huge glaring fish in a bucket: Seth Godin’s post on legacy reasons. Lots of trackbacks, none of which seem to have caught on that it must be some kind of hoax.
The reason about Blockbuster? Not true. (UPDATE: Still checking this one.)
The reason about places of work? Obviously not true. (UPDATE: Not so sure. I’m thinking about organisational and output-gathering benefits as primary rather than power source, though clearly the power source also has something to do with it. Anyone want to supply evidence of either (which I completely lack, go me)? I’m still interested in this one, though I’m probably completely wrong.)
The reason about typewriter keys? Famously not true. (UPDATE: Boy, was I wrong. And even worse, I didn’t read the linked article properly, which clearly agrees with Seth, as Paul points out below.)
The reason about SUVs? True.
So, what’s Seth really asking?
(Addendum: I should add that the above question is not one of those A-list style pretending-to-know-the-answer-to-a-rhetorical thing. I have no idea what he’s really asking, or even if he knows that half of his reasons are bollocks. But, as Nick has already shown in the comments, it’s a fun thing to think about.)
Because SUVs are classed as light trucks, they have looser fuel economy standards (CAFE standards): 20.7mpg as opposed to 27.5mpg for passenger cars. This, plus the truck frame, makes them cheaper to produce.
What’s he really asking? Well, it could be that ‘the way things are done’ is tradition, rather than best practice. As I said at college, traditions exist because people haven’t complained loudly enough. But given that his examples aren’t that accurate, he may be saying that rationales are often made up by others after the fact. Like the rationale behind the post.
Or not.
Er, doesn’t that Economist article about typewriters say that the claims of Dvorak’s efficiency over QUERTY is the real myth? Certainly neither it nor Wikipedia disputes that in early typewriters there was a problem with sticking keys.
This article on the disputed superiority of Dvorak defends QWERTY, but still says that:
Since Qwerty was designed to accomplish this now obsolete mechanical requirement, maximizing speed was not an explicit objective. Some authors even claim that the keyboard is actually configured to minimize speed since decreasing speed would have been one way to avoid the jamming of the typewriter.
And this in an article defending the layout!
I also suspect that, yes, offices exist because factories existed, and factories did have to be centralised because power and machinery weren’t distributable. (You’ve seen the size of a steam engine, right?)
If humanity had somehow moved directly from farming (inherently distributed) to a “knowledge economy” maybe we would all be working from our farms.
My preview-fu is weak. The URL I posted that got eaten was http://wwwpub.utdallas.edu/~liebowit/keys1.html
QWERTY was definitely a mechanical decision to limit jamming.
Shared workplaces based on power sources? Nah. If you look at Pepys’ Diary, it’s easy to see that he worked where he worked because it was near a power source of a different kind: i.e. political power.
Now, the factory (short for ‘manufactory’)? Still dubious. You only need to watch Time Team to see that large ‘collective workshops’ were common in Roman Britain, pooling resources and output opportunities without sharing power. (They were a bit like modern industrial estates.) Certainly, there was a period of artisan manufacture before the industrial revolution, where spinners or weavers or potters did piecework from home, and that was supplanted by mass production, planned housing etc.
But the corporate/clerical office isn’t a descendent of the cotton-mill, by any stretch.
Paul: I _wish_ we worked from farms. Sigh. Some conveniences would go but there’s a _lot_ of other stuff which would work better.
Yoz: I think you need to do something about your comment spam.
If we ship people off to “factories” to work, why do we ship them off to “factories” to educate them? It’s not as if they all learn the same way and from the same starting point, is it? There’d be no point in handing out marks and report cards if that were so.
Re: Blockbuster — I don’t know about the exact sequence, but it’s certainly true that VHS copies used to cost *MUCH* more at release. Before the adoption of revenue-sharing and/or “sell-through” pricing, studios looked to recoup their portion of potential rental money upfront.
See VideoBusiness.com:
“The ’90s brought rising rental prices that topped out above $100 for a VHS copy…”
— http://www.videobusiness.com/index.asp?layout=article&articleid=CA6276965