03-30-2024, 08:50 PM
The following program performs a sound effect by rapidly changing the frequency of the sound being played. It's a small thing that occurred to me today while traveling by car. It does not have filtered harmonic frequencies, so even lower frequencies creep into the sound above 1000Hz (well, that's how I explain it). I'm writing something completely different now, this was just an escape attempt for distraction.
Try value 10, 300, use MP3 (need single array type created with MemSound)
Try value 10, 300, use MP3 (need single array type created with MemSound)
Code: (Select All)
$NoPrefix
Screen _NewImage(600, 600, 32)
S = SndOpen("belfast.mp3")
Dim m As MEM
Dim As Single L, R, L2, R2
Dim As Long X, f
m = MemSound(S, 0)
If m.ELEMENTSIZE <> 8 Then
Print "Try another music file, program required SINGLE array. Try MP3."
Sleep
SndClose S
MemFree m
System
End If
Input "Insert start and end freq (start, end); 2 to 10600:"; U, D
If D > U Then Swap D, U
If D > 10600 Then D = 10600
If U < 2 Then U = 2
'try U = 10, D = 300
X = D
Stp = 4 'frequency step
Y = Stp
Do Until n& >= m.SIZE - SndRate
If n& Mod SndRate \ 6 = 0 Then 'set speed for setting freq
X = X + Y
If X > U Then Y = -Stp
If X < D Then Y = Stp
End If
f = _SndRate / X 'get freqency in samples
Do Until f Mod 4 = 0 'set f dividible by 4 for use with mem
f = f + 1
Loop
MemGet m, m.OFFSET + n&, L
MemGet m, m.OFFSET + n& + 4, R
MemGet m, m.OFFSET + n& + f, L2
MemGet m, m.OFFSET + n& + f + 4, R2
SndRaw (L2 - L), (R2 - R)
Do Until SndRawLen <= .2
Locate 2
Print X
Limit 20
Loop
n& = n& + 8
Loop
SndClose S
MemFree m
System