How do i get sound to play with each colour as you paint?
in
Contributed Library Questions
•
10 months ago
I'm making a drawing tool that makes a piano sound for each colour when you paint using a colour picker. Like red is a C note, Orange is a D note etc. I made the colour picker but there are 2 issues i am having with it, the first is it only grabs colour when you click and drag away from the picker instead of selecting the colour and painting with it, and the other issue is, i can get it to play sound when i paint with it but i want it to make a different sound for each colour and the sound to be sustained as you paint, i want the sound to be as long as the stoke.
Here is what i have so far:
PImage picker;
color paint;
int thick=1;
import arb.soundcipher.*;
void setup(){
smooth();
background(255);
size(700,700);
picker=loadImage("picker1.jpg");
}
void draw(){
image(picker,300,0);
}
void mousePressed(){
if(mouseY>20){
paint = get(mouseX,mouseY);
}
}
void mouseDragged(){
strokeWeight(thick);
stroke(paint,120);
line(pmouseX,pmouseY,mouseX,mouseY);
SoundCipher sc = new SoundCipher(this);
sc.playNote(60, 100, 3.0);
}
void keyPressed(){
if (key=='4')
thick+=50;
if(thick>300){
thick=300;
}
if (key=='3')
thick+=30;
if(thick>100){
thick=100;
}
if (key=='2'){
thick+=4;
if(thick>50){
thick=50;
}
}
if (key=='1'){
thick-=5;
if(thick<3){
thick=3;
}
}
if (key=='c'){
noStroke();
fill(255);
rect(0,0,700,600);
noFill();
}
if (key=='b'){
noStroke();
fill(0);
rect(0,0,700,600);
noFill();
}
if (key=='s'){
saveFrame("picture####.tif");
}
}
1