I really have a passion for nostalgic 8 bit computer music. I thought it might be a nice idea to create 'old' digital music with a 'new' interface. Online there are many examples of people that chip-tune gameboys and nintendo entertainment systems to create 8 bit compositions. One really nice find is the Chipophone:
Here is a really nice description of the build process: http://www.linusakesson.net/chipophone/index.php
Example of how gameboy music is composed:
Lots of information about how to create music with gameboys: http://www.audiocatch.com/blog/?p=225
Project videos:
Here is the code of my music box:
import processing.serial.*;
Serial myPort; // The serial port
import pitaru.sonia_v2_9.*;
float a = 0;
float inByte;
float snelheid;
float verschil;
Sample mySample;
float vol;
void setup() {
// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
size(1000,100);
Sonia.start(this); // Start Sonia engine.
// create a new sample object.
mySample = new Sample("8.aif");
mySample.repeat();
}
void draw() {
background(0,30,0);
strokeWeight(1);
// If sample is playing (or looping), do this...
if(mySample.isPlaying()) {
background(0,40,0);
}
setRate(); // use mouseY to control sample-rate playback
// setPan(); // use mouseX to control sample Panning
// setVolume(); // use mouseX to control sample volume
drawScroller();
a++;
if(a>50){
// (mouseX-pmouseX)*-1;
a = (mouseX-pmouseX)*-1;
}
}
void mousePressed() {
// loop the sample
mySample.repeat();
}
void mouseReleased() {
// Stop the sample, and unload it form memory in 1 frames (each frame is about 1 ms).
mySample.stop(1);
}
void setPan() {
// set the pan of the sample object.
// Range: float from -1 to 1 .... -1 -> left, 0 -> balanced ,1 -> right
// notes: only works with MONO samples. Pan for Stereo support in next version.
float pan = -1f + mouseX/(width/2f);
mySample.setPan(pan); //(a*-1)/10
}
// NOT IN USE FOR THIS EXAMPLE
void setVolume() {
// set the volume of the sample.
// Range: float from 0 to 1
vol = mouseY/(height*1f);
mySample.setVolume(vol);
}
void setRate() {
// set the speed (sampling rate) of the sample.
// Values:
// 0 -> very low pitch (slow playback).
// 88200 -> very high pitch (fast playback).
float rate = (height - mouseY)*88200/(height);
println(int(verschil*100)*88200/(height));
mySample.setRate(int(verschil*50)*88200/(height));
}
// Draw a scroller that shows the current sample-frame being played.
// Notice how the sample plays faster when the Sample-Rate is higher.(controlled by mouseY)
void drawScroller() {
strokeWeight(1);
stroke(0,255,0);
// figure out which percent of the sample has been played.
float percent = mySample.getCurrentFrame() *100f / mySample.getNumFrames();
// calculate the marker position
float marker = percent*width/100f;
// draw...
line(marker,0,marker,20);
line(0,10, width,10);
}
// Safely close the sound engine upon Browser shutdown.
public void stop() {
Sonia.stop();
super.stop();
}
float[] values = new float[50];
void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
inByte = float(inString);
//println(inByte);
//inByte = map(inByte, 0, 1023, 0, height);
for (int i = 0; i < values.length-1; i ++ ) {
// Shift all elements down one spot.
// xpos[0] = xpos[1], xpos[1] = xpos = [2], and so on. Stop at the second to last element.
values[i] = values[i+1];
}
values[values.length-1] = inByte/10; // Update the last spot in the array with the mouse location.
// values[0] = inByte/50; // nieuwe waarde
verschil = values[49]-values[0];
println(int(verschil));
println(values[0] + "andere = " + values[49]);
}
}