http://processing.org/discourse/yabb2/YaBB.pl?num=1224778221
he suggested altering the gain() of the audio track using setGain(). This worked a treat.
The next step was to figure out how to use the mouse x/y's to manipulate the gain amount. I borrowed the principles of the Color Transparencies with sound sketch which used the map() function to remap the mouseY position into something useful for the gain value.
http://www.openprocessing.org/sketch/15427
The next task was to split the area (400 x 400 sketch) into zones. As the concept is still to get people to trigger different instruments I need to use the mouseX/Y's to achieve this initially. Using the principles again from the Color Transparencies with sound code again I discovered that -80db is inaudible. - so the easy thing to do was to tell the program to make the track inaudible when in the wrong zone. ie, if you are in Track 1's Zone Track 2's gain is set to -80 ..etc The issue that arose from this was an annoying clipping sound, like a scratched CD. I went back to the forum where Zachary Seldess helped us out and searched untill I wfound a solution to this problem - mute() & unmute how simple. Muting the track will allow me to keep the tracks coherent whilst stopping the sound from emiting.
the code to date is as follows:
// import minim libraries
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
//------------------------------------------------------------------------
//set up audio functions
AudioPlayer player1;
AudioPlayer player2;
Minim minim;
// setup varables
int x = 10;
int y = 0;
int rectWidth = 400;
int rectHeight = 400;
//------------------------------------------------------------------------
void setup() {
size(400, 400);
minim = new Minim(this); // telling the sketch that this object is infact the Minim Function.
// these are the two tracks being loaded into the functions
player1 = minim.loadFile("08 - Samba Tranquille.mp3", 2048);// Thievory Corporation
//feel free to add your favorite songs in place - as you can see they can bee mp3 or wav
player2 = minim.loadFile("13 Aqueous Transmission.wav", 2048); // Incubus
}
//------------------------------------------------------------------------
void draw () {
// playing the Audio
if (mousePressed == true) {
player1.play();
player2.play();
}
// using the mouseY to set the gain of the tracks, map() helps re - map so to fit with
// the db range
float vol = map(((y+rectHeight)-mouseY), y, (y+rectHeight), -40, 0); //variable vol is created with the map() as its value
player1.setGain(vol); // set the gain of the player1 function
player2.setGain(vol); // set the gain of the player2 function
println(player1.gain());// have a look to see how everything is (or isn't) working
println(player2.gain());
//this is suposed to mute the tracks when the mouse goes out of the window - so far doesn't work
if ((mouseX < 0 || mouseX > rectWidth) && (mouseY < 0 || mouseY > rectHeight)) {
player1.mute(); // stop the sound of the audio but keep the function running.
player2.mute();
}
// zoning the window
if (mouseX > 200) {// right hand side if the window
player1.mute();// silence Incubus
player2.unmute(); // unsilence Thievory Corporation
}
if (mouseX < 200) {
player2.mute();// silence Thievory Corporation
player1.unmute(); // unsilence Incubus
}
}
//------------------------------------------------------------------------
//yet to discover a good explanation for this function (apart from the obvious)
void stop() {
// always close Minim audio classes when you are done with them
player1.close();
minim.stop();
super.stop();
}
please comment - would like to hear of possible improvements.
My USB interface and home recording software is all set up and ready to start laying down some tracks. I am using Reaper recording software which is incredibly intuitive, and I am using m-audio Fast Track as my interface to input into Reaper. The next step is to get some dummy tracks set up and add a swarm to the sketch window to test the responsiveness of the sketch.