flat assembler
Message board for the users of flat assembler.

Index > Windows > Sound output example?

Author
Thread Post new topic Reply to topic
Artlav



Joined: 23 Dec 2004
Posts: 188
Location: Moscow, Russia
Artlav 09 Nov 2009, 21:20
Greetings.
Is there any example of a simple Fasm Windows 32 bit program that can output sound from a memory buffer (procedurally generated?), using some common Windows mechanism?

The search failed me in the situation.
Post 09 Nov 2009, 21:20
View user's profile Send private message Visit poster's website Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 09 Nov 2009, 21:57
PlaySound function + SND_MEMORY flag does what you want.
Post 09 Nov 2009, 21:57
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 10 Nov 2009, 06:32
Artlav, check out the attachments, let me know if it helps.

The attachments are:
waveplay.zip is in FASM. It is for an old version of FASM, I am not sure which. It probably won't compile with the latest FASM. This example parses a PCM .wav file and plays it out from a sound buffer. Also check out zhirik.wav in this zip file, I think you'll like it Smile

toneplay.zip is in C. It generates a wave, puts it in a buffer, and uses the same APIs to play it from that buffer. The Tone field specifies what frequency to generate, and the Length specifies for how many seconds to generate it. I just looked at this 7 year old source, and it looks I was generating a saw-tooth wave.

Both samples are not commented well. If you are looking for a better example, just look for anything using waveOut* APIs (Windows Multimedia APIs). There should be lots of stuff on www.codeproject.com, www.codeguru.com, or even www.wasm.ru. Or even in the Windows SDK.

Another alternative is DirectSound, but I've never used that.

Remember, your real question here is what API to use. It does not matter if its written in assembly, C, or Visual Basic.


Description: waveplay.zip is in FASM. It is for an old version of FASM, I am not sure which. It probably won't compile with the latest FASM. This example parses a PCM .wav file and plays it out from a sound buffer.
Download
Filename: waveplay.zip
Filesize: 57.59 KB
Downloaded: 333 Time(s)

Description: toneplay.zip is in C. It generates a wave, puts it in a buffer, and uses the same APIs to play it from that buffer.
Download
Filename: toneplay.zip
Filesize: 6.48 KB
Downloaded: 235 Time(s)


_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 10 Nov 2009, 06:32
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 10 Nov 2009, 07:44
Also dont forget about OpenAL.
Its the best choice for games.
Its easy to use with multichannel and 3D mixing.
But for simple windows events i would use PlaySound.
Like for custom button click sounds and such...
Post 10 Nov 2009, 07:44
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.