Author Topic: Should I start Music in Room_load of Room_Afterfadein?  (Read 2243 times)

bx83

  • Get 'Er Doooooone
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #40 on: 21 May 2018, 00:41 »
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

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #41 on: 21 May 2018, 00:51 »
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.

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".



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.
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.

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.

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
« Last Edit: 21 May 2018, 03:05 by Crimson Wizard »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #42 on: 21 May 2018, 06:38 »
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. 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.)

Quote
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".

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

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #43 on: 21 May 2018, 07:19 »
bx83, in addition to what CW explained:

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.

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

  • Get 'Er Doooooone
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #44 on: 21 May 2018, 08:52 »
Good points Snarky and CrimsonWizard.
This comment was written originally after CrimsonWizards comment.
I will get to write *even more comments* after :P

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
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
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(); )
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: Adventure Game Studio
  1. function room_LeaveRight()        //to BEACH
  2. {
  3.   if (cJulius.y<=405){
  4.                 cJulius.Walk(1054, cJulius.y, eBlock, eAnywhere);
  5.                 beachThemePos=music_chan.Position;        //load up pointers for next room
  6.                 oceanThemePos=sounds_chan.Position;
  7.                 cJulius.ChangeRoom(2, 2, 500, eDirectionRight); //goto BEACH
  8.   }
  9. }
  10.  
  11. function room_Load()
  12. {
  13.         beachThemePos=music_chan.Position;
  14.         music_chan=aBeachTheme_cave.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
  15. }
  16.  
  17. function room_AfterFadeIn()
  18. {
  19.         music_chan.Volume=30;
  20.         sounds_chan.Volume=1;
  21.         cJulius.Walk(900, 385, eBlock, eAnywhere);
  22. }

Room 2/BEACH:
Code: Adventure Game Studio
  1. function room_Load()
  2. {
  3.     ChangeFootsteps_normal();    //changes footsteps to normal_a and normal_b, which are set as AudioType FootPrints (works now)
  4.     cJulius.ScaleVolume=true;    //turned this on again, works a treat :P
  5.        
  6.         if (GameStarted) {              //IF GAME IS STARTED
  7.                 music_chan=aBeachTheme.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
  8.                 sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityNormal, eRepeat);
  9.  
  10.         } else {                //IF GAME *NOT* STARTED
  11.                 Game.SetAudioTypeSpeechVolumeDrop(eAudioTypeMusic, 30);
  12.                 Game.SetAudioTypeSpeechVolumeDrop(eAudioTypeSound, 40);
  13.                 Game.SetAudioTypeVolume(eAudioTypeFootPrints, 30, eVolExistingAndFuture);
  14.                 music_chan=aBeachTheme.PlayFrom(beachThemePos, eAudioPriorityNormal, eRepeat);
  15.                 GameStarted=true;
  16.         }
  17. }
  18.  
  19. function room_AfterFadeIn()
  20. {
  21.         if (cJulius.PreviousRoom == 3) {                //farmer
  22.                 aAfternoonSounds.Stop();    //stop the Music from rom farmer
  23.                 cJulius.Walk(910, 330, eBlock, eAnywhere);
  24.                 sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityLow, eRepeat);
  25.         }
  26.  
  27.         sounds_chan=aOcean_crash.PlayFrom(oceanThemePos, eAudioPriorityNormal, eRepeat);
  28.         sounds_chan.Volume=7;
  29. }
  30.  
  31. function room_LeaveRight()
  32. {
  33.   if (cJulius.y<=470) {
  34.     beachThemePos=music_chan.Position;    //load up pointers for room farmer
  35.     oceanThemePos=sounds_chan.Position;
  36.     cJulius.Walk(1024, cJulius.y, eBlock, eWalkableAreas);
  37.     cJulius.Walk(1064, cJulius.y, eBlock, eAnywhere);
  38.     cJulius.ChangeRoom(3, -20, 617, eDirectionDownRight);     //Farmer
  39.   } else {
  40.     cJulius.ChangeRoom(23, 164, 472, eDirectionRight);   //pixelated forest
  41.   }
  42. }
  43.  
  44.  
  45. function room_LeaveLeft()
  46. {
  47.         if (cJulius.y >= 240 && cJulius.y <= 520) {
  48.                 cJulius.Walk(0, cJulius.y, eBlock, eWalkableAreas);
  49.                 beachThemePos=music_chan.Position;    //load up pointers for room cave
  50.                 oceanThemePos=sounds_chan.Position;    
  51.                 cJulius.ChangeRoom(7, 1044, 385);       //Cave
  52.         }
  53. }

Room 3/FARMER:
Code: Adventure Game Studio
  1. function room_LeaveLeft()
  2. {
  3.         cJulius.Walk(0, 606, eBlock, eWalkableAreas);
  4.         cJulius.Walk(-20, 606, eBlock, eAnywhere);
  5.         cJulius.ChangeRoom(2, 1064, 330, eDirectionLeft);       //Beach
  6. }
  7.  
  8. function room_LeaveRight()
  9. {
  10.         cJulius.Walk(1044, cJulius.y, eBlock, eAnywhere);
  11.         cJulius.ChangeRoom(4, -20, 560, eDirectionRight);         //Crossroads
  12. }
  13.  
  14. function room_LeaveTop()
  15. {
  16.                 cJulius.Walk(654, 452, eBlock, eWalkableAreas);
  17.                 cJulius.ChangeRoom(32, 196, 384, eDirectionRight);       //Mountaintop
  18. }
  19.  
  20. function room_Load()
  21. {
  22.         sounds_chan.Volume=1;
  23. }
  24.  
  25.  
  26. function room_AfterFadeIn()
  27. {
  28.         aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);           //regardless of which room was last, start crossfade this now from whatever to aAfternoonSounds
  29.        
  30.         if (cJulius.PreviousRoom==2) {  //beach
  31.                 cJulius.Walk(0, 617, eBlock, eAnywhere);
  32.                 cJulius.Walk(90, 617, eBlock, eWalkableAreas);
  33.         }
  34.        
  35.         if (cJulius.PreviousRoom==4) {  //crossroads
  36.                 cJulius.Walk(940, 600, eBlock, eAnywhere);
  37.         }
  38.        
  39.         if(cJulius.PreviousRoom==32) {  //mountain cave
  40.                 cJulius.Walk(426, 539, eBlock, eWalkableAreas);
  41.         }
  42.        
  43.         beachThemePos=music_chan.Position;              //save for later when we re-enter room 2/Beach
  44.         music_chan.Volume=80;
  45. }

Room 4/CROSSROADS:
Code: Adventure Game Studio
  1. function room_LeaveLeft()
  2. {
  3.         if (cJulius.y >= 370) {
  4.             cJulius.Walk(-30, 560, eBlock, eAnywhere);
  5.             cJulius.ChangeRoom(3, 1044, 600, eDirectionLeft);       //Farmer
  6.         } else {
  7.             cJulius.ChangeRoom(12, 935, 310, eDirectionDown);   //W village
  8.         }
  9. }
  10.  
  11. function room_LeaveRight()
  12. {
  13.   cJulius.ChangeRoom(24, 317, 690);     //dark seeds, outside
  14. }
  15.  
  16.  
  17. function room_Load()
  18. {
  19.         aOcean_crash.Stop();
  20.         if (music_chan.PlayingClip!=aCrossroads) {
  21.             music_chan=aCrossroads.Play(eAudioPriorityNormal, eRepeat);    //it's complicated why this is checking if itself is playing, but I'll explain if asked
  22.         }
  23. }


bx83

  • Get 'Er Doooooone
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #45 on: 21 May 2018, 09:02 »
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
« Last Edit: 21 May 2018, 09:04 by bx83 »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #46 on: 21 May 2018, 09:40 »
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.

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?
« Last Edit: 21 May 2018, 09:52 by Crimson Wizard »

bx83

  • Get 'Er Doooooone
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #47 on: 21 May 2018, 09:55 »
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
« Last Edit: 21 May 2018, 09:57 by bx83 »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #48 on: 21 May 2018, 10:43 »
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.

Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #49 on: 21 May 2018, 13:59 »
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

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #50 on: 21 May 2018, 14:05 »
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?
« Last Edit: 21 May 2018, 14:08 by Crimson Wizard »

Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #51 on: 21 May 2018, 14:12 »
You're only human, I just wanted you to know you're appreciated. Its all good.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #52 on: 21 May 2018, 15:11 »
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

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #53 on: 21 May 2018, 15:22 »
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

  • Get 'Er Doooooone
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #54 on: 22 May 2018, 03:16 »
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

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #55 on: 22 May 2018, 15:59 »
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

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #56 on: 22 May 2018, 19:04 »
Yeah, I'm also not sure exactly what behavior you're talking about. Which AudioType volumes are going crazy again?

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

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #57 on: 22 May 2018, 19:51 »
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.
« Last Edit: 22 May 2018, 20:09 by Crimson Wizard »

bx83

  • Get 'Er Doooooone
Re: Should I start Music in Room_load of Room_Afterfadein?
« Reply #58 on: 23 May 2018, 13:39 »
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.
« Last Edit: 23 May 2018, 13:41 by bx83 »