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 / Create sounds - with no media.

Author
Message
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 8th May 2005 01:20
hmmm well thats not good if u have to develop with it
i dont think people want to have to "adjust there mixer" just to play a game

i would say this bug be fixed asap

X-Patch x-patch.exe(gui):75% make.exe:5% x-patch.dll(runtime dll):0% developed on win xp home sp2
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 8th May 2005 05:08
What bug?

Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 8th May 2005 10:50
Quote: "Everyone, if it did not work for you, you probably need to adjust your mixer. To do that, in xp click blue button at bottom right of screen on tool bar, to show more icons. Then find your volume icon.
Think left click it but experiment. Then you can adjust wave volume, overall volume, and un mute if it was set to mute.
For windows98 there is a yellow speaker volume icon on tool bar beside your clock, you might have to scroll around a bit or slide the panel back for it to show up. Do the same thing there. It should work with dark basic pro ok."


isnt that a bug

NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 8th May 2005 17:06
It is no bug to have to adjust the audio mixer for midi or wave or other audio output, and check if they are in mute or not. Its just part of the hassle of a windows system. The mixer is in windows, not the program. Game programs that use either or both should provide instructions on setting the mixer.
UFOs other account lol
18
Years of Service
User Offline
Joined: 3rd Jun 2005
Location: Somewhere :)
Posted: 4th Jun 2005 03:45
If I was used to using sound files I would be excited, but I am used to it being the only way to make noise (which doesn't require 20 lines of code) in Qbasic which runs on DOS.

By the way, this is my first post. Yay!

Green Bunnies rule!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jun 2005 09:42
@Ric and co

Have just read this thread with interest. (I've just written a simple working program to create very basic sound effect saved as a wav file and then decided "Surely someone must have done this already." and then did the sensible thing. Well several of you have - but a nagging question remains ...)

If you want genuinely "no media" programs, why not store your data in a memblock, then use make sound from memblock ? I haven't tried this yet but it seems to bypass the rather messy need to store your sounds as wav files (obviously you will want to do this sometimes but not always).

Is there a problem with the memblock commands for sound?

P.S. Incidentally, for those who are interested, I got the necessary wave file specification from the link [href]www.sonicspot.com/guide/wavefiles.html[/href] which I found using Google.
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 4th Jun 2005 20:19
Absolutely right - I think I mentioned somewhere earlier in this thread that using memblocks would be much quicker, if you didn't need to save the files. Just never got round to writing it, though - you up for the challenge Green Gadalf?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Jun 2005 22:49
@Ric

I guess I asked for that! It's raining outside here today so perhaps I'll give it a go ...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2005 18:29
@Ric

Here is my first attempt - no wav files!

The program is based on your original code and uses the DBP5.8 memblock format.

The program seems to produce the sounds correctly - but for some reason all the sounds are the same and equal to the first sound created (so if you rem out some of the samples as in the code below and re-run it you hear a different sound). There must be a silly error in my code but I cannot see it. Could you give it a try? (I tried using DBP5.7 and 8 bit sound first and got the same problem.)

I'm baffled because the memblocks ARE different (this is why I included some code to write these out as .txt files so I could examine them in Notepad). Once we've eliminated the bug those lines can be deleted, of course.

I've also included some queries after the header bytes - I can't
find any "Help" information describing these - and the DBP5.8 example files don't include examples!

If you can help, I'd be very grateful!

My code follows:

Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 6th Jun 2005 18:47
Looking good. Can't try it out yet because I'm at work, and only have 5.7 on my laptop. Will take a look when I get home. The problem with it playing the same sound sounds very familiar - I had the same problem initially - can't quite remember how I got round it, but it was something to do with needing to change the file name/number for a new sound rather than just deleting the old one and using the same name/number.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2005 07:39
@Ric

I think I've cracked it. You only need one memblock, number 1 say, and then create the sound using a temporary number, e.g. 999, then clone this sound as the sound number you want, then delete the temporary sound number. Then proceed to the next sound and all seems to work. Will post the new code in a few minutes.

Seems a bit roundabout.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2005 07:57
@Ric

Here's the code:



This gives your sounds without the media files.
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 8th Jun 2005 08:47
Great work GG - that's going to be really useful for the no-media coding challenges. I wonder how this code is going to develop next!?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2005 23:02
@Ric

Thanks. What we really need now is an explanation of the 28 header bytes from someone who knows - inspired guesswork and experimentation can only get us so far. Twenty eight bytes is a lot of information and ought to cover a lot of sound options (unless they are included to allow room for future developments). For example, how many channels are supported?

For my part, I've now got some working code so that I can create my own sound effects - without .wav files. Hopefully, as you suggest, others will be able to do the same. Yippee!

If I get any nice sound effects programmed I'll post them up.

P.S. Thanks for the challenge - it was well worthwhile.
Lampton Worm
21
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 12th Jun 2005 02:14 Edited at: 12th Jun 2005 02:39
Hi folks,

Here's a sort of real-time version for making faster edits to the params..

Keys:
Up/down = select parameter
Left/Right = adjust parameter
Space = create/play (in one go)

Edits:
Lampton Worm edits..
- basic real time edit mode
- one key to create/plan
- put param data into a typed array
Lampton Worm suggests..
- add a save to file option
- add a load option
- add a BlueGUI interface
- add some safety in the code, e.g. currently lets you enter a negative length but this obviously breaks the createsound function

Oh, I slightly modified the function, as for this case I needed to delete the sound if it already existed before cloning.



p.s. really cool code Ric+Green Gandalf, good work on that function.

Update: ok, here's the very basics for save and load, paste this into the main loop. This saves to a file that can then be re-loaded and also outputs a .code file that can be pasted into your game which is basically the createsound function with the parameters filled in. Hope its useful to someone.



Cheers.
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 12th Jun 2005 06:02 Edited at: 12th Jun 2005 06:03
Great! Now why didn't I think of doing that?! Oh yes - it wouldn't have been possible before GG's memblock conversion, that's why. Just been playing around with some high frequency noises - really annoying my neighbour's dog!!

I like the BlueGUI idea too - maybe when I finish my current project (whenever that may be) I might do one.



Lampton Worm
21
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 12th Jun 2005 21:50
Hi, glad you liked it, it really is alot of fun! Ah, shameless plug alert - I've used a few sounds made with this in my compo entry early demo..

http://forum.thegamecreators.com/?m=forum_view&t=55567&b=8

..which has no external media at all now thanks to this stuff.

p.s. another idea, could also draw out the wave form to the screen, adding an option to continually loop the sound while you play with the params could also be amusing.

Cheers
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 13th Jun 2005 05:09
Hmm..... something like this....



Obviously needs work - if you put the frequency down to around 100 you'll see it is a single waveform - much higher and it's just a mess!

Lampton Worm
21
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 13th Jun 2005 19:29
Hi, might be me (its monday morning after all!) but that code looks unchanged?

Cheers
X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 14th Jun 2005 02:34
this is absolutely brilliant!!!!
and you have managed to write a wav file!!! this should be so useful to me...... for my synthesizer project.

by the way, for anyone wanting to know. to play to sounds together, you may not believe this, but the wave data (raw waves atleast) are just added together...

so if you had two sine waves at different pitches, you just add them together. it may sound simple... but thats how its done in synthesizers and electronics etc.

www.AoFP.co.uk
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 14th Jun 2005 09:31
@Lampton: look closer - you missed the all important 4 lines I added!

@X Trade: keep me posted on your synthesiser project. It sounds interesting, as I've also been playing around with wave layering, such as squarewave formation.

Lampton Worm
21
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 14th Jun 2005 18:38
@Ric, whoops! Sorry 'bout that, found them now the coffee has kicked in
X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 15th Jun 2005 00:01
well i was counting on just using set sound speed to change the pitch of pre-recorded wave samples..... but not like a sampler because the waves are just simple sine waves... each exactly 4 loops at 440hz...
but i can't get filter effects or anything like that, and i need a MIDI IN dll for dbp to get keyboard data, and there is only a MIDI Out dll at the moment

so i may try to use this method... although writing to disk would take too long in real-time.. so i need to figure out the memblock format, or get a dll for sending real-time wave data to the sound card

www.AoFP.co.uk
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 15th Jun 2005 05:11
Here is an easy way to make it make random sounds. I just set the first sound to create a random sound.
For example replace 7000 with rnd(7000)+100 will give random numbers at least as great as 100 up to 7100.

For decimal numbers you can use rnd(20)*.001+n where n is the lower value you want to allow.

You might need to go into dark basic folder and delete all the soundfiles if it will not run the first time. I do not know why but I had to do that, and then it worked, seems there is someway the file exists check can fail, if one modifys the files the first time around.

Now regarding mixing and filters on wave files. I would like to remind you that there is a vst dll, and a dx dll. After you get plugins working with the audio, there are filter plugins, etc, that can do all the things your wanting to do, and a lot you probably never even imagined. (theres some real strange plugins around on the net for free, and do all kinds of bizzare things with audio.)

Do a search in the dll forum, I posted some web links there not to long ago, so its about a page or two back from the first page, or still the first page of the forum.

Now can we figure out what the minumum and max values for each of these sound parameters are? If we can do that, then we can set them all to get set up at random, and have a sound factory out of this program.






NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 15th Jun 2005 05:45
Tutorial: How to write audio plugins, what tools will you need?
www.computermusic.co.uk/tutorial/diy1/diy1.asp
[href]
www.computermusic.co.uk/tutorial/diy1/diy1.asp
[/href]

Also check out this;
www.nuim.ie/academic/music/musictec/SndObj/main.html
[href]
http://www.nuim.ie/academic/music/musictec/SndObj/main.html
[/href]
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 23rd Jun 2005 14:15
Freq = -1000MHz To 1000MHz
Length = 0 To 1000 MiliSec
Loudness .. 2500 = 0dB, 0 = -20dB, 5000 = +20dB
Bend = -1.0 To +1.0
Decay = 0.0 To +1.0

Dunno about the rest they don't really seem to do much.


Didn't bother cleaning it up, just added an easier way to change everything.

Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 24th Jun 2005 06:58
Nice one Raven. I've also added an 'attack' parameter to enable sounds to fade in aswell as fade out. Best not use negative values of attack - sounds horrible! Took me ages following the code in order to play around with it - it's mutated so much in this thread!!



Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 24th Jun 2005 07:21
I totally missed the 'Wait' functions in each of the key strokes, if you take them out it works better.

Below should help alot, although the code itself doesn't work.. it's a mystery i've set Mike on fixing.



also i've been toying most of the evening trying to get this to work.. I can sort-of get it working, you can use 1 sound; but then it silenty crashes trying to create the other. I feel something has gone wrong but I'm not entire sure what given it works the first time and your function works just fine multiple times. just weird



Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Jun 2005 02:28 Edited at: 25th Jun 2005 02:28
I'm trying to get a good visual form of the wave



PETA - People for the Eating of Tasty Animals

Attachments

Login to view attachments
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 25th Jun 2005 03:14


You might want to grab a sample point per Nth of a second. But those should allow you to create a relatively smooth visual curve.

Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Jun 2005 05:19
Interpolation - good idea. Might take a look at that later.


s0l1dsnak3123
18
Years of Service
User Offline
Joined: 29th Jun 2005
Location: Scotland
Posted: 30th Jun 2005 02:54
I have absolutely no Idea what ur talkin about I'm still a newbie I suppose...


(real forum name s0l1idsnak3123)
qwe
20
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 2nd Jul 2005 18:40
well i was messing around with the program (i dont think i changed the code at all, just playing hte sounds) i was pressing all the numbers on the keyboard... and then realised there was a constant sound and it wouldnt stop. couldnt move mouse or ctrl alt delete..had to shut down by holding button

If you want anything DB related hosted, log in (with ws ftp or something) www.lysergium.net with username public@lysergium.net and password public. you'll be directed to lysergium.net/public
qwe
20
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 2nd Jul 2005 19:19 Edited at: 2nd Jul 2005 19:24
p.s. ... whatever happened to the BEEP command? was it taken out? im pretty sure it was in an older version of dbp or maybe dbc. you could specify the frequency and length and the computer would play a beep but i searched the help files for "beep" and nothing came up...is there a dll i can get to do this?

p.p.s i am going to design a program to create patterns and turn them into sound.. and im going to see if i can get some sort of computer generated techno music from a couple settings. this will come in handy

If you want anything DB related hosted, log in (with ws ftp or something) www.lysergium.net with username public@lysergium.net and password public. you'll be directed to lysergium.net/public
Sho Ryu Ken
18
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 26th Jul 2005 09:51
Uhhhh... I tried to run the program at the beginning of this post with DB Lite and it says Syntax Error: Parameters Differ Between Function Call and Declaration. What's wrong??
Sho Ryu Ken
18
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 26th Jul 2005 10:06
Hey, I try and run the original prog at the beginning of the post but it gives me syntax error saying the parameters differ between function call and declaration. Anybody know what's wrong? I use DB Lite, btw.
Keaz
20
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Somewhere in south Texas
Posted: 5th Aug 2005 23:52 Edited at: 6th Aug 2005 22:25
This is all very well and interesting and now I need to do some research. The type of music I believe you all are try to generate is known as "Brownian Fractal Music" I did a QBASIC project on it in high school similar to this.

Here's a site on it:
http://www.tursiops.cc/fm/
Then it's just a matter of different alogrythms for different scences/moods. Check the mid files at the bottom they are random generated.

Breaking Stuff=Fun!,Bug Testing<>Fun!, Bug Testing=Breaking Stuff, so...
Bug Testing=Fun! Hmmmm....
DOES NOT COMPUTE! SYSTEM MALFUNTION!
XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 6th Aug 2005 21:10
You can do a good effet with the possibility of changing sinus for saw. The sinus is the more pure sound of the world but not enought rich.
XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 7th Aug 2005 02:26
What do you think about this graphical interface ? I can make the tracker for you If you want, because I'm interested by this software !

Attachments

Login to view attachments
XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 13th Aug 2005 17:54
I've made a tracker with this code, and st-sound (converted to a dll). You can record your music with this sinus function, you can replay a track, and when you want to listen a pattern or the song, st-sound is called.
This (freeware!) software is called sinus tracker. But I have 3 problems :
-The vibrato and tremolo don't works properly.
-I don't know how to make a saw to replace the sinusoidal function
Can someone help me ?
XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 13th Aug 2005 19:46
oops !
I've forgotten to tell that I do not use the vibrato and tremolo in this routine but I call it with the new volume and frequency each time i need it. (each time I play a note from the pattern)
But my problem is that a pattern have 64 notes. (The vibrato and tremolo are synchronised with the pattern speed, so, I can't use the vibrato in the function)
And the problem with stsound is that I need 64x5 notes for each pattern. (1 note for the tracker = 5 notes for st-sound YM player)
So, I don't know what I must do...
I've tried to multiply or divide the speed by 5, but the problem is that each "5 notes" in the pattern use the same frequency.
i don't know how to make "5 steps" to go from the old frequency to the new frequency !
Same thing with the tremolo but with the volume.
Each note of the pattern do 5 times the same thing.
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 14th Aug 2005 01:21
The work you're doing on this tracker sounds interesting - hope you manage to figure out a solution to the problems. One question - will you be able to play a tracker file - ie. the piece of music you've made - within another game you have written? For example, like when you play a midi track or an mp3, where the timing of the music is independent of and uninterupted by the other things happening in the program.

XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 14th Aug 2005 09:16
To play a YM file, you've just to download the freeware st-sound on the web. But if you want to play a YM file in a game, you'll need the dll version. (This dll is used by the tracker and can be used by an other dark basic program)
XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 14th Aug 2005 09:19
This is an example of music made with this tracker here !

And you can download stsound player here...
http://leonard.oxg.free.fr/stsound_download.html

Attachments

Login to view attachments
Darkbasic MADPSP
18
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 14th Aug 2005 12:41
wow......................

See you at the convention!
xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 15th Aug 2005 17:43 Edited at: 20th Aug 2005 23:03
I've compiled a version with BlueGUI

http://www.teamxtcgames.com/files/DBSoundCreatorv1.2.rar (1mb)

- one click random sounds
- save sound as .dbs (createsound function call saved at end of file for coding)
- load sound
- save as wav file




XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 16th Aug 2005 07:37
I don't know a save sound command but you can save a memblock sound by getting all bytes and writing them in a simple file. (open to write) i think
XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 16th Aug 2005 07:43
You can find sinus tracker here for download at the right/bottom corner :
http://pagesperso.aol.fr/levrailoupardent/
It uses saw now.

hello xtom, will you add a noise command in a futur version (white or pink noise) ?
xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 16th Aug 2005 15:13 Edited at: 16th Aug 2005 15:15
XANAX 2B I got the save sound problem worked out, you should be able to save it as a dbs and load it back in or save as a wav.

I'm not very good with programming the sound effects so I'm just going to do the gui, if someone puts a noise command or other functionality into the sound code I will update the gui program.

XANAX 2B
20
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 16th Aug 2005 15:33
I just know that the white noise is always random values, but I don't know how to do the pink noise ( pink noise is a modulation between the white noise and a sinus function but I've to experiment... )
If I find how to do a good pink noise, I'll tell you on this place.

Login to post a reply

Server time is: 2024-05-07 09:03:22
Your offset time is: 2024-05-07 09:03:22