# Audio Unit wrong sample rate in NI Maschine

**URL:** <https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521>\
**Category:** Audio Plugins\
**Created:** [March 27, 2017, 7:31am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521 "2017-03-27T07:31:10Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrickkunz](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@patrickkunz](https://forum.juce.com/u/patrickkunz)\
**Post date:** [March 27, 2017, 7:31am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/1 "2017-03-27T07:31:10Z")

</div>

I’m using JUCE 4.3. Some users reported that the Audio Unit of our plug-in instruments are detuned in Machine 2.6. I think that they work with the wrong sample rate, because the users work with 48000Hz and the pitch is around a semitone higher, but not exactly.  
The VST works fine. We update the sample rate in the process block (getSampleRate()) and we don’t have any issues in other hosts.

Anyone noticed the same?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [March 27, 2017, 8:05am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/2 "2017-03-27T08:05:31Z")

</div>

We’ve not had any similar reports.

I’m curious why you’re updating the sample rate in your process block, rather than using the sample rate provided to `prepareToPlay`. Have you found situations where this was required?

---

<div class="post-metadata">

**Author:** ![patrickkunz](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@patrickkunz](https://forum.juce.com/u/patrickkunz)\
**Post date:** [March 27, 2017, 8:13am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/3 "2017-03-27T08:13:51Z")

</div>

Thanks for the fast response. I do this the last 10 years 🙂 It was recommended a few years back. Always thought that getSampleRate() returns the actual used sample rate. I will try to use the sample rate from prepareToPlay.

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [March 27, 2017, 8:20am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/4 "2017-03-27T08:20:59Z")

</div>

Getting the sample rate in `processBlock` should work correctly; I just wanted to find out if you were working around a specific problem that we might be unaware of.

---

<div class="post-metadata">

**Author:** ![patrickkunz](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@patrickkunz](https://forum.juce.com/u/patrickkunz)\
**Post date:** [March 27, 2017, 9:35am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/5 "2017-03-27T09:35:12Z")

</div>

I don’t have a machine 2.6 installed, so i can’t reproduce it at the moment. Not sure if all users are affected, but it seems that it wasn’t an issue the last years. Maybe it has to do with the latest Maschine update.  
Does JUCE always have the same sample rate reported in prepareToPlay or do they have different sources and can they be different?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [March 27, 2017, 10:14am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/6 "2017-03-27T10:14:53Z")

</div>

It’s possible that they could be different, but I’m fairly confident that JUCE users would have reported that before now.

---

<div class="post-metadata">

**Author:** ![patrickkunz](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@patrickkunz](https://forum.juce.com/u/patrickkunz)\
**Post date:** [March 27, 2017, 3:01pm UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/7 "2017-03-27T15:01:48Z")

</div>

Not sure, maybe most users set the sample rate in prepareToPlay… i will try to find out more about it.

---

<div class="post-metadata">

**Author:** ![patrickkunz](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@patrickkunz](https://forum.juce.com/u/patrickkunz)\
**Post date:** [March 28, 2017, 6:38am UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/8 "2017-03-28T06:38:22Z")

</div>

Moving the sample rate code into prepareToPlay didn’t help. The AU tuning is still off. I just wonder how it can be that in two user reports the Audio Unit is detuned and the VST not… i have to get maschine and test it by myself.

---

<div class="post-metadata">

**Author:** ![patrickkunz](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@patrickkunz](https://forum.juce.com/u/patrickkunz)\
**Post date:** [May 9, 2017, 3:57pm UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/9 "2017-05-09T15:57:26Z")

</div>

I had time to reproduce the issue by myself installing the maschine 2 demo.  
The JUCE framework delivers the wrong sample rate with the AU instruments. It’s always 44100Hz. The debugger shows that

`GetOutput(0)->GetStreamFormat().mSampleRate`

always returns 44100Hz in my AU instrument plugins. Didn’t check the FX. The bus configuration of my plugins is the simple `{2, 2}` config. It works in other hosts. Any help is welcome!

---

<div class="post-metadata">

**Author:** ![samuel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/samuel/32/21_2.png) [@samuel](https://forum.juce.com/u/samuel)\
**Post date:** [May 9, 2017, 4:35pm UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/10 "2017-05-09T16:35:26Z")

</div>

Maybe Machine 2 is reporting the wrong (fixed 44.1kHz) sample rate to AU plugins. IIRC NI Reaktor is a non-JUCE based plugin that reports the sample rate provided by the host. Use Reaktor to figure out if Machine 2 reports the correct sample rate.

Audacity is a host that reports the wrong sample rate to plugins, by the way. [https://www.klangfreund.com/support/lufsmeter/manual/#troubleshooting\_audacity\_sample\_rate](https://www.klangfreund.com/support/lufsmeter/manual/#troubleshooting_audacity_sample_rate)

---

<div class="post-metadata">

**Author:** ![patrickkunz](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@patrickkunz](https://forum.juce.com/u/patrickkunz)\
**Post date:** [May 9, 2017, 5:47pm UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/11 "2017-05-09T17:47:25Z")

</div>

Hi Samuel

Thanks for pointing me into the right direction, I already have an open bug report at NI since a few weeks.  
Don’t have reactor to test it, but what could be better than using apples AU plugins and AUSampler also have the same issue, while DLSMusicDevice works and changes the sample rate. I have reported this new infos and hope NI will fix that.

---

<div class="post-metadata">

**Author:** ![jpo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jpo/32/503_2.png) [@jpo](https://forum.juce.com/u/jpo)\
**Post date:** [November 25, 2019, 3:50pm UTC](https://forum.juce.com/t/audio-unit-wrong-sample-rate-in-ni-maschine/21521/12 "2019-11-25T15:50:21Z")

</div>

I just got the same issue reported by a user, and I can reproduce it with the latest juce develop version with the AudioPluginDemo, and Maschine 2.9.0.

Maschine is configure for a 48kHz sample rate, so the AU plugin should be running at 48kHz, but its prepareToPlay is always be called with 44kHz as the sample rate. The VST plugin receives the correct sample rate.

Also, older versions of my AU plugin (build with JUCE v3) run fine, with the correct sample rate. Maybe it is a problem with the CoreAudioUtilityClasses embedded with juce.
