XAudio2 setting the frequency (SetFrequencyRatio)


  • Can someone shed some light on what I am doing wrong. The foll code is a excerpt of the code. I am able to load the sound and it plays correctly without a frequency change and it plays correctly if the frequency is 1 or lower; Frequencies over 1 (for ex 1.19) does not raise the frequency, it plays the default frequency of 1.

    using SharpDX;
    using SharpDX.Multimedia;
    using SharpDX.XAudio2;
    using Windows.Storage;
    using SharpDX.IO;
    public float tempFrequency = 1f;
    void PlaySound(string soundFileName)
    	... // code that loads the sound
    	tempFrequency = 1.19F; // Does not raise the frequency
    	// tempFrequency = 0.09F; // Lowers the frequency
    	var sourceVoice = new SourceVoice(device, waveFormat, true);
    	sourceVoice.SubmitSourceBuffer(buffer, stream.DecodedPacketsInfo);
    Friday, August 24, 2012 4:00 PM


  • Thanks James

    What I was doing wrong was setting the sourceVoice as

    var sourceVoice = new SourceVoice(device,waveFormat,true);

    instead of            

    var sourceVoice = new SourceVoice(device, waveFormat, 0, 2.0f);

    • Marked as answer by JamesBlond Tuesday, August 28, 2012 2:15 AM
    Tuesday, August 28, 2012 2:14 AM

All replies