public void PlaySound(CachedSound sound, int volume = 100) { if (LastAudioDevice != Constants.DefaultAudioDevice) { OutputDevice.Stop(); SetupEngine(); } Mixer.AddMixerInput(new CachedSoundSampleProvider(sound, (float)volume / 100)); }
public CachedSoundSampleProvider(CachedSound cachedSound, float volume = 1.0f) { _cachedSound = cachedSound; _volume = volume; }
public void PlaySound(CachedSound sound, int volume = 100) { if (LastAudioDevice != Constants.DefaultAudioDevice) { OutputDevice.Stop(); SetupEngine(); } Mixer.AddMixerInput(new CachedSoundSampleProvider(sound, (float) volume / 100)); }
public static CachedSound TryGetSetSoundFile(string soundFile, int volume = 100) { var fileName = Regex.Replace(soundFile, @"[\\/]+", "\\", SharedRegEx.DefaultOptions); lock (SoundFiles) { try { CachedSound value; if (SoundFiles.TryGetValue(fileName, out value)) { return value; } value = new CachedSound(Path.Combine(Constants.SoundsPath, fileName)); SoundFiles.Add(fileName, value); return value; } catch (Exception ex) { return null; } } }