# Dsp\_state-\>functions-\>getsamplerate(dsp\_state, &bitrate) get incorrect sample rate

**URL:** <https://qa.fmod.com/t/dsp-state-functions-getsamplerate-dsp-state-bitrate-get-incorrect-sample-rate/14964>\
**Category:** FMOD Studio\
**Created:** [August 20, 2019, 3:25am UTC](https://qa.fmod.com/t/dsp-state-functions-getsamplerate-dsp-state-bitrate-get-incorrect-sample-rate/14964 "2019-08-20T03:25:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kodywu](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@kodywu](https://qa.fmod.com/u/kodywu)\
**Post date:** [August 20, 2019, 3:25am UTC](https://qa.fmod.com/t/dsp-state-functions-getsamplerate-dsp-state-bitrate-get-incorrect-sample-rate/14964/1 "2019-08-20T03:25:45Z")

</div>

I want to implement a dsp plugin to capture audio data and save wav file, using getsamplerate api to get error 24000(48000 is correct) sample rate

```
FMOD_RESULT F_CALLBACK myDSPCreateCallback(FMOD_DSP_STATE *dsp_state)
{
    unsigned int blocksize;
    int bitrate;
    FMOD_RESULT result;
    
    result = dsp_state->functions->getblocksize(dsp_state, &blocksize);
    ERRCHECK(result);
    
    result = dsp_state->functions->getsamplerate(dsp_state, &bitrate);
    ERRCHECK(result);
    
    mydsp_data_t *data = (mydsp_data_t *)calloc(sizeof(mydsp_data_t), 1);
    if (!data)
    {
        return FMOD_ERR_MEMORY;
    }

    dsp_state->plugindata = data;
    if (g_record) {
        data->record = g_record;
    }
    if (g_bitpersample > 0){
        data->sample_bits = g_bitpersample;
    }
    data->sample_length = blocksize;
    data->sample_rate = bitrate;
    data->buffer = (float *)malloc(blocksize * 8 * sizeof(float));
    if (!data->buffer)
    {
        return FMOD_ERR_MEMORY;
    }
    
    return FMOD_OK;
}
```

---

<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:** [August 21, 2019, 4:23am UTC](https://qa.fmod.com/t/dsp-state-functions-getsamplerate-dsp-state-bitrate-get-incorrect-sample-rate/14964/2 "2019-08-21T04:23:32Z")

</div>

`DSP_state::functions::getsamplerate` should return the same value as `System::getSoftwareFormat` which, if it is on a mobile device will default to 24KHz.
