public SoundReversibleInstance(SoundReversible sound, byte[] audioBytes, int sampleRate, AudioChannels channels, bool inReverse) { this.sound = sound; this.sampleRate = sampleRate; this.channels = channels; reversed = inReverse; baseAudioBytes = audioBytes; dynamicSound = NewDynamicSoundEffectInstance(); count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(BUFFER_CHUNK_SIZE)); }
public static void PlaySoundOnce(SoundReversible sound, PlayMode mode, bool playInReverseDuringReverse) { if (mode == PlayMode.Forward) { sound.Play(soundMasterVolume, 0, 0); if (playInReverseDuringReverse) soundsToSaveForReversePlayback.Add(new Tuple<SoundReversible, TimeSpan>(sound, latestGameTime.TotalGameTime + sound.Length - new TimeSpan((long)(sound.Length.Ticks * (1 - PERCENTAGE_SOUND_REVERSE_DELAY))))); } else { sound.Play(soundMasterVolume, 0, 0, true); } }
public static void LoadContent(ContentManager Content) { //clean out accidental xnb files FileInfo[] filePaths = new DirectoryInfo(Content.RootDirectory + AUDIO_ROOT).GetFiles("*.xnb"); foreach (FileInfo file in filePaths) { file.Delete(); } filePaths = new DirectoryInfo(Content.RootDirectory + AUDIO_ROOT).GetFiles("*.wav"); foreach (FileInfo file in filePaths) { string soundName = file.Name.Split('.')[0]; SoundReversible sound = new SoundReversible(Content.RootDirectory + AUDIO_ROOT + soundName + ".wav"); if (SoundMap.ContainsKey(soundName)) SoundMap.Remove(soundName); SoundMap.Add(soundName, sound); } }