Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [AGK] Generate sounds with memblocks

Author
Message
Phaelax
DBPro Master
22
Years of Service
Recently Online
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Mar 2025 16:38
The original function was written by Ric 20 years ago. https://forum.thegamecreators.com/thread/49008

I've ported it to AppGameKit, which has a different memblock header, and clarified some previous unknowns in the original code. You can change the sample rate, but altering the number of channels or bits per sample would require you to also update how the sound frames are written to the memblock. Not hard, I just didn't do it. The samples in the code are taken from my old DBC space invaders game which you can still download here: https://zimnox.com/dbcc/index.php?page=games (surprisingly, it still runs ok on win10)

For instance, 16-bit mono requires writing 2-bytes per frame. (each loop in the function writes 1 frame)
16-bit stereo would write 4-bytes per frame; 2 for left channel and 2 for right channel.
Obviously 8-bit audio is then only 1 byte for mono and 2 bytes for stereo.

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2025-05-07 17:09:51
Your offset time is: 2025-05-07 17:09:51