Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

879836 Posts in 33010 Topics- by 24381 Members - Latest Member: MinuteMan

May 25, 2013, 04:12:01 AM
TIGSource ForumsDeveloperCreativeAudioGetting the most from your background music
Pages: [1] 2
Print
Author Topic: Getting the most from your background music  (Read 3734 times)
Glaiel-Gamer
One Epic Motherfucker
Level 10
*


Stoleurface!


View Profile WWW Email
« on: December 23, 2008, 07:58:50 AM »

So like, I like making music for my games, it's a good break from the programming. But I am nowhere near pro at music or anything, it's always been my sub-hobby after programming. Anyway I always had the problem that sometimes I could make neat music, but I have trouble making stuff not repetitive sounding (when I make something sound good in the first place, I tend to grow attached to the melodies I write and anything else I try to add ends up just sounding worse or too different to be in the same song).

Even so, if you have a game which takes an indefinite amount of time to play through (i.e. it depends a lot on the person playing it and how they go about it), ANY music track you have will be repetitive after a while. The most common way to solve this problem is to have a lot of different background music tracks which you switch often. It works, but sometimes one track fits so well that it sucks to have to switch it out.

The problem here is finding tracks that are complimentary AND varied at the same time.

Since I worked on Aether, however, I've been playing around with this new method of stretching music and making ONE song sound varied and different at different parts of the game. It's simple. You split your song into multiple tracks, all of the same length, after making something that is intentionally busy and cluttered feeling. Then you fade the tracks in and out depending on circumstances of the game, while they are all playing at the same time. You decide the circumstances yourself, there's a lot of ways to do this and it makes the music interactive, dynamic, and less repetitive, all while being ONE SONG. I played around with this effect on Aether and I love how the music turned out on it enough to try it again on my next project Closure, and the second I got the music in that game it make it feel so much more like a completed project. The best part about this effect is that it works for ANYTHING, any mood, any type of game, any style of music.

There are a few cons to this effect, however.
- Larger filesize. A 5-track song will use up 5x the filesize and memory of a 1-track song unless you're using midi.
- More work. If you don't have a good audio engine, it'll take a little work to keep everything in sync with each other. Flash does a good job at this if you start them at the same time, but I found with Aether that lag can sometimes offset the times they start at, so I had to counter that effect and start each song at the playhead position of the background track which was started first.
- Can't use premade songs unless you track down the person who made them and ask them to split it into tracks for you. Not a problem if you're getting a custom soundtrack or doing the music yourself.

Anyway I encourage everyone to try this effect, it adds more depth to your music, makes it more dynamic and less repetitive, and can really enhance the mood of your games.
Logged

Core Xii
Level 10
*****


the resident dissident

corexii@gmail.com Core+Xii
View Profile WWW Email
« Reply #1 on: December 24, 2008, 02:42:41 AM »

Quote from: Glaiel-Gamer link=topic=4038.msg124487#msg124487
- Larger filesize. A 5-track song will use up 5x the filesize and memory of a 1-track song unless you're using midi.

You might want to consider modules/trackers. They're a fair compromise between waveform audio and midi.

Quote from: Glaiel-Gamer link=topic=4038.msg124487#msg124487
- More work. If you don't have a good audio engine, it'll take a little work to keep everything in sync with each other. Flash does a good job at this if you start them at the same time, but I found with Aether that lag can sometimes offset the times they start at, so I had to counter that effect and start each song at the playhead position of the background track which was started first.
- Can't use premade songs unless you track down the person who made them and ask them to split it into tracks for you. Not a problem if you're getting a custom soundtrack or doing the music yourself.

There are always going to be issues with dynamic music. There's nothing you can do about it.

There is another way, which is to create 'blocks' of tracks, then stitch them together. Before the last one ends, pick a new one that fits the current game situation. You may need to make a lot of different transitions though.

Edit: That's weird, did I screw up the quotes somehow?
Logged
Kekskiller
Guest
« Reply #2 on: December 24, 2008, 03:10:58 AM »

Another way is to split all audio channels you have in your track. So you can mix them depending on the situation... Imagine the player is far frome every enemy and comes in a real empty, but exploration heavy area. The game could fade in the big ambient background + some other, pure atmospheric elements. Getting nearer to an enemy means less stringy stuff, more percussion and bass or somewhat - mixing all them together would give you very fat overloaded track, so you can fit the music to every situation. It's a bigger amount of work, and definitly more CPU consuming, but worths the effort of having a great, epic and dynamic soundtrack Smiley .
It's like ambient goa or somewhat in video games - plus all these sweeping strings and flowing elements Coffee
Logged
Paul Eres
Level 10
*****


Also known as RinkuHero.

RinkuHero
View Profile WWW Email
« Reply #3 on: December 24, 2008, 07:25:53 AM »

Coincidentally I showed my friend Long Dao (who did the music for my game Immortal Defense) Aether yesterday and he specifically remarked on how he liked that the music did that. I told him we should try it too with our next game, but that I wasn't sure how it could be programmed, so this thread shows up eerily to answer that.
Logged

Glaiel-Gamer
One Epic Motherfucker
Level 10
*


Stoleurface!


View Profile WWW Email
« Reply #4 on: December 24, 2008, 12:22:07 PM »

Coincidentally I showed my friend Long Dao (who did the music for my game Immortal Defense) Aether yesterday and he specifically remarked on how he liked that the music did that. I told him we should try it too with our next game, but that I wasn't sure how it could be programmed, so this thread shows up eerily to answer that.

if you want the AS3 code I use if you're using flash here it is (from Closure but i copied it from Aether nonetheless)

Code:
var mus1:Track1 = new Track1();
var mus2:Track2 = new Track2();
var mus3:Track3 = new Track3();
var mus4:Track4 = new Track4();
var mus5:Track5 = new Track5();

var channel1:SoundChannel = new SoundChannel();
var channel2:SoundChannel = new SoundChannel();
var channel3:SoundChannel = new SoundChannel();
var channel4:SoundChannel = new SoundChannel();
var channel5:SoundChannel = new SoundChannel();

var transform1:SoundTransform = new SoundTransform(1.00, 0.0);
var transform2:SoundTransform = new SoundTransform(0.00, 0.0);
var transform3:SoundTransform = new SoundTransform(0.00, 0.0);
var transform4:SoundTransform = new SoundTransform(0.00, 0.0);
var transform5:SoundTransform = new SoundTransform(0.00, 0.0);

channel1 = mus1.play(0, 65535);
channel5 = mus5.play(channel1.position, 65535);
channel2 = mus2.play(channel1.position, 65535);
channel3 = mus3.play(channel1.position, 65535);
channel4 = mus4.play(channel1.position, 65535);

channel1.soundTransform = transform1;
channel2.soundTransform = transform2;
channel3.soundTransform = transform3;
channel4.soundTransform = transform4;
channel5.soundTransform = transform5;

NOTE: The reason why I don't start the tracks in order 12345 is because I group the tracks that need to be in time closer together so there's less chance for lag between them, and the more ambient/stringy stuff gets played farther away from the rhythm and melody ones.

then to adjust the music, you change the sound like so:
Code:
transform2.volume = transform2.volume * .90 + wrap(lightSum*((levelnumb/40) + 1), 2, 8) *.1;
transform3.volume = transform3.volume * .90 + wrap(lightSum*((levelnumb/40) + 1), 5, 12) *.1;
transform4.volume = transform4.volume * .97 + wrap((1-white)*((levelnumb/120) + 1), .50, .9) *.03;
transform5.volume = transform5.volume * .97 + wrap((1-white)*((levelnumb/120) + 1), .85, 1) *.03;

channel1.soundTransform = transform1;
channel2.soundTransform = transform2;
channel3.soundTransform = transform3;
channel4.soundTransform = transform4;
channel5.soundTransform = transform5;

You'll have to change what you set the volume too but this works.

I probably also could have used arrays for it all but meh I was lazy.


« Last Edit: December 24, 2008, 12:29:02 PM by Glaiel-Gamer » Logged

Paul Eres
Level 10
*****


Also known as RinkuHero.

RinkuHero
View Profile WWW Email
« Reply #5 on: December 24, 2008, 12:29:57 PM »

Hm, I don't know Flash yet, but from what I gather reading that, five tracks are played simultaneously and the volume of four of them is adjusted dynamically? That doesn't sound too hard, I could do the same in Game Maker pretty easily. What does the function "wrap" do?
Logged

Glaiel-Gamer
One Epic Motherfucker
Level 10
*


Stoleurface!


View Profile WWW Email
« Reply #6 on: December 24, 2008, 12:38:52 PM »

Hm, I don't know Flash yet, but from what I gather reading that, five tracks are played simultaneously and the volume of four of them is adjusted dynamically? That doesn't sound too hard, I could do the same in Game Maker pretty easily. What does the function "wrap" do?

wrap was my way of giving a value and a range and having it wrap the result to between 0 and 1, like .5 to .9 would return 0 for .5 and lower and 1 for .9 and higher
Logged

Paul Eres
Level 10
*****


Also known as RinkuHero.

RinkuHero
View Profile WWW Email
« Reply #7 on: December 24, 2008, 01:53:54 PM »

That's an interesting function idea, sounds useful for a lot of things.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #8 on: December 24, 2008, 05:04:57 PM »

wrap was my way of giving a value and a range and having it wrap the result to between 0 and 1, like .5 to .9 would return 0 for .5 and lower and 1 for .9 and higher
I don't think you are wrapping, that would give very sudden changes in volume. Sounds like you are rescaling and clamping. Pedantry of course, but it did confuse me when reading your code.
Logged
Chris Whitman
Sepia Toned
Level 10
*****


A master of karate and friendship for everyone.


View Profile Email
« Reply #9 on: December 24, 2008, 07:25:23 PM »

To be even more technical it's linear interpolation, not scaling (as it is an affine mapping).

But yeah, whatever you call it, as long as it works I figure you're A-okay.
Logged

Formerly "I Like Cake."
Glaiel-Gamer
One Epic Motherfucker
Level 10
*


Stoleurface!


View Profile WWW Email
« Reply #10 on: December 24, 2008, 08:31:24 PM »

Ya well I'm mostly 100% self taught (just started college recently actually, 1 semester down and lucky me it was mostly stuff I'd done before) so my semantics might be off a bit BUT IT WORKS DAMNIT. Not like the computer cares about names or anything.
Logged

increpare
Guest
« Reply #11 on: December 25, 2008, 03:40:20 AM »

I've been thinking about doing various things like this recently as well.  One pleasant way to do it would be to use some audio library with geometric positioning (to avoid stereo weirdness say you position all the sounds in a line in front of the player), and to have the background tracks move according to their own physical laws (affected by game events, and to have their positions normalized so that their distance from you always adds up to 1, say).  It wouldn't be much better than what you're doing, though, so....

Actually, screw it: I'm going to use something like this for a project I'm working on.  Maybe. ... 

One related idea I did have was to have three corridors configured like a triangle, to have one music source from each endpoint, such that any two of them sound good together, but that all three don't necessarily; (with traditional audio occlusion) you'd only hear two of them at once though, so wouldn't notice.  Maybe at some point to break down the walls though, so that players hear all three at once, and hopefully experience some discomfort at the resulting din.


To be even more technical it's linear interpolation, not scaling (as it is an affine mapping).
actually, given that you're bing technical, the term 'scaling' isn't actually used by people at all to my knowledge in a technical manner, the only terms with technical definitions have extra adjectives, so 'uniform scaling'/&c..  (So it's the 'not' part I disagree with in your statement).  Also the parenthetical comment, the point I think you make being that it's not a linear mapping rather than that it be an affine mapping, though that remark is in support of a nonsensical argument.
« Last Edit: December 25, 2008, 03:46:58 AM by increpare » Logged
Core Xii
Level 10
*****


the resident dissident

corexii@gmail.com Core+Xii
View Profile WWW Email
« Reply #12 on: December 25, 2008, 05:32:45 AM »

Actually I'd call it more like thresholding.
Logged
Glaiel-Gamer
One Epic Motherfucker
Level 10
*


Stoleurface!


View Profile WWW Email
« Reply #13 on: December 25, 2008, 09:04:42 AM »

you know, it's reverse linear interpolation, OK? Linear interpretation would map 0 to 1 to between lower and upper, my function goes the opposite way, only naming the function reverse_linearly_interpolate(a, b, c) would just suck. It's a freaking trivial function though that really has nothing to do with the point of the thread so quit getting hung up on it.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #14 on: December 25, 2008, 10:11:04 AM »

Yes, we are getting sidetracked.
I once made a music playing thing based on continuous time markov chains. So I'd split a song into several short segements, and it would randomly choose transitions between segments as appropriate for gameplay. It was also meant to handle multiple tracks and cross fading.
I never really put it to use though, as I couldn't compose anything worth a damn.
Logged
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic