Close

Does this project spark your interest?

Become a member to follow this project and don't miss any updates

PC Keyboard becomes synthesizer / drum computer

Converted an old PS2 keyboard into a synthesizer/drum computer/... using arduino nano.

Similar projects worth following

This project was created on 07/26/2014 and last updated 5 months ago.

Description
Converted an old PS2 keyboard into a drum machine using arduino nano.
I added key release handling to the teensy ps/2 keyboard library, to allow note on and note off
handling. Result : a playable keyboard synth with drum n bass sequencing and lead instrument selection.

The project can run standalone from a single 9V battery, or be powered through the arduino's usb connector. It uses a Dreamblaster S1 breakout board to generate the sound.
A cheap ps2 to usb cable was scavenged for the necessary connector.

All source code and the arduino shield schematic and pcb layout is available in the github repo.

Details

Let's see it in action first : 

How does it work ?

I recycled part of a cheap ebay ps2-to-usb cable to get a female mini din connector.

I think you can get the same from dealextreme here.

The connections were clearly marked on that chinese pcb : Vdd, CLK, Data, GND

The color convention is :

red = Vdd

white =  Clock

green = Data

black = Ground

So I connected these to my arduino nano shield (see photo), and used the teensy ps2keyboard library.

(excellent instructions on the teensy site, you could use any arduino).

Reused some arduino code from my bicycle drummer project, and... voila

a drum computer using the ps2 keyboard !

At fist I just implemented some drum sounds for testing purposes, and it works perfectly.

The source code is available on github.

The Kicad project with schematic and PCB layout for the Arduino Shield can be found here.

It is simple to integrate a ps2 keyboard in your own projects, add this code in your arduino sketch : 

#include <PS2Keyboard.h>

const int DataPin = 2;

const int IRQpin = 3;

PS2Keyboard keyboard;

void setup() {

...

keyboard.begin(DataPin, IRQpin); // ps2 keyboard

...

}

void loop() {

...

  if (keyboard.available()) {

// read the next key

char c = keyboard.read();

KeyboardHandler(c);

}

...

}

So the KeyboardHandler is where you can add features. 

For this simple demo it recognizes 3 keys, and sends the right midi command :

void KeyboardHandler(char key)

{

if(key==' ')

{

midiwrite(0x99, _BASSDRUM_NOTE, 0x65);

return;

}

if(key==PS2_ENTER)

{

midiwrite(0x99,_CLOSEDHIHAT_NOTE, 0x65);

return;

}

if(key=='0')

{

midiwrite(0x99, _SNAREDRUM_NOTE, 0x65);

return;

}

}

See video for demo using the above KeyboardHandler code (low audio quality from camera mic):

A lot of features could be added to the keys, including instrument change, piano style key layout, sequences start/stop, effect enable disable,.... I will update the project log when I expand the features.

Here's one expansion already : I extended the ps/2 keyboard to notify key releases as well.

This allows to send note off on key release. I also added some more features like tap tempo beat, bass sequence toggle, lead instrument selection,...  see video. I committed the update code to the repo.

See project log for some more details. A video recorded with my camera (low audio quality from camera mic) :

I found a way to record the audio directly : use virtual dub, and record audio from my soundcard's line in, and video from my webcam. A slight shift between video and audio, but most important :  The sound is much better preserved, if you have good speaker you will sure hear the difference. I added short video to the front of this description.

Components

Project logs
  • Harry Potter PS/2 Mouse

    5 months ago • 0 comments

    Hi,

    here are the PS/2 Harry Potter mouse details.

    The mouse glows red when you move it : it shines between the buttons and lights the harry potter logo, which is transparent.  Should I used it in this project, to control filters, pitch, balance, volume or reverb depth? 

    Or maybe it deserves a project on its own ? Maybe I should open it up, and try to mod it ?

    You judge, here are the photos:

     MOUSE NOT POWERED :

    MOUSE POWERED, NOT MOVING: 

    MOUSE POWERED + MOVING :

  • Bass Line instrument selection

    5 months ago • 0 comments

    Implemented instrument selection for the bass line, using the '+' and '-' keys. Also found a way to record the audio directly, the next movies will have a much  better sound quality.

  • Added Filter Resonance Control

    5 months ago • 0 comments

    Added a second potmeter to control filter resonance of the bassline. Had to place it horizontally to avoid obstructing the usb cable.

    new situation :

    pot1 : bass line filter cutoff control
    pot2 : bass line filter resonance control 

    This allows to shape your sound like an analog synth. But there's more ! You can not only filter synth like sounds such as the square and sawtooth synth leads.  You can apply to piano, flute, gunshot, applause, oooh choir, bird tweet, telephone ring, ... 

    Amazing effects :-). The code is updated in the repo.

     See photo for the new setup :

View all 4 project logs

Discussions

Similar projects