Page 1 of 1
Good to know about sound
Posted: Fri Oct 03, 2008 11:32 pm
by djes
As I've spent several hours on this bug, let me share it. On some computers, playing a sound with a frequency > 44100 slows down everything. Don't ask me why ; I don't think it's a PB bug but an hardware problem. :roll:
Fred> it was the reason why the ball slowed down on white tiles

I've totally revamped the collision engine only for that, but it was NOT the collision engine!

Posted: Sat Oct 04, 2008 12:19 am
by KarLKoX
The rule : always set the sampling freq according to the native sampling freq of your spu (ie : 48khz for a creative soundcard).
Despite this, crappy soundcard drivers can also be the cause ... (ie: hdaudio, ac97 ...)
Posted: Sat Oct 04, 2008 2:41 am
by PB
Wrong forum. Where's the PureBasic code? This is off-topic.
Posted: Sat Oct 04, 2008 10:20 am
by djes
KarLKoX wrote:The rule : always set the sampling freq according to the native sampling freq of your spu (ie : 48khz for a creative soundcard).
Despite this, crappy soundcard drivers can also be the cause ... (ie: hdaudio, ac97 ...)
I just wanted to use the same sound with different frequencies... I'll add this on my todo list : testing soundcard capabilities before using it.
Pseudo-code to not be "off topic"
Code: Select all
;******************************************************************************************************
; Play specified sound specifying parameters
Procedure play_sound(sound.l, pan.l = -1, volume.l = -1, frequency.l = -1)
If pan <> -1
SoundPan( sound, pan )
EndIf
If volume <> -1
SoundVolume( sound, volume )
EndIf
If frequency <> -1
SoundFrequency( sound, frequency )
EndIf
PlaySound( sound, #PB_Sound_MultiChannel )
EndProcedure
;******************************************************************************************************
InitSprite()
InitSound()
If LoadSound(0, "mysound.wav")
;OK
play_sound(0, 0, 100, 44100)
;On some soundcards, pauses the program for some ms
play_sound(0, 0, 100, 50000)
EndIf
End