jamoma / jamoma2

A header-only C++ library for building dynamic and reflexive systems with an emphasis on audio and media.
MIT License
30 stars 6 forks source link

Should SampleRate have a lower limit? #61

Closed nwolek closed 8 years ago

nwolek commented 8 years ago

This could save us from having to needlessly and repeatedly check it when using it in division. I might also be nice for the AudioObject to store a variable for 1 over the SampleRate.

https://github.com/jamoma/jamoma2/blob/master/includes/core/JamomaAudioObject.h#L105

If we agree, then what should the lower limit be? My instinct is 1, but I could be convinced otherwise.

tap commented 8 years ago

We could. It defaults to 96K. Where is it being set to 0?

nwolek commented 8 years ago

No where currently. It's just my instincts to be on the lookout for potential divide by zeros. The new algorithm for phasor uses something like this:

mStep = frequency / sampleRate;

That's a problem if the sampleRate could ever be zero. Right now there is nothing to stop it.

tap commented 8 years ago

I think it's a good idea to add both a Range and Limit to that parameter.

Thanks for confirming that we aren't doing something ridiculous somewhere else :-)

nwolek commented 8 years ago

I'll tackle this at some point in the near future.

tap commented 8 years ago

great!