src/apu/apu.cc
/*
 * Gets the TND channel output sample.
 */
Gets the TND channel output sample.
Gets the TND channel output sample .
float Apu::GetTndOutput(void) {
  uint32_t t = triangle_->output;
  uint32_t n = noise_->output;
  uint32_t d = dmc_->level;
  uint32_t xtnd_mantissa = (t * 0x18e4c) + (n * 0x10bb0) + (d * 0x90bf);
  union { float f; uint32_t i; } xtnd;
  xtnd.i = (xtnd_mantissa | 0x3F800000U);
  return 1.5979f * (xtnd.f - 1.0f) * Inverse(xtnd.f);
}
float Apu :: GetTndOutput ( void ) { uint32_t t = triangle_ -> output ; uint32_t n = noise_ -> output ; uint32_t d = dmc_ -> level ; uint32_t xtnd_mantissa = ( t * 0x18e4c ) + ( n * 0x10bb0 ) + ( d * 0x90bf ) ; union { float f ; uint32_t i ; } xtnd ; xtnd . i = ( xtnd_mantissa | 0x3F800000U ) ; return 1.5979f * ( xtnd . f - 1.0f ) * Inverse ( xtnd . f ) ; }
Gets the TND channel output sample.
Gets the TND channel output sample .
/*
   * We use fixed point decimal multiplication to quickly obtain
   * the floating point representation of xtnd + 1.0. We set the radix
   * after bit 22, as this allows us to simple or our result with
   * the hex value of the floating point representation of 1.0.
   *
   * Since this avoids a floating point addtion and uses integer multiplication
   * instead of floating point multiplication, it is faster on most systems.
   *
   * This approximation introduces an error of up to 0.5%.
   */