# Get raw PCM data

**URL:** <https://qa.fmod.com/t/get-raw-pcm-data/14933>\
**Category:** FMOD Engine\
**Created:** [August 9, 2019, 3:43pm UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933 "2019-08-09T15:43:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flone](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/flone/32/590_2.png) [@Flone](https://qa.fmod.com/u/Flone)\
**Post date:** [August 9, 2019, 3:43pm UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933/1 "2019-08-09T15:43:03Z")

</div>

Hello, I’m trying to get raw PCM data from MP3 file just by opening the file and calling lock() and unlock() but don’t get any sound when I’m trying to play sound from memory, does lock() even return raw PCM data by just opening the file?

---

<div class="post-metadata">

**Author:** ![Flone](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/flone/32/590_2.png) [@Flone](https://qa.fmod.com/u/Flone)\
**Post date:** [August 15, 2019, 10:07am UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933/2 "2019-08-15T10:07:26Z")

</div>

Found out that Sound::readData does just what I need.

---

<div class="post-metadata">

**Author:** ![nayeem2021](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@nayeem2021](https://qa.fmod.com/u/nayeem2021)\
**Post date:** [June 29, 2024, 2:00am UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933/3 "2024-06-29T02:00:33Z")

</div>

Does really readData() gives PCM data if I createSound() with mp3 file?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [July 2, 2024, 3:42am UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933/4 "2024-07-02T03:42:48Z")

</div>

You are able to get the PCM data from `readData`, we also have an example doing this in our docs [https://www.fmod.com/docs/api/core-guide.html#extracting-pcm-data-from-a-sound](https://www.fmod.com/docs/api/core-guide.html#extracting-pcm-data-from-a-sound).

---

<div class="post-metadata">

**Author:** ![nayeem2021](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@nayeem2021](https://qa.fmod.com/u/nayeem2021)\
**Post date:** [July 7, 2024, 4:03pm UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933/5 "2024-07-07T16:03:06Z")

</div>

I’ve followed this already. If the audio is wav format, I can successfully get the PCM data.  
But if the audio is in mp3 format, I can some data. But I don’t know what that data means.  
Let me clarify a bit. If my audio is a wav file, I could successfully read each sample. I could draw wave from that data.

But if my audio is mp3 file, I can’t read the sample data after doing readData(). I am failing to get at which structure these data are in. I can’t read each sample. I can’t make wave out of it.

Can you help me here?

By wave I mean of what we see in many music player application, on the x-axis time and on y axis amplitude.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [July 9, 2024, 5:19am UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933/6 "2024-07-09T05:19:03Z")

</div>

It could be caused by calling `createSound` with `FMOD_CREATECOMPRESSEDSAMPLE`

Your other thread would be a better place to continue this discussion:

> [@What does lock() really reads](https://qa.fmod.com/t/what-does-lock-really-reads/21816/2):
>
> The format a sound’s data is stored in, and subsequently what format is retrieved by lock(), will depend on the [FMOD\_MODE](https://www.fmod.com/docs/2.02/api/core-api-common.html#fmod_mode) used to create the sound - either PCM data, if the mode decompresses the source audio, or compressed data if a mode like [FMOD\_CREATECOMPRESSEDSAMPLE](https://www.fmod.com/docs/2.02/api/core-api-common.html#fmod_createcompressedsample) is used. A sound’s bit rate/sample rate will depend on the asset used. You can get format info on the sound with [Sound::getFormat](https://www.fmod.com/docs/2.02/api/core-api-sound.html#sound_getformat). However, upon data from the sound being played into the FMOD system, it will be resampled to mat…

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [July 9, 2024, 5:19am UTC](https://qa.fmod.com/t/get-raw-pcm-data/14933/7 "2024-07-09T05:19:08Z")

</div>


