Пример #1
0
        public OpenALSoundOutput(IHostAudioManager sound)
        {
            _sound = sound;
            string deviceName = GetDeviceNames().FirstOrDefault(n => n == _sound.ConfigDevice);

            _context = new AudioContext(deviceName, _sound.SampleRate);
        }
 public OpenALSoundOutput(IHostAudioManager sound, string chosenDeviceName)
 {
     _sound   = sound;
     _context = new AudioContext(
         GetDeviceNames().Contains(chosenDeviceName) ? chosenDeviceName : null,
         _sound.SampleRate
         );
 }
        public DirectSoundSoundOutput(IHostAudioManager sound, IntPtr mainWindowHandle, string soundDevice)
        {
            _sound        = sound;
            _retryCounter = 5;

            var deviceInfo = DirectSound.GetDevices().FirstOrDefault(d => d.Description == soundDevice);

            _device = deviceInfo != null ? new DirectSound(deviceInfo.DriverGuid) : new DirectSound();
            _device.SetCooperativeLevel(mainWindowHandle, CooperativeLevel.Priority);
        }
Пример #4
0
        public XAudio2SoundOutput(IHostAudioManager sound)
        {
            _sound  = sound;
            _device = new XAudio2();
            int?deviceIndex = Enumerable.Range(0, _device.DeviceCount)
                              .Select(n => (int?)n)
                              .FirstOrDefault(n => _device.GetDeviceDetails(n.Value).DisplayName == _sound.ConfigDevice);

            _masteringVoice = deviceIndex == null ?
                              new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate) :
                              new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate, deviceIndex.Value);
        }
 public XAudio2SoundOutput(IHostAudioManager sound, string chosenDeviceName)
 {
     _sound  = sound;
     _device = new XAudio2();
     for (int i = 0, l = _device.DeviceCount; i < l; i++)
     {
         if (_device.GetDeviceDetails(i).DisplayName == chosenDeviceName)
         {
             _masteringVoice = new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate, i);
             return;
         }
     }
     _masteringVoice = new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate);
 }
Пример #6
0
 public static double SamplesToMilliseconds(this IHostAudioManager audioMan, int samples)
 {
     return(samples * 1000.0 / audioMan.SampleRate);
 }
Пример #7
0
 public static int MillisecondsToSamples(this IHostAudioManager audioMan, int milliseconds)
 {
     return(milliseconds * audioMan.SampleRate / 1000);
 }
Пример #8
0
 public DummySoundOutput(IHostAudioManager sound)
 {
     _sound = sound;
 }
Пример #9
0
 public static ISoundOutput CreateXAudio2SoundOutput(IHostAudioManager sound, string chosenDeviceName)
 => new XAudio2SoundOutput(sound, chosenDeviceName);
Пример #10
0
 public static ISoundOutput CreateDSSoundOutput(IHostAudioManager sound, IntPtr mainWindowHandle, string chosenDeviceName)
 => new DirectSoundSoundOutput(sound, mainWindowHandle, chosenDeviceName);