PopUp Killer… and why I’m not a millionaire

PopUp Killer

If you had access to the Internet circa 1995 then you may know or at least, have heard about, a program called PopUp Killer.
At that time, it was the only solution to prevent pop-ups from disturbing your Internet experience.

Back in the day we didn’t have spam, or web worms/viruses — we had pop-ups. Basically, these were just new instances of a browser displaying some sort of advertising so when you visited a particular web site, it would launch one or more instances of the browser with small windows containing ads.
These weren’t harmful (at first) and you could just close them “by hand”, but they were extremely annoying since a single web site could display a series of pop-ups by simply visiting different sections of the web site, you could soon end up having all sorts of problems; does anyone remembers the dreaded “Insufficient Windows System Resources” error?

As time passed, these pop-ups became more and more aggressive so that when you would close one, another one would popup, as they were intercepting the onUnload event to perform additional actions as you interacted with the browser window.

Overtime, this situation became unbearable, so I decided to do something about it and this is how the first ever pop-up blocker was born.

[…]

Core Audio for .NET

The story of why and how Core Audio .NET came to be, in three chapters

Chapter 1: The Good Ol’ Audio Mixer API

Up until Vista, Windows used the same API from Windows 95 to let third-party programs consume a series of resources (exposed by the drivers) that allowed them to discover and manipulate all the available settings on a sound card.

This API was known as the Audio Mixer API and it relied on the ability to first, enumerate all the available mixers (references to the sound cards, as exposed by their drivers) and then query them for the lines they exposed. Each line then had its own set of objects, called controls, which were a representation of the physical properties on the sound card, such as the volume of the microphone, the mute state of the CD line, etc.
A control could also expose a series of items that provided access to some advanced feature on the sound card, such as a loudness setting, or peak meter, or some other resource that was exposed by the sound card’s driver.

Sounds simple, right? Well let me tell you that it was anything but.
This API is awful, unorganized, complicated and worst of all, back in the day, it lacked documentation. No, the documentation wasn’t scarce, poorly documented or lacked samples — it simply didn’t exist. There were mentions, here and there, about the members, structures and other topics but there was nothing concise about it.

mixapp

Microsoft’s mixapp

I’m sure Microsoft partners and affiliates of some sort had access to some privileged documentation, but we (the freelance developers) did not.

So, if you wanted to implement some sort of, for example, volume control on your application your best bet was to get a copy of the Windows SDK and check the source code for an application that it included, appropriately named mixapp.

This little program (just 61 KiB in size) was made available as a compiled binary accompanied by its C source code. Unfortunately, the code wasn’t documented!
Anyway, the little mixapp program did everything I mentioned before:

  • Enumerate all the mixers
  • Enumerate their lines
  • Enumerate each line’s controls
  • And, finally, it exposed (if any) the item controls inside each control

I had already spent a considerable amount of time fiddling with the API (without any valuable results) and seeing this (so damn small) program do what it did, appeared as a magic to me.

Fast forward three weeks (yep, that’s what it took me to fully understand how the API worked) and I had the first working prototype… in VB6.

[…]

Fast Fourier Transform (FFT) written in VB

Back in 2001, when I began working on DXVUMeter (an ActiveX control used to display audio in various formats) I wanted to implement the ability to display the monitored audio in the frequency domain, that is, be able to apply a Fast Fourier Transform over the sampled audio and display it.

[Again], I found a C and VB version of an FFT implementation done by no other than Murphy McCauley and if you look hard enough you can still find web sites hosting his original version.

The initial implementation of McCauley’s code worked well and did its job. Actually, DXVUMeterNETGDI, the latest version of this control, still uses a very similar version to do all its internal FFT calculations.

So what’s different in my (new) FFT implementation? Most importantly, the use of a new data type which allows all related FFT calculations to utilize complex numbers.
Also, my FFT module includes several additional functions such as:

So, if you are interested in using or simply peeking at this code, you can download the library from this link:
VB.NET FFT Library (10977 downloads )

[…]

An MP3 decoder written in VB

I cannot keep track of the number of times I needed an easy way to decode an MP3 file from a .NET program.
Sure there are many libraries available and sure there are many ways you can do it but I just wish I could do it natively (with managed code) and have complete control over the decoding process.

Well, I guess that’s why I created the CMP3Decoder class, a .NET VB wrapper that encapsulates a native MP3 decoder, also written in VB, and provides an abstraction layer to facilitate the decoding process.

This is a very old project since the first version was written for VB6 and although it worked, the code was so damn slow that it was unusable for a real-time MP3 player.
The MP3 decoding stuff is a port from Krister Lagerström‘s C version of the decoder and it was initially ported to VB6 by Murphy McCauley from http://www.constantthought.com/

MP3Player.NET

An MP3 decoding class for .NET

When Visual Studio 2003 was released I started porting (that is, re-creating by hand) most of my VB6 projects to VB.NET and this was one of them.
As the language matured I started to optimize the code up to the point where the decoder is now able to run without any considerable impact on the CPU. In simpler words, it runs pretty fast.

The quality of the decoded audio is not very good but for basic purposes it does its job and its a nice proof of concept project.

Update (9/2/2012): The library has been updated so that it no longer depends on DirectX’s SDK, instead it relies on the amazing SlimDX library.

Feel free to grab the source code for this project from this link:
VB MP3 Decoder (3532 downloads )

Countdown: Problem #4

A few years ago I stumbled upon a web site which presents various problems that you are supposed to solve using Ruby. So I wondered how easy would it be to create a solution for one of the problems (the hard one) using VB.NET

The problem’s description is as follows:

You’ll be provided (in the $input variable) with ‘source’ numbers and ‘target’ numbers. What you’ll have to do is arrange the source numbers into a mathematical expression that equals the target number.

The input is provided as single string, like this:

TARGET:104;SOURCE:100,3,4,7,1,2;

According to the description of the problem, you are supposed to combine the SOURCE numbers using the four basic arithmetic operations (addition, subtraction, multiplication and division) until you find a combination that produces the desired result, the TARGET.

So a possible solution would be:
100+(3-(4-(7*1)+2)) == 104

And that’s the output that is expected from the program.

Once I had the basic the code implemented I started enhancing it with several features that were not required but that made the program quite nice, and entertaining:

  • Ability to search for all possible solutions (not just one).
  • Option to display the progress, that is, all the combinations that the program is trying.

Here’s a link to the project source code:
Countdown (1212 downloads )

[…]