Author Topic: Sound - PlayVoice  (Read 1377 times)

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Sound - PlayVoice
« on: August 05, 2015, 12:42:21 PM »
Any chance you will add in the play_voice function back in?

This was really handy for delays.

Code: [Select]
def BarrelHitChecker(self):
if self.BarrelHitCount ==1:
voice_delay = self.game.sound.play('chrissies_death')
self.delay(delay=voice_delay,handler=self.kickOutBall)

def kickOutBall(self):
self.game.coils.barrelKicker.pulse()

Sound.py doesn't look too different from the last version but I am trying not to adjust anything here and trying to build a game as quick as I can with the current functions.

Or is there another way like this without manual timer and keeping it nice and short?

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Sound - PlayVoice
« Reply #1 on: August 05, 2015, 12:48:34 PM »
Oh wow, it worked as it is when I added the play_voice method back into the sound.py

Case closed.




dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Sound - PlayVoice
« Reply #2 on: August 06, 2015, 09:27:09 PM »
 8) Just spotted the play method returns duration if you set a channel....doh

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Sound - PlayVoice
« Reply #3 on: August 07, 2015, 10:30:35 PM »
Okay, to close the loop on this one and help future folks, this version of the sound controller does not need a play_voice because  play_sound can take a channel argument, and if you provide one, it will return the delay.  Specifically if you want to play a sound that's a voice, you should use the voice channel --and should probably add the channel argument, as shown in the modified snippet below.

Code: [Select]
def BarrelHitChecker(self):
if self.BarrelHitCount ==1:
voice_delay = self.game.sound.play('chrissies_death', channel=procgame.sound.SNDCHL_VOICE)
self.delay(delay=voice_delay,handler=self.kickOutBall)

def kickOutBall(self):
self.game.coils.barrelKicker.pulse()

Without a doubt this is information that would have been far more useful before now, but at least now it's here for posterity..?

Thanks for your patience with my incomplete docs.

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Sound - PlayVoice
« Reply #4 on: August 07, 2015, 10:33:13 PM »
Heh yeah, I figured that out if you read the post above. It wasn't until I read what what going on in the function rather than blindly using it and leaving the channel at default.

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Sound - PlayVoice
« Reply #5 on: August 10, 2015, 08:55:06 AM »
I just remembered why another reason I added this. The old play_voice wouldn't play a voice if a voice was already playing. This one doesn't seem to care and can trigger off a sound twice, unless I am missing something?

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Sound - PlayVoice
« Reply #6 on: August 10, 2015, 09:24:16 AM »

I thought the voice channel should queue audio to play. Is that not the case..?

I just remembered why another reason I added this. The old play_voice wouldn't play a voice if a voice was already playing. This one doesn't seem to care and can trigger off a sound twice, unless I am missing something?

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Sound - PlayVoice
« Reply #7 on: August 10, 2015, 09:34:55 AM »
I just had a better look and tested on a few switches.

You have to specify an audio channel. If call is just left at "sound.play(key)" it will repeat. That's fine though mate at least I know now.