Anthony Walter via lazarus wrote:
I have summer camp with several successive week long classes coming up
and am trying to put together some fun programming materials to engage
the kids and hopefully encourage them to explore more.
Yesterday I created the start of my next project for teaching kids on
the subject of computer programming using Lazarus and Free Pascal as the
teaching tools. Here is a brief video demonstrating what I have so far
along with a github page containing the sources.
https://cache.getlazarus.org/videos/sound-shop-example.mp4
https://github.com/sysrpl/SoundShop/
Hi,
I your video you talked about popping and clicking of the tones. You
partly solved this by adding an Attack and a Release (you use attack
here in in fact these are 2 different values, and while you're at it you
can add a Decay too :))
Anyway, I haven't looked at the code itself (only what was shown in the
video), but most likely those pops and clicks are caused by phase jumps
when you switch from one frequency to another.
Imagine your playing A -> B and you start generating the sine of B at
phase=0, there is a big chance that A isn't at phase=0. So you get a
sudden jump in your output. your ear is very sensitive for this and
results in a click.
What I've done in this case is based on the frequency/samplerate to
play, is calculate the delta phase for each sample (for 220Hz/48k ->
delta=220*2Pi/48000) and increase a global phase for each sample you
calculate with this global phase.
Therefore if if you change frequency, the phase of the new tone
continues where the previous ended.
To prevent your global phase to grow, substract 2Pi when it is larger
than 2Pi. Or even better, leave out 2Pi in the delta phase, and use
2Pi*globalphase to calculate and globalphase=fraq(globalphase + deltaphase)
Hope this solves your issue,
Marc
--
_______________________________________________
lazarus mailing list
[email protected]
https://lists.lazarus-ide.org/listinfo/lazarus