Changeset 951

Show
Ignore:
Timestamp:
03/17/08 19:16:43 (16 years ago)
Author:
jwoithe
Message:

MOTU: clip float samples to +/- 1.0 to avoid nasty audio wraparound effects.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r948 r951  
    155155#define MOTU_MAX_CYCLES_TO_TRANSMIT_EARLY                  6 
    156156 
     157// ensure that the MOTU tx SP clips all float values to [-1.0..1.0] 
     158#define MOTU_CLIP_FLOATS                                   1 
     159 
    157160#endif // CONFIG_H 
  • trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp

    r948 r951  
    4848#endif 
    4949 
     50/* Provide more intuitive access to GCC's branch predition built-ins */ 
     51#define likely(x)   __builtin_expect((x),1) 
     52#define unlikely(x) __builtin_expect((x),0) 
     53 
    5054namespace Streaming 
    5155{ 
     
    582586 
    583587                for(j = 0; j < nevents; j += 1) { // decode max nsamples 
    584                     unsigned int v = lrintf(*buffer * multiplier); 
     588                    float in = *buffer; 
     589#if MOTU_CLIP_FLOATS 
     590                    if (unlikely(in > 1.0)) in = 1.0; 
     591                    if (unlikely(in < 1.0)) in = -1.0; 
     592#endif 
     593                    unsigned int v = lrintf(in * multiplier); 
    585594                    *target = (v >> 16) & 0xff; 
    586595                    *(target+1) = (v >> 8) & 0xff;