Idea about iMUSE style music...

Started by Bandersnatch, Fri 16/03/2012 02:27:23

Previous topic - Next topic

Bandersnatch

Hi all,

I was having a thought about how to implement seamless music in the style of the wonderful iMUSE system, and how a similar (if not quite so perfect) system could be achieved using .mp3 audio...

I understand AGS has several audio channels that run simultaneously, right? I'm struggling to find just how many, but let's imagine there's 8 - a number I feel might just be the right one. I'll use the setting of the game I'm currently developing as a backdrop...

The player arrives in the dank, foggy frontier town of Gundersen's Valley. Upon arriving, 5 pieces of .mp3 music (all with the same tempo, key signature, chord structure and running time) start playing, all on different channels, but only one is audible as the rest are muted. The master track plays in all external areas of the town. When the player enters either the Saloon, Livery, General Store, or Madwoman's Tent, the master track fades out and the track corresponding to the new location/room fades in simultaneously.

Now this sounds pretty convincing to me, and has probably been championed LONG before I came up with the notion. ut either way, would I be correct in thinking this would be viable? Sorry to waffle on.  :-X

Calin Leafshade

Sounds perfectly fine to me.

The only problem may be that the audio files may not sync up perfectly and you'll get phasing as you fade between them.. it depends how accurate AGSs sound system is timing wise... I would bet its not sample accurate which might be a problem..

Worth a try tho.. give it a whirl and see if it works. I'd love to hear a demo.

Snarky

What Linus Bruckman Sees When His Eyes Are Closed uses a very simple version of this, with two tracks that are synced together which the game fades between (at random, I think). So it should work. I'd recommend using OGG rather than MP3, though. I seem to remember something about the syncing being more accurate with OGG than with MP3.

HandsFree

I tried something like that in my RON game. I had two music files, one normal and one with everything but the bass muted down.

When you enter the bar both start playing but only the first audible. If you then enter a backroom it switches to the second file (and back when you enter the bar again).
The sync wasn't perfect but it didn't need to be in that situation. I used mp3 so maybe ogg would have been better...

monkey0506

I typed out most of this in a comment, decided it was getting too long, copied, didn't paste, and copied something else. :=

But, I've done some preliminary testing, and this should pretty much achieve the effect:

AGSMuse v2.0

Usage:

Code: ags
// wherever
AudioChannel *backgroundMusic; // import/export or use Global Variables pane

// elsewhere
backgroundMusic = aBackground.Play();

// finally!
backgroundMusic = aSaloon.PlayMuse(backgroundMusic, GetGameSpeed() * 3);


Basically the AudioClip.PlayMuse function starts fading in the specified AudioClip, while simultaneously fading out the given AudioChannel. You specify how slow/fast the fade is in game loops, so this will perform the fading in 3 seconds.

Warning: Be sure that in the audio type properties that you have at least 2 channels available for this audio type as it currently doesn't check if the new AudioClip is playing on the AudioChannel you're replacing.

I did this at work so I couldn't test with actual sound (lol) but I did test using the AGS audio functions and it is apparently working correctly. ;)

Bandersnatch

Wow, that's brilliant! I'll have to give it a shot when I get the opportunity - there's a chance I might not be able to quite work it out properly but I'll post back in this thread with the results  ;D

monkey0506

I forgot to mention in my post (I speculated about it before I started typing up the code, in the post that got lost in another copypasta dimension), the basic idea that I was working from is that you shouldn't need to start every clip simultaneously if you can start playing it and/or seek to the same millisecond position in MP3/OGG audio.

As I said, I haven't had a chance to test it out with any audio clips that actually fit the original description, but let me know how it works for you.

SMF spam blocked by CleanTalk