flat assembler
Message board for the users of flat assembler.

Index > Windows > Using PlaySound

Author
Thread Post new topic Reply to topic
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
How can I use PlaySound to play an audio file in the background? When I use it like this:

Code:
       invoke PlaySound,tempstring,NULL,$20000 OR 1
    


It doesn't play anything. But if I do:

Code:
       invoke PlaySound,tempstring,NULL,$20000
    


It does play, but pauses the program. Is it possible to make an audio file play in the background?

_________________
Charles Childers, Programmer
Post 18 Jul 2004, 00:10
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Didn't it play at all, or did your main thread reach ExitProcess before the sound even started?

(PS: what about using nice symbolic constants rather than hardcoded magic numbers?)
Post 18 Jul 2004, 00:49
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
It doesn't play it at all with "$20000 or 1" Sad

Since I only call this in one routine, I didn't see much value in putting the numbers in as symbolic constants.
Post 18 Jul 2004, 01:00
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Well, if you have the symbolic constants available (header/include files, whatever) there's not much reason not to use them - and it makes it quite a bit easier to see wtf is going on Wink.

I mean, given your problem it was quite easy to guess that "1" had to mean "async", but SND_FILENAME or SND_ASYNC is a bit easier to read than the hardcoded numbers :p

Sounds a bit weird that you get no sound if the program is still running... can you reproduce this in a small test?
Post 18 Jul 2004, 01:12
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
I'm wondering if the problem is due to the use of a DLL. See, I have a DLL implementing a Forth interpreter/compiler. The app implements several functions, which are then wrapped in Forth. (E.g., the Forth word in the DLL calls the assembly routine in the app). This works, from within Forth, but not from with the event loop. I can post the entire code as a .zip file, but I haven't managed to duplicate the problem outside this program Sad
Post 18 Jul 2004, 02:22
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Ugh, this sounds pretty weird :-s.
Hm, you say within event loop - could it perhaps be that you trigger PlaySound multiple times? (Try putting a int3 or MessageBox before the PlaySound call)
Post 18 Jul 2004, 02:37
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Thanks! That was the problem. Adding "OR $10" to the invoke fixed it. Thank you again!
Post 18 Jul 2004, 03:16
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
SND_NOSTOP you mean Wink - cheers
Post 18 Jul 2004, 03:29
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Yup Smile
Post 18 Jul 2004, 03:40
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Ok, how about this: Is it possible to play two audio files at the same time? For example, background music and sounds over the background music.
Post 18 Jul 2004, 05:50
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
You'll need to look into more advanced code than PlaySound, then. There's basically two major ways to do this: WAVEOUT and DirectSound. With DSound you can either use hardware mixing, or do your own. With WAVEOUT, you have to do your own mixing.

If you don't feel like writing "a bunch of code", perhaps take a look at one of the existing sound libraries like BASS, FMOD, OpenAL (overkill?), or whatnot.
Post 18 Jul 2004, 09:20
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.