Author Topic: Music Playlist  (Read 1260 times)

Bloodwurm

  • Summoner
  • **
  • Posts: 52
    • View Profile
    • Email
Music Playlist
« on: 17 December 2011, 00:52:27 »
Hi all,

I'm working on implementing some music playlist features for GAE and this is what I've got up until now. I'd like feedback on it to see if everyone is going to be happy with it, or would have other ideas/requests.

So the basis of the work is to address 3 feature requests: music playlist on a tech tree, per subfaction and per unit. I went about this as if dealing with stacks of music playlists, each level possibly stacking on top of each other or adding to the current one.

For instance, the first "level" would be the tech tree music playlist. Afterwards, there is the faction playlist and then the subfaction's. Each playlist can either add to the previous level or replace it completely (creating the stacking effect) or declare no music playlist at all.

An example would be where the tech tree would define a base music playlist, comprising of faction agnostic tracks. In the different factions, playlists would be defined that add tracks to the tech tree playlist. A modder could then decide that a subfaction could redefine the music playlist with a different set of tracks.

Finally, a playlist can be set on a unit so that when that unit is built it would affect the playing tracks.

Playlists have several options on them:
randomize="true" means that the playlist will randomly choose a file in it's list and play it. When done, the playlist is considered done playing.
loop="true" means that when the playlist is done playing, it will restart it's logic.
activation-type="add" means that the tracks of the playlist will actually be added to the current playing one.
activation-type="replace" means that the playlist is meant to replace the currently playing one
activation-mode="wait" means that the playlist will be considered for playing only when the system requires to choose a new track
activation-mode="interrupt" means that the currrently playing playlist will stop and that this one will start immediately.

A playlist set on units also have these supplementary options:
activation-time="created" means that the playlist will start when the unit is spawned on the map
activation-time="build" means that the playlist will start when the unit starts building

Also, for legacy reasons, the current <music> tags are still valid and will take precedence over the tech and faction music playlist. This is obviously to prevent breaking anyone`s mod with the latest changes.

Also, don't know if it was known or not, but the underlying tech to play music tracks re-uses the same sound buffer when switching from one track to the other. Which means that the wave files should all be exported with the same sampling rate, bit rate and channel count. Else you could have slow downs/ speed ups or glitches, which sounds awful.

Thoughts? Ideas? Complaints?

Bloodwurm

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,121
  • I'm totally not a robot
    • View Profile
    • Glest Wiki
    • Email
Re: Music Playlist
« Reply #1 on: 17 December 2011, 05:04:00 »
First of all, big thank you in advance for your work, I can't wait to see it completed.

Anway, everything sounds great, though I'm a bit curious on how exactly unit music tracks work. Is it adding/replacing tracks when the unit is created/built or just when selected? I could see a use for the former, as you could add a new track when a special type of unit is created (eg, creating a war drummer might add a new drum track into the playlist). So provided I understand it correctly, an interesting idea would be to remove the track if all units of the type that added it die. So if my war drummer dies, the new drum track is removed from the playlist. But if I had two war drummers, both would have to die in order for the track to be removed. And ideally removal of tracks would also have the activation-mode parameter (wait/interrupt).

Another possible feature request I'd like to see would be crossfading of tracks (presumably with custom timings). When a track is within the specified time left in the track, it would start reducing the track's volume and start the next track, starting at zero volume and rising to 100% by the time the initial track ended. For example, if the crossfade time is 5 seconds, when track 1 has five seconds left (if it was one minute long, this would be at 55 seconds), it's volume would be reduced to zero at a steady pace (so at 5 seconds to go it would be 100%, at 4 seconds to go, 80%, all the way until it's time to switch to the next track, by which it should be at 0%). At the same time as the first track starts fading out, the second track would be doing the opposite, starting at zero and going up at a constant rate until it reaches 100% volume (which should be at the same time the first track ends). Crossfading is a very noticeable and very professional, yet fairly simple, sound addition.

Also, don't know if it was known or not, but the underlying tech to play music tracks re-uses the same sound buffer when switching from one track to the other. Which means that the wave files should all be exported with the same sampling rate, bit rate and channel count. Else you could have slow downs/ speed ups or glitches, which sounds awful.
I don't really know much about how the game handles sound, but perhaps they should use a different sound buffer for the next track? And if crossfading were to be implemented, it would have to, wouldn't it?
Edit the MegaGlest wiki: http://docs.megaglest.org/

Comprehensive documentation is our goal. Help us reach it!

Bloodwurm

  • Summoner
  • **
  • Posts: 52
    • View Profile
    • Email
Re: Music Playlist
« Reply #2 on: 18 December 2011, 18:02:30 »
Hi Omega,

Thanks you for your interest in the feature  :)

Yes, I know exactly what cross-fading is and your suggestion would more than be feasible but would effectively require to "drastically" change how the game currently handles sounds.
And yes, you are right, cross-fading would require the use of a second sound buffer, thus alleviating the limitation.

I can tell you that while the current audio support is a nice start, it is effectively rather limited right now. It is in no way a complaint, it's more than usual in the industry to see audio features done mid-project or even last (what's the use in having audio if you can't even have a game running?). So I'm convinced that more audio work will be done in the future.

I'm the new guy here so I'm yet to understand how feature requests are done, approved and scheduled so I can't say to when or even if this cross-fading requests will get done. I can only totally agree that cross-fading should be added and will add more quality to the game. Maybe silnarm would agree to me looking into it next?

In regards to your more precise question about units. Yes, the feature is intended for when a unit is starting to being built or when done building, so NOT when selected or the like (this would sound like hell! :( ).
Your example of the war drummers would be a good one (though I would wonder if it wouldn't be more interresting to have an "idle" state simply fire off from time to time with accompanying sfx). Another one could be for building some "unique" unit, say a Death Star, and you want the musical score to change to reflect that game changer.

Thanks again and keep them coming!

Psychedelic_hands

  • Archmage
  • ******
  • Posts: 621
  • It's all in the mind you know....
    • View Profile
    • Constellus Wiki Page
    • Email
Re: Music Playlist
« Reply #3 on: 19 December 2011, 02:53:33 »
Nice work, thanks for your future help to GAE!

Hi Omega,

Thanks you for your interest in the feature  :)

Yes, I know exactly what cross-fading is and your suggestion would more than be feasible but would effectively require to "drastically" change how the game currently handles sounds.
And yes, you are right, cross-fading would require the use of a second sound buffer, thus alleviating the limitation.
If you want to talk about sound, I think Daniel.santos is your guy, he mentions having a almost rewritten sound engine in the experimental branch in the mailinglist here :http://sourceforge.net/mailarchive/message.php?msg_id=28194947
Quote
I'm the new guy here so I'm yet to understand how feature requests are done, approved and scheduled so I can't say to when or even if this cross-fading requests will get done. I can only totally agree that cross-fading should be added and will add more quality to the game. Maybe silnarm would agree to me looking into it next?

I'm pretty sure Silnarm won't mind.  ;)
Quote
In regards to your more precise question about units. Yes, the feature is intended for when a unit is starting to being built or when done building, so NOT when selected or the like (this would sound like hell! :( ).
Your example of the war drummers would be a good one (though I would wonder if it wouldn't be more interresting to have an "idle" state simply fire off from time to time with accompanying sfx). Another one could be for building some "unique" unit, say a Death Star, and you want the musical score to change to reflect that game changer.
I think that ticket might be a bit.... not worth doing. But hey; your the one doing it, So good luck man.  :thumbup:

jda

  • Archmage
  • ******
  • Posts: 664
    • View Profile
Re: Music Playlist
« Reply #4 on: 19 December 2011, 03:34:52 »
Hi Bloodwurm!

GAE uses sourceforge.net for hosting and tracking. The tracker is the actual schedule-thing the devs use to organize their work - tracks bug reports (called "defects"), feature requests ("enhancements"), TODOs ("tasks"), possibly more - each of these, regardless of the said type, is called a "ticket".
A query on this tracker ( http://sourceforge.net/apps/trac/glestae/query ) for summaries containing "music", ordered by milestone, gave me 2 closed tickets:
Milestone 0.3:     #99      Multiple music tracks per faction
Milestone 0.3.1:    #159      Shuffle option for multiple music tracks
And 3 open ones for Milestone 0.5 (note current stable GAE is 0.3.2 and there is a 0.4 beta3 out):
#187      non-faction music play-lists
#291    music play-lists per subfaction
#292    allow music play-lists defined per unit
Now don't these three sound exactly like what you want?  ;)
None of these has a "Owner" yet - not assigned to anyone yet.

So, my suggestion:
1. Signup for a free sourceforge.net account if you don't have one yet - just use the link I gave you above to find your way around.
2. Find your way to the gae-devel mailing list, introduce yourself and your intentions. - friendly list, all people who are out here in the GAE forums...
3. Through the mailing list, this very topic or the tracker interface, try to assign yourself to those tickets. I'm sure you'll have no problem at all with this. ;)

Cheers!
(and though I'm no GAE dev, just a player/modder, WELCOME!  8) )
Dwarf Aglarond faction, realease 0.1.2 published on December 16th 2011
Check the linked thread for details and up to date download link !
A patch with new Goat sounds has been released December 18th ! A new patch with minor improvements to the Goat animations has been released December 22nd !

Bloodwurm

  • Summoner
  • **
  • Posts: 52
    • View Profile
    • Email
Re: Music Playlist
« Reply #5 on: 19 December 2011, 18:26:28 »
Thanks for the input Jda, I had done all of that prior to starting working on anything :)

The only thing that's left is for someone to give me write access to the sourceforge depot and I'll be able to submit my work for everyone to try out (waiting on Silnarm for the access, surely busy).

Yes those 3 open tickets are the ones I tackled, I got them pretty much all done. Only thing that would be missing, besides crossfading, is to remove the playlist when all the units died, as per Omega's suggestion.

My gut feeling was also that the per unit thingy was a bit overkill but then the ticket was there! :)
Personnaly I would have went with some form of lua support for this feature but there is still work to be done lua-wise apparently so, whatever! It's done :)

For the crossfade, I'll probably look into more after the Christmas break.

Cheers all!

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,121
  • I'm totally not a robot
    • View Profile
    • Glest Wiki
    • Email
Re: Music Playlist
« Reply #6 on: 19 December 2011, 18:44:38 »
The only thing that's left is for someone to give me write access to the sourceforge depot and I'll be able to submit my work for everyone to try out (waiting on Silnarm for the access, surely busy).
You should upload a diff (if unsure of how to do this, the Linux has a diff command and Windows has programs like WinMerge).
Edit the MegaGlest wiki: http://docs.megaglest.org/

Comprehensive documentation is our goal. Help us reach it!

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,569
    • View Profile
    • http://blog.nturn.net/
Re: Music Playlist
« Reply #7 on: 20 December 2011, 00:54:06 »
Git also has the format-patch command for creating a diff. Once I've seen a diff I can give you write access. I'll need your sourceforge username.
Glest Advanced Engine - Admin/Programmer
http://sourceforge.net/apps/trac/glestae/

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,569
    • View Profile
    • http://blog.nturn.net/
Re: Music Playlist
« Reply #8 on: 18 February 2012, 06:11:34 »
I've pushed Bloodwurm's patches to sourceforge (commits 854041.., 3118a87..) . I haven't properly tested it but it doesn't seem to break existing functionality. I've modified SoundPlayerOpenAL (for Linux) so that it matches the changes in SoundPlayer (commit 56156ac..) so it will compile but probably won't be available on Linux without more work.

This appears to be the xml (will need clarification):
Code: [Select]
In tech tree xml:
<music-play-list enabled="true|false" randomize="true|false" loop="true|false" activation-type="add|replace" activation-mode="wait|interrupt">
<!-- must not be empty if enabled -->
<music-file path="" />
</music-play-list>

In unit xml:
<music-play-list enabled="true|false" randomize="true|false" loop="true|false" activation-type="add|replace" activation-mode="wait|interrupt" activation-time="build|created">
<!-- must not be empty if enabled -->
<music-file path="" />
</music-play-list>

In faction xml:
<subfactions>
<subfaction name="">
<music-play-list enabled="true|false" randomize="true|false" loop="true|false" activation-type="add|replace" activation-mode="wait|interrupt">
<!-- must not be empty if enabled -->
<music-file path="" />
</music-play-list>
<subfaction>
<subfactions>
Glest Advanced Engine - Admin/Programmer
http://sourceforge.net/apps/trac/glestae/

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,737
  • I have to go now. My planet needs me.
    • View Profile
Re: Music Playlist
« Reply #9 on: 18 February 2012, 19:03:20 »
While this isn't a fatal error, the game still doesn't seem to like my XML now:
Code: [Select]
Glest Advanced Engine: Error log file. 18-Feb-2012_10-38-44

XML Error in techs/solunar/solunar.xml:
Node "tech-tree" doesn't have 1 children named  "music-play-list"

Tree: tech-tree (description attack-types (attack-type attack-type attack-type attack-type attack-type attack-type )  armor-types (armor-type armor-type armor-type armor-type armor-type armor-type )  damage-multipliers (damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier damage-multiplier )  )
XML Error in techs/solunar/factions/moon/units/broch/broch.xml:
Node "parameters" doesn't have 1 children named  "music-play-list"

Tree: parameters (size height max-hp max-ep armor armor-type sight time multi-selection cellmap levels fields (field )  properties light unit-requirements (unit )  upgrade-requirements (upgrade )  resource-requirements (resource resource resource )  resources-stored image image-cancel meeting-point selection-sounds command-sounds tags (tag )  )
XML Error in techs/solunar/factions/moon/units/cairn/cairn.xml:
Node "parameters" doesn't have 1 children named  "music-play-list"
and so on for each unit, as well as:
Code: [Select]
XML Error in techs/solunar/factions/moon/moon.xml:
Node "faction" doesn't have 1 children named  "music-play-list"

Tree: faction (starting-resources (resource resource resource resource )  starting-units (unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit )  music )

It seems like it should ignore that, since it never existed before.
My projects: Solunar; Project Green; Project Red.
My free art: OpenGameArt

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,569
    • View Profile
    • http://blog.nturn.net/
Re: Music Playlist
« Reply #10 on: 19 February 2012, 03:42:40 »
Thanks John. I've pushed a fix (commit 458e855a0d..).
Glest Advanced Engine - Admin/Programmer
http://sourceforge.net/apps/trac/glestae/

Bloodwurm

  • Summoner
  • **
  • Posts: 52
    • View Profile
    • Email
Re: Music Playlist
« Reply #11 on: 28 April 2012, 18:45:15 »
Just so you everyone knows, my changes were reverted because it was crashing a lot apparently :)

Since the feature was fundamentally flawed in it`s implementation, I`m currently redoing it, so it will be back.
Still intent on doing all 3 tickets mentioned in this thread.
With added crossfading support.

Keep you all posted

 

anything