# Resample Raw Audio Data

**URL:** <https://qa.fmod.com/t/resample-raw-audio-data/14029>\
**Category:** FMOD Engine\
**Created:** [August 2, 2018, 4:34pm UTC](https://qa.fmod.com/t/resample-raw-audio-data/14029 "2018-08-02T16:34:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spirrwell](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Spirrwell](https://qa.fmod.com/u/Spirrwell)\
**Post date:** [August 2, 2018, 4:34pm UTC](https://qa.fmod.com/t/resample-raw-audio-data/14029/1 "2018-08-02T16:34:10Z")

</div>

Hello there!

My goal is to be able to open any of the various audio formats with FMOD, and export raw PCM data at a sample rate of 48 kHz.

It seems I can do mostly that, but I can’t seem to figure out how to resample the audio to be 48 kHz.

`
unsigned int length = 0;
unsigned int read = 0;
pSound->getLength( &length, FMOD_TIMEUNIT_PCMBYTES );
unsigned char *buf = new unsigned char[length];
pSound->readData( buf, length, &read );
std::ofstream file;
file.open( "test.raw", std::ofstream::binary );
file.write( ( const char *)buf, length );
file.close();
`

That’s pretty much it, it’s just a requirement that the output is 48 kHz. Is there any way to do that?

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 5, 2018, 8:51am UTC](https://qa.fmod.com/t/resample-raw-audio-data/14029/2 "2018-08-05T08:51:26Z")

</div>

The only time FMOD will resample audio is during live playback. It is not a format conversion tool.

You can hack around it with things like FMOD\_OUTPUTTYPE\_WAVEWRITER which writes the output of the mix to a wav file, at the rate you set it to (ie 48khz) and you have to use playSound to do it.
