Sounds

Blitz3D Forums/Blitz3D Beginners Area/Sounds

Im sure there was some mention of accessing beeper controls from within blitz somewhere but ^^&*^*&%ered if I can find it :)

--------------

I just started toying around with some code, and I got stuckl into making a quaint little game that so far uses NO external media (woooh!) Unfortuantely, it's of course rather quiet. Are there any ideas on how to make sound effects at all without loading anything in?

I don't care even if it sounds like a strangled, dying ZX Spectrum (god bless), just any sort of functioning audible recognition will do!

I think you might be thinking of the WinAPI 'Beep' function... Here's what MSDN say:-

Beep
The Beep function generates simple tones on the speaker. The function is synchronous; it does not return control to its caller until the sound finishes.

BOOL Beep(
DWORD dwFreq, // sound frequency
DWORD dwDuration // sound duration
);
Parameters
dwFreq
[in] Specifies the frequency, in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
Windows 95/98/Me: The Beep function ignores this parameter.

dwDuration
[in] Specifies the duration, in milliseconds, of the sound.
Windows 95/98/Me: The Beep function ignores this parameter.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
Terminal Services: The beep is redirected to the client.

Windows 95/98/Me: On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep.

Example Code
For an example, see Registering a Control Handler Function.

Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

Isn't there a Control character to perform a system BEEP?

Could be, though... I have tried wrapping up the characters in a For... Next loop and I cannot hear anything on my setup (Because my setup is rather pap!)

Hmm.........


Thanks, Dabz- I think that was what I remembered seeing. Shame, though- all that API stuff is over my head ;)

I remember doing this, there was a dll for speaker beep on the forum here somewhere, but it was a dead link... so I nabbed someone else's code in Purebasic and made a beep.dll.

I then wrote a bit of code to create sounds from a spectrum game, which was cool enough, but I was never happy with it because it sounded crap and I think some setups can't do a beep, not sure though... so I decided to use wave files.

I could upload a zip with the beep.dll and an example usage if you like.

Yes please! or you can email to:
teutanis_support@...

Malice,

Have a look at what Cygnus did in this .....

http://www.blitzbasic.com/codearcs/codearcs.php?code=1188

No external resource or DLL's!!!

ok, since the dll is very small the easiest thing for me is just to post a .bb file that creates the dll from a data block, rather than host it somewhere. So just run this file and put beep.dll in userlibs folder like it says.

Edit: fixed a bug where frequencies of 0-18 caused a crash. Thought I might as well fix it as it was a bit of a pain.

;Put beep.dll in userlibs folder, by AKJ (Anthony Jordan) on 5/9/05

Restore beepDLL ;data pointer
fileout=WriteFile("beep.dll") ;<- create file
While byte>=0
 Read byte ;get next byte
 WriteByte(fileout,byte)
Wend
CloseFile(fileout)
Print "file written"
WaitKey()

.beepDLL
Data 77,90,144,0,3,0,0,0,4,0,0,0,255,255,0,0,184
Data 0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,128,0,0,0,14,31,186,14
Data 0,180,9,205,33,184,1,76,205,33,84,104,105,115,32,112,114
Data 111,103,114,97,109,32,99,97,110,110,111,116,32,98,101,32,114
Data 117,110,32,105,110,32,68,79,83,32,109,111,100,101,46,13,13
Data 10,36,0,0,0,0,0,0,0,80,69,0,0,76,1,6,0
Data 214,63,206,67,0,0,0,0,0,0,0,0,224,0,14,33,11
Data 1,2,55,0,8,0,0,0,10,0,0,0,4,0,0,72,17
Data 0,0,0,16,0,0,0,32,0,0,0,0,0,16,0,16,0
Data 0,0,2,0,0,1,0,0,0,0,0,0,0,4,0,0,0
Data 0,0,0,0,0,112,0,0,0,4,0,0,0,0,0,0,3
Data 0,0,0,0,0,16,0,0,16,0,0,0,0,16,0,0,16
Data 0,0,0,0,0,0,16,0,0,0,0,96,0,0,100,0,0
Data 0,0,64,0,0,56,3,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 80,0,0,220,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,46,116,101,120,116,0,0,0,164,7,0,0,0,16,0
Data 0,164,7,0,0,0,4,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,32,0,0,96,46,98,115,115,0,0,0,0,152
Data 2,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,128,0,0,192,46,100,97
Data 116,97,0,0,0,88,0,0,0,0,48,0,0,88,0,0,0
Data 0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64
Data 0,0,192,46,105,100,97,116,97,0,0,56,3,0,0,0,64
Data 0,0,56,3,0,0,0,14,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,96,0,0,192,46,114,101,108,111,99,0,0
Data 228,0,0,0,0,80,0,0,228,0,0,0,0,20,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,32,0,0,2,46,101
Data 100,97,116,97,0,0,100,0,0,0,0,96,0,0,100,0,0
Data 0,0,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 32,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,184,1,0,0,0,195,49,192,64,139,76,36,4
Data 247,65,4,6,0,0,0,116,15,139,68,36,8,139,84,36,16
Data 137,2,184,3,0,0,0,195,83,86,87,139,68,36,16,80,106
Data 254,104,6,16,0,16,100,255,53,0,0,0,0,100,137,37,0
Data 0,0,0,139,68,36,32,139,88,8,139,112,12,131,254,255,116
Data 32,59,116,36,36,116,26,141,52,118,139,12,179,139,76,36,8
Data 139,72,12,131,124,179,4,0,117,215,255,84,179,8,235,209,100
Data 143,5,0,0,0,0,131,196,12,95,94,91,195,85,137,229,83
Data 86,87,85,106,0,106,0,104,152,16,0,16,255,117,8,232,88
Data 6,0,0,93,95,94,91,137,236,93,195,252,85,137,229,131,236
Data 8,83,86,87,85,139,93,12,139,69,8,247,64,4,6,0,0
Data 0,117,109,137,69,248,139,69,16,137,69,252,141,69,248,137,67
Data 252,139,115,12,139,123,8,131,254,255,116,98,141,12,118,131,124
Data 143,4,0,116,58,86,85,141,107,16,255,84,143,4,93,94,139
Data 93,12,9,192,116,40,120,49,139,123,8,83,232,133,255,255,255
Data 131,196,4,141,107,16,86,83,232,30,255,255,255,131,196,8,141
Data 12,118,139,4,143,139,67,12,255,84,143,8,139,123,8,141,12
Data 118,139,52,143,235,172,49,192,235,25,85,141,107,16,106,255,83
Data 232,243,254,255,255,131,196,12,106,11,232,67,6,0,0,131,196
Data 4,93,95,94,91,137,236,93,195,85,137,229,83,86,87,131,125
Data 12,1,117,5,232,23,0,0,0,255,117,16,255,117,12,255,117
Data 8,161,0,48,0,16,255,208,95,94,91,201,194,12,0,85,137
Data 229,131,236,12,87,106,0,106,246,232,196,5,0,0,137,69,248
Data 106,0,106,245,232,184,5,0,0,137,69,252,106,0,106,244,232
Data 172,5,0,0,137,69,244,104,30,48,0,16,255,117,248,232,144
Data 5,0,0,163,8,48,0,16,104,28,48,0,16,255,117,252,232
Data 126,5,0,0,163,4,48,0,16,104,28,48,0,16,255,117,244
Data 232,108,5,0,0,131,196,48,163,12,48,0,16,139,61,4,48
Data 0,16,9,255,116,11,106,0,87,232,166,5,0,0,131,196,8
Data 139,61,12,48,0,16,9,255,116,16,106,0,87,232,145,5,0
Data 0,131,196,8,232,41,0,0,0,95,201,195,0,0,85,137,229
Data 131,196,244,217,125,254,102,139,69,254,128,204,12,102,137,69,252
Data 217,109,252,219,93,244,217,109,254,139,69,244,201,195,0,0,85
Data 137,229,131,236,20,83,86,87,199,69,244,0,0,0,0,232,67
Data 4,0,0,137,195,137,93,240,235,33,128,60,29,0,0,0,0
Data 61,116,3,255,69,244,137,223,49,192,249,25,201,242,174,247,217
Data 141,65,254,137,199,71,141,28,59,128,60,29,0,0,0,0,0
Data 117,213,139,125,244,71,141,60,189,0,0,0,0,137,125,236,255
Data 117,236,232,223,4,0,0,89,137,69,248,163,16,48,0,16,131
Data 125,248,0,117,4,49,192,235,118,139,93,240,235,84,137,223,49
Data 192,249,25,201,242,174,247,217,141,65,254,137,199,71,137,125,252
Data 128,60,29,0,0,0,0,61,116,48,255,117,252,232,161,4,0
Data 0,89,139,117,248,137,4,53,0,0,0,0,9,192,117,2,235
Data 58,83,139,125,248,255,52,61,0,0,0,0,232,176,4,0,0
Data 131,196,8,131,69,248,4,139,85,252,141,28,19,128,60,29,0
Data 0,0,0,0,117,162,139,85,248,199,4,21,0,0,0,0,0
Data 0,0,0,184,1,0,0,0,95,94,91,201,195,0,131,124,36
Data 8,1,117,14,139,68,36,4,163,8,32,0,16,232,34,0,0
Data 0,131,124,36,8,2,117,0,131,124,36,8,0,117,5,232,10
Data 1,0,0,131,124,36,8,3,117,0,184,1,0,0,0,194,12
Data 0,104,0,0,0,0,232,67,3,0,0,163,8,32,0,16,104
Data 0,0,0,0,104,160,15,0,0,104,0,0,0,0,232,90,3
Data 0,0,163,0,32,0,16,104,244,1,0,0,104,12,32,0,16
Data 255,53,8,32,0,16,232,4,3,0,0,184,12,32,0,16,137
Data 193,138,48,64,128,254,92,117,2,137,193,128,254,0,117,241,198
Data 1,0,232,203,0,0,0,233,154,0,0,0,83,81,85,86,87
Data 137,230,131,236,8,137,224,137,194,131,194,8,199,0,0,0,0
Data 0,131,192,4,57,208,117,243,139,70,24,137,4,36,139,70,28
Data 137,68,36,4,139,28,36,131,251,255,126,15,139,60,36,131,255
Data 19,125,7,184,1,0,0,0,235,2,49,192,33,192,116,7,199
Data 4,36,19,0,0,0,102,186,67,0,176,182,238,102,186,97,0
Data 236,12,3,238,102,186,18,0,102,184,220,52,102,139,28,36,102
Data 247,243,102,186,66,0,238,136,224,238,139,68,36,4,232,56,0
Data 0,0,102,186,67,0,176,182,238,102,186,97,0,236,36,252,238
Data 49,192,131,196,8,95,94,93,89,91,194,8,0,195,232,12,0
Data 0,0,255,53,0,32,0,16,232,126,2,0,0,195,195,193,232
Data 16,37,255,0,0,0,195,80,232,169,2,0,0,195,193,232,8
Data 37,255,0,0,0,195,232,58,2,0,0,232,178,1,0,0,195
Data 195,15,190,0,195,15,191,0,195,139,0,195,217,0,195,81,139
Data 21,4,32,0,16,82,61,0,0,0,0,116,18,138,40,64,136
Data 42,66,128,253,0,117,245,74,137,21,4,32,0,16,198,2,0
Data 88,89,195,81,87,139,21,4,32,0,16,82,61,0,0,0,0
Data 116,29,137,215,3,124,36,16,71,138,40,64,136,42,66,57,250
Data 116,5,128,253,0,117,241,74,137,21,4,32,0,16,198,2,0
Data 88,95,89,194,4,0,139,84,36,4,136,16,194,4,0,139,84
Data 36,4,102,137,16,194,4,0,139,84,36,4,137,16,194,4,0
Data 139,84,36,4,137,16,194,4,0,81,137,194,139,68,36,8,137
Data 21,4,34,0,16,61,0,0,0,0,116,20,138,40,64,136,42
Data 66,128,253,0,117,245,74,137,208,43,5,4,34,0,16,198,2
Data 0,89,194,4,0,81,137,194,139,68,36,8,137,21,4,34,0
Data 16,61,0,0,0,0,116,229,129,124,36,12,0,0,0,0,126
Data 24,255,76,36,12,138,40,64,136,42,66,128,253,0,117,231,74
Data 137,208,43,5,4,34,0,16,198,2,0,89,194,8,0,37,255
Data 0,0,0,195,143,5,4,34,0,16,90,193,226,8,1,208,90
Data 193,226,16,1,208,255,37,4,34,0,16,83,139,29,76,48,0
Data 16,139,13,80,48,0,16,139,147,16,34,0,16,139,131,20,34
Data 0,16,193,194,19,193,192,27,3,145,16,34,0,16,3,129,20
Data 34,0,16,137,131,16,34,0,16,137,147,20,34,0,16,129,235
Data 8,0,0,0,115,5,187,128,0,0,0,129,233,8,0,0,0
Data 115,5,185,128,0,0,0,137,29,76,48,0,16,137,13,80,48
Data 0,16,91,195,163,12,34,0,16,232,151,255,255,255,83,139,29
Data 12,34,0,16,43,29,84,48,0,16,120,23,67,137,209,247,227
Data 137,200,137,209,247,227,1,200,19,21,84,48,0,16,137,208,91
Data 195,184,0,0,0,128,91,195,49,201,105,192,5,75,86,172,64
Data 137,4,141,16,34,0,16,65,129,249,34,0,0,0,114,233,217
Data 232,217,29,64,48,0,16,199,5,76,48,0,16,0,0,0,0
Data 199,5,80,48,0,16,80,0,0,0,232,48,255,255,255,87,191
Data 30,0,0,0,232,37,255,255,255,79,117,248,95,195,208,49,192
Data 64,194,12,0,0,0,255,37,224,64,0,16,144,144,0,0,0
Data 0,255,37,228,64,0,16,144,144,0,0,0,0,255,37,232,64
Data 0,16,144,144,0,0,0,0,255,37,236,64,0,16,144,144,0
Data 0,0,0,255,37,240,64,0,16,144,144,0,0,0,0,255,37
Data 244,64,0,16,144,144,0,0,0,0,255,37,248,64,0,16,144
Data 144,0,0,0,0,255,37,252,64,0,16,144,144,0,0,0,0
Data 255,37,0,65,0,16,144,144,0,0,0,0,255,37,4,65,0
Data 16,144,144,0,0,0,0,255,37,8,65,0,16,144,144,0,0
Data 0,0,255,37,12,65,0,16,144,144,0,0,0,0,255,37,16
Data 65,0,16,144,144,0,0,0,0,255,37,20,65,0,16,144,144
Data 0,0,0,0,255,37,24,65,0,16,144,144,0,0,0,0,255
Data 37,36,65,0,16,144,144,0,0,0,0,255,37,40,65,0,16
Data 144,144,0,0,0,0,255,37,44,65,0,16,144,144,0,0,0
Data 0,255,37,48,65,0,16,144,144,0,0,0,0,255,37,52,65
Data 0,16,144,144,0,0,0,0,255,37,56,65,0,16,144,144,0
Data 0,0,0,255,37,60,65,0,16,144,144,0,0,0,0,255,37
Data 64,65,0,16,144,144,0,0,0,0,255,37,68,65,0,16,144
Data 144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,133,24,19,0,16,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,37,115,0,0,119,0,114,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255
Data 0,0,0,0,0,0,0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,64,0,0,0,0,0,0,0,0,0,0,8,67,0,0,36
Data 65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,80,65,0,0,108,65,0,0,132,65
Data 0,0,152,65,0,0,168,65,0,0,184,65,0,0,196,65,0
Data 0,212,65,0,0,228,65,0,0,240,65,0,0,252,65,0,0
Data 12,66,0,0,36,66,0,0,44,66,0,0,60,66,0,0,0
Data 0,0,0,0,0,0,0,76,66,0,0,88,66,0,0,108,66
Data 0,0,120,66,0,0,132,66,0,0,144,66,0,0,156,66,0
Data 0,164,66,0,0,176,66,0,0,0,0,0,0,0,0,0,0
Data 80,65,0,0,108,65,0,0,132,65,0,0,152,65,0,0,168
Data 65,0,0,184,65,0,0,196,65,0,0,212,65,0,0,228,65
Data 0,0,240,65,0,0,252,65,0,0,12,66,0,0,36,66,0
Data 0,44,66,0,0,60,66,0,0,0,0,0,0,0,0,0,0
Data 76,66,0,0,88,66,0,0,108,66,0,0,120,66,0,0,132
Data 66,0,0,144,66,0,0,156,66,0,0,164,66,0,0,176,66
Data 0,0,0,0,0,0,0,0,0,0,159,0,71,101,116,69,110
Data 118,105,114,111,110,109,101,110,116,83,116,114,105,110,103,115,65
Data 0,0,137,229,178,0,71,101,116,77,111,100,117,108,101,70,105
Data 108,101,78,97,109,101,65,0,0,116,131,179,0,71,101,116,77
Data 111,100,117,108,101,72,97,110,100,108,101,65,0,0,210,0,71
Data 101,116,83,116,100,72,97,110,100,108,101,0,0,232,0,71,101
Data 116,84,105,99,107,67,111,117,110,116,0,0,4,1,72,101,97
Data 112,65,108,108,111,99,0,6,1,72,101,97,112,67,114,101,97
Data 116,101,0,0,172,64,7,1,72,101,97,112,68,101,115,116,114
Data 111,121,0,116,47,9,1,72,101,97,112,70,114,101,101,0,0
Data 117,1,82,116,108,85,110,119,105,110,100,0,118,1,82,116,108
Data 90,101,114,111,77,101,109,111,114,121,0,150,1,83,101,116,67
Data 117,114,114,101,110,116,68,105,114,101,99,116,111,114,121,65,0
Data 0,195,1,83,108,101,101,112,0,241,1,87,114,105,116,101,67
Data 111,110,115,111,108,101,65,0,76,0,69,120,105,116,80,114,111
Data 99,101,115,115,0,228,81,127,0,95,102,100,111,112,101,110,0
Data 0,137,77,1,95,111,112,101,110,95,111,115,102,104,97,110,100
Data 108,101,0,69,208,8,2,102,99,108,111,115,101,0,0,64,0
Data 57,0,95,99,101,120,105,116,0,0,168,64,73,2,109,97,108
Data 108,111,99,0,0,12,0,86,2,112,114,105,110,116,102,0,0
Data 200,80,91,2,114,97,105,115,101,0,98,2,115,101,116,98,117
Data 102,0,0,69,204,112,2,115,116,114,99,112,121,0,0,7,136
Data 75,69,82,78,69,76,51,50,46,68,76,76,0,0,137,126,0
Data 64,0,16,0,64,0,16,0,64,0,16,0,64,0,16,0,64
Data 0,16,0,64,0,16,0,64,0,16,0,64,0,16,0,64,0
Data 16,0,64,0,16,0,64,0,16,0,64,0,16,0,64,0,16
Data 0,64,0,16,0,64,0,16,67,82,84,68,76,76,46,68,76
Data 76,0,0,20,64,0,16,20,64,0,16,20,64,0,16,20,64
Data 0,16,20,64,0,16,20,64,0,16,20,64,0,16,20,64,0
Data 16,20,64,0,16,255,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,16,0,0,152,0,0,0,49,48,140,48,99,49
Data 156,49,169,49,174,49,187,49,192,49,208,49,214,49,235,49,142
Data 50,36,51,90,51,115,51,125,51,131,51,141,51,81,52,146,52
Data 172,52,186,52,223,52,26,53,53,53,73,53,114,53,133,53,151
Data 53,158,53,164,53,170,53,176,53,188,53,194,53,200,53,206,53
Data 238,53,244,53,251,53,7,54,13,54,34,54,61,54,78,54,84
Data 54,94,54,134,54,146,54,158,54,170,54,182,54,194,54,206,54
Data 218,54,230,54,242,54,254,54,10,55,22,55,34,55,46,55,58
Data 55,70,55,82,55,94,55,106,55,118,55,130,55,142,55,154,55
Data 0,0,0,48,0,0,12,0,0,0,0,48,0,0,0,64,0
Data 0,56,0,0,0,204,50,208,50,212,50,216,50,220,50,224,50
Data 228,50,232,50,236,50,240,50,244,50,248,50,252,50,0,51,4
Data 51,20,51,24,51,28,51,32,51,36,51,40,51,44,51,48,51
Data 52,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,214,63,206,67,0,0,0,0
Data 40,96,0,0,1,0,0,0,2,0,0,0,2,0,0,0,56
Data 96,0,0,64,96,0,0,72,96,0,0,112,117,114,101,98,97
Data 115,105,99,46,100,108,108,0,0,0,175,19,0,0,24,19,0
Data 0,76,96,0,0,84,96,0,0,0,0,1,0,66,101,101,112
Data 0,0,0,0,68,76,76,69,110,116,114,121,80,111,105,110,116
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0 ,-1 ;end of file


Next step is to create a file called beep.decls in the userlibs folder and put this in it.

.lib "beep.dll"

Beep%(Frequency%, Duration%)


Now you should be able to run this example code. The main problem with using beep is that it uses a delay to make the beep, so you can't stop it pausing the engine. This is why I'll be doing something like Cygnus' retrosound demo for my sounds. :)

;Beep dll example - musical keyboard, by muk on 16/1/06

Graphics3D 640,480,16,2
SetBuffer BackBuffer()

camera=CreateCamera()
light=CreateLight()
RotateEntity light,90,0,0
cube=CreateCube()
PositionEntity camera,0,0,-5

;Main Loop
While Not KeyDown(1)

y#=y+0.4 : If y>359 Then y=0
RotateEntity cube,y,y,y

RenderWorld

If KeyDown(2) ;1 key - Bell tone
 Beep(660,50)
 Beep(525,50)
EndIf

If KeyDown(3) ;2 key - Siren wail
 If k2=0
  k2=1 ;init
  np=0
 EndIf
 np=np+1
 If np>179 Then np=0
 s=Sin(np)*500+500
 Beep(s,15)
Else
 k2=0
EndIf

If KeyDown(4) ;3 key - Pitch up
 If k3=0
  k3=1 ;init
  np=100
 EndIf
 np=np+2
 If np>1000 Then np=100 ;wrap
 Beep(np,5)
Else
 k3=0
EndIf

If KeyDown(5) ;4 key - Pitch down
 If k4=0
  k4=1 ;init
  np=1000
 EndIf
 np=np-2
 If np<100 Then np=1000 ;wrap
 Beep(np,5)
Else
 k4=0
EndIf

If KeyDown(6) ;5 key - Frere Gustav
 If k5=0
  k5=1 ;init
  ncou=0
  Restore FrereGustav
 EndIf
 If bf=0
  bf=1 ;note on
  ncou=ncou+1
  Read frequency : Read duration
  Beep(frequency,duration)
 EndIf
 If bf=1
  bf=0 ;note off
  Delay duration 
 EndIf
 If ncou>=36 Then k5=0 ;reset, last note
Else
 k5=0
EndIf

If KeyDown(7) ;6 key - Worms Theme
 If k6=0
  k6=1 ;init
  ncou=0
  Restore WormsTheme
 EndIf
 If bf=0
  bf=1 ;note on
  ncou=ncou+1
  Read frequency : Read duration
  Beep(frequency,duration)
 EndIf
 If bf=1
  bf=0 ;note off
  Delay duration 
 EndIf
 If ncou>=24 Then k6=0 ;reset, last note
Else
 k6=0
EndIf

dur=150 ;note duration

If KeyDown(17) ;W key - Db5
 If kw=0 Then kw=1 : Beep(280,dur)
Else : kw=0 : EndIf
If KeyDown(18) ;E key - Eb5
 If ke=0 Then ke=1 : Beep(315,dur)
Else : ke=0 : EndIf
If KeyDown(20) ;T key - F#5
 If kt=0 Then kt=1 : Beep(370,dur)
Else : kt=0 : EndIf
If KeyDown(21) ;Y key - G#5
 If ky=0 Then ky=1 : Beep(420,dur)
Else : ky=0 : EndIf
If KeyDown(22) ;U key - Bb5
 If ku=0 Then ku=1 : Beep(470,dur)
Else : ku=0 : EndIf
If KeyDown(24) ;O key - Db6
 If ko=0 Then ko=1 : Beep(560,dur)
Else : ko=0 : EndIf
If KeyDown(25) ;P key - Eb6
 If kp=0 Then kp=1 : Beep(630,dur)
Else : kp=0 : EndIf

If KeyDown(30) ;A key - C5
 If ka=0 Then ka=1 : Beep(265,dur)
Else : ka=0 : EndIf
If KeyDown(31) ;S key - D5
 If ks=0 Then ks=1 : Beep(295,dur)
Else : ks=0 : EndIf
If KeyDown(32) ;D key - E5
 If kd=0 Then kd=1 : Beep(330,dur)
Else : kd=0 : EndIf
If KeyDown(33) ;F key - F5
 If kf=0 Then kf=1 : Beep(350,dur)
Else : kf=0 : EndIf
If KeyDown(34) ;G key - G5
 If kg=0 Then kg=1 : Beep(395,dur)
Else : kg=0 : EndIf
If KeyDown(35) ;H key - A5
 If kh=0 Then kh=1 : Beep(445,dur)
Else : kh=0 : EndIf
If KeyDown(36) ;J key - B5
 If kj=0 Then kj=1 : Beep(495,dur)
Else : kj=0 : EndIf
If KeyDown(37) ;K key - C6
 If kk=0 Then kk=1 : Beep(530,dur)
Else : kk=0 : EndIf
If KeyDown(38) ;L key - D6
 If kl=0 Then kl=1 : Beep(595,dur)
Else : kl=0 : EndIf

If KeyDown(44) ;Z key - C4
 If kz=0 Then kz=1 : Beep(130,dur)
Else : kz=0 : EndIf
If KeyDown(45) ;X key - D4
 If kx=0 Then kx=1 : Beep(150,dur)
Else : kx=0 : EndIf
If KeyDown(46) ;C key - E4
 If kc=0 Then kc=1 : Beep(165,dur)
Else : kc=0 : EndIf
If KeyDown(47) ;V key - F4
 If kv=0 Then kv=1 : Beep(175,dur)
Else : kv=0 : EndIf
If KeyDown(48) ;B key - G4
 If kb=0 Then kb=1 : Beep(195,dur)
Else : kb=0 : EndIf
If KeyDown(49) ;N key - A4
 If kn=0 Then kn=1 : Beep(220,dur)
Else : kn=0 : EndIf
If KeyDown(50) ;M key - B4
 If km=0 Then km=1 : Beep(245,dur)
Else : km=0 : EndIf


 Text 16,16,"|1|2|3|4|5|6|"

 Text 16,48," |W|E| |T|Y|U| |O|P|"
 Text 16,64,"|A|S|D|F|G|H|J|K|L|"
 Text 16,80,"|c|d|e|f|g|a|b|c|d|"

 Text 16,112,"|Z|X|C|V|B|N|M|"
 Text 16,128,"|c|d|e|f|g|a|b|"

Flip
Wend
End

.FrereGustav ;36 notes
;C/1 D/1 Eb/0.5 D/0.5 C/1
Data 265,200,295,200,315,100,295,100,265,200
Data 265,200,295,200,315,100,295,100,265,200
;Eb/1 F/1 G/2
Data 315,200,350,200,395,400
Data 315,200,350,200,395,400
;G/0.75 G#/0.25 G/0.5 F/0.5 Eb/0.5 D/0.5 C/1
Data 395,150,420, 50,395,100,350,100,315,100,295,100,265,200
Data 395,150,420, 50,395,100,350,100,315,100,295,100,265,200
;C/1 B/1 C/2
Data 265,200,195,200,265,400
Data 265,200,195,200,265,400

.WormsTheme ;24 notes
;C/0.5 D/0.5 E/1 G/1 G/1
Data 265,100,295,100,330,200,395,200,395,200
;F/0.5 E/0.5 D/0.5 C/0.5 D/0.5 E/0.5 D/1.5
Data 350,100,330,100,295,100,265,100,295,100,330,100,295,300
;C/0.5 D/0.5 C/0.5 D/0.5 E/0.5 A/1.5
Data 265,100,295,100,265,100,295,100,330,100,220,300
;C/0.5 D/0.5 C/0.5 D/0.5 E/0.5 D/1
Data 265,100,295,100,265,100,295,100,330,100,295,200


Waheyy! That's all great! Thanks peeps!