March 28, 2024, 11:10:56 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


WAV file play...

Started by J B Wood (Zumwalt), November 27, 2006, 12:01:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)

How do I play a WAV sound and have it included as an internal resource?
Or heck, just play it from disk?

Ionic Wind Support Team

#define SND_FILENAME  0x20000
#define SND_MEMORY  0x4
#define SND_NODEFAULT  0x2
DECLARE IMPORT,PlaySoundA(name as POINTER,handle as UINT,flags as UINT),INT;

PlaySoundA("bam.wav", NULL, SND_NODEFAULT | SND_FILENAME);
Ionic Wind Support Team

J B Wood (Zumwalt)

Did I ever mention how cool you are?
Slapping this code into the game.

Now to do this as a resource sometime in the future :)

joske

With mciSendString you can play wav, mp3, mid, avi, mpg, wmv.

DECLARE IMPORT,mciSendStringA(lpszCommand:STRING,lpszReturnString:POINTER,cchReturn:INT,hwndCallback:UINT),int

mciSendString: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_mcisendstring.asp

Multimedio Command Strings:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_multimedia_command_strings.asp

I can post some IBasic pro examples if that helps

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

He was asking for Aurora code.  But we can convert it easy enough.
Ionic Wind Support Team

joske

Here is a nice example, it is rather easy to see how to use mciSendString

http://www.codingmonkeys.com/index.php?topic=524.0 (IBasic pro)



J B Wood (Zumwalt)

Thanks, trying to find a way to do multiple at the same time. Spent a few hours last night trying to decipher what I need to do for DirectSound since once the sound bytes are loaded into memory cache, I call them by the cache ID. Didn't get very far with it though.

Kale

Aurora needs native sound playing commands to round off the game making capabilities.

J B Wood (Zumwalt)

Paul has sound in the plans from what I read somewhere, not a top of the list item for Aurora at the moment since through third party stuff it is doable.
I still can't believe I made a game on top of the 3d space using 3d sprites on a flat surface. I am still debating on removing the back image and placing a spinng world there instead...

DominiqueB

Here is the IBpro mci player ported to EBasic (did it last night)

Dominique

J B Wood (Zumwalt)

Thanks, going to take a look at the code to see how you did it.

J B Wood (Zumwalt)

Can mciSendStringA play more than 1 sound file at a time?
I notice in the code before you play the next sound you are calling "close all"

LarryMc

I know it can play multiple tracks on a CD.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

J B Wood (Zumwalt)

November 29, 2006, 02:16:38 PM #14 Last Edit: November 29, 2006, 02:55:45 PM by Jonathan (zumwalt) Wood
I probably don't have this declared right:




DECLARE IMPORT, mciSendStringA(lpszCommand as string,lpszReturnString as STRING,cchReturn as INT,hwndCallback as INT),INT;





In EBasic its declared as:




DECLARE "winmm",mciSendStringA(lpszCommand:STRING,lpszReturnString:STRING,cchReturn:INT,hwndCallback:INT),INT





Do I have the declaration correct?

Ionic Wind Support Team

Anytine you see hwnd it is a uint or int.
Ionic Wind Support Team

LarryMc

November 29, 2006, 02:47:17 PM #16 Last Edit: November 29, 2006, 02:56:15 PM by Jonathan (zumwalt) Wood
This works in my program:
   


DECLARE IMPORT,mciSendStringA(lpszCommand:STRING,lpszReturnString:STRING,cchReturn:INT,hwndCallback:int),int



even though Paul said hwndCallback:int should be an uint.

I didn't know any better when I wrote my program; but since it always 0 in my program I guess that's why it didn't hurt me.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

J B Wood (Zumwalt)

I just modified it to add some space in the code brackets...
Anyway, changing it from pointer to int doesn't matter for me either.
I get no sound with this...




string statusBuf,command;
command="Open " + GetStartPath()+ "snd\\LevelStart.wav Type WaveAudio alias lvlStart";
int j=messagebox(NULL, command, "Command");
mciSendStringA(command,"",0,0);
mciSendStringA("set lvlStart time format milliseconds" ,"",0,0);
command = "Status lvlStart length";
mciSendStringA(command,statusBuf,254,0);
j=messagebox(NULL, statusBuf, "Status");
mciSendStringA("status lvlStart position",statusBuf,254,0);
j=messagebox(NULL, statusBuf, "Status");
mciSendStringA("play lvlStart","",0,0);
command = "Close lvlStart";
mciSendStringA(command,"",0,0);





LarryMc

In the IBPro example the output is tied to the handle of a text control.
In your Aurora code you haven't tied it to anything.  Maybe that;s where the problem lies.

I don't know how to help you in Aurora.
I'm IBpro/Ebasic freak. ;)
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Steven Picard

November 29, 2006, 04:13:22 PM #19 Last Edit: November 29, 2006, 04:25:01 PM by Steven Picard
Johnathon,

Your code should work but I don't thinking you're letting it actually have time to finish (or even start) playing .  Add a message box after the play command to see what I'm talking about:
messagebox(null,"Click OK when you're done listening.","Instructions");

J B Wood (Zumwalt)

November 29, 2006, 06:51:35 PM #20 Last Edit: November 29, 2006, 06:53:16 PM by Jonathan (zumwalt) Wood
Didn't make a difference still no sound.
I am thinking it has something to do with EBasic pointing to the dll through this:
DECLARE "winmm"

But in Aurora I am only doing a DECLARE IMPORT but not telling it where to look for it?

J B Wood (Zumwalt)

Blasted all!!!

*sigh*
Ok, I broke down and found out more about the mci object and did one more declare of:
DECLARE IMPORT, mciGetErrorStringA(int fdwError, string lpszErrorText,UINT cchErrorText),int;

Well, the 'result' from the call to the send for the open, returns error 259..
Error 259 when pulled from the geterror call returns... blah... "The Driver"
*sigh*
It is not automatically recognizing the driver based on my send, *gets out the sledgehammer*

Parker

Allowing you to use a string is just a leftover from IBStd where DLLs were loaded dynamically and it needed them. It was left in IBPro for compatibility with IBStd, and so it's in EBasic for compatibility with IBPro. But it doesn't mean anything; the compiler just sees it as IMPORT.

J B Wood (Zumwalt)

But I have absolutely no problems with the EBasic code but I can't get the mci to work in Aurora.
Makes no sense to me.. going to just wait on a sound mechanism for Aurora, this is giving me a serious headache.

ExMember001

you can also use bass.dll , well i know its kinda big engine for a wav or 2 but you can open more than 1 stream at the same time and add effect...
well just an idea ;)