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 / Make Sound From Memblock woes.. please help..

Author
Message
David Gervais
Retired Moderator
20
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 21st Jul 2010 14:07
Ok, I dissected a small .wav file I created, to make sure I understood the file format.. it has a header and 128 bytes of sound data. The first 44 bytes of the file contain the header info, the next 128 bytes are the raw sound data (can be any values from 0 o 255) followed by 2 zero bytes.

When I run this code it always errors out saying could not load sound file at line 16. Line 16 is the "MAKE SOUND FROM MEMBLOCK 1,1" command all on it's own.

can someone look at this code and tell me what I'm doing wrong?

I have the 174byte long wave file if you need that.. but the point is to recreate the wave but without the need to load media.



Thanks in advance for any help.

Cheers!

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jul 2010 14:15
Does it work if you use 'make memblock from file'?

I'm not sure, but it may be that DBPro uses a different format for memblocks than for .wav files.

[b]
sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 14:21 Edited at: 21st Jul 2010 14:22
Check out the opposite command 'MAKE MEMBLOCK FROM SOUND' which looks like it explains the format it uses for memblock sounds.

Edit: Alternately, make a memblock the normal way from your existing wav file and then dump the contents of the memblock to see what format it's in.
David Gervais
Retired Moderator
20
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 21st Jul 2010 16:54
the data in the data statements is 'exactly' that of the wave file. I converted the info from hex to decimal.. that gave me the header info.. the only info I want to change is the raw sound data.. to see if random numbers produces a hiss, or whatever.. I can make tones by manually editing the data in a hex editor,.. but I wanted to manipulate the info by code..

I'll try loading the wav first and make memblock from sound, then reverse it.. I'm betting it's the same data.. just how dbpro handles it.. which would make using make sound from memblock a bit useless.. unless I need to put bytes/ long words and stuff to the memblock, I just thought that with such a small file, data statement was good enough.

Thanks for the quick replies.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jul 2010 17:06 Edited at: 21st Jul 2010 17:17
I don't think the memblock header info matches the wave file header info.

I might have a working demo somewhere. I'll see if I can dig it out.

Edit Here's one demo. I'm afraid I haven't time to simplify it now. If you run the demo and click the notes you'll hear the notes as they are clicked. The individual notes are saved to the project's directory.

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 17:21 Edited at: 21st Jul 2010 17:23
Quote: "make memblock from sound, then reverse it."


Yes that would probably give back exactly the same, what I meant was convert a sound into a memblock the normal way, then byte examine the contents of the memblock which would show how a wav is stored in a memblock. Then you can get your wav file, strip the original wav header and create a memblock header with the original wav sound data.

Check this thread out:

http://forum.thegamecreators.com/?m=forum_view&t=133019&b=34

edit: 2/3 way down chunks chunks shows how memblock wav is stored, which looks like as described in the dbpro help file.
David Gervais
Retired Moderator
20
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 21st Jul 2010 18:57 Edited at: 21st Jul 2010 18:59
Interesting code GG, the header info in your code is almost identical to mine, but there are differences..

what DBPro needs is built in sound. like the good old Atari 8-bits LoL, that would be sweet.. But alas I'm just dreaming again.

I'll stick with the load sound "filename.wav".. this memblock thing is too complicated f0r me.. bring back peeks and pokes please LOL j/k

thanks for all the replies,

Cheers!

P.S. when I loaded the wav file (174 bytes in size) made a memblock from sound and then deleted the sound and made sound from memblock.. it worked, but when I checked the size of the memblock, it got stripped to 154bytes.. strange.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Jul 2010 21:17
The header of a sound memblock is only 28 bytes, [0-27].






16-bit audio
Each sample is 2 bytes long, so the value is a "word".
Value range is -32768 to 32767 (signed 2^16)

8-bit audio
Each sample is 1 byte long.
Value range is 0-255 (unsigned 2^8)


Here's a 16-bit example:


You'll probably want to read through this thread:
http://forum.thegamecreators.com/?m=forum_view&t=49008&b=6


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jul 2010 23:46
Quote: "what DBPro needs is built in sound. like the good old Atari 8-bits LoL, that would be sweet.. But alas I'm just dreaming again."


YYEEEESSSSSS!!!!!

Absence of decent built-in sound support was one thing that really surprised me when I first used DBPro. I just loved the Atari SOUND command on my old Atari 800XL machine.
David Gervais
Retired Moderator
20
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 21st Jul 2010 23:59
Phaelax said..

Quote: "You'll probably want to read through this thread:
http://forum.thegamecreators.com/?m=forum_view&t=49008&b=6"


Wow, simply WOW!, and this function has not been made a sticky in the code snippets? Ric? Everyone? last post in that thread was back in 2005.. it's still a valid function today in 2010, it never should have been allowed to slip into the dusty old archives.

When I did a search for 'Memblock Sounds' that thread was nowhere near in the list. In fact only 5 threads were shown and I didn't find my answers in them. This is a wonderful function and should have been made part of the DBPro Sound functions back in 2005 when it was born.

Cheers and thanks for the heads up Phaelax.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 22nd Jul 2010 13:47
Quote: "Quote: "what DBPro needs is built in sound. like the good old Atari 8-bits LoL, that would be sweet.. But alas I'm just dreaming again."

YYEEEESSSSSS!!!!!

Absence of decent built-in sound support was one thing that really surprised me when I first used DBPro."

Not quite the same, but there is always my midi plugin.

Regarding the wave format, the last dword in the 28 byte header denotes an offset to the actual sound data beginning after the header. Usually it is 0, which means that sound data begins at byte 29, but other stuff might be stored as part of an "additional" header, which I suppose might be the additional 16 bytes you mentioned being part of the header. By looking at your waveheaderdata section though, it seems to be invalid in that the offset value is neither 16, nor 0 but rather a pretty large number that would point outside your small wave data, hence probably being the reason for failure.

On further investigation, what you have there is actually a wave FILE header. That is a bit different from the wave DATA header. The data you want to set up a memblock (WAVEFORMATEX structure) is stored from bytes 12 through 36 in that data. There is however no offset value stored, but you can set that to 0 for yourself.

------
I have to go now, but I can get back to this tonight if there are anything that needs clearing up.

Cheers,
Rudolpho

Login to post a reply

Server time is: 2026-07-25 05:32:43
Your offset time is: 2026-07-25 05:32:43