All I want to do is play a WAV at random pitches in my Universal App. If there is a more straight forward way to do this than needed SharpDX tell me!
private void PlayTone(float randomPitch)
{
var xAudio = new XAudio2();
var masteringVoice = new MasteringVoice(xAudio);
var nativeFileStream = new NativeFileStream("Assets/440tone2.wav", NativeFileMode.Open, NativeFileAccess.Read, NativeFileShare.Read);
var stream = new SoundStream(nativeFileStream);
var waveFormat = stream.Format;
var buffer = new AudioBuffer
{
Stream = stream.ToDataStream(),
AudioBytes = (int)stream.Length,
Flags = BufferFlags.EndOfStream
};
var sourceVoice = new SourceVoice(xAudio, waveFormat, true);
sourceVoice.SubmitSourceBuffer(buffer, stream.DecodedPacketsInfo);
// sourceVoice.SetFrequencyRatio(200.0f);
sourceVoice.Start();
}
I had to switch these around