amplitude wrap around

Anders Vinjar anders.vinjar@notam.uio.no
24 Nov 1997 11:47:38 +0100


  LS>  I've noticed that amplitudes of 1.0 in CLM will actually wrap
  LS> around such that for signed word output, the result is -1. I know
  LS> this seems a trivial point, but for my application it is
  LS> catastrophic. Can it be fixed easily? Alternatively where should I
  LS> start looking in the code? 

I guess this stems from the resolution your output-sound-file-format can
give you.  If you use one of the default sound-file-formats,
"16-bit-linear", there are (expt 2 16) = 65536 possible amplitude values
between -1.0 and 1.0.  The next higher amplitude-step is equal to the
lowest one.  (Bill, should there be a headroom here?)

Until you get a qualified answer you can solve the problem in a fast and
very good manner by using the ':scaled-to option in 'with-sound :

        (with-sound (:scaled-to 0.99) ins-list.. )

... will write an intermediate sound-file of your computation, with
higher resolution, keeping track of the maxamp in the whole run, and
finally handing you a file with the desired resolution (16-bit linear)
where the maximum amplitude is 0.99.  

Or else, play with (with-sound (:statistics t) ...) to get the maxamp of
the run, and scale the outputs from all instruments by 0.99 or something
like it.

-anders