matrefeytontias

Game-breaking pitch shifting

Nov 26th, 2016
519
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.haxepunk.Sfx;
  2. import lime.audio.openal.AL;
  3.  
  4. @:access(lime.audio.AudioSource)
  5. @:access(lime._backend.native.NativeAudioSource)
  6. @:access(openfl.media.SoundChannel)
  7. class LBSfx extends Sfx
  8. {
  9.     public function setPitch(v:Float) : Bool
  10.     {
  11.         #if (html5 || js)
  12.         return false;
  13.         #elseif flash
  14.         return false;
  15.         #else
  16.         var h = _channel.__source.backend.handle;
  17.         // This crashes the game on Scene.update()
  18.         // It doesn't have to be called, it just has to exist somewhere in the code (ie be compiled)
  19.         AL.sourcef(h, AL.PITCH, v);
  20.         return true;
  21.         #end
  22.     }
  23.    
  24.     public function getPitch() : Float
  25.     {
  26.         #if (html5 || js)
  27.         return 1.;
  28.         #elseif flash
  29.         return 1.;
  30.         #else // sys
  31.         var h = _channel.__source.backend.handle;
  32.         // same here
  33.         return AL.getSourcef(h, AL.PITCH);
  34.         #end
  35.     }
  36. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×