We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey guys, so I have this slider, which should change the frequencies when you move it, but I don't know how to realise this. Does anyone have an idea on how to do this?
Answers
It looks like you figured out how to set the position of the slider with
.setPosition()
. How do you get the position?You also figured out how to set the frequency with
currentFreq = Frequency.ofHertz();
andwave.setFrequency(currentFreq);
So:
How do you get the current position of the slider? Then, in the draw loop, you can write code that says:
I take that back. You set the screen Position of your sliders, and initialized its Range, but you didn't set its Value.
Read the "Accessing Controllers" sections of the ControlP5 page. Then try these changes:
You create your sliders, but you don't name then anything! Declare the global object, then assign to it when you call addSlider in setup e.g.
At the beginning or end of each draw, set your frequency based on your slider. Because you named it, you can refer to it.
Change your keyPressed code so that now your keys affect your sliders -- which affect the frequency. Now your key presses won't get overwritten by the next slider update, or be out of sync with what the slider shows.
P.S. Here are working ControlP5 examples sketches, including sliders: 1, 2, 3
Oh, now I got it! Thank you very much!! Do you have an idea, how to change the volume of the frequencies? Everything I found online was for MP3 sounds, I guess song.setGain(0.5); its not meant to be used for the frequencies?
Your question is: "I know how to
wave.setFrequency
, can I wave.somethingToChangeTheVolume ... or do I need a different object type from wave?wave
?According to your code, it is an
Oscil
.Oscil
do?Check out the minim documentation, and look up the Oscil class. Looks like it has something called .amplitude
Did that help you find a solution?
Oh ok, I added "wave.setAmplitude( sliderVolume.getValue() );" into the draw. But now I have the problem, that the volume is not changing. If the slider is on 0, there is no sound. Increasing the slider doesnt change the volume, but the Sinuswave. Do you have a clue on how to fix this?
@sampletape -- Maybe you should post your latest code.