Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Sun 16/06/2013 10:42:26

Title: SOLVED: Sound L to R / R to L
Post by: Slasher on Sun 16/06/2013 10:42:26
Hi

I have a scenario that for best effect 'sound' would go speaker L to R / R to L...

It's for an unseen 'object' above scuttling about/around.

What is the efficient way of doing this?

cheers



Title: Re: Sound L to R / R to L
Post by: Ghost on Sun 16/06/2013 11:02:20
That's pretty easy to do by setting up an audio channel
AudioChannel *channel = MYSOUND.Play();

and then playing with the panning property:
channel.Panning = VALUE;

-100 is left speaker only, 100 is right speaker only, 0 is "the middle". You can "move" a sound by adjusting the value:

Code (AGS) Select

int soundPos = -100
while (soundpos < 100)
{
  channel.Panning = soundPos;
  soundPos++;
  Wait(1);
}


[edit]
You may want to include a failcheck if the sound has stopped while the "panning" is still in progress; I do NOT know if panning a channel that does no longer exist will throw an error.
Title: Re: Sound L to R / R to L
Post by: Slasher on Sun 16/06/2013 15:34:14
Hi Ghost,

Got this error:

QuoteFailed to save room room2.crm; details below
room2.asc(175): Error (line 175): undefined symbol 'soundpos'


Code (AGS) Select

}
  if (IsTimerExpired(3))
  {
  AudioChannel *channel = aScuttling_creature.Play();
 
  int soundPos = -100;
  while (soundpos < 100) // * UNDEFINED SYMBOL soundpos

  channel.Panning = soundPos;
  soundPos++;
  Wait(1);
  cspaceman.SayBackground("What the hell is that scuttling noise???");
  Wait(60);
  cspaceman.SayBackground("");
  SetTimer(3, 600);
}
}


slasher




Title: Re: Sound L to R / R to L
Post by: Ghost on Sun 16/06/2013 15:53:51
Declare int soundpos at the top  of the room script, that should do the trick.
Title: Re: Sound L to R / R to L
Post by: Scavenger on Sun 16/06/2013 15:57:40
Quote from: slasher on Sun 16/06/2013 15:34:14
Hi Ghost,

Got this error:


Code (AGS) Select

}
  if (IsTimerExpired(3))
  {
  AudioChannel *channel = aScuttling_creature.Play();
 
  int soundPos = -100;
  while (soundPos < 100)
    {
      channel.Panning = soundPos;
      soundPos++;
      Wait(1);
    }
  cspaceman.SayBackground("What the hell is that scuttling noise???");
  Wait(60);
  cspaceman.SayBackground("");
  SetTimer(3, 600);
}
}


Variables are case sensitive. Also, remember to bracket your while loop! Otherwise the code will just hang.
Title: Re: Sound L to R / R to L
Post by: Stupot on Sun 16/06/2013 16:00:34
You need to change soundpos to soundPos. There are inconsistencies. X sorry, scavenger addressed it. Not sure how I missed that.
Title: Re: Sound L to R / R to L
Post by: Slasher on Sun 16/06/2013 16:31:33
Many thanks guys,

with a bit of tweaking and stuff its perfect...

Many thanks

slasher