i am following the tutorial https://www.youtube.com/watch?v=Bk8rLzzSink where frequency is changed using slider. how can i change the amplitude using slider in the same manner?
i tried the following:
function draw() {
wave.freq(slider.value());
wave.amp(AmpSlider.value());
if (playing) {
background(255, 0, 255);
} else {
background(51);
}
}
Suggestion: Re-name the first slider that the author created to ‘freqSlider’, then make another one just like it called ‘ampSlider’. You should be able to do that on your own; please give it a try.
Hint: Set ampSlider parameters to something like this: (0.0,0.5,0.1,0.1) which is (min, max,init,step) and then set wave.amp(0); in setup(). Otherwise you will hear the sound at startup if it’s not set to zero (contrary to what the slider sets it at).
I was able to get the amplitude working but for square wave the amplitude does not increase as much as other waveform, that is, sine, triangle,sawtooth amplitude increases but not square. also when the background is black and the stroke is white there are filled up spaces as shown below.
Also how can i add time increase/decrease the time resolution and amplitude like setting V/div on vertical axis and ms/div on horizontal axis. any suggestion on this would be helpful.
Not sure I can help you on the size of the square wave, but I would try changing the max amplitude to see if that makes a difference. I don’t have the code to plot the wave so I’m unable to test it here.
i have noticed that and i think it is because the current and previous drawn same waveform are in phase and therefore overlapping producing a single waveform at that frequency. But how can we draw single waveform at any frequency, it looks rather wired with multiple waveform
i don’t understand the reason for why it is drawing double triple of the same waveform, is it because the previous values of the same waveform stored in buffer gets redrawn? it can be only for this reason, and i wanted to know how we can flush out the previous drawn waveform.