コード例 #1
0
        public async Task Play(SoundboxContext context, SoundPlayback sound)
        {
            if (Finished)
            {
                return;
            }

            this.Sound = sound;
            var engine = await EngineProvider.GetSoundEngine();

            Playback = engine.Play2D(context.GetAbsoluteFileName(sound.Sound), false, true);

            //set playback options
            Playback.PlaybackSpeed = (float)sound.Options.SpeedPitch;

            double volume = sound.Options.Volume;

            //try to connect to a virtual volume service if any
            var virtualVolumeService = ServiceProvider.GetService(typeof(IVirtualVolumeService)) as IVirtualVolumeService;

            if (virtualVolumeService != null)
            {
                volume = Volume.GetVolume(volume, await virtualVolumeService.GetVolume());
                virtualVolumeService.RegisterSoundPlayback(this);
            }

            Playback.Volume = Utilities.GetVolume(volume);

            //notify when the sound is done playing
            Playback.setSoundStopEventReceiver(this);

            //setup is done: start playing the sound
            Playback.Paused = false;
        }
コード例 #2
0
        private static ExtractedSoundPlayback ReadSoundPlayback(IReader reader, byte version)
        {
            if (version > 0)
            {
                throw new InvalidOperationException("Unrecognized \"snpb\" block version");
            }

            var playback = new SoundPlayback();

            int originalIndex = reader.ReadInt32();

            playback.InternalFlags        = reader.ReadInt32();
            playback.DontObstructDistance = reader.ReadFloat();
            playback.DontPlayDistance     = reader.ReadFloat();
            playback.AttackDistance       = reader.ReadFloat();
            playback.MinDistance          = reader.ReadFloat();
            playback.SustainBeginDistance = reader.ReadFloat();
            playback.SustainEndDistance   = reader.ReadFloat();
            playback.MaxDistance          = reader.ReadFloat();
            playback.SustainDB            = reader.ReadFloat();
            playback.SkipFraction         = reader.ReadFloat();
            playback.MaxPendPerSec        = reader.ReadFloat();

            playback.GainBase             = reader.ReadFloat();
            playback.GainVariance         = reader.ReadFloat();
            playback.RandomPitchBoundsMin = reader.ReadInt32();
            playback.RandomPitchBoundsMax = reader.ReadInt32();
            playback.InnerConeAngle       = reader.ReadFloat();
            playback.OuterConeAngle       = reader.ReadFloat();
            playback.OuterConeGain        = reader.ReadFloat();
            playback.Flags           = reader.ReadInt32();
            playback.Azimuth         = reader.ReadFloat();
            playback.PositionalGain  = reader.ReadFloat();
            playback.FirstPersonGain = reader.ReadFloat();

            return(new ExtractedSoundPlayback(originalIndex, playback));
        }
コード例 #3
0
ファイル: ExtractedSound.cs プロジェクト: MadJayQ/MCCEditor
 public ExtractedSoundPlayback(int index, SoundPlayback src)
 {
     OriginalIndex = index;
     Source        = src;
 }