I tried DaMusix. It does have the same (subtle) issues. Also it uses very gently sloped fades, which click less often or not at all.
I put together a sound demo with Inform 7. You can download it here:
aeriae.com/no/GlulxSoundDemogblorb.zip
It lets you jam the volume on and off, run multiple fades in a row, etc. In an ideal situation, none of these actions would ever cause a click, but as is, sometimes they will. The steeper a fade, the more clicky it can be.
The appearance of these clicks etc. is entirely dependant on the nature of the sound wave at the moment the volume is changed. For instance, if you ‘volume off’ at a particular moment in a piece of audio and no click happens, and you supernaturally had the ability to ‘volume off’ at that exact same moment in the audio when it came around again, it also would generate no click the second time. The same goes for a moment that would produce a click, etc.
I’ve pasted source code of the demo below. If you wish to compile it and play with it yourself, you will need to first have the following 2 extensions in your inform kit:
Multiple Sounds
inform7.com/extensions/Massimo%2 … Sounds.i7x
Real-Time Delays
inform7.com/extensions/Erik%20Te … Delays.i7x
Btw, Damusix uses the glulx timer in such a way that the user can keep performing actions while fading, etc. I used Erik Temple’s real-time delays to do the fades in my demo, but either way can generate artifacts as the timer itself has nothing to do with the issue.
Code below:[spoiler][code]“Glulx Sound Demo” by Wade Clarke
Include Basic Screen Effects by Emily Short.
Include Multiple Sounds by Massimo Stella.
Include Real-Time Delays by Erik Temple.
There is a room called Don’t Plank.
To decide whether glulx sound is supported:
(- ( glk_gestalt(gestalt_Sound, 0) ) -)
Include (-
[ VolumeRaw chan val;
if (glk_gestalt(gestalt_SoundVolume,0)) {
if ((val <= 81920) && (val >=0)) {
glk_schannel_set_volume(chan, val);
}
else {
“Invalid Volume Level: please insert a value between 0 and 81920.”;
}
}
else {
“Your interpreter doesn’t support volume control.”;
}
]; -).
To set the raw foreground volume to (VOL - a number):
(- VolumeRaw(gg_foregroundchan,{VOL}); -)
Sound of StartingMusic is the file “tench_seg.ogg”.
To play_start_music: if glulx sound is supported, play the sound of StartingMusic in foreground with loop.
The infinite_loop is a number that varies. The infinite_loop is 1.
when play begins:
say “[italic type]Glulx Sound Demo - by Wade Clarke[roman type][line break]”;
try requesting the story file version;
say “and Version 2 of Multiple Sounds by Massimo Stella[paragraph break]”;
say “The sample in this tech demo is a brief passage from PS1 game Tenchu.[line break]”;
if glulx sound is supported, rock out;
otherwise switch off.
To switch off:
say “This demo only works in an interpreter with sound. This demo has stopped running.”;
stop game abruptly.
To rock out:
while the infinite_loop is 1 begin;
say “[line break]Music will be play on the foreground audio channel. Hit the number keys to do things with it. Kick off by pressing 1 to start music. Fades cannot be interrupted by keypresses![paragraph break]”;
say “1 Set volume to max then play song from beginning. Song will loop.[line break]”;
say “2 Immediately stop song dead (volume dial is untouched).[line break]”;
say “3 Immediately drop volume to OFF (song keeps playing but you can’t hear it)[line break]”;
say “4 Immediately bump volume to MAX[line break]”;
say “5 Max Volume then Fade track out with a nice-ish fade curve in steps of 25 ms (song keeps playing after fade but you won’t hear it)[line break]”;
say “6 Max Volume then Fade track out with a numerical straight line fade in steps of 25 ms (song keeps playing after fade but you won’t hear it)[line break]”;
say “7 Max Volume then Fade out with minimum possible gradient but unlimited CPU speed (fade will be so fast it will be perceived as a cut - song keeps playing after fade but you won’t hear it)[line break]”;
say “8 Max Volume then Fade out with minimum possible gradient in steps of 1 ms. This is the shallowest possible fade you can program, so bring a good book, as it will take 82 seconds to fade the track out. (song keeps playing after fade but you won’t hear it)[line break]”;
say “9 Quit this demo[paragraph break]”;
let k be 0;
while k is 0 begin;
let k be the chosen letter;
if k is 49 begin; [1]
set the foreground volume to 5;
play_start_music;
otherwise if k is 50; [2]
stop the foreground sound;
otherwise if k is 51; [3]
set the foreground volume to 0;
otherwise if k is 52; [4]
set the foreground volume to 5;
otherwise if k is 53; [5]
say “[line break]Fading out with a curve…[line break]”;
let CV be 81920;
repeat with N running from 1 to 1000 begin;
if CV is less than 300, break;
now CV is CV minus 64;
if CV is greater than 2561, now CV is CV minus 128;
if CV is greater than 5121, now CV is CV minus 256;
if CV is greater than 10241, now CV is CV minus 512;
if CV is greater than 20481, now CV is CV minus 1024;
if CV is greater than 40961, now CV is CV minus 2048;
set the raw foreground volume to CV;
wait 25 milliseconds before continuing, strictly;
end repeat;
set the foreground volume to 0;
say “Fade complete.”;
otherwise if k is 54; [6]
say “[line break]Fading out in a numerical a straight line…[line break]”;
let CV be 81920;
repeat with N running from 1 to 1000 begin;
if CV is less than 2050, break;
now CV is CV minus 2048;
set the raw foreground volume to CV;
wait 25 milliseconds before continuing, strictly;
end repeat;
set the foreground volume to 0;
say “Fade complete.”;
otherwise if k is 55; [7]
say “[line break]Fading out at max CPU speed…[line break]”;
let CV be 81920;
repeat with N running from 1 to 82000 begin;
if CV is less than 2, break;
now CV is CV minus 1;
set the raw foreground volume to CV;
end repeat;
set the foreground volume to 0;
say “Fade complete.”;
otherwise if k is 56; [8]
say “[line break]Fading out with minimum fade gradient…[line break]”;
let CV be 81920;
repeat with N running from 1 to 82000 begin;
if CV is less than 2, break;
now CV is CV minus 1;
set the raw foreground volume to CV;
wait 1 millisecond before continuing, strictly;
end repeat;
set the foreground volume to 0;
say “Fade complete.”;
otherwise if k is 57; [9]
say “You’ve quit, so now you can do whatever you want. / end of line”;
stop game abruptly;
if k is less than 49 or k is greater than 57, say “Press a number between 1 and 7, please.[line break]”;
end if;
end while;
end while.[/code][/spoiler]