News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Playing wav file from within a program

Started by white scorpion, October 10, 2005, 07:48:07 PM

Previous topic - Next topic

white scorpion

Hi all,

i'm currently writing a program where i want to play a wav file from within the program.
I can solve it by calling "C:\program files\windows media player\wmplayer.exe" test.wav
but then i have no control over the file anymore.

I'm sure there should be an easy way to do this, but all i can find are code for C# and VB and all functions used there aren't windows API's which i can easily invoke from within masm.

Any idea?

Thanks in advance!

Regards,

Mark

Darrel

Have a look at Waveform Functions. I have used sndPlaySound in the past.

HTH,

Darrel

white scorpion

Wonderful!!!

So there ARE Api's for it... Thanks, that's all i needed to know for now ;-))


Tedd

You can also use MCI - which basically gives you a wmplayer 'window' that you have control over - so you can play wav, mp3, etc; play, stop, skip, ...
No snowflake in an avalanche feels responsible.

Farabi

Quote from: Tedd on October 11, 2005, 11:15:09 AM
You can also use MCI - which basically gives you a wmplayer 'window' that you have control over - so you can play wav, mp3, etc; play, stop, skip, ...


What MCI function to do fast forward dan backward?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

I don't think there are real fast-forward and fast-reverse, but so you can use seek.
No snowflake in an avalanche feels responsible.

white scorpion

Thanks guys, the API's were all i needed, it works like a charm...

ToutEnMasm

Hello,
The answer is in the SDK,i translate it for masm


    SonWav         PROTO :DWORD
;déclaring the ressource in .RC, 530 WAVE DISCARDABLE "name.wav"
;include winmm.lib et winmm.inc
;call functio like that, invoke SonWav,530
;les macros SADD et FUNC font parties de MASM32
;################################################################
SonWav PROC IDwave:DWORD
;           Local retour:DWORD
;           Local hResInfo:DWORD,hRes,lpRes,bRtn
         mov retour,0
    ; Trouver la ressource WAVE défini ainsi dans le .rc
    mov hResInfo,FUNC(FindResource,hInstance, IDwave,SADD("WAVE"))
;   .if eax == 0     
;       wavechec:     
;       invoke MessageBox,NULL,SADD("son wavechec"),SADD("ECHEC"),MB_OK
;       jmp FindeSonWav
;   .endif
 
    ;charger la ressource
 
    mov hRes,FUNC(LoadResource,hInstance, hResInfo)
    .if hRes == NULL
;   jmp wavechec
    .endif
    ; verrouiller la ressource et la jouer
 
    mov lpRes,FUNC(LockResource,hRes)
    .if lpRes != NULL
        mov bRtn,FUNC(sndPlaySound,lpRes, SND_MEMORY + SND_SYNC + SND_NODEFAULT)
        ;invoke UnlockResource,hRes ;obsolete pas necessaire en 32 bits
;   mov retour,eax
    .endif
    ;libérer la resource et passer la valeur de retour
 
    invoke FreeResource,hRes
FindeSonWav:
         mov eax,retour
         ret
SonWav endp






white scorpion

That code indeed is nice if you want to use a wav packed as resource but since i want the user to choose the wav file himself i've made an openfile button so he can select it.