How do I adjust the value of a slider in controlP5 in Processing?
For example. I’ve made a slider using the cp5 library, and I would like to change the volume from low to high whenever I move the slider up and down. So if the slider is moved up the sound gets louder and louder and vice versa. I hope this makes sense. Thank you.
import controlP5.*;
ControlP5 controlP5;
import processing.sound.*;
foundFile file;
int from = color(255,0,0);
int to = color(0,120,200);
void setup() {
size(500,700);
//smooth();
file = new SoundFile(this, "Sweetdreams.mp3"); //loading my sound file
file.play();
controlP5 = new ControlP5(this);
//change the default font to Verdana;
PFont p = createFont("Verdana",20); //skrifttype og størrelse
ControlFont font = new ControlFont(p);
//change the original colors
controlP5.setColorForeground(lerpColor(from, to, 0.5));
controlP5.setColorBackground(color(150,158,159));
controlP5.setFont(font);
controlP5.setColorActive(lerpColor(from, to, 0.5));
controlP5.addSlider("")
.setRange(0,30)
.setValue(20)
.setPosition(180,80)
.setSize(120,600)
.setColorValue(200)
.setColorLabel(200);
}
void draw() {
background(0); // background black
}
PLEASE,
i asked you to format your code,
not to delete it.
vandalizing your question AFTER you got answers
might make the whole thread worthless for following readers,
this is not a private helpline ( from a company selling software for 600 TALER )
in a public forum the questions and the answers should express the will of a community
to help each other and also to learn from each other to make a better codebase, free for all.
Hello,
I’m fairly new to programmation,
I tried to recreate this code for a class, I download the P5 library as well as the Sound library. When I want to run the program, the error box indicates the “foundFile” doesn’t exists. Am I missing something to download here, or is it directly in the code?