Mysterious audio playing in only 1 room SOLVED

Started by Funkpanzer, Sun 29/10/2017 12:24:04

Previous topic - Next topic

Funkpanzer

I have a weird issue that is only affecting one room of my game. When the player enters the room, whatever the 1st file in Audio/Music is starts playing every three seconds. When I try to cue up another song in the room, it gets instantly replaced as well. I also attempted to enter the room from a different starting room and the same thing happens.

I know I'm missing something obvious but after two weeks of searching I feel like things are making less and less sense and my next step might be to start the room over.

Please excuse the messy script. I included my rep_execs and anything relevant from both the room and my global and I searched my entire game for any other MusicChannel, or the word "Play" that might be conflicting so I imagine the culprit is somewhere here.

Room script:
Code: ags

// room script file
bool firstEnters, bookOnTable;

function room_FirstLoad()	{

}

function room_Load()	{
	Ambient1.Stop(); // REPLACE THESE WITH AMBIENT TRACKS
	Ambient2.Stop();
	oTVglow.SetView(73, 0, 0); // ANIMATE THE TELEVISION
	oTVglow.Animate(0, 5, eRepeat, eNoBlock);
}

function room_AfterFadeIn()	{
	player.Walk(399, 102, eBlock);
	player.Walk(399, 107, eBlock);
	if (firstEnters==false) {
		firstEnters=true;
		player.FaceDirection(eDirectionLeft, eBlock);
		// SCROLL SCREEN LEFT
		int viewX = GetViewportX();
                int holdViewX = GetViewportX();
		int viewY = GetViewportY();
		while (viewX > 158) { // CAMERA IS TO THE RIGHT OF THE DESIRED POSITION
			SetViewport(viewX, viewY);
			Wait(1);
			viewX--;
		}
		cJoce.Say("*snork* - Oh, hey %s.", player.Name);
		cJoce.Say("Thanks for waking me up, I almost slept through Hoppy Pals!");
		// JOCE TURNS ON TV
		cAndre.Say("I thought you were only watching it with Cassie?");
		cJoce.Say("I wish but she ends up watching with her mom during the week so I need to keep up!");
		
		MusicChannel = aHoppyPals.Play(eAudioPriorityNormal, eOnce); // Theme starts playing
		setMusicVolume = 30;
		
		cJoce.Say("Shh! It's starting!"); 
		// SCROLL SCREEN LEFT
		while (viewX < holdViewX) {
			SetViewport(viewX, viewY);
			Wait(1);
			viewX+=2;
		}
		ReleaseViewport();
	}
}

function room_RepExec()	{
	if (player.Loop==0) oReflection.SetView(75, 3); // Mirror is Andre's back
	if (player.Loop==1) oReflection.SetView(75, 1); // Mirror is Andre's left side
	if (player.Loop==2) oReflection.SetView(75, 2); // Mirror is Andre's right side
	if (player.Loop==3) oReflection.SetView(75, 0); // Mirror is Andre's front
}


GlobalScript:
Code: ags

function repeatedly_execute() {
	
	//if (player.ActiveInventory
	if (tipLatch==true) {
		tipLatch=false;
		tips_touch();
	}
	if (inFight==true) {
		fightLatch=true;
		d1_1 = 0; // MILLIE RESETS HER CUBBY DIAL
		btnCub1d1.Text=String.Format("%d",d1_1);
		d1_2 = 0;
		btnCub1d2.Text=String.Format("%d",d1_2);
		d1_3 = 0;
		btnCub1d3.Text=String.Format("%d",d1_3);
		d1_4 = 0;
		btnCub1d4.Text=String.Format("%d",d1_4);
	}
	if ((fightLatch==true) && (inFight==false)) { // END OF ACT I, RESETS EVERYTHING FOR ACT II
		fightLatch=false;
		FadeOut(2);
		Wait(30);
		Ambient1.Volume=0;
		Ambient2.Volume=0;
		MusicChannel.Volume=0;
		Wait(240);
		timeline=11;
		// Sandra on the beach, Kai away, Chris closer to water
		cSandra.ChangeRoom(1, 1151, 134, eDirectionRight); // Make her sit down
		cSandra.ChangeView(60);
		cKai.ChangeRoom(4);
		cChris.ChangeRoom(1, 1144, 124, eDirectionRight);
		// Remove napper
		cNapper.ChangeRoom(4);
		// Place tanner
		cTanner.ChangeRoom(1);
		// Sit Ernie on the crate
		cErnie.LockViewAligned(33, 1, eAlignCentre);
		cErnie.SpeechView=63;
		cErnie.ChangeRoom(3, 76, 126, eDirectionRight);
		// SET UP MILLIE
		cMillie.ChangeRoom(1, 1105, 108, eDirectionRight);
		// Set up Andre
		player.SpeechView=3;
		player.ChangeView(3);
		player.ChangeRoom(1, 876, 102);
	}
  relativeX = player.x -160; // Update coordinates for UI placement
	
  //PLAYER OCEAN BOB EFFECT
  if (player.Room==5) {
		if (IsTimerExpired(5)) {
			SetTimer(5, 15);
			if ((playerBob<2) || (playerBob>5)) player.y++;
			else player.y--;
			playerBob++;
      if (playerBob==3) player.x++;
			if (playerBob==8) {
        player.x++;
        playerBob=0;
      }
		}
	}
  
	// BRING UP SET NAME
  if (setName==true) {
    gSetname.Visible=true;
    setName=false;
  }
}

// Clear inspector and active inventory
function scrub_ui() {
	// clear the inspector and active inventory
}

function repeatedly_execute_always() {
	if (player.Room==1) { // CALCULATE CLOUD PLACEMENT
		float playerAdjust = IntToFloat(player.x);
		float cloudCalc = playerAdjust / 6.0;
		cloudPos = FloatToInt(cloudCalc, eRoundUp);
	}
	
	if (player.Room==5) wet=true; // Player is in the ocean
	
	// CHANGE CURSOR GRAPHIC
  LocationType loc_type = GetLocationType(mouse.x, mouse.y);
  if ((loc_type != eLocationNothing) && (player.ActiveInventory==null)) {
    if (loc_type == eLocationCharacter) Mouse.UseModeGraphic(eModeTalkto);
		else if ((loc_type == eLocationObject) && (lblInspector.Text == "Hotrod")) Mouse.UseModeGraphic(eModeTalkto);  //HOVER OVER GILDA'S CAR
  }
	
  // FIND A WAY TO MAKE THE GAME SHOW A DIALOG WHEN LOOKING AT THE HOTROD WHILE IT'S RUNNING
  else if (player.ActiveInventory==null) Mouse.UseModeGraphic(eModeInteract);
	// UI hiding
	if ((gPause.Visible==false) && (IsInterfaceEnabled())) hideUI=false;
	else hideUI=true;
	// UI HIDING & STATES
	// FANNYPACK
  if ((hideUI==false) && (gCubbies.Visible==false) && (gStartmenu.Visible==false) && (hideInv==false)) {
    if ((mouse.x>103) && (mouse.x<225) && (mouse.y>135)) {
			if (zipLatch==false) {
				aZipDown.Play();
				zipLatch=true;
			}
      gFanny.Visible=false;
      gInventory.Visible=true;
    }
    else if (game.in_cutscene==false) {
			if (zipLatch==true) {
				aZipUp.Play();
				zipLatch=false;
			}
      gInventory.Visible=false;
      gFanny.Visible=true;
    }
	}
	else {
		gFanny.Visible=false;
		gInventory.Visible=false;
  }
	// MENU BUTTON VISIBILITY
	if (hideUI==false) gMenubutton.Visible=true;
	else gMenubutton.Visible=false;
	
	// ANDRE FOOTSTEPS
	if (player.Moving==false) footLatch=false;
	if ((player.Moving==true) && (player.Room==5)) { // ANDRE IS IN THE OCEAN
		int foot = Random(2);
		if ((player.Frame==2) && (frameCheck==false)) {
			frameCheck=true;
			if (stroke==false) {
				if (foot==0) Swim1 = aSplash1.Play(eAudioPriorityNormal);
				if (foot==1) Swim1 = aSplash2.Play(eAudioPriorityNormal);
				if (foot==2) Swim1 = aSplash3.Play(eAudioPriorityNormal);
				stroke=true;
			}
			else {
				if (foot==0) Swim2 = aSplash1.Play(eAudioPriorityNormal);
				if (foot==1) Swim2 = aSplash2.Play(eAudioPriorityNormal);
				if (foot==2) Swim2 = aSplash3.Play(eAudioPriorityNormal);
				stroke=false;
			}
		}
		else if (player.Frame!=2) frameCheck=false;
		return;
	}
	if ((player.Moving==true) && (player.Frame==2) && (footLatch==false)) { // Left foot
		int foot = Random(2);
		footLatch=true;
		if (player.Room!=2) {
			if (foot==0) aLfoot1.Play(eAudioPriorityNormal);
			if (foot==1) aLfoot2.Play(eAudioPriorityNormal);
			if (foot==2) aLfoot3.Play(eAudioPriorityNormal);
		}
		else {
			if (foot==0) aLfoot1hut.Play(eAudioPriorityNormal);
			if (foot==1) aLfoot2hut.Play(eAudioPriorityNormal);
			if (foot==2) aLfoot3hut.Play(eAudioPriorityNormal);
		}
	}
	if ((player.Moving==true) && (player.Frame==7) && (footLatch==true)) { // Right foot
		int foot = Random(2);
		footLatch=false;
		if (player.Room!=2) {
			if (foot==0) aRfoot1.Play(eAudioPriorityNormal);
			if (foot==1) aRfoot2.Play(eAudioPriorityNormal);
			if (foot==2) aRfoot3.Play(eAudioPriorityNormal);
		}
		else { // Andre is inside the hut
			if (foot==0) aRfoot1hut.Play(eAudioPriorityNormal);
			if (foot==1) aRfoot2hut.Play(eAudioPriorityNormal);
			if (foot==2) aRfoot3hut.Play(eAudioPriorityNormal);
		}
	}

	// SOUND MIX
	
	// Volume adjusters *THESE SEEM TO BE WORKING FINE*
	if (setMusicVolume!=MusicChannel.Volume) {
		if (setMusicVolume>MusicChannel.Volume) MusicChannel.Volume ++;
		else if (setMusicVolume<MusicChannel.Volume) MusicChannel.Volume --;
		else if (setMusicVolume<=1) {
			MusicChannel.Stop();
			setMusicVolume=saveUserMusicVol;
		}
	}
	if ((nGameLatch==true) && (player.Room==1) && (MusicChannel.IsPlaying==true)) { // THIS IS USEFUL!
		MusicChannel.Volume--;
		if (MusicChannel.Volume==1) {
			MusicChannel.Stop();
			nGameLatch=false;
		}
	}
	// AMBIENT CHANNEL 1
	if (player.Room!=4) {
		if (player.Room==1) { // Is playing ocean ambient, mix based on distance
			// RC plane mixer
			RCx=oRCplane.x;
			if (RCx!=0) {
				int RCcalc;
				int RCpancalc;
				if (RCx<player.x) {
					RCcalc=player.x-RCx;
					RCpancalc=RCx-player.x;
					if (RCpancalc<-100) RCpancalc=-100;
					if (RCpancalc>100) RCpancalc=100;
					RCchannel.Panning=RCpancalc; // PAN LEFT
				}
				if (RCx>player.x) {
					RCcalc=RCx-player.x;
					RCchannel.Panning=RCpancalc; // PAN RIGHT
				}
				if (RCcalc>98) RCcalc=98;
				if (RCcalc<1) RCcalc=1;
				if (RCchannel.IsPlaying==true) RCchannel.Volume=100-RCcalc;
			}
			// Ocean ambient
			// PAN THE OCEAN LOOP
			int Amb1PanCalc = 1297 - player.x;
			float Amb1PanHold = IntToFloat(Amb1PanCalc / 2);
			Amb1PanCalc = FloatToInt(Amb1PanHold, eRoundUp);
			if (player.x<1097) Ambient1.Panning=98;
			else if (player.x>1297) Ambient1.Panning=0;
			else Ambient1.Panning=Amb1PanCalc;
			
			// Mix the ocean loop
			if (player.x<333) Amb1Mixer=1570-333;
			else if (player.x<1570) Amb1Mixer=1570-player.x;
			else Amb1Mixer=1570;
			AmbCalc=IntToFloat(Amb1Mixer)*0.1034;
			Amb1Mixer=FloatToInt(AmbCalc, eRoundDown);
			if (Amb1Mixer>99) Amb1Mixer=99;
			Ambient1.Volume=100-Amb1Mixer;
		}
		else if (Ambient1.Volume!=2) {
			Ambient1.Volume=6; // Player is not on beach
			if (player.Room==2) Ambient1.Panning=-98;
			else if (player.Room==3) Ambient1.Panning=60;
		}
		// AMBIENT CHANNEL 2
		if (timeline<6) Amb2Adjust = 390; // Hot rod ambient
		if (timeline>6) Amb2Adjust = 330; // Food truck ambient
		if (player.Room==1) { // Is playing truck area ambient
			if (player.x>Amb2Adjust) { // East of the food truc
				Amb2Mixer=player.x-Amb2Adjust;
				float Amb2IntFlo = IntToFloat(Amb2Mixer / 3);
				Amb2Mixer = FloatToInt(Amb2IntFlo, eRoundUp);
				if (Amb2Mixer>90) Amb2Mixer=90; // 0 = Loud, 100 = Quiet
				if (Amb2Mixer<1) Amb2Mixer= 1; // Stand in front of sound 
				Ambient2.Volume=100-Amb2Mixer;
			}
			else { // West of the food truck
				Amb2Mixer=Amb2Adjust-player.x;
				float Amb2IntFlo = IntToFloat(Amb2Mixer / 13);
				Amb2Mixer = FloatToInt(Amb2IntFlo, eRoundUp);
				if (Amb2Mixer>65) Amb2Mixer=65; // 0 = Loud, 100 = Quiet
				if (Amb2Mixer<1) Amb2Mixer=1;
				Ambient2.Volume=100-Amb2Mixer;
			}
			
			// Pan the hot-rod		
			int Amb2PanCalc = Amb2Adjust - player.x;
			float Amb2PanHold = IntToFloat(Amb2PanCalc / 2);
			Amb2PanCalc = FloatToInt(Amb2PanHold, eRoundUp);
			if (player.x< Amb2Adjust - 194) Ambient2.Panning=98;
			else if (player.x> Amb2Adjust + 194) Ambient2.Panning=-98;
			else Ambient2.Panning=Amb2PanCalc;
		}
		else Ambient2.Volume=100;  // Player is not on beach
	}
	//
  if (player.Room!=2) player.Baseline=player.y;
  /* DEBUG SHITS */
  lblPlayerX.Text=String.Format("x: %d",player.x);
  lblPlayerY.Text=String.Format("y: %d",player.y);
  lblTime.Text=String.Format("%d",timeline);
  if (blowing==true) lblDblow.Text=String.Format("blowing = 1");
  else lblDblow.Text=String.Format("blowing = 0");
  if (nearCar==true) lblDcar.Text=String.Format("nearCar = 1");
  else lblDcar.Text=String.Format("nearCar = 0");
  if (gildaTalking==true) lblDgil.Text=String.Format("gildaTalking = 1");
  else lblDgil.Text=String.Format("gildaTalking = 0");
}


:(

Khris

In Views you can set frames to play sound (most common example are footsteps).
My guess is you accidentally added a sound to your TV animation's View, Nr. 73.

Funkpanzer

#2
Thanks for taking a look, Khris. I checked all the frames for both the reflection and the TV view and there's unfortunately nothing in there.

The weirdest part is that it's grabbing whatever the first sound is in the game's audio list and it's only affecting my MusicChannel.


UPDATE: I removed View 73 from the scene and even though it appears that it's not trying to play any audio, it fixed it! Thank you so much for your suggestion! I still don't know why but at least I can move on! :P

Funkpanzer

#3
I found the culprit! The TV animation (View73) had "Run the next loop after this..." checked on it's last loop. If anyone else is experiencing this problem that may be your issue. Thanks again, Khris!

Gurok

Let me get this straight, the audio was completely unrelated?
I think a similar thing can happen if you use a 0-frame view as a character's speech view.
I suspect there is a hole in AGS' error checking somewhere. This should probably be looked at.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Funkpanzer

#5
Yes, if I went into audio and moved the order of files, it would play whatever was now first in the list.

SMF spam blocked by CleanTalk