function room_FirstLoad()
{
SetGameOption(OPT_CROSSFADEMUSIC, 1);
music_chan=aBeachTheme.Play(eAudioPriorityNormal, eRepeat);
sounds_chan=aOcean_crash.Play(eAudioPriorityNormal, eRepeat);
}
function room_AfterFadeIn()
{
if (cJulius.PreviousRoom == CAVE) { //cave
aWater_dripping.Stop();
cJulius.Walk(265, 500, eNoBlock, eWalkableAreas);
}
if (cJulius.PreviousRoom==CAVE || cJulius.PreviousRoom==FARM) {
beachThemePos=music_chan.Position;
music_chan=aBeachTheme.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
}
}
function room_Load()
{
if (cJulius.PreviousRoom == 2) {
beachThemePos=music_chan.Position;
music_chan=aBeachTheme_cave.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
}
}
Bonus question: which runs first, the Room_Load function, or the Room_FirstLoad function?
Setting max channels to 1 doesn't guarantee you are using the same channel again and again, just that (any) one channel will be available to use.
I don't think you can stay on the same channel if cross-fading, since you are playing two streams at once.
I think to keep the the script pointer pointing at what you asked to be played (as so you can set its volume etc), it would have to move what is playing to the crossfade channel, and then starting playing what is faded in on the (hopefully) original channel. So perhaps this channel is always id 2?
I think to keep the the script pointer pointing at what you asked to be played (as so you can set its volume etc), it would have to move what is playing to the crossfade channel, and then starting playing what is faded in on the (hopefully) original channel. So perhaps this channel is always id 2?
From the code it looks like it does opposite: it keeps old music in its channel, and puts new music on crossfade channel.
bx83, could you try defining a global audio channel and use that across both rooms? That should rule out pointing to the wrong channel as the problem.
function room_Load()
{
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);
if (FutureTime) {
music_chan.Stop();
} else {
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;
}
}
function room_FirstLoad()
{
}
function room_AfterFadeIn()
{
if (cJulius.PreviousRoom == CAVE) { //cave
aWater_dripping.Stop();
cJulius.Walk(265, 500, eNoBlock, eWalkableAreas);
}
}
function room_Load()
{
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()
{
}
Is there a way to reference channels in the style of Audiochannel* channel[1] or channel[5] or what have you?
I don't think I understand (stil!) the AudioChannel system.
For example, if your Type:Music has MaxChannels of 1, and Crossfade is set to MediumFade, can I just type:
aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);
or must it be:
music_chan=aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);
???
And if I want to find an AudioClip that's being player, ie.
if (sounds_chan.PlayingClip!=aOcean_crash_cave) {
sounds_chan = aOcean_crash_cave.Play;
}
I should do the above to stop it playing twice, or three times, or 15 times etc?
There's no other way to check if an actual audioclip, referenced by it's name, is playing or not -- is this because you need the audiochannel pointer to find a specific audioclip; or it just grab's the clip's name from a list of playing tracks, and then returns a pointer to you?
I'm really very confused about thier functioning :/
For example, in the code above, would things work the same or better if I just made it:
aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);
rather than:
music_chan=aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);
QuoteAnd if I want to find an AudioClip that's being player, ie.
if (sounds_chan.PlayingClip!=aOcean_crash_cave) {
sounds_chan = aOcean_crash_cave.Play;
}
I should do the above to stop it playing twice, or three times, or 15 times etc?
Huh? Have you got sounds set to only 1 channel? Otherwise the code above doesn't make much sense. Why would the clip play more than once in the first place?
If I have 5 sound channels, then channel 1, 2, 3, etc can be taken up by aOcean_crash_cave. Or is the audioclip unique?
Okay well I need to do one of the following:
a) make maxaudiochannels 1 for both music and sounds; or
b) have a function which finds and then stops an audioclip for a given name
But I'm really warn out now, so I think I'll go off and kill myself :P
The mists of Audiochannel are beginning to clear, but it's still quite confusing. I mean, why the hell isn't it easy to just say: 'you know that audio clip you were just playing? well crossfade it into this one.'
or 'you know those sound effect clips you were just playing? well just cross-fade them nothing, and then start up these new ones.'
AND, at the default volume, etc.
I've run into yet more problems crossfading to sounds and music clips for no known reason.
They just immediately jump into the new track (and .Stop() the old one); or sometimes not! And they just never play.
Plus, this changes depending on whether I do a Display() of the audiochannel ID, volume etc; or not. So it seems to take some time to do the transition.... but not for the other rooms.
ps: is AudioClip.Stop() just a way of stopping and AudioClip cold, or does it crossfade to nothing? Not that this seems to have any relationship to what actually happens, but I was just wondering the correct version.
If I have 5 sound channels, then channel 1, 2, 3, etc can be taken up by aOcean_crash_cave. Or is the audioclip unique?
Well, it is unique, but it can be playing on multiple channels at the same time. Just like "a particular sprite" is unique, but can be assigned to different objects or character loops and displayed simultaneously.
My question was more about why it would be playing on multiple channels simultaneously in the first place. I guess if there's a long "tail" to the sound I can see having two waves playing simultaneously, but with a regularly repeating sound like a wave I would expect you to have pretty tight control over it (you wouldn't be randomly triggering wave sounds at lots of different points in the code, I hope).
ff (music_chan.PlayingClip!=aOcean) { aOcean.Play() );
then it will start to fill up the available audio channels with this clip each time I enter the room.Okay well I need to do one of the following:
a) make maxaudiochannels 1 for both music and sounds; or
b) have a function which finds and then stops an audioclip for a given name
QuoteBut I'm really warn out now, so I think I'll go off and kill myself :P
If you don't rush things, but just take the time to figure things step by step (for example with a test game), things are much easier. Trying to get something buggy to work as quickly as possible by just hacking away randomly without quite understanding what's going on is always frustrating. (That's what I had to do for the Awards client towards the end, since I had fatal bugs popping up at the last minute before a hard deadline, and it was intensely stressful and unpleasant.)
Cross-fading is not that simple an operation in the first place, and cross-fading multiple tracks simultaneously can very easily fail in various ways (particularly because you run out of channels to do the mixing), so it's never going to be trivial to do.
"crossfading to sounds and music clips"? These are two entirely different things, though. With music you're using OPT_CROSSFADEMUSIC to do built-in crossfading (using the hidden crossfade channel Crimson Wizard explained). For sounds you have to do the crossfading manually using separate channels.
QuoteThey just immediately jump into the new track (and .Stop() the old one); or sometimes not! And they just never play.
Plus, this changes depending on whether I do a Display() of the audiochannel ID, volume etc; or not. So it seems to take some time to do the transition.... but not for the other rooms.
Can't comment without seeing your code.
Quoteps: is AudioClip.Stop() just a way of stopping and AudioClip cold, or does it crossfade to nothing? Not that this seems to have any relationship to what actually happens, but I was just wondering the correct version.
It just stops it. (Perhaps for a music track with OPT_CROSSFADEMUSIC on it fades it out, but I'm not betting on it.)
Wave as in ocean wave or sound wave?
Consider:
I have 4 Sound channels (MaxChannels=4). Each time I enter a room, we play an ocean waves sound.
If I don't have theCode: [Select]ff (music_chan.PlayingClip!=aOcean) { aOcean.Play() );
then it will start to fill up the available audio channels with this clip each time I enter the room.
QuoteDo you want to be able to play multiple sounds at the same time? (For example in order to crossfade them?) If yes, don't do this.
But how will not setting it to 1 allow me to crossfade? That's the opposite.
It just stops it. (Perhaps for a music track with OPT_CROSSFADEMUSIC on it fades it out, but I'm not betting on it.)
Well what about crossfading sound effects?
Sounds and Music both have a 'crossfade tracks' option in the editor, but I can only set it for music (OPT_CROSSFADEMUSIC).
Well what about crossfading sound effects?
Sounds and Music both have a 'crossfade tracks' option in the editor, but I can only set it for music (OPT_CROSSFADEMUSIC).
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.True, that would be much simplier. Also if they fade in/out in a short time, players likely won't notice a difference.
"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)
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.
using the built-in crossfade for any type of audio is going to keep the channel pointer valid?
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?
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.using the built-in crossfade for any type of audio is going to keep the channel pointer valid?Surely this.
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);
...
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.
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.
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
sounds_chan=aOcean_crash_cave.PlayFrom(oceanThemePos, eAudioPriorityLow, eRepeat);
aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);
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
}
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;
}
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;
}
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
}
}
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
}
SetNextScreenTransition(eTransitionInstant);
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
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.No more 'Music_chan' etc, we have audio types which themselves are 1 track maxchannel pointers to begin with :)
Are there 7 channels in total, or per AudioType?
AudioChannels are 7-9 separate channels for audio (AudioClips) to play on, of different AudioTypes.
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
<...>
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(); )
But in music_chan pointer/Music, this *doesn't* happen. What makes sound_chan pointer/Sounds different?
Perhaps you could link me to the page in the manual (for v3.x only) that exaplains this?
There are 8 channels TOTAL, with 1 reserved for speech.
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".
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.
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.
There are 8 channels TOTAL, with 1 reserved for speech.Okay, remebered.
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.
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.
If I set Sounds to maxchannels 2, it stops when I enter a room.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.
Maxchannels 3, it stops when I have 2 sounds playing (ie sound_chan=aSound1.Play(); aSound2.Play(); )
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);
}
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
}
}
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;
}
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
}
}
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.
There are 8 channels TOTAL, with 1 reserved for speech.
Are you counting the crossfade channel in those 8 channels?
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.
Could we change subject, please?
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.)
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.
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.