| 101 | } |
| 102 | |
| 103 | float OversamplesCalculator::tickInterval( float frame, int &tickLow, int &tickHigh ) const |
| 104 | { |
| 105 | float step = ( float )m_ticksPerSecond / ( m_frameRate * m_samplesPerFrame ); |
| 106 | |
| 107 | float tickF = frame * m_ticksPerSecond / m_frameRate ; |
| 108 | int tick = ( int )( tickF ); |
| 109 | |
| 110 | float tickLowF = ( float )tick - fmod(( float )tick,step ); |
| 111 | float tickHighF = tickLowF + step; |
| 112 | |
| 113 | /// Due to rounding errors we might find that our low/high bound does not actually bracket the tick. Correct |
| 114 | /// for that here. |
| 115 | if ( tick > ( int )tickHighF ) |
| 116 | { |
| 117 | tickLowF += step; |
| 118 | tickHighF += step; |
| 119 | } |
| 120 | if ( tick < ( int )tickLowF ) |
| 121 | { |
| 122 | tickLowF -= step; |
| 123 | tickHighF -= step; |
| 124 | } |
| 125 | tickLow = int( tickLowF ); |
| 126 | tickHigh = int( tickHighF ); |
| 127 | assert( tick >= tickLow ); |
| 128 | assert( tick <= tickHigh ); |
| 129 | |
| 130 | float x = ( float )( tickF - tickLowF ) / ( float )( tickHigh - tickLowF ); |
| 131 | return x; |
| 132 | } |