I haven’t been writing posts lately, as I’ve been focusing on other things and I didn’t feel like making them, but here I am.
On Monday we changed our concept direction a little bit, now we want to create a music sampler connected to the stages and music of the music in de straten.
For the demo I created a short code that plays isolated drums and guitar when the conductive sensors are touched and reacts to the distance a person is.
import processing.serial.*;
import ddf.minim.*;
String val;
int[] data = new int[4];
Serial myPort;
Minim minim;
AudioPlayer groove;
AudioPlayer groove1;
AudioPlayer drums;
AudioPlayer guitar;
void setup()
{
size(200,200);
myPort = new Serial(this, "COM4", 9600);
minim = new Minim(this);
groove = minim.loadFile("kiss.mp3", 2048);
groove1 = minim.loadFile("fginc.mp3", 2048);
// gdrums = minim.loadFile("gdrums.mp3", 2048);
drums = minim.loadFile("drums.mp3", 2048);
guitar = minim.loadFile("guitar.mp3", 2048);
// gguitar = minim.loadFile("gguitar.mp3", 2048);
}
void draw() {
if (myPort.available() > 0) {
val = myPort.readStringUntil(10);
if (val != null) {
val = trim(val);
int[] data = int(split(val, ','));
int ultrasonic = data[0];
int ultrasonic2 = data[1];
int port2 = data[2];
int port8 = data[3];
println("ultrasonic: " + data[0]);
println("ultrasonic2: " + data[1]);
println("port 2: " + data[2]);
println("port 8: " + data[3]);
//if (port2 == 1) {
// background(255);
//} else if (port8 == 1) {
// background(255, 255, 51); //EXAMPLE WITH COLOR
//} else {
// background(0);
//}
//int distance = (int) map(ultrasonic, 0, 100, 30, 150);
//ellipse(width/2, height/2, distance, distance);
if (ultrasonic 50){
groove.rewind();
}
if (ultrasonic2 50){
groove1.rewind();
}
// float currentPan = groove.getPan();
// println("current pan: " + currentPan);
// float panPlus = currentPan + 0.1;
// float panMinus = currentPan - 0.1;
// float currentPan1 = groove1.getPan();
// println("current pan: " + currentPan1);
// float panPlus1 = currentPan1 + 0.1;
// float panMinus1 = currentPan1 - 0.1;
if (port2 == 1) {
drums.play();
} else {
drums.rewind();
}
if (port8 == 1) {
guitar.play();
}
else {
guitar.rewind();
}
}
}
}
This worked out and I was quite satisfied with it. The next we have to do is add all the touch pins and leds for what sample is chosen. Furthermore, we have to start thinking about creating the music soon.
I also made a simple sampler in processing.
import processing.opengl.*;
import ddf.minim.*;
import ddf.minim.ugens.*;
Minim minim;
AudioOutput out;
Sampler kick;
Sampler snare;
Sampler hat;
boolean[] hatRow = new boolean[16];
boolean[] snrRow = new boolean[16];
boolean[] kikRow = new boolean[16];
ArrayList buttons = new ArrayList();
int bpm = 120;
int beat; // which beat we're on
// here's an Instrument implementation that we use
// to trigger Samplers every sixteenth note.
// Notice how we get away with using only one instance
// of this class to have endless beat making by
// having the class schedule itself to be played
// at the end of its noteOff method.
class Tick implements Instrument
{
void noteOn( float dur )
{
if ( hatRow[beat] ) hat.trigger();
if ( snrRow[beat] ) snare.trigger();
if ( kikRow[beat] ) kick.trigger();
}
void noteOff()
{
// next beat
beat = (beat+1)%16;
// set the new tempo
out.setTempo( bpm );
// play this again right now, with a sixteenth note duration
out.playNote( 0, 0.25f, this );
}
}
// simple class for drawing the gui
class Rect
{
int x, y, w, h;
boolean[] steps;
int stepId;
public Rect(int _x, int _y, boolean[] _steps, int _id)
{
x = _x;
y = _y;
w = 14;
h = 30;
steps = _steps;
stepId = _id;
}
public void draw()
{
if ( steps[stepId] )
{
fill(0,255,0);
}
else
{
fill(255,0,0);
}
rect(x,y,w,h);
}
public void mousePressed()
{
if ( mouseX >= x && mouseX = y && mouseY <= y+h )
{
steps[stepId] = !steps[stepId];
}
}
}
void setup()
{
size(395, 200);
minim = new Minim(this);
out = minim.getLineOut();
// load all of our samples, using 4 voices for each.
// this will help ensure we have enough voices to handle even
// very fast tempos.
kick = new Sampler( "BD.wav", 4, minim );
snare = new Sampler( "SD.wav", 4, minim );
hat = new Sampler( "CHH.wav", 4, minim );
// patch samplers to the output
kick.patch( out );
snare.patch( out );
hat.patch( out );
for (int i = 0; i < 16; i++)
{
buttons.add( new Rect(10+i*24, 50, hatRow, i ) );
buttons.add( new Rect(10+i*24, 100, snrRow, i ) );
buttons.add( new Rect(10+i*24, 150, kikRow, i ) );
}
beat = 0;
// start the sequencer
out.setTempo( bpm );
out.playNote( 0, 0.25f, new Tick() );
}
void draw()
{
background(0);
fill(255);
//text(frameRate, width - 60, 20);
for(int i = 0; i < buttons.size(); ++i)
{
buttons.get(i).draw();
}
stroke(128);
if ( beat % 4 == 0 )
{
fill(200, 0, 0);
}
else
{
fill(0, 200, 0);
}
// beat marker
rect(10+beat*24, 35, 14, 9);
}
void mousePressed()
{
for(int i = 0; i < buttons.size(); ++i)
{
buttons.get(i).mousePressed();
}
}
which worked out great.
Lastly, I decided to send an sponsorship enquiry to Bare Conductive, as they are the market leader for conductive paint. With the following email:
To whom it may concern,
My name is Andro Gjuric and I am a 2nd year Creative Media & Game Technology student at Saxion University of Applied Sciences in Enschede, the Netherlands.
Me and my 5 other project members are currently creating an interactive music/art installation for the town of Enschede as part of our final semester university project. We expect around 150+ people per day to see/interact with our installation during the final exhibition, which lasts from Tuesday July 2nd, 2019 to Thursday 4th of July, 2019
The added value we want to create is to provide visitors of the "Muziek in de Straten" street music festival an opportunity to create music with intuitive controls and no prior musical knowledge. This is done with range detection and capacitive touch sensing by a multitude of sensors.
In order for us to enrich the user experience, we wanted to use your conductive paint to create beautiful paintings on the installation and by touching these, the music would change. We thought of having copper plates for conduction sensing, but after a target group questionnaire we found out that these do not fit the installation and thus we thought of using paint to keep the user immersed. I have attached concept sketches of our art installation for visualization purposes.
During our research, we found that your company is the market leader for the mentioned product. Furthermore, we believe that our installation will evoke a satisfying user experience in which Bare Conductive can play a crucial role. Thus we are asking for a sponsorship of your product in exchange for exposure on our product and in our promotional campaign.
Our intended goal for this semester project is to be chosen by our client, Enschede Promotie, as the most successful project and thus be in negotiating talks regarding a permanent installation.
Kind regards,
Andro Gjuric
and I am hoping for positive feedback.
Leave a comment