Discussion:
PlayAudioStream() sample failing
(too old to reply)
dave
2010-01-26 21:48:39 UTC
Permalink
i'm using the PlayAudioStream() sample code

i'm trying to tell it that i need to play PCM audio at 44100 hz (cuz
that's what i've got to feed it)

but when i call IsFormatSupported(), it changes the wFormatTag to 0x03
and the HZ to 48000

how do i deal with that?
dave
2010-01-27 06:19:19 UTC
Permalink
another problem i'm having now, is that (on a different computer),
calling IsFormatSupported() returns 0 (no error), so that means it
will work, right?

but if i then just call

resultL = i_audioClient->Initialize(
AUDCLNT_SHAREMODE_SHARED, 0,
hnsRequestedDuration,
0, i_wfx, NULL);

it returns E_INVALIDARG, indicating i_wfx is a bad format. but it's
not, i just checked. any idea about that?
dave
2010-01-27 07:29:57 UTC
Permalink
okay so wFormatTag == 0x03 is WAVE_FORMAT_IEEE_FLOAT, but i don't have
float samples. i have SInt32 samples.

how do i tell the hardware that this is what i want to feed it?

i mean, okay i *could* do the conversion to float on the fly.

but i have no idea how to convert from 44.1kHz to 48kHz on the fly.

it just seems like i should be telling the hardware what I want to do,
not be forced to do what the hardware wants me to do.
Bob Masta
2010-01-27 13:27:46 UTC
Permalink
On Tue, 26 Jan 2010 23:29:57 -0800 (PST), dave
Post by dave
okay so wFormatTag == 0x03 is WAVE_FORMAT_IEEE_FLOAT, but i don't have
float samples. i have SInt32 samples.
how do i tell the hardware that this is what i want to feed it?
i mean, okay i *could* do the conversion to float on the fly.
but i have no idea how to convert from 44.1kHz to 48kHz on the fly.
it just seems like i should be telling the hardware what I want to do,
not be forced to do what the hardware wants me to do.
I have never used PlayAudioStream, just the
low-level audio API. But it looks like your
problem is that you need wFormatTag = 1 for PCM
audio.

Best regards,


Bob Masta

DAQARTA v5.00
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
Frequency Counter, FREE Signal Generator
Pitch Track, Pitch-to-MIDI
DaqMusic - FREE MUSIC, Forever!
(Some assembly required)
Science (and fun!) with your sound card!
dave
2010-01-27 20:18:18 UTC
Permalink
I have never used PlayAudioStream, just the low-level audio API.  But it looks like your
problem is that you need wFormatTag = 1 for PCM audio.
what i mean is, i'm using the sample code from here:
http://msdn.microsoft.com/en-us/library/dd316756%28VS.85%29.aspx

however, between pAudioClient->GetMixFormat() and pAudioClient-
Initialize(), i am stuffing my own values in to the wfx, because
that's what i've got, (PCM, 16 bit signed int stream), then i call
pAudioClient->IsFormatSupported() and it says "NO" :(

note i'm NOT calling pMySource->SetFormat(pwfx), because my source
format is fixed, so i'm trying to get the audioClient to adapt to me,
not the other way around.

but IsFormatSupported() sez no. so what do i do with that? btw i
figured out the audioClient->Initialize() call, all set with that, i
just had to call CoInitialize().
Alessandro Angeli
2010-01-27 21:20:29 UTC
Permalink
From: "dave"
Post by dave
that's what i've got, (PCM, 16 bit signed int stream),
Before you wrote that your samples are SInt32, not SInt16.
What values are you putting in the WAVEFORMATEX exactly?
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
dave
2010-01-28 20:44:36 UTC
Permalink
sorry, 16bit per channel, so 32 bits for a full sample (stereo)

my wfx wants to look like this:

.wFormatTag = 1
.nChannels = 2
.nSamplesPerSecond = 44100
.nAvgBytesPerSec = 176400
.nBlockAlign = 4
.wBitsPerSample = 16
.cbSize = 0

but when i call IsFormatSupported() it comes back like this:

.wFormatTag = 3
.nChannels = 2
.nSamplesPerSecond = 48000
.nAvgBytesPerSec = 384000
.nBlockAlign = 8
.wBitsPerSample = 32
.cbSize = 22

bummer.

Loading...