SOLVED: Sound L to R / R to L

Started by Slasher, Sun 16/06/2013 10:42:26

Previous topic - Next topic

Slasher

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




Ghost

#1
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

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.

Slasher

Hi Ghost,

Got this error:

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


Code: AGS

}
  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





Ghost

Declare int soundpos at the top  of the room script, that should do the trick.

Scavenger

Quote from: slasher on Sun 16/06/2013 15:34:14
Hi Ghost,

Got this error:


Code: AGS

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

Stupot

#5
You need to change soundpos to soundPos. There are inconsistencies. X sorry, scavenger addressed it. Not sure how I missed that.
MAGGIES 2024
Voting is over  |  Play the games

Slasher

Many thanks guys,

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

Many thanks

slasher


SMF spam blocked by CleanTalk