-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample rates #13
Comments
Hi @steeley, thanks for the suggestion. Can you provide an example of how you think the API should look for this? Just a code snippet or something to show what you have in mind :) |
Maybe: ofxAudioUnit.setSampleRate(48000); Based on:
|
Yeah at first glance that's what makes sense, but the problem really is that audio units have to work together to support non-default sample rates. So, you'd have to set the sample rate on all of your audio units individually, or drill down to the input / output busses explicitly (e.g. For example, if you had a chain of audiounits A -> B-> C, and you wanted to set C's sample rate to 48000, you'd have to do it on B as well, which means you'd have to do it on A.. Maybe it'd make sense to be able to operate on the whole graph at once, via the output unit. So you set the output unit's sample rate, and it will traverse the graph "backwards" to set the sample rates on all of the units that are attached to it. This might be overthinking it though :) I'll take a stab at adding just the simple version you proposed since it's fairly straightforward. |
Good point - I guess the ideal way is to set it on the output as you say. |
What if we have a static function* ofxAudioUnitSetSampleRate(int On Thu, Dec 5, 2013 at 4:19 PM, steeley [email protected] wrote:
Jason Levine |
@jasonlevine that would be pretty convenient, but I'm against having magic statics like that can lead to some pretty weird and unintuitive behaviour in edge cases (like if you had > 1 graph in an app, for instance). I think setting the output's sample rate, and having that traverse backwards over the connected units setting the sample rate as it goes makes sense. I'd think most people would be thinking something like "I want to render at 96000 Hz", in which case it'd be pretty intuitive to set it at the output. There should probably also be a special case for setting the sample rate of an input device as well. .. Actually, in that case there'd probably need to be an internal AUConverter in the ofxAudioUnitInput that can handle the sample rate conversion in the very likely scenario that the input and output units in a graph aren't operating at the same sample rate. So, basically, this is a bit more complex than just wrapping the |
So the problem is that someone might have two AUGraphs with different sampling rates? |
The problem is that having a global variable like that opens the door to unintuitive "magic" behaviour, and is just generally bad form if there are other options available. It's also not as simple as just having a single static With the "set it at the output" function, all of this isn't necessary since the output will have access to all of the units connected to it (recursively going backwards through the connected units). Anyway, I'm not veto-ing the static global solution, but I'd really rather not start introducing global functionality if it can be avoided. It might turn out that there's some gotcha with "set it at the output", in which case I'll take a look at the magic global way. My gut instinct is that the global solution will have waaay more subtle gotchas, though :) |
I guess the other thing to consider is that the sample rate could be set by default to whatever the AudioMIDI setup--> sound settings are. |
needs to support sample rates other than 44100
The text was updated successfully, but these errors were encountered: