# Output samplerate of NOSOUND output type system

**URL:** <https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946>\
**Category:** FMOD Engine\
**Created:** [August 15, 2019, 9:59am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946 "2019-08-15T09:59:48Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [August 15, 2019, 9:59am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/1 "2019-08-15T09:59:48Z")

</div>

Is the only available builtin way of telling FMOD what samplerate to use to play a sound when initialized with NOSOUND flag just ‘setSoftwareFormat’ ?  
(was looking among available DSP types, but there doesn’t seem to be one :/)

– I’m capturing decoder output via custom DSP, but the samplerate of media might differ from system output, which is a problem when NOSOUND outputtype is used as well –

Thank you !

---

<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:09am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/2 "2019-08-21T04:09:40Z")

</div>

Have you had a look at `DSP_GETSAMPLERATE_FUNC` in [`FMOD_DSP_STATE_FUNCTIONS`](https://www.fmod.com/resources/documentation-api?version=2.0&page=plugin-api-dsp.html#fmod_dsp_state_functions)?

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [August 21, 2019, 5:09am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/3 "2019-08-21T05:09:21Z")

</div>

Thank you, but I’m not sure I’m following, I should have probably described this more:

- If I play 44.1 kHz media on a 48 kHz output directly via playSound with normal/common system I get correct playback
- If I play the same with a NRT system with simplest capture DSP added which just passes its read callback buffer to the output  
(it’s being played by entirely different/unity’s sytem via its pcmreadcallback - if I use readData to feed unity pcmreadcallback with NRT system the output sounds as expected, too), I get playback which is not upmixed to 48 kHz - so pitched down

(I can e.g. compensate by setting pitch of the channel to the ‘output samplerate/media’ ratio, but this is not ideal as it accumulates buffer over time)

I should have probably mentioned that I’m using setFileSystem and filesystem callback/s too to feed FMOD sound with encoded data - maybe that plays a role  
(but the same file system callbacks are used with RT version, so I’m not entirely sure /)

So if anything I would need something like DSP\_SETSAMPLERATE\_FUNC, I am not sure how getting samplerate would help me, but maybe I’m missing something!

I hope it makes more sense now

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [August 22, 2019, 5:43am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/4 "2019-08-22T05:43:43Z")

</div>

[ just a small followup: NOSOUND, and NOSOUND\_NRT systems behave the same with attached passthru DSP - i.e. they keep original media samplerate when played on 48 kHz output - so N/RT part is consistent, just NO/SOUND part seems to be ignoring output rate - which is logical in its own way : just the original question with ‘setSoftwareFormat’ stands -  
seems like it will have to be done that way ~/ ]

---

<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 23, 2019, 4:07am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/5 "2019-08-23T04:07:20Z")

</div>

`setSoftwareFormat` is always the way to set the rate that the system runs at. NoSound/WavWriter will always accept the system rate, other output plugins may request a downmix.

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [August 23, 2019, 6:38am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/6 "2019-08-23T06:38:15Z")

</div>

Thank you!

The NoSound/WavWriter system is running at system rate

– if I use sound.readData with it, the audio output is correct (sound is not being played)  
but since no channel is being active in this case this, it’s a bit uncomfortable to work with, so I tried to add simple capture DSP to forward its output, and play it, so

– if I use minimal capture DSP to forward PCM data, the audio is downmixed to media rate on the final output

If I create a system with setSoftwareFormat with media rate instead, it works correctly with the capture DSP, too.

– hence my initial question and searching for a way to tell FMOD to upmix the signal from media rate to something else, if possible

I’m not sure this is correct/intended behavior, but if yes I was looking for ‘upmix’ DSP, which probably doesn’t exist - since because setSoftwareFormat needs to be called before init I’d have to create a new system for media if its rate differs from system rate, which is bit uncomfortable, but not impossible ) - to work with.

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [August 23, 2019, 7:17am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/7 "2019-08-23T07:17:51Z")

</div>

AH! looking at `DSP_GETSAMPLERATE_FUNC` - setting rate in a callback _would make sense_ but I see no way of using it mainly because DSP\_STATE\_FUNCTIONS members are not public in the c# wrapper, and manually exposing DSP\_GETSAMPLERATE\_FUNC and setting it to custom callback didn’t seem to do anything though (callback is not being called)

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [August 30, 2019, 8:45am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/8 "2019-08-30T08:45:40Z")

</div>

may I bump this ?  
Still would like to know what’s the correct approach/behavior with this  
Thanks !

---

<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:** [September 2, 2019, 3:32am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/9 "2019-09-02T03:32:24Z")

</div>

The `DSP_STATE_FUNCTIONS` cannot be set, but instead should be called to access them. Although there are a couple of issues in the way when trying to do this in the C# wrapper. As you mentioned the `DSP_STATE_FUNCTIONS` members need to be public, and the struct itself needs to be marshaled from the DSP State.

You can then access these through the [`DSP_STATE`](https://www.fmod.com/resources/documentation-api?version=2.0&page=plugin-api-dsp.html#fmod_dsp_state) which is available in any of the DSP Callbacks.  
Once you have the state you can access the `DSP_STATE_FUNCTIONS`.

```auto
...
FMOD.DSP_STATE_FUNCTIONS functions = (FMOD.DSP_STATE_FUNCTIONS)Marshal.PtrToStructure(dsp_state.functions, typeof(FMOD.DSP_STATE_FUNCTIONS));
functions.getsamplerate(ref dsp_state, ref rate);
...

```

You will need to make the functions public yourself for now, but I have added a task to fix this in an upcoming release.

We have plans to improve the usability of the DSP Plugin API in C# by doing more of the Marshaling in the wrapper, but this is a longer term task.

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [September 2, 2019, 7:20am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/10 "2019-09-02T07:20:07Z")

</div>

getting the samplerate from DSP\_STATE\_FUNCTION is not a problem  
( if a system is created with system ( e.g. 48000 ) rate, the DSP\_STATE (correctly) returns 48000 )

- the problem is the final audio is still being played in wrong rate - pitched down - as if upmix from 44100 (media rate) to 48000 was missing somewhere  
… I just verbatim copy out the buffer in DSP\_READCALLBACK

- if I use readData on an opened sound with the same (48000) system, the playback is correct however

Do you want me to create reproduction project ?

---

<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:** [September 4, 2019, 5:16am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/11 "2019-09-04T05:16:41Z")

</div>

Getting a reproduction would be the best bet at this point.

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [September 6, 2019, 12:00am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/12 "2019-09-06T00:00:38Z")

</div>

It’s done, I referenced this thread in the email  
Thank you for having a look and for your community support

[I just hope I didn’t perform something extremely dumb ), - but since readData works correctly and systems are identical otherwise, reaching out to forums seemed like a good idea 🙂]

---

<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:** [September 6, 2019, 1:12am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/13 "2019-09-06T01:12:46Z")

</div>

Thanks very much for the repro, made things much clearer.

When you open a sound through `ReadData`, it does not get added to the DSP graph and the sample rate is the sample rate of the data in the file (in this case 44100).

Whereas when using a Capture DSP, when the sound is created in FMOD it is converted to the system sample rate. At that point there isn’t a way to get the source files sample rate, and it doesn’t matter because it is now the same as the system’s. So then the issue was when you were trying to create an AudioClip with a samplerate of 44100 instead of 48000.

---

<div class="post-metadata">

**Author:** ![r618](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/r618/32/36_2.png) [@r618](https://qa.fmod.com/u/r618)\
**Post date:** [September 6, 2019, 1:30am UTC](https://qa.fmod.com/t/output-samplerate-of-nosound-output-type-system/14946/14 "2019-09-06T01:30:43Z")

</div>

AHH! Brilliant ! Thank you very much for having a look !  
I should have been more careful - I’m _so_ glad that you could figure it out without problems 😃  
Thanks a TON - I can proceed now with standalone completely independent decoder, which is great !  
Cheers & thanks for awesome community support !
