Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - bx83

#481
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
#482
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
#483
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
	}
}


#484
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?
#485
Are there 7 channels in total, or per AudioType?
Will post updated code later, all... seems to work now.
#486
This further gives me knowledge into Audio. Didn't know I could have 7 extra named types, and separate them into 7 different 'channels'.
I've got half a mind to do this:

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

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

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

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

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

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

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

Code: ags

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

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

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

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

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

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

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

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


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

I think was my reason for putting:
Code: ags

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

...was an attempt to prime the music_chan pointer; removed it, still works, god knows what I was thinking.
#488
Anyone...?
Anyway, I do understand AudioChannel and crossfade more. Pitty about footstep sounds but it will be fixed later I suppose.
Thankyou :)
#489
Here's a video of the above:
link here

You might want to listen on 100%+ volume, the footsteps are just audible in room 4 (crossroads).
#490
Okay, all code:
room 2 is BEACH, to the right of CAVE
room 7 is CAVE
room 3 is FARMER, to the right of BEACH
room 4 is CROSSROADS, to the right of FARMER
room 32 is MOUNTAIN TOP, to the top of FARMER

so:
           _32_
7  |  2  |  3   |  4

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

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

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


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

aAfternoonSounds.Play(eAudioPriorityNormal, eRepeat);


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


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

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

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

===========

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

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

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

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

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

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



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


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



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


ROOM 7 - CAVE
Code: ags

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

function room_FirstLoad()
{
  BeenToCave=true;
}

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

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

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


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

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

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

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

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

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


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


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

ROOM 4 - CROSSROADS
Code: ags

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

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

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

  
}



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

ROOM 32 - MOUNTAINTOP
Code: ags


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

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

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


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



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

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

SetNextScreenTransition(eTransitionInstant);


This has Julius wakling off a eg. a left edge, room transitons instantly, and then in the next he walks in from the eg. right edge, before finally stopping and returning control to the user.
#491
Thanks guys, it's all coming together... slowly.

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

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

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

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

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

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

Code: ags

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


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

:undecided:
#492
Quote from: Snarky on Wed 16/05/2018 09:20:46
Quote from: bx83 on Wed 16/05/2018 08:46:01
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).

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 the
Code: ags
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.

QuoteOkay well I need to do one of the following:
a) make maxaudiochannels 1 for both music and sounds; or

Do 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.[/quote]

But how will not setting it to 1 allow me to crossfade? That's the opposite.

Quoteb) have a function which finds and then stops an audioclip for a given name

AudioClip.Stop(). But why do you need this?[/quote}

Sorry, meant to say 'crossfade to nothing' not 'stops'.
Quote
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.)

Yeah, well I know what you mean :/


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

Yeah but could it be trivial for just one music track and one sound track?
I get the feeling I'll need to build a function which loops through all the audio channels, crossfades ones I want closed to nothing, and the others to crossfade to new tracks with a Wait(10) pause (using Wait has helped me to solve a few problems recently.)

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

Is the hidden crossfade channel in addition to the MaxChannels we've set up? Or is it just one channel, used for each sound crossfading.
Are they crossfaded simultaneously? One at a time?....

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

I can send you a link to the main project? It will be about 1GB but it will explain everything and allow you to see quickly what's wrong. It really only affects the first 3 rooms, which use the crossfading music/sounds run by the position of each (ie. beachThemePos) in an audiochannel (ie. music_chan).

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

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).
#493
Quote from: Snarky on Wed 16/05/2018 07:32:07
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'll try the VolumeReductionWhileSpeechPlaying to 0 and see if that changes anything.

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.

I'm not trying to be obnoxious, I'm really not, but this is getting self destroying. I mean I will literally pay you money to debug these rooms for me.
#494
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);

???
#495
I've now altered my code to just get rid off FirstLoad for simplicities sake.
I think I've discovered the error, but I don't know how to fix it.

When I run this code, all runs fine, no intermitent stops -- though, there are intermittent volume changes for music and sound. I haven't touched .Volume for any of these variables.
Sometimes, CAVE resets the music/sound volume for BEACH; but I can't see why CAVE is more 'stable'.

The default volume for both music and sounds was set to 100% inherited for both; just to make sure, I then changed it to 100% for both non-inherited. No difference.
They have 95 (music) and 99 (sounds) ReductionWhileSpeechPlaying

My code:

BEACH:
Code: ags

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);
	}
}


CAVE:
Code: ags

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()
{
}


I ran a test to see which audiochannel ID and Volume were being used, by placing this immmediately in AfterFadein after each time music_chan or sounds_chan was invoked:
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);

Sounds volume I decided to ignore, as there's a MaxChannel of 5 for sounds, so each test of sounds_chan.Volume got a different clip each time (I think? Anyway the channel bobbed around from 1 to 5 each room tresnition).

They were reporting channel ID 1 for music every time; and a volume of 6, for music.
This is a very low %, an didn't change; but the actual sound colming out of the speaker ranged from ~5 to 100 each transition.

Nothing was done to volume by me.
I changed the music_chan.Volume to 100 each room transition; this seemed to fix it.

Pointer variable corrupt/changing position in memory and reading garbage? Why only this room, though?
Or have I missed something? (feels like something huge.... :/)

This is a mess, but I don't know how or why. Once again, I'm happy to pay like US$1,000 to anyone who can debug the sound/music system. The above code is simplified, and leave out a lot of walking, animation commands, and etc. that's too complex to include here.

I mean, I don't want to beg, but this one simple 'OceanThemePos' has really screwed things up for me. I've tried like 50 different versions of the code, then always, *something* goes wrong at random times.
If you want me to include all code, unaltered, *and* a video, I will; or send you the code for the game as PM (CrimsonWizard and Snarky - or anyone else I could trust).

Truly, I'm at my wits end.
#496
Quote from: morganw on Tue 15/05/2018 17:14:48
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.

It already is:


#497
Should I start music in Load or Afterfadein?
Is there a manual page with a list of things that are better off in each function?

It comes from the yet-again dreaded 'how do I transition between two music tracks of the same lengths' question.

BEACH is the beach, the first room, enters after the player starts the game.
CAVE is a cave to the left of the BEACH.

Both music tracks aBeachTheme and aBeachTheme_cave are the same length; they're the same *song* - aBeachTheme_cave have a low volume and 'muted' sound (beccause it's, you know, in a cave).
Both tracks are .OGG format
The Types->Music has a MaxChannels of 1 (so it will always smoothly transition as a new room is entered, and that areas music is played).

BEACH:
Code: ags

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);
	}
}


CAVE:
Code: ags

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


HOWEVER - the CAVE and BEACH background music intermiddently stops, upon entering the room. It doesn't crossfade to nothing; just stops. This can happen the 6th or 7th time I enter, or the 2nd. Random.
What's odd is, when the music *is* working again, it will transition back to it at a different position to where I left off. So, it almost as if the beachThemePos is updating with each successive entry; but when it tried to play the music, a random bug hits, and the playing doesn't go.

Bonus question: which runs first, the Room_Load function, or the Room_FirstLoad function?
#498
Clarvalon, thankyou for helping me in the other thread - ps do you have the code from < v0.6, as opposed to the binaries?
#499
Ps do you have the code from v<0.6?
#500
Thank you :D
SMF spam blocked by CleanTalk