02-21-2024, 06:37 AM
Here's an example where I create a plain sound and the same sound but with some over- and subtones. Sounds like some sort of electric piano But maybe SFX could get another parameter dealing with these things.
Code:
include "sfx.n7"
#mem32000000
sfx = SFX()
set window "Test", 640, 480
duration = 0.75
freq = 523*0.5
vol = [0.75, 0.2, 0.2, 0.2, 0]
main = sfx.SineWaveData(duration, freq, vol)[0]
plainSnd = createsound(main, main, sfx.GetSampleRate())
hiFreq = freq
loFreq = freq
for i = 1 to 4
hiFreq = hiFreq*2
loFreq = loFreq/2
for j = 0 to sizeof(vol) - 1 vol[j] = vol[j]*0.2
high = sfx.SineWaveData(duration, hiFreq, vol)
low = sfx.SineWaveData(duration, loFreq, vol)
for j = 0 to sizeof(main) - 1
main[j] = main[j] + high[0][j]
main[j] = main[j] + low[0][j]
next
next
newSnd = createsound(main, main, sfx.GetSampleRate())
wln "press 1 to play the plain sound"
wln "press 2 to play the new sound"
while not keydown(KEY_ESCAPE, true)
if keydown(KEY_1, true) play sound plainSnd
if keydown(KEY_2, true) play sound newSnd
fwait 60
wend