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 / Random Music Generator, No Media

Author
Message
Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 6th Feb 2007 04:42 Edited at: 14th Feb 2007 22:31
I used that thing that creates sound with no media that was posted a while ago to make a random music maker program. It has a bass line and a melody. I'm working on making it so you can save the final sound.



I guess it's not that useful yet, but still kinda fun to listen to.

[EDIT]
****The Newest Version****

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 6th Feb 2007 13:26
Haha nice

Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 6th Feb 2007 17:17
Thanks, man. I'm working to improve it to make it sound more... musical. Then I'll probalby add a Save Sound function.
Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 6th Feb 2007 17:59
This one sounds a bit better. I added some more rules of what the progression and the melody can / can't do.

Alquerian
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location: Reno Nevada
Posted: 6th Feb 2007 21:02
hehe this is a pretty slick code snippet. I noticed that it continues to play, but you can't hear any audio if the app looses focus. Interesting implementation

Quit planning to make a game and make a game.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Feb 2007 00:12
Next step is to give it some more interesting rhythm, and then if you're up to it, some chords

Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 7th Feb 2007 00:32
Thanks, guys. You're right about the rhythm, I've been racking my brain for a way to add that. I might add drums eventually too. I figured out how to make those with the CreateSound thing a while ago, i wonder if i still have it....

Oh, and about it muting when the app loses focus, I'm pretty sure DB does that with play sound, but not with play music, I wonder if there's a way I can use that... Or maybe i can make it stop when you click away from the app. Is there a way to detect that?
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 7th Feb 2007 13:52
Maybe... try doing somethin like this:

if mousex()>screen width() or mousex()<0 or mousey()>screen height() or mousey()<0

If mouseclick()=1 then pause music 1

endif



Oh yeah and the snippet is awesome too

-Mansoor S.

(Formerly Xenocythe)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Feb 2007 19:41
See if you can create a musical interpretation of a fractal

Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 8th Feb 2007 01:16
Haha, thanks guys, I really didn't think I would get this much of a response on my music maker.

@Xenocythe, that is a good idea to use DB's mouse expressions to figure out if the window is active.

@Phaelax, I would create a musical interpretation if I knew what the heck a fractal was, hahaha.
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 12th Feb 2007 00:22
DBP's mouse commands 'lock up' if the window isn't in focus and the mouse isn't over the window, actually. I don't believe there's any internal method of telling whether the window has focus or not.

Nice work here, start of something really neat perhaps
Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 14th Feb 2007 01:59
I upgraded it to do a bunch of new things, making it sound alot better. I think these are all of the things I added, there might be more:
*Different rhythms
*Different key signatures
*Different tempos

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 14th Feb 2007 14:42 Edited at: 14th Feb 2007 14:45
That actually sounds real good! You wouldn't know that it was made by random numbers it's so good. It'd be great if you save the song as a midi so you could change the instruments.

Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 14th Feb 2007 20:05 Edited at: 14th Feb 2007 22:27
That's a really good idea. I'm working on adding a save sound thing, where it just saves it as its own type of file and is able to load it back up. If i figure out how to work with midi files, i will try to add that, cause i really like that idea.


[EDIT}


Okay, so I added the save sound thing. It will take your randomly made song and save it to a file that can be called up later.
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 23rd Mar 2007 06:55
Wow... I really like that it has comments, I can almost understand some of it. And, of course, as a band nerd I LOVE THIS APP!

"There will always be evil, for, without evil, the good shall lose their virtue."
Juso
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: Finland
Posted: 23rd Mar 2007 17:52
Nice code, but can you make the sound more soft? Now its (hard) sounding triagle wave, can you make (sotf) sounding sinus wave?

I didnt understand data clauses "data 82:data 73:data 70:data 70:data 208..." Is the wave form there?
Brain111
17
Years of Service
User Offline
Joined: 5th Feb 2007
Location: In my own little world.
Posted: 29th Apr 2007 21:12
I did not create the part of this program that generates the sound, only the part that generates the musical sequence. But from what I understand, the data statements at that part are the bytes that are placed at the beginning of every wav sound. Like if you open up a .wav file with notepad, it will start out like WAV_...something.

And yeah I remember seeing code for a sinus wav somwhere, I used this one cause the sinus one always seemed to make my program crash. I think it was casue it used memblocks and I had an old version of DB, but now that I upgraded, it should work.

Thanks for the comments, guys.

Login to post a reply

Server time is: 2024-11-22 18:46:26
Your offset time is: 2024-11-22 18:46:26