# Question about the pcmreadcallback invoke

**URL:** https://qa.fmod.com/t/question-about-the-pcmreadcallback-invoke/15797
**Category:** FMOD Engine
**Created:** [May 21, 2020, 9:56pm UTC](https://qa.fmod.com/t/question-about-the-pcmreadcallback-invoke/15797 "2020-05-21T21:56:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tezika](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tezika/32/1205_2.png) [@Tezika](https://qa.fmod.com/u/Tezika)
#### Post date: [May 21, 2020, 9:56pm UTC](https://qa.fmod.com/t/question-about-the-pcmreadcallback-invoke/15797/1 "2020-05-21T21:56:06Z")

</div>

Hey all  
I’ve been learning some basic stuff about FMOD(C++ API) now. However, I got stuck in the low-level stuff related to the pcmreadcallback.I supposed to write my sound and channel representation to handle the sound playback, pause, and stop.  
struct CustomSound  
{  
friend struct CustomChannel;  
public:  
CustomSound( const char\* i\_path );  
~CustomSound();  
private:  
U32 m\_samplingRate;  
U16 m\_numChannels;  
U16 m\_bitsPerSample;  
PCM16\* m\_pData;  
U32 m\_count;  
}; // The code for the custom sound representation

struct CustomChannel  
{  
public:  
CustomChannel() : m\_position( 0 ), m\_pSound( nullptr ) {};  
void Play( FMOD\_PG::CustomSound\* i\_pSound );  
void Stop();  
void WriteSoundData( PCM16\* i\_pData, int i\_count );  
inline void SetPaused( bool i\_paused ) { m\_paused = i\_paused; };  
inline bool GetPaused() { return m\_paused; };  
private:  
FMOD\_PG::CustomSound\* m\_pSound;  
int m\_position;  
bool m\_paused;  
}; // The code for the custom channel

I also used the pcmreadcallback to write the PCM data into it through my custom channel.  
FMOD\_RESULT F\_CALLBACK WriteSoundData( FMOD\_SOUND\* i\_pSound, void\* i\_pData, unsigned int i\_length )  
{  
static FMOD\_PG::AudioManager\* pManager = FMOD\_PG::AudioManager::getInstance();  
memset( i\_pData, 0, i\_length );  
FMOD\_PG::PCM16\* pcmData = (FMOD\_PG::PCM16\*)i\_pData;  
int pcmDataCount = i\_length / 2;  
pManager-\>GetCustomChannel()-\>WriteSoundData( pcmData, pcmDataCount );  
return FMOD\_OK;  
} // The code for writing the data through the callback.

My issue is that this callback will only be called when I created the sound with the createinfo once. Regarding the pause function, it seems that there is no way for me to reinvoke the callback and write new PCM data into it. So, I wonder that is there any way I can invoke this callback explicitly? Alternatively, maybe is there anything wrong with my approach?  
Thanks,  
Tezika

---

<div class="post-metadata">

### Author: ![Tezika](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tezika/32/1205_2.png) [@Tezika](https://qa.fmod.com/u/Tezika)
#### Post date: [May 21, 2020, 11:33pm UTC](https://qa.fmod.com/t/question-about-the-pcmreadcallback-invoke/15797/2 "2020-05-21T23:33:48Z")

</div>

I just figured that out! After I replaced the system-\>createSound to system-\>createStream, it would invoke the pcmreadcallback periodically as expected.
