Audio Sample Conversion

Audio Sample Conversion

Hi, I'm looking for help creating a function to convert audio samples
from one sample rate to another (22khz to 32khz for example).  I've already
tried the functions built into Visual C++ 6, but it doesn't seem to properly
convert the sample (my wave form looks like little stair-steps instead of
the pure sine wave I sent through it).
Does anyone know of some good sample code I could use to do this?  I've
been searching around the web, but with no luck.

Audio Sample Conversion

Try asking in a newsgroup dedicated to Windows programming.  This is just
the language itself.

>     Hi, I'm looking for help creating a function to convert audio samples
> from one sample rate to another (22khz to 32khz for example).  I've
> tried the functions built into Visual C++ 6, but it doesn't seem to
properly
> convert the sample (my wave form looks like little stair-steps instead of
> the pure sine wave I sent through it).
>     Does anyone know of some good sample code I could use to do this?
I've
> been searching around the web, but with no luck.

dashes)

Audio Sample Conversion

In general, the task of sample rate conversion requires interpolating the
original data stream (adding zero-value samples), filtering and then
decimating the result.  For your example (22 kHz -> 32 kHz), you would have
to upsample (interpolate) by a factor of 16 and then downsample (decimate)
by a factor of 11.  Doing this successfully requires some knowledge of DSP
techniques.

I don't know offhand of a source for a function that would fit your
particular case.  Much would depend on your specific requirements.  If you
are interested in pursuing this further, I did a Google search on "sample
rate conversion" and got 123,000 hits, so you might want to look there.

Bob Howe

>     Hi, I'm looking for help creating a function to convert audio samples
> from one sample rate to another (22khz to 32khz for example).  I've
> tried the functions built into Visual C++ 6, but it doesn't seem to
properly
> convert the sample (my wave form looks like little stair-steps instead of
> the pure sine wave I sent through it).
>     Does anyone know of some good sample code I could use to do this?
I've
> been searching around the web, but with no luck.

dashes)

In the DirectShow, the raw data(video frame, audio
samples) are parsed into a COM object called "media
samples" and delivered from the output pin of the source
filter to the input pin of the downstream filter. A media
sample object containing video data holds the data for one
video frame. For audio, a media sample object holds the
data for SEVERAL audio samples.

My question is, how can I set the audio sample number for
each audio media sample object? For example, each audio
media sample object contains exactly 10ms's audio samples?
The default is wrapping 500ms's audio samples (I guess) to
one object, which introduces extra latency if delivered to
Internet.