The Dink Network

midi

February 4th 2009, 02:36 PM
milder.gif
Is there a script that make midi s play in random order. I want that it starts to play and when the midi is finished the script will open another midi. Does anyone knows a script that can make that happened?
February 4th 2009, 09:42 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I think a loop with a random function would suffice, but I don't think that there's any hard coded way to tell whether or not a midi is already playing, so you'd have to use specific wait commands equal to the approximate length of the midi. Here's some sample code, but the hard part is getting the wait commands to match up with the midi length.

void main ()
{
script_attach(1000);
int &rand;

loop:
&rand = random(3,1);

if (&rand == 1)
{
playmidi("1.mid");
wait(X);
}

if (&rand == 2)
{
playmidi("2.mid");
wait(X);
}

if (&rand == 3)
{
playmidi("3.mid");
wait(X);
}

goto loop;
}