Dr. Wummi's Stuff - Contraptoid

Play that funky music nerdboi

Does anyone remember the Phantom of the Floppera ?

Well, i do and now the time has come to buld something like this. How hard can it be?

Look at the spec and see: We have 5V interface, and 3 relevant pins for the stepper motor (Drive select, Direction and Step)

Alrighty then: sowhere i got an old floppy,  5V screams Arduino , and Arduino supplies us with a tone() function. Dis gon be easy.. Just reverse direction every other note and hope for the best:


Well thats a bit shit isn't it.
But it kinda works so let's grab some other music from other people and just rip off their code and find another floppy we can look like we ballin:



But fo reals that ain't gonna get the females moist, we have to do better.
It's seriously un-cool to upload a stinkin arduino sketch every time you want to listen to a new tune. (also where the fuck are you supposed to find em?)
Also if you play a note for to long the drive will overdrive it's 80 tracks and bonk a lot. Also until now skill needed is aproaching 0.

First, we gonna need..


More Drives!

Thanks ebay
Thanks, ebay

I started sourcing drives from wherever i could, and i even got some special ones! (and i'm still looking for more, send em to me!)
If you're interested in old tech, you can look at my Floppy oddities page. DO IT NOW.

Some drives turned out to be bitchy little shits, refusing to obey my (arguably weird) commands, going into error states (requiring a power-cycle) or disintegrating.

Not everyone is ready to be a star


Then we gonna need something bigger to control many drives.
Upgrade to Arduino Mega and hope it's fast enough. 
(Hint: it later turned out to be.... close/tricky/not)
Having the Arduino is great and all, but how do we get music to it? Fear not, dear friends, somebody already had a smart moment and invented midi .

Theres a buttload of players, editors, and midi files all over the web, so thats a good start. Another wonderful person wrote a software midi driver for windows:  Tobias Erichsen - virtualMidi
Delicious! So let's use this in a shoddy C# project, and if all goes well we can receive midi commands from every windows app there is!

port = new TeVirtualMIDI("Contraptoid");
Thread thread = new Thread(new ThreadStart(WorkThreadFunction));
Console.WriteLine("Virtual port created.");

Straigt up from the example. Now we got midi messages going in, sweet. Just gettem out to the arduino via serial and then read this awesome instruction on what those messages actually mean.

Ojn the Arduino we then generate a table for all the midi pitches:

static void genMidi()
	double a = 440; // a is 440 hz...
	for (int x = 0; x < 127; ++x)
		midi2freq[x] = (a / 32.0) * pow(2 ,((x - 9) / 12.0));

so after parsing the notes i did this in a loop:

for(int d = 0; d < NUM_DRIVES; d++)
    selectDrive(d,freq[d] != 0);    //select all drives playing, deselect silent

    if (freq[d] != 0 && micros() > freqMicros[d] + (1000000 / freq[d]))
        freqMicros[d] = micros();

which somehow sounded garbage, because it's horribly inefficient. Playing an A (440Hz) on further investigation resulted in ~ 411 Hz, or worse, depending on how many drives are playing at this moment. 


This has just left easy-territory, and got much worse. 

..more to come