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 / Procedural music anyone?

Author
Message
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 14th Jun 2018 22:50
Is there any dll or plugin I can use to generate procedural music in realtime - or generate a file to be loaded and played in such way my game can have infinite amount of different musics?

I am thinking about something like WolframTones, but they don't have any DLL I can load, just an online service and it would be great to use something like this for a game.
[size=+2]Forever and one[/size]
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 16th Jun 2018 18:16
I don't know of such a plugin myself, but you could make use of the SET SOUND SPEED command to harness different notes from one instrument sample. Then, by loading, say, 20 instruments and using the volume (fading) and speed settings (notes) and working out timer flags (rhythm) you could definitely come up with some interesting noise!
Send your parents to noisy sprite demo hell... enter the D-Zone
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 18th Jun 2018 00:00
Yeah. I use SET SOUND SPEED to produce different variations of musics and sounds. That was the only easy solution I could think of.

A cool thing I was imagining for a fully procedural game was getting the My Music folder location and load at random whatever the user has inside it, but there is one thing I simply can't do:

I can get any file from a directory and load it, OK, no problem. But I don't know how to check the inside directories and the ones inside them, and normally users organize their files inside folders by artist or album.

Is there a simple way to read all directories inside a folder and get all the files in there and store them into - for example - a list to be furtherly loaded?
[size=+2]Forever and one[/size]
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 18th Jun 2018 02:24
Oh yes indeed. All built-in:

DIR : DIR
DRIVELIST : DRIVELIST
SET DIR : SET DIR Path$
MAKE FILE : MAKE FILE Filename
MAKE DIRECTORY : MAKE DIRECTORY Directory Name
DELETE FILE : DELETE FILE Filename
DELETE DIRECTORY : DELETE DIRECTORY Directory Name
COPY FILE : COPY FILE Source Filename, Destination Filename
MOVE FILE : MOVE FILE Source Filename, Destination Filename
RENAME FILE : RENAME FILE Source Filename, New Filename
EXECUTE FILE : EXECUTE FILE Filename, Commandline, Directory
FIND FIRST : FIND FIRST
FIND NEXT : FIND NEXT
CD : CD Path$

OPEN TO READ : OPEN TO READ File Number, Filename
OPEN TO WRITE : OPEN TO WRITE File Number, Filename
CLOSE FILE : CLOSE FILE File Number
READ BYTE : READ BYTE File Number, Variable
READ FILE : READ FILE File Number, Variable
READ DIRBLOCK : READ DIRBLOCK File Number, Folder to Read
READ FILEBLOCK : READ FILEBLOCK File Number, Filename to Read
READ FLOAT : READ FLOAT File Number, Variable
READ LONG : READ LONG File Number, Variable
READ MEMBLOCK : READ MEMBLOCK File Number, Memblock Number
READ STRING : READ STRING File Number, Variable String
READ WORD : READ WORD File Number, Variable
WRITE WORD : WRITE WORD File Number, Variable
WRITE BYTE : WRITE BYTE File Number, Variable
WRITE LONG : WRITE LONG File Number, Variable
WRITE DIRBLOCK : WRITE DIRBLOCK File Number, Folder to Create
WRITE FILEBLOCK : WRITE FILEBLOCK File Number, Filename to Create
WRITE FLOAT : WRITE FLOAT File Number, Variable
WRITE FILE : WRITE FILE File Number, Variable
WRITE MEMBLOCK : WRITE MEMBLOCK File Number, Memblock Number
WRITE STRING : WRITE STRING File Number, String
SKIP BYTES : SKIP BYTES File Number, Bytes To Skip
WRITE BYTE TO FILE : WRITE BYTE TO FILE Filename, Position, ByteValue
READ BYTE FROM FILE : Return Integer=READ BYTE FROM FILE(Filename, Position)

PERFORM CHECKLIST FOR DRIVES : PERFORM CHECKLIST FOR DRIVES
PERFORM CHECKLIST FOR FILES : PERFORM CHECKLIST FOR FILES
MAKE MEMBLOCK FROM FILE : MAKE MEMBLOCK FROM FILE Memblock Number, File Number
MAKE FILE FROM MEMBLOCK : MAKE FILE FROM MEMBLOCK File Number, Memblock Number

FILE EXIST : Return Integer=FILE EXIST(Filename)
PATH EXIST : Return Integer=PATH EXIST(Path String)
GET DIR$ : Return String=GET DIR$()
APPNAME$ : Return String=APPNAME$()
WINDIR$ : Return String=WINDIR$()
MYDOCDIR$ : Return String=MYDOCDIR$()

FILE END : Return Integer=FILE END(File Number)
FILE OPEN : Return Integer=FILE OPEN(File Number)
FILE SIZE : Return Integer=FILE SIZE(Filename)
GET FILE DATE$ : Return String=GET FILE DATE$()
GET FILE NAME$ : Return String=GET FILE NAME$()
GET FILE TYPE : Return Integer=GET FILE TYPE()
GET FILE CREATION$ : Return String=GET FILE CREATION$()
CAN MAKE FILE : Return Integer=CAN MAKE FILE(Filename)

EXECUTABLE RUNNING : Return Integer=EXECUTABLE RUNNING(Executable ID)
EXECUTE EXECUTABLE : Return DWORD=EXECUTE EXECUTABLE(Filename, Commandline, Directory)
STOP EXECUTABLE : STOP EXECUTABLE Executable ID

WRITE FILEMAP STRING : WRITE FILEMAP STRING Filemap Name, String
WRITE FILEMAP VALUE : WRITE FILEMAP VALUE Filemap Name, Value
READ FILEMAP STRING : Return String=READ FILEMAP STRING(String Value)
READ FILEMAP VALUE : Return DWORD=READ FILEMAP VALUE(Filemap Name)
Send your parents to noisy sprite demo hell... enter the D-Zone
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 18th Jun 2018 02:30
If you need further help with those commands , us crocs are here below the water waiting to bite. LoL.

They are actually very forgiving commands once the dots are connected. Very logically designed, IMO.



Send your parents to noisy sprite demo hell... enter the D-Zone
Mage
11
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 18th Jun 2018 12:45
Not too tough, just need a recursive algorithm.

Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 18th Jun 2018 14:36
@Mage, your example is EXACTLY what I was looking for.

It may work better adding every retrieved music file to a list - with ARRAY INSERT AT BOTTOM or whatever - at least from my point of view. I have 27 thousand music files and I don't know if expanding the array every time I need more space is the best alternative.

I will not just copy and paste yor code. In fact, I'll use it as inspiration, since I understood how you made the recrsion and, man, your programming logic is awesome!

Hope one day I can code 10% as well as you do. The way you use DBPro to serve your needs is inspiring!
[size=+2]Forever and one[/size]
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 18th Jun 2018 23:59 Edited at: 19th Jun 2018 00:00
Another idea, you could simply let the user choose a music folder via some Windows API code, store the entire directory list into an array (as you said) and voila. A Playlist. Basically a 2-step process.
Send your parents to noisy sprite demo hell... enter the D-Zone
Mage
11
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 19th Jun 2018 00:38
Starshyne Emir wrote: "It may work better adding every retrieved music file to a list - with ARRAY INSERT AT BOTTOM or whatever - at least from my point of view. "

I don't like using that command. Also you might have performance problems using it with a large array. Commands like that you never know what they are really doing and they might run through the entire list every time. Small arrays you don't notice but problems can creep up when you scale things up. You decide.

Starshyne Emir wrote: "I have 27 thousand music files and I don't know if expanding the array every time I need more space is the best alternative."

The array expands at bursts of 100, not every time. However I would suggest changing this to 1000 increments instead for your case.

You're going to find that the most significant time consuming process is actually searching the folders and files. The File I/O is many orders of magnitude slower than any array operations you might be performing.

Starshyne Emir wrote: "I will not just copy and paste yor code. In fact, I'll use it as inspiration, since I understood how you made the recrsion and, man, your programming logic is awesome!"

Use it if you like. It is kind of a waste if you do not.

Login to post a reply

Server time is: 2018-09-21 15:32:01
Your offset time is: 2018-09-21 15:32:01