Should I start Music in Room_load of Room_Afterfadein?

Started by bx83, Tue 15/05/2018 13:18:19

Previous topic - Next topic

Snarky

Great, thanks for the info/clarification, CW!

Agreed completely about using test games or prototypes. It's also one of Ben304's recommendations on the BCT podcast.

As for this case, I would recommend as a general approach: use built-in crossfading for music only. For sounds, write a module that does it manually. You probably don't even need to crossfade, just fade out one clip, stop it, then play and fade in the next. I even seem to remember recommending this to you a long time ago, bx83.

Crimson Wizard

#21
Something that I just realized, I am not sure if the previous crossfade of one type actually fades-in correctly if replaced by the new one of another type. This needs to be tested also.

Quote from: Snarky on Wed 16/05/2018 11:31:44For sounds, write a module that does it manually. You probably don't even need to crossfade, just fade out one clip, stop it, then play and fade in the next. I even seem to remember recommending this to you a long time ago, bx83.
True, that would be much simplier. Also if they fade in/out in a short time, players likely won't notice a difference.

selmiak

Quote from: Crimson Wizard on Tue 15/05/2018 13:56:33
"First time enters room" event creates "Room_FirstLoad" function name by default, but that's a misleading name (and to think of it, should be fixed), because in reality it is "Room first time After Fade-in".
The order of their running is following:

* "Enters room before fade-in" (Room_Load)
* room transition effect
* "First time enters room" (Room_FirstLoad) <--- only if the room is entered for the first time
* "Enters room after fade-in" (Room_AfterFadeIn)

this is interesting and should be noted somewhere. I always figured Room_Load commands and loading things into memory happens while the screen is black when fading out. But then, there are different screen transition effects, even one effect for warping screens together without any moment of complete blackness throughout the transition.

would it be more precise to say it like this? :
* "cChar enters next room before even fading out the current room" (Room_Load)
* room transition effect
* "First time enters room" (Room_FirstLoad) <--- only if the room is entered for the first time
* "Enters room after fade-in" (Room_AfterFadeIn)

or more like
* "Engine loads room commands of the next room into memory before even fading out the current room" (Room_Load)
* room transition effect while cChar Sprite enters next room

the cChar doesn't suddenly disappear while fading out, does it?

where in that chain would a new music track (no sfx) start playing?

morganw

The next thing I'm looking at (next month) are the templates and a test game, so I'll try and start with audio tests (since that was also the bit of the ScummVM port which I was looking at). I'm not sure if the behaviour that is confirmed is just for music tracks, but if max channels actually reserved each channel, what happens when it is greater than 1? Are we saying that music is special case, or that using the built-in crossfade for any type of audio is going to keep the channel pointer valid?

Snarky

Quote from: Crimson Wizard on Wed 16/05/2018 11:49:08
Something that I just realized, I am not sure if the previous crossfade of one type actually fades-in correctly if replaced by the new one of another type. This needs to be tested also.

You mean if you have two different AudioTypes (both set to crossfade) with MaxChannels set to 0, and you're already playing clips of (let's say) AudioType1 on all the available channels, and then you ask to play a clip of AudioType2 with higher priority? I'm not even sure crossfading the clips is the desired behavior in this case. I'm inclined to think only clips of the same AudioType should be crossfaded with each other. And what if one AudioType is set to crossfade but the other not?

Quote from: morganw on Wed 16/05/2018 12:33:55
using the built-in crossfade for any type of audio is going to keep the channel pointer valid?

Surely this.

Crimson Wizard

Quote from: Snarky on Wed 16/05/2018 12:47:51
Quote from: Crimson Wizard on Wed 16/05/2018 11:49:08
Something that I just realized, I am not sure if the previous crossfade of one type actually fades-in correctly if replaced by the new one of another type. This needs to be tested also.

You mean if you have two different AudioTypes (both set to crossfade) with MaxChannels set to 0, and you're already playing clips of (let's say) AudioType1 on all the available channels, and then you ask to play a clip of AudioType2 with higher priority?

No, I mean if there is already crossfade of two clips of type 1 in progress, and you begin crossfading other two clips of type 2.
Assuming MaxChannels for each type is 1, for simplicity.

morganw

Quote from: Snarky on Wed 16/05/2018 12:47:51
Quote from: morganw on Wed 16/05/2018 12:33:55
using the built-in crossfade for any type of audio is going to keep the channel pointer valid?
Surely this.
Will have to test by trying to play a lower priority clip, because I don't think we should rule out getting null as the return.

bx83

Thanks guys, it's all coming together... slowly.

Looks like I won't bother with AudioChannel pointers now unless for things like 'beachThemePos=music_chan.Position' and the crossfading I was talking about.

Also, the time it takes to crossfade multiple channels (ie. a sound and some music, and another sounds) can be controlled with just Wait(30), or some general Waiting. I've recently converted my rooms transition to 'instant', and tried to setup a walk of edge of screen to just-in-front-of-border, so every room transition feels more natural, and also, *takes some time that would normally be Blocking*. This seems to work well :)
Hopefully this approach works better consistently.

However, I'm still having problems with volume.
If I set music_chan.Volume=100, all is well; no phantom reduction and restoration of volume level. Upgraded to 3.4.1-p2, still has this problem. Anyway, a stop-gap for the moment.

But I *also* (I've just noticed) I'm having trouble with footstep sounds. They're only at 100% volume when I (sometimes) first enter a room (or, is this entering the area around the 'edge' of the room?...).
After this, they transiton to 0% volume or 8-10% volume, or whatever. One room it's totally silent, next room it's just audible, etc.

I've tried increasing the number of sound channels to 3 and 4, in case the footsteps audio takes up a channel; and also checked the footstep audio is correctly linked to the footsteps in question: but no dice, it's volume is still random.
Anyway: I thought of just setting the footstep volume to 100%, to act as stop-gap for that as well.

Which brings me finally to my question: HOW do you set the audiochannel volumes for footsteps? Are they on their own 'secret' channel (like crossfading)? Do they take up an additional channel, meaning I should increase my MaxChannels to, I don't know, 5?
Is it even possible to set a pointer to footsteps - after setting the footsteps with this kind of code:

Code: ags

function ChangeFootsteps_normal (int view) {
  ViewFrame *frame = Game.GetViewFrame(1, 0, 1);
  frame.LinkedAudio = aFootstep_normal_a;
  frame = Game.GetViewFrame(view, 1, 1);
  frame.LinkedAudio = aFootstep_normal_a;
  frame = Game.GetViewFrame(view, 2, 1);
  frame.LinkedAudio = aFootstep_normal_a;
  frame = Game.GetViewFrame(view, 3, 1);
...


Experience would tell me no, since the audiochannel pointer is always null, or doesn't seem to join to the footsteps.

:undecided:

Snarky

There's a Character.ScaleVolume setting, which if set to true will adjust the volume of the character depending on its scaling. (Or at least it's supposed to; it's been broken in some versions in the past.) Maybe try to disable that.

There's otherwise no very convenient way to control the volume of footsteps or other audio linked to an animation frame. If you do a forum search, you'll see that the usual recommendation is to create a new audio type, set the type of the clips to that, and use Game.SetAudioTypeVolume().

I'm also curious why you're limiting the Sound channels at all. By setting MaxChannels to 0 it'll use as many as needed for Sound (out of the ones left over once the ones reserved for Speech, Music, etc. are accounted for).

Quote from: bx83 on Thu 17/05/2018 07:51:26
Also, the time it takes to crossfade multiple channels (ie. a sound and some music, and another sounds) can be controlled with just Wait(30), or some general Waiting. I've recently converted my rooms transition to 'instant', and tried to setup a walk of edge of screen to just-in-front-of-border, so every room transition feels more natural, and also, *takes some time that would normally be Blocking*. This seems to work well :)
Hopefully this approach works better consistently.

This doesn't sound like you've taken our advice. :-\ I can't be sure without seeing your code since the description is a bit unclear.

Quote from: bx83 on Thu 17/05/2018 07:51:26
However, I'm still having problems with volume.
If I set music_chan.Volume=100, all is well; no phantom reduction and restoration of volume level. Upgraded to 3.4.1-p2, still has this problem. Anyway, a stop-gap for the moment.

There's a mistake somewhere in your code, and going by the snippet you had in your last post, I'm guessing it has to do with overwriting the music_chan pointer, so that when you're trying to adjust the volume of other clips later on you're actually messing with the music volume.

Forcing the volume to 100 may fix this particular bug, but as long as the mistake is still there it could pop up again in other ways. It might even be what is causing the trouble with the footsteps.

Crimson Wizard

#29
Quote from: bx83 on Thu 17/05/2018 07:51:26
However, I'm still having problems with volume.
If I set music_chan.Volume=100, all is well; no phantom reduction and restoration of volume level. Upgraded to 3.4.1-p2, still has this problem. Anyway, a stop-gap for the moment.

I've read the whole thread again, but for some reason still could not grasp what exactly happens with the volume in your game.

However, only yesterday Chicky has found following bug and posted it on Discord channel:

Quote
Seems with OPT_CROSSFADEMUSIC set to 1 AGS automatically resets volume and crossfades from 0 to 100, ignoring all volume commands until the crossfade has finished

Maybe it is related? Haven't tested this myself.

bx83

Okay, all code:
room 2 is BEACH, to the right of CAVE
room 7 is CAVE
room 3 is FARMER, to the right of BEACH
room 4 is CROSSROADS, to the right of FARMER
room 32 is MOUNTAIN TOP, to the top of FARMER

so:
           _32_
7  |  2  |  3   |  4

I turned off the ScaleVolume=true; no difference, the sound of footsteps in inaudable in room 7, 2 and 3, but audible in room 32 and 4.

In room 3, FARMER
What I meant by the 'blocking pause' was the walking in from the edge of the screen initially in a room transition. If I place the Walk() code after track 1 (sound) crossfades:
Code: ags

sounds_chan=aOcean_crash_cave.PlayFrom(oceanThemePos, eAudioPriorityLow, eRepeat);


but before track 2 (music) crossfades:
Code: ags

aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);


...this should work for giving an appropriate pause while crossfading 2 tracks at once; and will hopefuly have me removing the Wait(5) and Wait(30) commands.


Please IGNORE all comments, commented out snippets, 'cheats' etc, the whole thing is in flux. I've also removed all functions that have nothing to do with music, or were not touched by me while testing.
The room transition is now Instant (left a few SetNextScreenTransition(eTransitionInstant) in case i switch it back).
beachTheme is set as volume is 50 set in editor, beachTheme_Cave is set to 40. I also had to set their volumes manually in code or they had volume randomness or cut out intermitendly on room transition.

Also, might be easier to delete anything you don't see as significant.

aBeachTheme, aBeachTheme_cave, a4_mountainCave_92bpm, aSilence (1 second of ansolute silence, to fade out on), and aAfternoonSounds are Music.
aShake_matches, aOcean_crash (for room 2), aOcean_crash_cave (for room 7 and 4) are Sounds.

===========

ROOM 2 - BEACH (this is where the game starts)
Code: ags

function room_Load()
{
	ChangeFootsteps_normal();
  //cJulius.ScaleVolume=true;
	
	if (GameStarted) {
		beachThemePos=music_chan.Position;
		oceanThemePos=sounds_chan.Position;
		music_chan=aBeachTheme.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
		sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityNormal, eRepeat);

	} else {
	  //SetGameOption(OPT_CROSSFADEMUSIC, 1);
		Game.SetAudioTypeSpeechVolumeDrop(eAudioTypeMusic, 30);
		Game.SetAudioTypeSpeechVolumeDrop(eAudioTypeSound, 40);
	
		BeenToBeach=true;
		
		if (FutureTime) {                                                    //LATER IN THE GAME, YOU RETURN TO THE BEACH IN AN UNSPECIFIED LATER TIME, TO SILENCE AND A DIFFERENT BACKGROUND
			aSilence.Play(eAudioPriorityNormal, eOnce);
		} else {
			music_chan=aSilence.Play(eAudioPriorityLow, eOnce);
			music_chan=aBeachTheme.Play(eAudioPriorityNormal, eRepeat);
			beachThemePos=music_chan.Position;
		}
		
		sounds_chan=aOcean_crash.Play(eAudioPriorityNormal, eRepeat);
		oceanThemePos=sounds_chan.Position;
				
		cJulius.x=436;
		cJulius.y=537;
		
		GameStarted=true;
	}

	QuicksandConquered=true;	//CHEAT                    //IN THE BEACH ROOM, YOU MUST WALK ACROSS QUICKSAND, WHICH IS IMPOSSIBLE WITHOUT SOLVING A PUZZLE; BUT IT WAS TOO HARD SOLVING THIS PUZZLE OVER AND OVER WHEN TESTING, SO I REMOVED IT
}

function room_AfterFadeIn()
{
	if (cJulius.PreviousRoom == 3) {		//farmer
		aAfternoonSounds.Stop();
		sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityLow, eRepeat);
	}

	if (cJulius.PreviousRoom == 7) {		//cave
		aWater_dripping.Stop();
		cJulius.Walk(265, 500, eNoBlock, eWalkableAreas);
	}
	
	music_chan.Volume=50;
}



function room_LeaveRight()
{
  if (cJulius.y<=470) {
		
    SetNextScreenTransition(eTransitionInstant);
    SetGameOption(OPT_CROSSFADEMUSIC, 1);
		
    cJulius.ChangeRoom(3, 90, 600, eDirectionDownRight);     //Farmer
  } else {
    cJulius.ChangeRoom(23, 164, 472, eDirectionRight);   //pixelated forest
  }
}


function room_LeaveLeft()
{
	if (cJulius.y >= 240 && cJulius.y <= 520) {
		cJulius.Walk(0, cJulius.y, eBlock, eWalkableAreas);
		SetNextScreenTransition(eTransitionInstant);
		cJulius.ChangeRoom(7, 900, 385);       //Cave
	}
}
    
function room_LeaveBottom()
{
  cJulius.ChangeRoom(23, 120, 437);   //pixel forest
}



=====================


ROOM 7 - CAVE
Code: ags

function room_LeaveRight()
{
  if (cJulius.y<=405){
		cJulius.Walk(1054, cJulius.y, eBlock, eAnywhere);
		SetNextScreenTransition(eTransitionInstant);
		cJulius.ChangeRoom(2, 2, 500, eDirectionRight); //beach
  }
}

function room_FirstLoad()
{
  BeenToCave=true;
}

function room_Load()
{
	//braun fixes car
	cBraun.LockView(67);
	cBraun.Animate(0, 1, eRepeat, eNoBlock);

	if (FutureTime) {
		music_chan.Stop();
	} else {
			beachThemePos=music_chan.Position;
			music_chan=aBeachTheme_cave.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
	}
	
	sounds_chan=aWater_dripping.Play(eAudioPriorityNormal, eRepeat);
}

function room_AfterFadeIn()
{
	music_chan.Volume=40;
}


=====================

ROOM 3 - FARM (room 47 is 'farmer detail' - ignore)
Code: ags

function room_LeaveLeft()
{
  cJulius.ChangeRoom(2, 910, 330, eDirectionLeft);       //Beach
}

function room_LeaveRight()
{
  cJulius.ChangeRoom(4, 90, 560, eDirectionRight);         //Crossroads
}

function room_LeaveTop()
{
	cJulius.Walk(654, 452, eBlock, eWalkableAreas);
	cJulius.ChangeRoom(32, 196, 384, eDirectionRight);       //Mountaintop
}

function room_Load()
{
	ChangeFootsteps_normal();
	
	//oceanThemePos=sounds_chan.Position;
	
	
	//Display("music channel ID %d, sounds channel ID %d, volumes are %d and %d respectively",music_chan.ID, sounds_chan.ID,  music_chan.Volume,  sounds_chan.Volume);
	//Wait(30);
	sounds_chan=aOcean_crash_cave.PlayFrom(oceanThemePos, eAudioPriorityLow, eRepeat);
	//Display("music channel ID %d, sounds channel ID %d, volumes are %d and %d respectively",music_chan.ID, sounds_chan.ID,  music_chan.Volume,  sounds_chan.Volume);
	Wait(5);
	aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);
	//Display("music channel ID %d, sounds channel ID %d, volumes are %d and %d respectively",music_chan.ID, sounds_chan.ID,  music_chan.Volume,  sounds_chan.Volume);
	Wait(30);
	//REPLACE THIS WITH WALKING OFFSCREEN PART
}


function room_AfterFadeIn()
{
	if (cJulius.PreviousRoom==2) { 	//beach
		aOcean_crash.Stop();
	}
	
	if(cJulius.PreviousRoom==32) {	//mountain cave
		cJulius.Walk(426, 539, eBlock, eWalkableAreas);
	}
	
	music_chan.Volume=100;
}


============================

ROOM 4 - CROSSROADS
Code: ags

function room_LeaveLeft()
{
	if (!smallone) {
    if (cJulius.y >= 370) {
      cJulius.ChangeRoom(3, 900, 600, eDirectionLeft);       //Farmer
    } else {
      cJulius.ChangeRoom(12, 935, 310, eDirectionDown);   //W village
    }
	}
}

function room_Load()
{
	aOcean_crash.Stop();
	aOcean_crash_cave.Stop();
	
	music_chan=aCrossroads.Play(eAudioPriorityNormal, eRepeat);
  
	if (HasMace && dTrainer.GetOptionState(7)==eOptionOffForever) {		//north village
		cTrainer.Transparency=100;	//disappear
	}
}

function room_AfterFadeIn()
{
	if (cJulius.PreviousRoom==8) {		//south village
		cJulius.Walk(470, 628, eBlock, eAnywhere);	//walk up from south edge
	}

  
}



==============

ROOM 32 - MOUNTAINTOP
Code: ags


function room_Load()
{
  ChangeFootsteps_snow();
	
    aOcean_crash_cave.Stop();
    aAfternoonSounds.Stop();
}

function room_AfterFadeIn()
{
    if (music_chan!=null) {
        if (music_chan.PlayingClip!=a4_mountainCave_92bpm) {
            music_chan = a4_mountainCave_92bpm.Play(eAudioPriorityNormal, eRepeat);   
        }
    } else {
        music_chan = a4_mountainCave_92bpm.Play(eAudioPriorityNormal, eRepeat);   
    }
}

function room_RepExec()
{
  if (GetWalkableAreaAt(cJulius.x, cJulius.y)==1) {
    ChangeFootsteps_snow();
  } else if (GetWalkableAreaAt(cJulius.x, cJulius.y)==2) {
    ChangeFootsteps_concrete();
  }
}


function room_LeaveLeft()
{
  cJulius.ChangeRoom(3, 654, 452, eDirectionDown);  //farmer
}



That's it, abridged. Hopefully you can pick up a massive error to do with setting volumes etc.

There are quite a number of non-natural transitions in the code; the only natural transition are anywhere you see:
Code: ags

SetNextScreenTransition(eTransitionInstant);


This has Julius wakling off a eg. a left edge, room transitons instantly, and then in the next he walks in from the eg. right edge, before finally stopping and returning control to the user.

bx83

Here's a video of the above:
link here

You might want to listen on 100%+ volume, the footsteps are just audible in room 4 (crossroads).

bx83

Anyone...?
Anyway, I do understand AudioChannel and crossfade more. Pitty about footstep sounds but it will be fixed later I suppose.
Thankyou :)

Snarky

The obvious difference between these rooms is that in 2,7 and 3 you're playing background sounds on sound_chan, while you're not doing so in rooms 4 and 32.

So if you still have the Sounds set to use only 1 channel, then it straightforwardly won't work, for obvious reasons.

Your game logic is also a bit of a mess. I think things would be a lot cleaner if you distinguished game-wide, permanent settings, like OPT_CROSSFADEMUSIC (which, as we've learned, shouldn't be used in the first place) and the screen transition style, from temporary state. Don't set these repeatedly whenever you change rooms, but once at game start.

Also, what purpose is there to lines like
Code: ags
                        music_chan=aSilence.Play(eAudioPriorityLow, eOnce);
                        music_chan=aBeachTheme.Play(eAudioPriorityNormal, eRepeat);
                        beachThemePos=music_chan.Position;

in Room_Load? (1) You're first telling it to play one clip and then immediately telling it to play another, presumably of the same type. Why? Is this some hack to disable crossfading by interrupting it? If some of CW's concerns turn out to be correct, this could potentially lead to erratic volume changes, so... maybe don't? (2) Shouldn't oceanThemePos always be 0 since you're just starting to play it on the line above? (3) By the time you use it, it will be completely outdated anyway.

bx83

I completely agree.
All of this is left over in code from revisions of revisions based on an imperfect knowledge of the sound system and partially done re-writing of various room's code.
I'll clean these up before putting more code here.

BTW are you planning on ever making more than one crossfade channel?

Also - if a programmer has to change the OPT_CROSSFADEMUSIC from 1 to 0 and then back again -  how should they do it if OPT_CROSSFADEMUSIC is not to be used anymore? How do you control *this* option (the one in the Editor, the 'Crossfade Tracks', as opposed to OPT_CROSSFADEMUSIC)? Like Game.SetAudioTypeCrossfade?
The reason I ask is this presents a pickle in my one piece of simultaneous dialogue in the whole game:

Code: ags

	SetGameOption(OPT_CROSSFADEMUSIC, 0);		//set crossfade to 'no crossfade' for sounds_chan (because the dialogue sound is set as a 'Music' or dialogue ("&123 This is a line") piece, and we want it played cleanly, not to crossfade in or out)

	game.bgspeech_stay_on_display = 1;
        sounds_chan=aCombinedLineLibrary.Play(eAudioPriorityNormal, eOnce);    //<-- this is the combined speech of two players

	cJulius.LockView(68);
	cJulius.Animate(0, 4, eOnce, eNoBlock);        //animate 1st player's speech

	cNerd.SayAtBubble(550, 270, "&110 We are very sorry to makers of Everyone Loves Raymond. He is not our own creation and wholly the property of 'Where's Lunch', 'Worldwide Pants', and 'HBO Independent Productions'. Thankyou for viewing our slap-stick play.");        //get 2nd player to say his line (???)

	aCombinedLineLibrary.Stop();    //stop the combined speech line

	cJulius.LockView(1);            //back to normal animation
	cJulius.Animate(8, -7, eOnce, eBlock);    

	cJulius.UnlockView();        //unlock view(s)

	SetGameOption(OPT_CROSSFADEMUSIC, 1);	//set crossfade back for sounds_chan


(obviously there is random confusing crap in there, but it works)
The above code uses the crossfade option to change it from 'slow' to 'no crossfade', and then back again... and it works! Somehow :/ ...... because according to you and the errors I was getting before, it shouldn't work.

I think was my reason for putting:
Code: ags

music_chan=aSilence.Play(eAudioPriorityLow, eOnce);
music_chan=aBeachTheme.Play(eAudioPriorityNormal, eRepeat);

...was an attempt to prime the music_chan pointer; removed it, still works, god knows what I was thinking.

Snarky

The obvious solution to the speech issue is to not have the audio type of the background speech clips be Music.

... I may regret this, because I think the best solution would be to clean up your code thoroughly, but I think there is a pretty simple workaround/fix.

As we have learned, AGS has 9 AudioChannels:

-1: Crossfade [reserved]
0: Speech [reserved]
1: Game-assigned
2: Game-assigned
3: Game-assigned
4: Game-assigned
5: Game-assigned
6: Game-assigned
7: Game-assigned

The way you have it set up now, if I understand it correctly, it's:

-1: Crossfade [reserved]
0: Speech [reserved]
1: Music
2: Sound
3: [Unused]
4: [Unused]
5: [Unused]
6: [Unused]
7: [Unused]

(I don't know for sure that it's precisely channel 1 for Music and Channel 2 for Sound, but it's something like this.)

Instead, I suggest you create a new AudioType, which you can call e.g. BackgroundSound. Set its MaxChannels property to 1 and crossfade to true. Set the MaxChannels property of Sound to 0 (unlimited) and crossfade to false. Change the AudioType of the background sounds to BackgroundSound. Change the AudioType of the background speech clips to Sound.

This way, the AudioChannel assignments should be something like:

-1: Crossfade [reserved]
0: Speech [reserved]
1: Music
2: BackgroundSound
3: [Free - Can be used for Sound]
4: [Free - Can be used for Sound]
5: [Free - Can be used for Sound]
6: [Free - Can be used for Sound]
7: [Free - Can be used for Sound]

This way, Music and BackgroundSound can still be crossfaded using the built-in feature (though not at the same time), background speech (as Sound clips) won't crossfade, you'll be able to play up to five Sound effects simultaneously (e.g. footsteps, background speech), and Sounds won't be affected by Music or BackgroundSound at all.

There's probably still some code that needs cleaning up so this will work bug-free, but it should simplify things a lot.

bx83

This further gives me knowledge into Audio. Didn't know I could have 7 extra named types, and separate them into 7 different 'channels'.
I've got half a mind to do this:

-1: crossfades
0: Speech  (crossfade off, maxchan 1)
1: Music (crossfade on, maxchan 1)
2: Sounds_1 (crossfade on, maxchan 1)
3: Sounds_2 (crossfade on, maxchan 1)
4: Extra (crossfade off, maxchan 1)
5: free
6: free
7: free

Each room has music; so just set Music to new track, then it's the nex track, all smooth.
They also have 1 sound; I use Sounds_1, same thing.
It might have 1 extra sound: Sounds_2.
For temporary sounds (door-bell, jangling keys, etc. that just do the sound 'eOnce'), we have Extra
The other's probably won't be used.
I can track and separate all :)

And I can figure out how to drop in blocking pauses like Wait for 2 or 3 sounds, so all of them have a smooth crossfade if needed.

No more 'Music_chan' etc, we have audio types which themselves are 1 track maxchannel pointers to begin with :)
No possibility of having pointer's overwritten; these internal anyway and don't *need* a global variable.

Correct?

Snarky


  • You can't set crossfade or MaxChannels for the Speech channel. It's controlled by AGS.
  • The drawback of having two separate Background Sound types is that each clip has to be assigned a specific type, so you won't be able to mix and match between the channels.
  • Why are you so dead set on setting MaxChannels=1 for everything? In this setup, just set the MaxChannels for the "Extra" type to 0, and then if it happens that you need to play multiple sounds at the same time it will just work.

Quote from: bx83 on Sat 19/05/2018 12:31:31
No more 'Music_chan' etc, we have audio types which themselves are 1 track maxchannel pointers to begin with :)

No, they're not. AudioTypes are enums, and the mapping from AudioType to AudioChannel* is not accessible to the game script.

In order to adjust volumes etc. you'll still need AudioChannel pointers.

bx83

Are there 7 channels in total, or per AudioType?
Will post updated code later, all... seems to work now.

Snarky

Quote from: bx83 on Sun 20/05/2018 05:56:07
Are there 7 channels in total, or per AudioType?

:shocked:
Well, let me ask you this: What are AudioChannels, and why are they limited to 7 (or 8, or 9, depending on how you count) in the first place?

SMF spam blocked by CleanTalk