Computer Science Canada Random Music Player |
Author: | charlie56 [ Sat Apr 09, 2005 2:25 pm ] |
Post subject: | Random Music Player |
I was wondering if it is possible to have in procedure form a random music player. So im guess in the procedure you have to make a playlist out of all the midi files, abd then make it choose a random one to play and then when that ones finished it goes to another randomly chosen song. I would also just like to say that compsci.ca is by far the best turing resourse on the net and that you guys have great responose time with any question. |
Author: | Delos [ Sat Apr 09, 2005 4:06 pm ] |
Post subject: | |
Right you are (on all your statements ![]() Rand.Int() Music.PlayFileReturn() (better than .PlayFile) Music.PlayFileStop procedure() function() I'd suggest you look into arrays for this one, sepecifically flexible ones. Think about looking at a directory, writing down all the names of files than hold music (that OOT can play) one pieces of paper, putting them in a hat, and then drawing them out one after another. This of course raises the question of whether you want to have the files removed from the list after being played once or not... |
Author: | charlie56 [ Sat Apr 09, 2005 5:05 pm ] |
Post subject: | |
well i think the idea of removing them from the list would be perfect because i plan on having enuf songs that u couldnt possibly play long enuf to run out of music and then it would be better too cuz then you wouldnt hear the same song multiple times(which with midi's can really start to get annoying). |
Author: | charlie56 [ Sun Apr 10, 2005 1:18 am ] | ||
Post subject: | |||
ive read up on flexible arrays read the tut in the tutorials section and this is wut i have, its a mess it started off fine then since it wasnt working i kept playing around with it to try to get it to work and now i dont no wut im doing lol. It all works fine it opens up displays welcome starts a song then displays test(which btw is only there so i could tell whether it kept going after running it)but when the song stops another doesnt start.anyways could someone maybe tell me wut is rong with this. and this is goin to be background music for a game im working on so it cant just be in a loop cuz the game needs to keep going.
|
Author: | Delos [ Sun Apr 10, 2005 8:06 am ] |
Post subject: | |
I don't get why you're using a for loop there, but I'm betting that that's your problem. Also, your resizing of the array occurs outside the loop, so that's no use. To make your life easier, randomize the order of the songs before you start playing them. Your array should be a lot smarter than simple numbers. Right now you have to compare redundant values to find out which song to play. Why not use an array of strings instead? Each value could be the name of a song. Then randomize that. Play it the whole way through (you can use your for loop here), and if need be loop it at the end. This particular method won't require you to use a flexible array...though you could if you wanted... Once you've gotten this working, look into Dir. commands so that you can specifiy a particular folder and dynamically create a playlist from songs that are within it. This way you won't have to hardwire the names of the songs...which will be so much more efficient. |
Author: | Cervantes [ Sun Apr 10, 2005 8:16 am ] | ||||
Post subject: | |||||
Problem here is that while your music is playing, your program can't do anything else. If you use Music.PlayFileReturn, you'll need to find out how to determine whether a song is playing. As this gets more complex, you'll want to look into making a flexible array of a record, so that you can store lots of information.
|
Author: | Delos [ Sun Apr 10, 2005 10:44 am ] |
Post subject: | |
Cervantes wrote: If you use Music.PlayFileReturn, you'll need to find out how to determine whether a song is playing. Well, if you want to be sure then just use a Music.PlayFileStop(), and anything that was playing will cease to. The most one can really do is to ensure files exist and perhaps set up a check to log when Music.PlayFileReturn() has been called... |
Author: | charlie56 [ Sun Apr 10, 2005 11:03 am ] | ||
Post subject: | |||
what im thinking might be easier to do then all this is just have the music playing code in a seperate file then when u run the game it will open the other program and ill have it hide and then it can just play music wihile the game is going with no interfercnes or anything. Ya i read the flexible array tuts and i think it might be a little above me. EDIT
i no a lot of this isnt right. i think i might just scrap the music idea for my game its not needed nayways just wanted to make it nice. but if any1 could help some more that would be great. and again ive meesed around with it so much that now i dont no wut is happening |