Skip to content

Commit

Permalink
Added template setFreq(UFixMath<NI,NF>) for other UFix. Falls back to…
Browse files Browse the repository at this point in the history
… UFixMath<16,16>
  • Loading branch information
tomcombriat committed Dec 19, 2023
1 parent 73273a5 commit 179d057
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Oscil.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,20 @@ class Oscil
{
setFreq_Q16n16(frequency.asRaw());
}


/** Set the frequency using UFixMath<NI,NF> fixed-point number format. This falls back to using UFixMath<16,16> internally and is provided as a fallout for other UFixMath types. If possible try to use directly UFixMath<16,16> or UFixMath<24,8> for well defined (and well tested) behaviors.
@note This should work OK with tables 2048 cells or smaller and
frequencies up to 4096 Hz. Can't be used with UPDATE_RATE less than 64 Hz.
@note This didn't run faster than float last time it was tested, after 2014 code changes. Need to see if 2014 changes improved or worsened performance.
@param frequency in UFixMath<16,16> fixed-point number format.
*/
template <byte NI, byte NF>
inline
void setFreq(UFixMath<NI,NF> frequency)
{
setFreq_Q16n16(UFixMath<16,16>(frequency).asRaw());
}

/*
inline
Expand Down

0 comments on commit 179d057

Please sign in to comment.