Example #1
0
        public static async Task <ISampleProvider> PlaySound(this MixingSampleProvider mixer, string path,
                                                             SampleControl sampleControl)
        {
            var sound = await CachedSound.GetOrCreateCacheSound(path).ConfigureAwait(false);

            PlaySound(mixer, sound, sampleControl, out var rootSample);
            return(rootSample);
        }
Example #2
0
        private static void PlaySound(MixingSampleProvider mixer, CachedSound sound, SampleControl sampleControl,
                                      out ISampleProvider rootSample)
        {
            if (sound == null)
            {
                rootSample = default;
                return;
            }

            mixer.AddMixerInput(new CachedSoundSampleProvider(sound), sampleControl, out rootSample);
        }
Example #3
0
        public static void AddMixerInput(this MixingSampleProvider mixer, ISampleProvider input,
                                         SampleControl sampleControl, out ISampleProvider rootSample)
        {
            var adjustVolume  = input.AddToAdjustVolume(sampleControl.Volume);
            var adjustBalance = adjustVolume.AddToBalanceProvider(sampleControl.Balance);

            sampleControl.VolumeChanged  = f => adjustVolume.Volume = f;
            sampleControl.BalanceChanged = f => adjustBalance.Balance = f;

            rootSample = adjustBalance;
            mixer.AddMixerInput(adjustBalance);
        }
Example #4
0
 internal static ISampleProvider PlaySound(this MixingSampleProvider mixer, CachedSound sound,
                                           SampleControl sampleControl)
 {
     PlaySound(mixer, sound, sampleControl, out var rootSample);
     return(rootSample);
 }