stefandrissen / SAM-MOD-player

SAM MOD player, an Amiga MOD player for the SAM Coupé
https://www.worldofsam.org/products/sam-mod-player
15 stars 0 forks source link

Digital playback: reduce initial click #23

Open stefandrissen opened 11 months ago

stefandrissen commented 11 months ago

When playing back samples, the amplitude varies from a middle point, the middle point is half maximum volume. Initially, all devices are at "volume" 0, so as soon as playback starts volume jumps from 0 to half maximum volume, resulting in a click.

To reduce the click I tried gradually increasing volume from 0 to half maximum volume in the @buffer.init routines - but this does not seem to be helping and is even making things worse when playing a second mod, watch the ramped click between mod 1 and 2 of EFTPOTRM:

image

stefandrissen commented 11 months ago

I seem to be doing something a bit silly when initially filling the buffers. There are two buffers, each populated with sample data for two channels:

buffer 1:

buffer 2:

When using SAA1099 there are not two discrete channels, the sample data is interleaved for both, channel 2, channel 5, channel 2, channel 5, etc.

Also buffer 2 is played after buffer 1, so there is an additional ramp.

AntonyDTA commented 7 months ago

I already commented that it couldn't be solved, but then I had some ideas and it seems to be quite a bit better. I gradually reduced the most time-consuming part of the program to only one OUT instruction, which is only 16T (375000Hz) in the border. Volume now changes from &00 to &88 in 192 levels before envelope control is turned on. Here is a short break in amplitude, it seems that turning on the envelope first mutes the sound and immediately sets it back to maximum (%001=max.amplitude). I haven't tested it on a real Sam.

Not everything is visible in the 44100 Hz file, it's just a rough check. RstSAA_pwm12 RstSAA_Env_03_pwm12.zip