(SOLVED) Using sounds
(SOLVED) Using sounds
Hi again guys!
Im creating a shotter and I want to fire a missle. So I need to put a sound.
I was wondering on using SndPlaySound from Win32, so I tryed a function like this:
Sub play_sound(file_name as string)
sndPlaySound(file_name, SND_ASYNC)
End Sub
But this code is not compiling.
Yes Ive included "windows.bi"
Whats wrong?
Thanks in advance
Im creating a shotter and I want to fire a missle. So I need to put a sound.
I was wondering on using SndPlaySound from Win32, so I tryed a function like this:
Sub play_sound(file_name as string)
sndPlaySound(file_name, SND_ASYNC)
End Sub
But this code is not compiling.
Yes Ive included "windows.bi"
Whats wrong?
Thanks in advance
Last edited by vinians on Sep 29, 2010 15:18, edited 1 time in total.
-
- Posts: 1009
- Joined: Oct 11, 2008 7:42
- Location: ABQ, NM
- Contact:
-
- Posts: 1009
- Joined: Oct 11, 2008 7:42
- Location: ABQ, NM
- Contact:
Thanks, I discovered the error, Its was missing the include file "mmsystem.bi", now its compiles properly.
But still not working, no sound at all. My funcion below:
Ive tryed put another type of string etc etc but no sound..
Whats wrong?
But still not working, no sound at all. My funcion below:
Code: Select all
Sub som_toca(ByVal filename As String)
SndPlaySound(filename, SND_ASYNC Or SND_FILENAME)
End Sub
Whats wrong?
Try "playsound"
Be sure to use a full name or the file must be in the directory of the exe.
If you want to play more than one file at the same time use this code
Be sure to use a full name or the file must be in the directory of the exe.
Code: Select all
#include once "windows.bi"
#include once "win\mmsystem.bi"
PlaySound("c:\windows\media\tada.wav", NULL, SND_ASYNC Or SND_FILENAME or SND_LOOP)
Sleep
Code: Select all
#include once "windows.bi"
#include once "win/mmsystem.bi"
#include Once "vbcompat.bi"
Dim Shared MCIAliases(4095) As String
Function MCIPlaySound(filename_ As String) As Integer
Var filename = Trim(Ucase(filename_))
Dim soundalias As String
For i As Integer = 0 To 4095
If MCIAliases(i) = filename Then soundalias = "SPMCIPS" & Format(i, "0000"): Exit For
Next
If soundalias = "" Then
For i As Integer = 0 To 4095
If MCIAliases(i) = "" Or i = 4095 Then
mciSendString("close SPMCIPS" & Format(i, "0000"), NULL, 0, 0)
Function = 1
If mciSendString("open " & Chr(34) & filename & Chr(34) & " alias SPMCIPS" & Format(i, "0000"), NULL, 0, 0) = FALSE Then
Function = 0
MCIAliases(i) = filename
mciSendString ("set SPMCIPS" & Format(i, "0000") & " time format milliseconds", NULL, 0, 0)
soundalias = "SPMCIPS" & Format(i, "0000")
Endif
Exit For
Endif
Next
Endif
If soundalias <> "" Then
mciSendString("play " & soundalias & " from 0", NULL, 0, 0)
Endif
End Function
Sub MCIUnloadAll()
For i As Integer = 0 To 4095
mciSendString("close SPMCIPS" & Format(i, "0000"), NULL, 0, 0)
Next
End Sub
If MCIPlaySound("c:\windows\media\tada.wav") Then Print "error"
'Sleep 2000
If MCIPlaySound("c:\windows\media\chimes.wav") Then Print "error"
Sleep 2000
MCIUnloadAll()
-
- Posts: 248
- Joined: Jul 01, 2010 9:35
Sound
@Kiyote & SARG
Thanks from me as well. This solves my problem which I posted on 7 August. It was about rundll32, mmsystem.dll to play "Tada.wav".
My snippet used to work on WIN98SE but crashed on XP
Thanks from me as well. This solves my problem which I posted on 7 August. It was about rundll32, mmsystem.dll to play "Tada.wav".
My snippet used to work on WIN98SE but crashed on XP
Last edited by Theunis Jansen on Sep 30, 2010 6:03, edited 1 time in total.
-
- Posts: 1009
- Joined: Oct 11, 2008 7:42
- Location: ABQ, NM
- Contact:
@SARG
I think you just posted help for something I'm struggling with, but put far on the back burner..
Are you loading in sounds to the MCI interface thingy, and then calling them?
Can you break down into a bit more detail, how that code there works?
I'll be sure to take it apart in the mean time on my own, but that's like really cool.
I have been using SNDPLAY and whatnot to do sounds, cause I don't want to use certain libraries & stuff, cause they say you can't make money off what your doing if you use them.
~Kiyote!
I think you just posted help for something I'm struggling with, but put far on the back burner..
Are you loading in sounds to the MCI interface thingy, and then calling them?
Can you break down into a bit more detail, how that code there works?
I'll be sure to take it apart in the mean time on my own, but that's like really cool.
I have been using SNDPLAY and whatnot to do sounds, cause I don't want to use certain libraries & stuff, cause they say you can't make money off what your doing if you use them.
~Kiyote!
Sound - MCI
@ Kiyote
I tried both the snippets. The first one works for short voice Wav recordings.
The second one also works but it is limited to the "string(4095)". i.e it plays a very short sound. I had to use SLEEP 2000 after the first sound to hear the second sound. The buffer must therefore be made larger to play longer *.wav files.
I could only get it to play *.wav files and not *.mp3 or *.ogg.
If the SND _ASYNC isn't added the sound gives a snick/click on the speakers when it finishes.
I made a string PlayIt=".. and replaced "c\windows\media\Tada.wav" with it.
I tried both the snippets. The first one works for short voice Wav recordings.
The second one also works but it is limited to the "string(4095)". i.e it plays a very short sound. I had to use SLEEP 2000 after the first sound to hear the second sound. The buffer must therefore be made larger to play longer *.wav files.
I could only get it to play *.wav files and not *.mp3 or *.ogg.
If the SND _ASYNC isn't added the sound gives a snick/click on the speakers when it finishes.
I made a string PlayIt=".. and replaced "c\windows\media\Tada.wav" with it.
-
- Posts: 87
- Joined: May 21, 2010 17:38
- Location: Massachusetts, USA
- Contact:
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Playsound
The first snippet appears to play a full length *.wav file. It kept playing in the background until I moved to the second question in my file.
I let it run for 1 minute before I switched off.
Joshy's solution looks much better especially as it plays more than just *.wav files.
I let it run for 1 minute before I switched off.
Joshy's solution looks much better especially as it plays more than just *.wav files.
-
- Posts: 248
- Joined: Jul 01, 2010 9:35
using sound
@ D.J.Peters
Hi Joshy
I tried it and it works fine for *.wav files. (Using the windows.bi etc.)
I would like to use MP3 and OGG files but can't find FBsound you refer to.
I only found FMOD and DSL which means distribution of the libraries with my progs. I prefer stand-alone progs
I tried the Help file in FBIde but can't find FBSound.
Any pointer to where I can search for or find it will be appreciated.
Hi Joshy
I tried it and it works fine for *.wav files. (Using the windows.bi etc.)
I would like to use MP3 and OGG files but can't find FBsound you refer to.
I only found FMOD and DSL which means distribution of the libraries with my progs. I prefer stand-alone progs
I tried the Help file in FBIde but can't find FBSound.
Any pointer to where I can search for or find it will be appreciated.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
there are hundrets of posting about FBsound but it got never a sticky link
(the FB dev team supports only libs written in stable C/C++ code :lol: )
Download: fbsound0.10.zip
Joshy
(the FB dev team supports only libs written in stable C/C++ code :lol: )
Download: fbsound0.10.zip
Joshy
-
- Posts: 248
- Joined: Jul 01, 2010 9:35
using sounds
That is really great. Thank you Joshy.
This was my fifth attempt to log in. Looks like there is a gremlin.
This was my fifth attempt to log in. Looks like there is a gremlin.