The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RedXVII on November 02, 2005, 12:58:37 AM

Title: Midis, mp3 and wav
Post by: RedXVII on November 02, 2005, 12:58:37 AM
As a kindof mini learn win32 assembly i want to be able to know how to play midis, and less importantly mp3s and wav.

Anyone know how to do it?


Thanks  :U
Title: Re: Midis, mp3 and wav
Post by: gavin on November 02, 2005, 01:14:18 AM
Hello RedXVii

For the wav file you can use this code.


.data
sound db "benny.wav",0   ;the filename has to be in same dir or else put full path to it

.code

START:

Invoke PlaySound, ADDR sound, NULL, SND_FILENAME or SND_ASYNC

invoke ExitProcess, eax


end START


I'm not sure about the others but i read about mci strings  on msdn.

Good luck
Title: Re: Midis, mp3 and wav
Post by: Tedd on November 02, 2005, 11:23:17 AM
Or, if you want to do it the long way and decode the midi file yourself.. well, let's just say it's not pretty and really not a 'mini' project :bdg

Mp3 isn't too pretty either, but as long as you have a decoder library function then it's not so bad.
And wav is fairly simple :toothy
Title: Re: Midis, mp3 and wav
Post by: RedXVII on November 02, 2005, 11:43:20 AM
Thanks fellas,

Even if i figured out how to deocde the midi file (which i think i can do) i have no idea how to make it play the noise i want  :( 

isnt there a function to play midis?

Thanks  :U
Title: Re: Midis, mp3 and wav
Post by: Tedd on November 02, 2005, 05:27:36 PM
If you just want be able to play stuff, you can do it through the mci (which is what windows media player uses) - so you'll be able to play wav, midi, mp3, and many others without even needing to worry.

This should get you started..

invoke MCIWndCreate, hWnd,hInstance,WS_CHILD or MCIWNDF_NOTIFYMODE or MCIWNDF_NOMENU or MCIWNDF_NOPLAYBAR,pFName
mov hWndMCI,eax
invoke SendMessage, hWndMCI,MCI_PLAY,0,0

(rtfm for more info, explanations..)

Oh, you'll need to include msvfw32 inc and lib :toothy


[attachment deleted by admin]
Title: Re: Midis, mp3 and wav
Post by: mnemonic on November 02, 2005, 05:31:21 PM
RedXVII,

have a look in here (http://www.fmod.org/).
There is no need to reinvent the wheel  :wink

Regards
Title: Re: Midis, mp3 and wav
Post by: SamiP on November 04, 2005, 08:43:45 AM
RedXVII, you could also use BASS library from http://www.un4seen.com/
Title: Re: Midis, mp3 and wav
Post by: RedXVII on November 04, 2005, 05:10:49 PM
are there no functions in windows xp somewhere?
Title: Re: Midis, mp3 and wav
Post by: Tedd on November 04, 2005, 05:14:29 PM
Quote from: RedXVII on November 04, 2005, 05:10:49 PM
are there no functions in windows xp somewhere?

..refer to my previous post ::)
Title: Re: Midis, mp3 and wav
Post by: RedXVII on November 07, 2005, 12:13:16 AM
Woops, i seem to have missed youre post forsome reason...

Ah ha! just what i wanted! I presume this function is a part of windows somewhere?

Thanks alot Tedd, and everyone else who contributed!  :U
Title: Re: Midis, mp3 and wav
Post by: Retsim_X on November 09, 2005, 10:41:33 AM
hi

if i recall corectly i beleive there is an example of mp3 playing and even coverting though its in a dll (no code)
in the ide NAGOA i first worked with this but it is BAD

if you dont use qedit
USE RadASM it works verywell and use masm hehe

yours retsim x