XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

XACT3 Filter Frequency Inconsistency vs. Sample Rate

Last post 3/18/2009 12:40 AM by Big Daddio. 3 replies.
  • 2/19/2009 6:16 PM

    XACT3 Filter Frequency Inconsistency vs. Sample Rate

    I'm noticing that the filtering frequency is inconsistent based on the source sounds sample rate in XACT3 (and subsequently, XAudio2). XACT3 version is from November 2008. Project version is 2.17, Content version is 45. I have a test project set up with several mono pink noise wave/sound banks at differing sample rates like 44 KHz, 22 KHz, and 11 KHz. I've set up each sample rate wave on their own channel and enable the Low Pass Filter. I set all of the parameters to be exact. I'm using a frequency of 640 Hz and a Q of 0.71. The highest sample rate is getting filtered the most. Using an external RTA I can see that the 44 KHz pink noise starts rolling off close to the expected 640 Hz . The lowest sample rate is filtered the least. The 11 KHz pink noise starts rolling off close to 2000 Hz, but since SetFrequencyRatio is bugged in this version of XAudio2 I can hear some bad aliasing and/or distortion which might be affecting the filter. I was confused at the documentation on MSDN that talks about XAUDIO2_FILTER_PARAMETERS. I don't have a great understanding of Radian frequencies, but given the description of the Frequency parameter I was unable to discern when the frequency was either Radian or Hertz:
    Frequency: Filter radian frequency calculated as (2 * sin(pi * (desired filter cutoff frequency) / sampleRate)). The frequency must be greater than or equal to 0 and less than or equal to XAUDIO2_MAX_FILTER_FREQUENCY. The maximum frequency allowable is equal to the source sound's sample rate divided by six which corresponds to the maximum filter radian frequency of 1. For example, if a sound's sample rate is 48000 and the desired cutoff frequency is the maximum allowable value for that sample rate, 8000, the value for Frequency will be 1. If XAUDIO2_HELPER_FUNCTIONS is defined, XAudio2.h will include the XAudio2RadiansToCutoffFrequency and XAudio2CutoffFrequencyToRadians helper functions for converting between hertz and radian frequencies.
    Based off of this description, a 48000 Hz source wave will have a maximum cutoff frequency of 8000 Hz which translates to a value of 1 for the parameter. With the same logic, a 24000 Hz source wave (half the sample rate) will have a maximum cutoff frequency of 4000 Hz which translates to a value of 1 for the parameter. Is that correct? Is the filter parameter (0 to 1) being interpolated from the maximum frequency to the minimum frequency (20Hz if I remember correctly)? To add even more confusion to the filtering, playing back my 44 KHz pink noise test in XACT and watching my RTA I indeed notice no change from the maximum (20,000 Hz) down to past the expected 7,350 Hz maximum range. I can start to hear the filter apply slightly at around 6000 Hz. It becomes more noticable at around 4500 Hz where I can start to visualize the the change on my RTA. Doing this same evaluation with the 11 KHz pink noise, I notice no change from the filter maximum frequency of 20 KHz down to around the 1600 Hz range. Once it hits the 1000 Hz range in XACT I can see it start to visually roll off on my RTA at around 4000 Hz. In our project which uses XAudio2 (but not XACT) we see the same problem. I am not an audio programmer, but I believe we're using XAudio2CutoffFrequencyToRadians. Is it possible that this function is buggy or is not accurately adjusting the cutoff frequency based on the sample rate of the wave file/asset? According to what I am seeing it seems like the filter frequency (in Hertz) is accurate for 48 KHz and very close for 44.1 KHz sample rates. It seems that the filter cutoff frequency is really 2x for ~22 KHz files and around 4x for 11 KHz files. If the problem is ultimately a buggy conversion, can we work around this problem without an updated release of DirectX by writing our own "Helper" to do the Cutoff Frequency conversion for XAUDIO2_FILTER_PARAMETERS? Any help would be greatly appreciated.
  • 2/19/2009 7:48 PM In reply to

    Re: XACT3 Filter Frequency Inconsistency vs. Sample Rate

    Thought I would add that the Band Pass Filter frequency change is pretty obvious based on sample rate when you crank the Q factor all the way up to 30. With my same testing cross-over point of 640 Hz I see the following on my RTA: - 44 KHz sample rate @ ~630 Hz - 22 KHz sample rate @ ~1250 Hz - 11 Khz sample rate @ ~2300 Hz
  • 3/5/2009 2:30 AM In reply to

    Re: XACT3 Filter Frequency Inconsistency vs. Sample Rate

    I confirmed today that we were able to work around the issue by dividing the source voices sample rate by the "filter" sample rate and multiplying that result against the desired cutoff frequency. I performed some tests with a real time analyzer and found that the XACT3 filter frequency was accurate when the source sample rate was 44100Hz. I'm not 100% positive that it's always locked to that sample rate, but I did try setting my Vista Playback Device output to 48000Hz and there was no change in accuracy (thats what I meant by the "filter" sample rate). If it is some how determined by the mastering voice sample rate than you can easily substitute it for that.Anyhow, these various things seem to be working for us. Not sure if anyone else has been able to confirm the bug or not, but any sort of verification would be nice.
  • 3/18/2009 12:40 AM In reply to

    Re: XACT3 Filter Frequency Inconsistency vs. Sample Rate

    How are you using XACT 3 with XNA? I get an error when I try... or are you?


Page 1 of 1 (4 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG