Is there code out there to play a random song and then, when it's finished, play a different song? I never figured out how to do it in Necrotic Drift, but I imagine that it's possible.
And if this is in the release Future Boy! source, I apologize. I'm checking that tonight.
Music!
Moderators: Ice Cream Jonsey, joltcountry
- Ice Cream Jonsey
- Posts: 30184
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
Music!
the dark and gritty...Ice Cream Jonsey!
-
- Posts: 192
- Joined: Mon Nov 22, 2004 3:19 pm
- Location: Wichita, KS
- Contact:
- Ice Cream Jonsey
- Posts: 30184
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
inky and ctate from the ifMud got me heading down the system timer path... basically, Hugo can access the system time, so if you know the length of a piece of music you can determine when the next one should play.
I don't think that Hugo keeps track of the number of seconds since the beginning of Unix time (or even the number of seconds since you started playing the game, which would be helpful) so I think one will have to make a call for the current time and then increment to a future time that you'll check against every turn.
There's no way to start up that next piece of music until the player types something in, but that's fine for my purposes. If they aren't typing something in fairly regularly they probably aren't at the game, so no biggie.
I wrote a similar function to all of this when I was coding in C several years ago, so I guess I can re-use some of that code. (Well, I wasn't playing music thereafter, but still.) I'll package it up and release it so everyone can implement it.
(If I implement the Spellcasting interface, which I won't for a WIP, but probably will for the sake of HUMAN KNOWLEDGE) there could be a nice little framework a new coder could hopefully use and do something with. Possibilities!)
I don't think that Hugo keeps track of the number of seconds since the beginning of Unix time (or even the number of seconds since you started playing the game, which would be helpful) so I think one will have to make a call for the current time and then increment to a future time that you'll check against every turn.
There's no way to start up that next piece of music until the player types something in, but that's fine for my purposes. If they aren't typing something in fairly regularly they probably aren't at the game, so no biggie.
I wrote a similar function to all of this when I was coding in C several years ago, so I guess I can re-use some of that code. (Well, I wasn't playing music thereafter, but still.) I'll package it up and release it so everyone can implement it.
(If I implement the Spellcasting interface, which I won't for a WIP, but probably will for the sake of HUMAN KNOWLEDGE) there could be a nice little framework a new coder could hopefully use and do something with. Possibilities!)
the dark and gritty...Ice Cream Jonsey!
-
- Posts: 192
- Joined: Mon Nov 22, 2004 3:19 pm
- Location: Wichita, KS
- Contact:
Yeah, but since the music suspends when the Hugo window loses focus, it's only going to be accurate if the user never switches windows during a game. Or is it only MIDI that gets halted until the window gets focus again? No, it's MP3's as well, I'm pretty sure, because that's what I had in Trading Punches.
A better solution would be a counter that only ticks while the window has focus, *or* a way to not pause the music when the window loses focus. I guess the worst that would happen, though, is that a song ends before it's supposed to, and a different one starts.
A better solution would be a counter that only ticks while the window has focus, *or* a way to not pause the music when the window loses focus. I guess the worst that would happen, though, is that a song ends before it's supposed to, and a different one starts.
- Ice Cream Jonsey
- Posts: 30184
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
That's right. You'd have the song ending early when you went back to the game and it checked the time. "Oh!" the game would say, right before the hard-rocking part of Stairway to Heaven, "It's time for a new song!"
And then the game randomly chooses a piece of screechtronica and everyone hisses. =(
But yeah, a timer ticking while the game is active is probably the best solution.
And then the game randomly chooses a piece of screechtronica and everyone hisses. =(
But yeah, a timer ticking while the game is active is probably the best solution.
the dark and gritty...Ice Cream Jonsey!
-
- Posts: 192
- Joined: Mon Nov 22, 2004 3:19 pm
- Location: Wichita, KS
- Contact:
-
- Posts: 119
- Joined: Fri Jun 27, 2003 12:10 pm
Yeah, there's really no way to explicitly tell when a song has finished playing. Call this a shortcoming of the current implementation, and call the implementation "The thing that was easiest to do across all platforms and disparate sound/media subsystems".
A system() call could probably be implemented to return the state of media playback, and this could be wrapped in a handy library call. Man, that's a good idea.
A system() call could probably be implemented to return the state of media playback, and this could be wrapped in a handy library call. Man, that's a good idea.
- Ice Cream Jonsey
- Posts: 30184
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact: