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.

DarkBASIC Professional Discussion / Sound object question

Author
Message
aerostudios
17
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 10th Jun 2011 04:21
Is there a way to concatenate multiple loaded sound (.wav) objects, and output as a single sound object? I need to load say;

LOAD SOUND \"sound1.wav\", 1
LOAD SOUND \"sound2.wav\", 2
LOAD SOUND \"sound3.wav\", 3

then combine them into a single sound object for PLAY SOUND...

Should I look at CREATE MEMBLOCK FROM SOUND, etc?

ideas?

Russell B. Davis/aerostudios
MayoZebraHat 1979
18
Years of Service
User Offline
Joined: 21st Dec 2007
Location:
Posted: 10th Jun 2011 07:32 Edited at: 10th Jun 2011 12:26
I'm assuming that you want to have them play one right after the other (con+cat+en+ate) in a single wav. You can just check to see if the previous sound is done playing yet to play the next one (it would lower computing time)unless you are doing procedural audio editing and need that wave file for external/etc. use.

You will have to do the following (in no great detail)

Read the help for MAKE MEMBLOCK FROM SOUND, it will show you how to construct the header of a raw sound file.

Make sure all of your sounds are the same playback format.

Make them memblocks, read from them as files... whatever you can do to get each byte from them. ... On second thought just use memblocks, probably the fastest way.

Usually I read the first 28 bytes of data of one of the files and use it for my header.

Save everything after the first 28 bytes of each sound, that is the wave data.

Make a memblock the size of 28 + the combined data size of each sound (sound file size - 28 ) Then write each block of sound data in the order you want them played.

Now if you mean to mix all of the sounds together... I'm not really sure... but my first guess, the last step is averaging each frame of raw wave data with the corresponding offset of each file. Then again I'm probably horribly wrong.
aerostudios
17
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 10th Jun 2011 13:32
Thanks for the tips. Yes, I am attempting to piece together spoken phrases and output as a single response.

Russell B. Davis/aerostudios
MayoZebraHat 1979
18
Years of Service
User Offline
Joined: 21st Dec 2007
Location:
Posted: 10th Jun 2011 23:19 Edited at: 11th Jun 2011 01:13
Ah, nice. Like text-to-speech only full words and not phonemes? Good luck with it! You may want to check out Torrey's Enhanced Audio Plugin. It lets you get a bit more data from audio files like the current position in frames durring playback as well as lots of other format playback. And http://forum.thegamecreators.com/?m=forum_view&t=84732&b=8

Also, an advanced library, FMOD.dll. Though it has licencing if you intend on charging for the software you make. There's a header I posted a few years back on here somewhere. I'll re-post if needed.

BTW, if you have IanMs Matrix1Utils then there is a Memblock String$ and Write Memblock String$ feature that "might" be useful/faster in writing large chunks of other memblocks to each other... I think strings will maintain all 255 values of each byte as they are moved in memory.

Login to post a reply

Server time is: 2026-07-11 02:14:02
Your offset time is: 2026-07-11 02:14:02