After reading the conversation between you and redcrab talking about ticks in fbsound, i could hear them too and was searching for an answer to this.
The code:
Code: Select all
#libpath "./lib"
#include "./inc/fbsound.bi"
const plug_path = "./lib/"
const data_path = "./resources/"
' only if not same as exe path
fbs_Set_PlugPath(plug_path)
Dim As Integer hWave,hSound
Dim As Single w,wstep=pi2/44100.0*400
Dim As FBS_SAMPLE Ptr lpSamples
fbs_Init(44100,1)
fbs_Create_Wave(44100,@hWave,@lpSamples)
For i As Integer=0 To 44099
lpSamples[i]=Sin(w)*1000:w+=wstep
Next
screenres 512,512
dim as integer index=44100-256
line(0,255)-step(639,0),1
pset(0,lpSamples[index] shr 8),1
for x as integer=1 to 639
index+=1
if index<44100 then
line -(x,256+lpSamples[index] *0.2),2
else
index mod=44100
line -(x,256+lpSamples[index] *0.2),4
end if
next
fbs_Create_Sound(hWave,@hSound)
fbs_Play_Sound(hSound,-1) ' loop endless
? "playing clean sine wave for 5 seconds"
Sleep 5000
end
Can it be that the ticks occur when the samples are repeated, after one second?
Even more cleaner to hear this:
PS: Do'nt forget to lower the systems volume because if you do'nt then you may never hear any ticks any more!
Code: Select all
#libpath "./lib"
#include "./inc/fbsound.bi"
const plug_path = "./lib/"
const data_path = "./resources/"
' only if not same as exe path
fbs_Set_PlugPath(plug_path)
Dim As Integer hWave,hSound
Dim As Single w,wstep=pi2/44100.0*400
Dim As FBS_SAMPLE Ptr lpSamples
fbs_Init(44100,1)
fbs_Create_Wave(44100,@hWave,@lpSamples)
For i As Integer=0 To 44099
lpSamples[i]=Sin(w)*44100:w+=wstep
Next
fbs_Create_Sound(hWave,@hSound)
fbs_Play_Sound(hSound,-1) ' loop endless
? "playing clean sine wave for 5 seconds"
Sleep 5000
end
I also have two questions about fbsound:
1) How to do crossfade between two sounds?
(Is it even possible to fade out a sound and fade in another sound at the same time?)
2) How to load one sound, play it, stop this sound, load another sound, play it and then stop that sound?
I think fbs_Set_SoundPaused() is'nt a good option for this. Neither do fbs_Stop(). But what is?
Please, correct me if i'm wrong.