better Sound System
better Sound System
Hy,
why is PureBasic so bad with sounds? You can only play one sound at a time!?
I would like to see a *real* sound system be integrated - maybe via openGL or DirectX or whatever. Even MCI would be a step forward!
why is PureBasic so bad with sounds? You can only play one sound at a time!?
I would like to see a *real* sound system be integrated - maybe via openGL or DirectX or whatever. Even MCI would be a step forward!
You can play 10000 sounds at the same time if you've got enough hardware support.
Edit: The currect sound system uses DirectX. And OpenGL doens't have a sound system. And MCI is fully supported through API commands like mciSendString_().
Edit: The currect sound system uses DirectX. And OpenGL doens't have a sound system. And MCI is fully supported through API commands like mciSendString_().
Last edited by Trond on Wed Mar 01, 2006 9:52 am, edited 1 time in total.
ok, let me specify:
I just found out you can play more than one sound by doing multiple loadings.
But is doesn't work like this:
You should hear an echo effect but purebasic just stops the previous sound before playing the next. Do I have to load a sound 20 times to be able to do a tunnelecho effect? That doesn't seem very memory-saving!?
I just found out you can play more than one sound by doing multiple loadings.
But is doesn't work like this:
Code: Select all
sound=LoadSound(-1,"sound.wav")
Playsound(sound)
delay(100)
Playsound(sound)
delay(100)
Playsound(sound)
For Windows, you can use the sndPlaySound API command to do it:
Code: Select all
sndPlaySound_(filename$,#SND_ASYNC)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
No, sndPlaySound does only play one sound at a time (although asyncronious), I just checked out. Additionally this is bad for large files because you can't preload a sound with this command.
@Trond: This can't be true, because BlitzBasic uses DirectX7 and can play one loaded sound multiple times. It is based on channels -> each playing of a sound opens a new channel which can be paused, stopped etc...
channel1=Playsound(sound1)
delay(100)
channel2=Playsound(sound1)
delay(100)
stopchannel(channel2)
this way you have perfect control on sounds, can play them as often as you want, and all this is DX based... I would just like to do this in Pure too as I'm migrating to Pure...
@Trond: This can't be true, because BlitzBasic uses DirectX7 and can play one loaded sound multiple times. It is based on channels -> each playing of a sound opens a new channel which can be paused, stopped etc...
channel1=Playsound(sound1)
delay(100)
channel2=Playsound(sound1)
delay(100)
stopchannel(channel2)
this way you have perfect control on sounds, can play them as often as you want, and all this is DX based... I would just like to do this in Pure too as I'm migrating to Pure...
The manual says:
PlaySound(#Sound [, Mode])
Description
Start to play the specified sound. 'Mode' is optional and can take the following value:
0: Play the sound only once (Default value when 'Mode' is ommitted)
1: Play the sound continuously (loop). Not available under Linux!
Then you have:
SoundFrequency()
SoundPan()
SoundVolume()
StopSound()
To influence the sound (even while it is playing)
You cann use :UseOGGSoundDecoder()
to play ogg sounds and the music library for mp3 files + you have the API so where is the problem
PlaySound(#Sound [, Mode])
Description
Start to play the specified sound. 'Mode' is optional and can take the following value:
0: Play the sound only once (Default value when 'Mode' is ommitted)
1: Play the sound continuously (loop). Not available under Linux!
Then you have:
SoundFrequency()
SoundPan()
SoundVolume()
StopSound()
To influence the sound (even while it is playing)
You cann use :UseOGGSoundDecoder()
to play ogg sounds and the music library for mp3 files + you have the API so where is the problem
Visit www.sceneproject.org
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
I think you can achieve your objective by:
CatchSound() just points to the one soundfile, so this shouldn't add size to the exe or memory footprint. It just creates a separate channel for each instance.
I didn't test but it looks good to me. As long as they are different #sounds they should play concurrently.
[edit] OK I tested it. It works.
Code: Select all
Enumeration
#firstinstance_MySound
#secondinstance_MySound
#thirdinstance_MySound
EndEnumeration
InitSound()
OpenWindow(0,0,0,320,240,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"")
CatchSound(#firstinstance_MySound, ?MySound)
CatchSound(#secondinstance_MySound, ?MySound)
CatchSound(#thirdinstance_MySound, ?MySound)
PlaySound(#firstinstance_MySound)
Delay(500)
PlaySound(#secondinstance_Mysound)
Delay(500)
PlaySound(#thirdinstance_Mysound)
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
DataSection
MySound: IncludeBinary "MySound.wav"
EndDataSection
I didn't test but it looks good to me. As long as they are different #sounds they should play concurrently.
[edit] OK I tested it. It works.
BERESHEIT
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact: