Should I start Music in Room_load of Room_Afterfadein?

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

Previous topic - Next topic

bx83

I don't know if I follow you. Genuinely. There it is, I'm the stupidist person on the planet; but I really don't know.

AudioChannels are 7-9 separate channels for audio (AudioClips) to play on, of different AudioTypes.
I think????

for example:
-1: crossfade [hidden]
0: Speech
1: Music
2: Sound
3: Sound
4: Some_other_type
5: Some_other_type_as_well
6: [unused]
7: [unused]

Or: is it per *audiotype* - so:
7 channels for each Music, 7 channels for each set of Sounds, 7 channels for some_other_audio_type; etc.?

I don't know *why* you chose for them to be ~3bit (7-9 choices) rather than 64bit (2 or 4 billion choices). No-one's likely to play 200,000,000 sound effects and grow the exe file to 8gigabyte's or something, and crash the system.
The difference in program size is negigable in today's 64bit operating systems -- perhaps not in the early 90's, when many of the adventure games were made, but nowodays anyway.

I don't understand understand why there's only one crossfade channel - why not 7/8/9 also to mirror the AudioChannels? Why not a virtually *infinite* number of channels? Do they relate to a soundcard's minimum set-in-stone channels (so they'll work on any soundcard); or are they an arbitrary number?

I don't understand - sincerely, I yield to you. I give up. I've got it working; but don't really understand how. I just understand 10% of it now instead of 2% of it. Every time I think I do understand -- I don't.

For example:
When I set maxchannel as 1 for Music; it crossfades every time. It's always channel '1'. Simple.
When I set maxchannel for *Sounds* to 3 or 4; it crossfade 'almost' every time.
But then when I *add a pause* - blocking walking pause, or just a good ol 'Wait(45)', have space between Music crossfading and Sounds crossfading - it does work, every time.
Okay, so far so good.
BUT
When I have a blocking pause; and I set Sounds maxchannel's to *1*, it stops working as soon as I *move*.
If I set Sounds to maxchannels 2, it stops when I enter a room.
Maxchannels 3, it stops when I have 2 sounds playing (ie sound_chan=aSound1.Play(); aSound2.Play(); )
(and I have to have music_chan and sounds_chan global AudioChannel pointers to keep track of these two tracks between rooms, so I know their position)

So, in my mind I hatch a possibility, but it remains out of view. The possibility of it generating new channels for each new sound, but then always returning to the same pointer?... or something?... Something like this.
But in music_chan pointer/Music, this *doesn't* happen. What makes sound_chan pointer/Sounds different? I don't know, perhaps you can immediately solve this in 1 sentences, not sure.
This is only one poorly understood theory.
I will post code soon.

So as I say, I yield, I give up. It's too complicated; I don't understand how pointers relate to AudioChanels which relate to AudioClips and so on. I *thought* I did, but then every time I try something new, I don't!
I won't ask any more questions if you feel like you can't answer without some of this getting through my skull. There's 500 other things to debug in the game; just this is so misteriously hard for me (an only me! :P) to understand.

Perhaps you could link me to the page in the manual (for v3.x only) that exaplains this?

Crimson Wizard

#41
Quote from: bx83 on Mon 21/05/2018 00:41:00
AudioChannels are 7-9 separate channels for audio (AudioClips) to play on, of different AudioTypes.

There are 8 channels TOTAL, with 1 reserved for speech.

Quote from: bx83 on Mon 21/05/2018 00:41:00
I don't know *why* you chose for them to be ~3bit (7-9 choices) rather than 64bit
<...>
I don't understand understand why there's only one crossfade channel
<...>

You keep asking those "why" questions...
Once and for all: this program is over 20 years old. It was written by another person who is no longer coming here. It was started in times when he probably did not consider future problems very well, and system specifics were different. Over time he was adding more stuff while keeping old stuff in, and that complicated things further.
So why these channel limits are still there - we may only guess. Maybe he thought 8 channels will be enough. Maybe adding more crossfade channels into the old program with bad and overtwixed code was too difficult for him.
I do not think these are useful questions anyway, the useful question is whether it is possible to increase them, and the answer is yes. Another question is why this was not done yet, and the answer is "because it is not trivial to change that code, one would have to spend a fair amount of time to research it and find out how to do that correctly to not break anything, and no one bothered to do that yet".



Quote from: bx83 on Mon 21/05/2018 00:41:00
BUT
When I have a blocking pause; and I set Sounds maxchannel's to *1*, it stops working as soon as I *move*.

May that be related to footsteps? I thought you mentioned footsteps before. Are footsteps and "sounds" same type? Then since you limit sound channels to 1, they override previous sound.

Quote from: bx83 on Mon 21/05/2018 00:41:00If I set Sounds to maxchannels 2, it stops when I enter a room.
Maxchannels 3, it stops when I have 2 sounds playing (ie sound_chan=aSound1.Play(); aSound2.Play(); )

Same, maybe the number of currently playing sounds is simply larger than avaiable channels? It's hard to tell without researching all of your code.

Quote from: bx83 on Mon 21/05/2018 00:41:00
But in music_chan pointer/Music, this *doesn't* happen. What makes sound_chan pointer/Sounds different?

Come on, are you serious? The answer to mystery is right in your post: the number of sounds you play at the same time - that's what makes difference. You play only 1 music at a time on 1 restricted channel, so it is always same channel, and pointer always points to that one channel.
But with sounds - you have multiple channels and play multiple sounds at the same time. So at some conditions they ovewrite each other.
And when you are starting next sound - it will not necessarily take same channel again, it may take ANY of those channels, whichever is free at this point in time.


If you want *particular* type of sound (like ambient sound?) play all time no matter what, and potentially on the same channel, then you should create a separate AudioType for it and reserve 1 channel for it. Then it won't be overriden by other sounds.
But I guess, this is what Snarky suggested you to do only couple of days ago: http://www.adventuregamestudio.co.uk/forums/index.php?topic=56063.msg636586645#msg636586645


It seems to me that you overthink the unnecessary details too much, and keep trying to learn through experimentation with script, instead of studying theory first. This leads only to confusion.

Quote from: bx83 on Mon 21/05/2018 00:41:00
Perhaps you could link me to the page in the manual (for v3.x only) that exaplains this?

I tried to explain it on forums once: http://www.adventuregamestudio.co.uk/forums/index.php?topic=54062.msg636546051#msg636546051

Snarky

Quote from: Crimson Wizard on Mon 21/05/2018 00:51:59
There are 8 channels TOTAL, with 1 reserved for speech.

Are you counting the crossfade channel in those 8 channels?

Quote from: Crimson Wizard on Mon 21/05/2018 00:51:59
You keep asking those "why" questions...
Once and for all: this program is over 20 years old. It was written by another person who is no longer coming here. It was started in times when he probably did not consider future problems very well, and system specifics were different. Over time he was adding more stuff while keeping old stuff in, and that complicated things further.
So why these channel limits are still there - we may only guess. Maybe he thought 8 channels will be enough. Maybe adding more crossfade channels into the old program with bad and overtwixed code was too difficult for him.

I don't think that's entirely fair. The number of channels is the number of sounds that can play at the same time (polyphony), and this has historically been one of the main limitations of computer-generated audio and one of the most important dimensions along which different sound cards have varied.

Software abstraction layers like DirectSound (or whatever Allegro uses) allow you to mix an "unlimited" number of sounds playing simultaneously, but on the hardware layer you're still limited, so this requires software mixing. The more channels you use, the more processing and the more memory that downmixing is going to need. If you didn't limit it, at some point the program wouldn't be able to keep up any longer. A poorly written game (such as one that called AudioClip.Play() in repeatedly_execute(), or inside a loop), would very quickly bring down AGS.

So I think there are excellent reasons to set a limit. Of course, the limits that made sense 20 years ago are not necessarily ones we would set today.

(Here are a couple of articles that talk about hardware requirements for sound mixing. One interesting quote: "after swapping out my old spinning drives with SSDs and putting [16 GB] RAM in my Mac Mini I was able to run a Pro Tools session with 50 audio tracks and 250 reverbs!!" Now Pro Tools does a lot more fancy audio processing than AGS, but still, those are some high hardware requirements even today.)

QuoteI do not think these are useful questions anyway, the useful question is whether it is possible to increase them, and the answer is yes. Another question is why this was not done yet, and the answer is "because it is not trivial to change that code, one would have to spend a fair amount of time to research it and find out how to do that correctly to not break anything, and no one bothered to do that yet".

And also, because it's still quite rare that people actually need more than 7 channels.

Snarky

bx83, in addition to what CW explained:

Quote from: bx83 on Mon 21/05/2018 00:41:00
For example:
When I set maxchannel as 1 for Music; it crossfades every time. It's always channel '1'. Simple.
When I set maxchannel for *Sounds* to 3 or 4; it crossfade 'almost' every time.
But then when I *add a pause* - blocking walking pause, or just a good ol 'Wait(45)', have space between Music crossfading and Sounds crossfading - it does work, every time.
Okay, so far so good.

As already discussed, you cannot do more than one crossfade at the same time. Therefore, I don't believe the bolded version is correct. I believe that what is actually happening (with 3 channels, let's say) is something like...

In the first room:

SoundChannel 1: Room1AmbientSound (repeating)
SoundChannel 2: Footstep (whenever you walk)
SoundChannel 3: [unused]

(SoundChannel 1-3 are the AudioChannels reserved for Sound)
And then when you enter the second room:

SoundChannel 1: Room1AmbientSound (repeating)
SoundChannel 2: Room2AmbientSound (repeating)
SoundChannel 3: Footstep (whenever you walk)

There's no crossfading, you just have both/all the sounds playing simultaneously. With the music and everything, and the Room2AmbientSound probably starting quite softly, you just might not notice.

If you then go back to the first room:

SoundChannel 1: Room1AmbientSound (repeating)
SoundChannel 2: Room2AmbientSound (repeating)
SoundChannel 3: Room1AmbientSound (repeating) - second copy!

You would probably notice the second copy of Room1AmbientSound, but now you've run out of Sound channels, so as soon as you walk, it will have to stop one of the tracks (I'm not sure how it picks it when they're all the same priority, but let's say it just takes the first). If you've set Sounds to crossfade, I'm guessing this will happen:

SoundChannel 1: Footstep (fading in)
SoundChannel 2: Room2AmbientSound (repeating)
SoundChannel 3: Room1AmbientSound (repeating)
CrossFadeChannel: Room1AmbientSound (fading out)

If the footstep actually fades in, the first one would probably be pretty much inaudible. However, since it's a short clip, it should finish before the next footstep starts:

SoundChannel 1: [unused]
SoundChannel 2: Room2AmbientSound (repeating)
SoundChannel 3: Room1AmbientSound (repeating)
CrossFadeChannel: Room1AmbientSound (fading out)

And so now we can play the next footstep (and any future footsteps) on SoundChannel 1 without needing to crossfade, and it will work fine.

However, if you start walking as soon as you enter the room, that first AmbientSound/Footstep crossfade is going to conflict with the Music crossfade, and things will go bad more noticeably.

So this explains why it sometimes seems to work and sometimes breaks.

Quote from: bx83 on Mon 21/05/2018 00:41:00
So, in my mind I hatch a possibility, but it remains out of view. The possibility of it generating new channels for each new sound, but then always returning to the same pointer?... or something?... Something like this.

No.

Do what I explained here.

bx83

Good points Snarky and CrimsonWizard.
This comment was written originally after CrimsonWizards comment.
I will get to write *even more comments* after :P

Quote from: Crimson Wizard on Mon 21/05/2018 00:51:59
There are 8 channels TOTAL, with 1 reserved for speech.
Okay, remebered.

Quote
Once and for all: this program is over 20 years old. It was written by another person who is no longer coming here.
Okay, fair enough.

Quote
Quote from: bx83 on Mon 21/05/2018 00:41:00
BUT
When I have a blocking pause; and I set Sounds maxchannel's to *1*, it stops working as soon as I *move*.

May that be related to footsteps? I thought you mentioned footsteps before. Are footsteps and "sounds" same type? Then since you limit sound channels to 1, they override previous sound.

Footsteps are working correctly, I forgot to say. I created a FootPrint AudioType, then made all these sounds FootPrints, and set the volume manually; all good, they work now.

Quote
Quote from: bx83 on Mon 21/05/2018 00:41:00If I set Sounds to maxchannels 2, it stops when I enter a room.
Maxchannels 3, it stops when I have 2 sounds playing (ie sound_chan=aSound1.Play(); aSound2.Play(); )
Same, maybe the number of currently playing sounds is simply larger than avaiable channels? It's hard to tell without researching all of your code.

True, but in Music with maxchannel=1, this doesn't happen.
How many Sounds am I playing at once?
Well there is 1: aWavesCrash; and in the next room, aWavesCrash_Cave. They crossfade. This is controlled by the pointer oceanThemePos to keep track of the track's position.
This is exactly like Music with maxchanne=1, etc. - but it doesn't work.
Note: I have gotten rid of the 2nd track aWaveCrash_Cave (used for rooms 7/cave and 3/farmer), it was pointless; I'm now just controlling the volume so it's quiter the further (in rooms) yuo are away from it.
Yes - I tried increasing the wait pause between crossfades; at wait(100) it still cut out the new sound being introduced.
Yes - I've tried removing the .Volume to set the sound/music volume manually, and just relied on the default volumes set in the editor; doesn't work, volume goes bananas.

Here is my code:

AudioType Music has 1 channel, has crossfade
    aBeachTheme is set to volume 40, manually and in editor
    aBeachTheme_Cave (played in 7/cave) is set ot volume 30, manually and in editor

AudioType Sound has 1 channel, and crossfade
    aOceasn_crash has volume set to 7 (manually and in editor) in room 2/beach; set to 1 in 3/farmer and 7/cave, and stopped everywhere else.


From left to right order:

Room 7/CAVE:
Code: ags

function room_LeaveRight()        //to BEACH
{
  if (cJulius.y<=405){
		cJulius.Walk(1054, cJulius.y, eBlock, eAnywhere);
		beachThemePos=music_chan.Position;        //load up pointers for next room
		oceanThemePos=sounds_chan.Position;
		cJulius.ChangeRoom(2, 2, 500, eDirectionRight); //goto BEACH
  }
}

function room_Load()
{
        beachThemePos=music_chan.Position;
	music_chan=aBeachTheme_cave.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
}

function room_AfterFadeIn()
{
	music_chan.Volume=30;
	sounds_chan.Volume=1;
	cJulius.Walk(900, 385, eBlock, eAnywhere);
}


Room 2/BEACH:
Code: ags

function room_Load()
{
    ChangeFootsteps_normal();    //changes footsteps to normal_a and normal_b, which are set as AudioType FootPrints (works now)
    cJulius.ScaleVolume=true;    //turned this on again, works a treat :P
	
	if (GameStarted) {		//IF GAME IS STARTED
		music_chan=aBeachTheme.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
		sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityNormal, eRepeat);

	} else {		//IF GAME *NOT* STARTED
		Game.SetAudioTypeSpeechVolumeDrop(eAudioTypeMusic, 30);
		Game.SetAudioTypeSpeechVolumeDrop(eAudioTypeSound, 40);
		Game.SetAudioTypeVolume(eAudioTypeFootPrints, 30, eVolExistingAndFuture);
		music_chan=aBeachTheme.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
		GameStarted=true;
	}
}

function room_AfterFadeIn()
{
	if (cJulius.PreviousRoom == 3) {		//farmer
		aAfternoonSounds.Stop();    //stop the Music from rom farmer
		cJulius.Walk(910, 330, eBlock, eAnywhere); 
		sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityLow, eRepeat);
	}

	sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityNormal, eRepeat);
	sounds_chan.Volume=7;
}

function room_LeaveRight()
{
  if (cJulius.y<=470) {
    beachThemePos=music_chan.Position;    //load up pointers for room farmer
    oceanThemePos=sounds_chan.Position;
    cJulius.Walk(1024, cJulius.y, eBlock, eWalkableAreas);
    cJulius.Walk(1064, cJulius.y, eBlock, eAnywhere);
    cJulius.ChangeRoom(3, -20, 617, 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);
		beachThemePos=music_chan.Position;    //load up pointers for room cave
		oceanThemePos=sounds_chan.Position;	
		cJulius.ChangeRoom(7, 1044, 385);       //Cave
	}
}


Room 3/FARMER:
Code: ags

function room_LeaveLeft()
{
	cJulius.Walk(0, 606, eBlock, eWalkableAreas);
	cJulius.Walk(-20, 606, eBlock, eAnywhere);
	cJulius.ChangeRoom(2, 1064, 330, eDirectionLeft);       //Beach
}

function room_LeaveRight()
{
        cJulius.Walk(1044, cJulius.y, eBlock, eAnywhere);
	cJulius.ChangeRoom(4, -20, 560, eDirectionRight);         //Crossroads
}

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

function room_Load()
{
	sounds_chan.Volume=1;
}


function room_AfterFadeIn()
{
	aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);		//regardless of which room was last, start crossfade this now from whatever to aAfternoonSounds
	
	if (cJulius.PreviousRoom==2) {	//beach
		cJulius.Walk(0, 617, eBlock, eAnywhere);
		cJulius.Walk(90, 617, eBlock, eWalkableAreas);
	}
	
	if (cJulius.PreviousRoom==4) {	//crossroads
		cJulius.Walk(940, 600, eBlock, eAnywhere);
	}
	
	if(cJulius.PreviousRoom==32) {	//mountain cave
		cJulius.Walk(426, 539, eBlock, eWalkableAreas);
	}
	
	beachThemePos=music_chan.Position;		//save for later when we re-enter room 2/Beach
	music_chan.Volume=80;
}


Room 4/CROSSROADS:
Code: ags

function room_LeaveLeft()
{
        if (cJulius.y >= 370) {
            cJulius.Walk(-30, 560, eBlock, eAnywhere);
            cJulius.ChangeRoom(3, 1044, 600, eDirectionLeft);       //Farmer
        } else {
            cJulius.ChangeRoom(12, 935, 310, eDirectionDown);   //W village
        }
}

function room_LeaveRight()
{
  cJulius.ChangeRoom(24, 317, 690); 	//dark seeds, outside
}


function room_Load()
{
	aOcean_crash.Stop();
      	if (music_chan.PlayingClip!=aCrossroads) {
            music_chan=aCrossroads.Play(eAudioPriorityNormal, eRepeat);    //it's complicated why this is checking if itself is playing, but I'll explain if asked
	}
}



bx83

Quote from: Snarky on Mon 21/05/2018 07:19:16
However, if you start walking as soon as you enter the room, that first AmbientSound/Footstep crossfade is going to conflict with the Music crossfade, and things will go bad more noticeably.

But this happens in the first room (beach) of the entire game. As soon as I move, it cuts out; not on re-entering room.
However, I'm starting to feel a eureka coming on...
The last sound channel being overwritten by footsteps would explain this - for a small number of channels. What's the sound which plays when a character starts moving? Footsteps.
If footsteps and ambient sound are both Sound, then setting channel to 1 will automatically wipe on out.
Now, I've simplified (given footsteps it's own AudioType FoootPrints; gotten rid of crossfading sound and second sound (aDrippingWater) in cave) - it all works.
So you were right :P

Crimson Wizard

#46
Quote from: Snarky on Mon 21/05/2018 06:38:15
Quote from: Crimson Wizard on Mon 21/05/2018 00:51:59
There are 8 channels TOTAL, with 1 reserved for speech.

Are you counting the crossfade channel in those 8 channels?

8 channels for AudioTypes, and 1 for crossfade.

Quote from: Snarky on Mon 21/05/2018 06:38:15
Quote from: Crimson Wizard on Mon 21/05/2018 00:51:59
You keep asking those "why" questions...
Once and for all: this program is over 20 years old. It was written by another person who is no longer coming here. It was started in times when he probably did not consider future problems very well, and system specifics were different. Over time he was adding more stuff while keeping old stuff in, and that complicated things further.
So why these channel limits are still there - we may only guess. Maybe he thought 8 channels will be enough. Maybe adding more crossfade channels into the old program with bad and overtwixed code was too difficult for him.

I don't think that's entirely fair.

Yes, yes, this is not fair. SORRY. I am loosing my head every time someone starts asking "Why why why why why why why is this so". It drives me crazy. It's like asking "why you did not make it better". "Why you all are sitting here instead of fixing it". And I do not know what to answer! What could be the excuse? I was lazy? Incompetent? Gave up?

bx83

Crimson, I feel like this every day as I program the game :P

Don't worry - I'm never saying 'why are you so incompetant!'; just 'but why is this thing the way it is, I'm mystified :/' Sometimes I really don't know why something is the way it is; so I ask. If there wasn't this forum (and you, Snarky and Kris, and others to answer my complex and incredibly annoying questions), I wouldn't be able to learn the ags system :)

I'm slow on the uptake; and I'm learning, each day. This game will take about 2 years to write; the next one will take 3.5 weeks. I've learnt so much about the editor, as well as the whole organisation of the project, how to record and level speech soundclips from different studio recordings, how to do more with Photoshop, how animation is done and works, how to save the walkable areas masks, etc etc etc; it's basically like 1.5 years so far of just pure learning, about 5% actual programming :P

Snarky

Yeah, CW! No one is blaming you for the AGS sound system... which â€" as I said in the other thread â€" I don't think is that bad, if only it were properly documented. Even the "new" system (which is what, ten years old at this point?) was created before you got involved in the AGS development, anyway. And improving the documentation is something that I have long wanted to do, but just never get around to, so that's more on me.

Also, a lot of that alternative audio API we discussed in the other thread would actually be possible to implement as a module (as a direct consequence of improvements you have made to the engine), so nobody can blame the engine developers that it's not available.

ManicMatt

Crimson, you know when I try and help people in the technical help threads even though I probably shouldn't.. well its because you're always on there helping people out and I want to lighten the load for you!

You're a legend, and you have more patience than I! So I hope you don't feel discouraged, we all know you work your ass off, for very little or nothing in return. So, thank you.

Crimson Wizard

#50
Ok, this is getting too far, seriously, I again should not be posting what I posted, but it's too late to delete it.
Could we change subject, please?

ManicMatt

You're only human, I just wanted you to know you're appreciated. Its all good.

Snarky

Quote from: Crimson Wizard on Mon 21/05/2018 14:05:40
Could we change subject, please?

All right. :)
Well, one question we never got sorted was quite how OPT_CROSSFADEMUSIC interacts with the Crossfade option on the AudioTypes, if bx83 is right that setting the OPT_CROSSFADEMUSIC value to 0 actually disabled crossfading temporarily. (And if there's any other way to control the crossfade setting from within the game.)

Crimson Wizard

Quote from: Snarky on Mon 21/05/2018 15:11:57
Well, one question we never got sorted was quite how OPT_CROSSFADEMUSIC interacts with the Crossfade option on the AudioTypes, if bx83 is right that setting the OPT_CROSSFADEMUSIC value to 0 actually disabled crossfading temporarily. (And if there's any other way to control the crossfade setting from within the game.)

Oh, right.
When possible, AGS emulates old style script commands through the new system.
From my previous findings in the code it looks like changing OPT_CROSSFADEMUSIC actually sets "Crossfade speed" option in the audio type #2, which corresponds to the legacy "music" type.
In other words, if you delete or otherwise change default audio types you have in project, this may work differently.
For the reference, default audio types are:
#0: I thought it is "speech", but not sure if it is used in code at all.
#1: Ambient Sound
#2: Music
#3: Normal sound

Unfortunately, I do not see any other way to change "Crossfade" setting in script, although there does not seem to be anything to prevent changing it at runtime. So perhaps implementing such command was low priority.

bx83

I have one more question to ask: Did anyone figure out the volume problem (of going crazy unless manually set everytime to something with channel.Volume= ?)
If you feel you've already answered this just say and I'll review.
My most recent working code is up; and the manual setting of volume is the only things that stops it going up and down.
Also I've changed VolumeReductionWhileSpeechIsPlaying in the editor, to 0 for all AudioTypes, and let it do it manually. Same problem.

Crimson Wizard

Quote from: bx83 on Tue 22/05/2018 03:16:27
I have one more question to ask: Did anyone figure out the volume problem (of going crazy unless manually set everytime to something with channel.Volume= ?)
If you feel you've already answered this just say and I'll review.
My most recent working code is up; and the manual setting of volume is the only things that stops it going up and down.
Also I've changed VolumeReductionWhileSpeechIsPlaying in the editor, to 0 for all AudioTypes, and let it do it manually. Same problem.

Could you explain what is going on with the volume again, in detail? I think got confused by this thread, because the code and audio settings were changed many times.

Snarky

Yeah, I'm also not sure exactly what behavior you're talking about. Which AudioType volumes are going crazy again?

Quote from: Crimson Wizard on Mon 21/05/2018 15:22:57
For the reference, default audio types are:
#0: I thought it is "speech", but not sure if it is used in code at all.

I don't think there's an accessible AudioType for speech (or that you can ever access the audio clips), but AudioChannel 0 (IIRC) is always reserved for speech, and when speech is playing, AudioChannel.IsPlaying will return true.

Crimson Wizard

#57
Quote from: Snarky on Tue 22/05/2018 19:04:57
I don't think there's an accessible AudioType for speech (or that you can ever access the audio clips), but AudioChannel 0 (IIRC) is always reserved for speech, and when speech is playing, AudioChannel.IsPlaying will return true.

Hmm, you can call "SetAudioTypeVolume" and "SetAudioTypeSpeechVolumeDrop" for audio type 0, but that won't do anything, because it first checks if there is a valid AudioClip associated with the sound.

OTOH, that never came to me that you can use AudioChannels[0].Volume. Does this mean you may play with speech volume? Also what will happen if you do AudioChannels[0].Stop()? This suddenly opens alot of unusual (and undocumented) options.
EDIT: Oh wait, speech is blocking, so that will work only in rep_exec_always. Probably.

bx83

Don't worry guys; having been dragged to my whits end, so I just simplified: I made 'Sounds' AudioType 'Ambient' (only get's used in rooms 7,2,3); run the song straight off, so it's persistent; not buggery with PlayFrom, oceanThemePos etc; and have nice long pauses between when the Music starts amd the Ambient fades in (which is now only once when the game starts; elsewhere it's just .Stop'ed or .Play'ed - it's ambient after all, so no-one remebers where it begins and ends).

Got rid of reduce volume when speaking; I'm just playing the sound/music quietly and 'naturally', so the player doesn't consciously notice much about sound, and instead just 'eases into it'. Anyway, the sounds are not too loud.

Both Music and Ambient are set maxchannel 1, crossfade on.
All sound effects are 'Extra' (infinite channels, no crossfade)
'Footprints' sounds are set to a nice low volume, but always audible; and it works with ScaleVolume as well.

Now, not setting the volume manually work's fine - sound is now set to default volume in editor, and holds this throughout (which was the problem I was speaking about before - volume went up and down randomly).

I had too many things on Sound. Or something. I don't know. I'll post code tomorrow when I've tested it and I'm sure (this time - sure!!!) the room(s) works. I'm beginning to understand AudioChannel etc. more fully. I'm sorry for only being capable of half a thought at a time and constant experimentation with ever-changing code.

SMF spam blocked by CleanTalk