The Trunk: Sound-ul.20.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Sound-ul.20.mcz

commits-2
Levente Uzonyi uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-ul.20.mcz

==================== Summary ====================

Name: Sound-ul.20
Author: ul
Time: 3 August 2010, 4:01:13.3 pm
UUID: 24415f7e-d674-f643-a087-a03906092306
Ancestors: Sound-ar.19

- FFT >> #transformForward: now uses FFTPlugin
- use #transformForward: instead of #pluginTransformData:

=============== Diff against Sound-ar.19 ===============

Item was changed:
  ----- Method: FFT>>transformForward: (in category 'transforming') -----
  transformForward: forward
  | lev lev1 ip theta realU imagU realT imagT i |
+ <primitive: 'primitiveFFTTransformData' module: 'FFTPlugin'>
  self permuteData.
  1 to: nu do:
  [:level |
  lev := 1 bitShift: level.
  lev1 := lev // 2.
  1 to: lev1 do:
  [:j |
  theta := j-1 * (n // lev).   "pi * (j-1) / lev1 mapped onto 0..n/2"
  theta < (n//4)  "Compute U, the complex multiplier for each level"
  ifTrue:
  [realU := sinTable at: sinTable size - theta.
  imagU := sinTable at: theta + 1]
  ifFalse:
  [realU := (sinTable at: theta - (n//4) + 1) negated.
  imagU := sinTable at: (n//2) - theta + 1].
  forward ifFalse: [imagU := imagU negated].
  "
  Here is the inner loop...
  j to: n by: lev do:
  [:i |   hand-transformed to whileTrue...
  "
  i := j.
  [i <= n] whileTrue:
  [ip := i + lev1.
  realT := ((realData at: ip) * realU) - ((imagData at: ip) * imagU).
  imagT := ((realData at: ip) * imagU) + ((imagData at: ip) * realU).
  realData at: ip put: (realData at: i) - realT.
  imagData at: ip put: (imagData at: i) - imagT.
  realData at: i put: (realData at: i) + realT.
  imagData at: i put: (imagData at: i) + imagT.
  i := i + lev]]].
  forward ifFalse: [self scaleData]  "Reverse transform must scale to be an inverse"!

Item was changed:
  ----- Method: FFT>>transformDataFrom:startingAt: (in category 'bulk processing') -----
  transformDataFrom: anIndexableCollection startingAt: index
  "Forward transform a block of real data taken from from the given indexable collection starting at the given index. Answer a block of values representing the normalized magnitudes of the frequency components."
 
  | j real imag out |
  j := 0.
  index to: index + n - 1 do: [:i |
  realData at: (j := j + 1) put: (anIndexableCollection at: i)].
  realData *= window.
  imagData := FloatArray new: n.
+ self transformForward: true.
- self pluginTransformData: true.
 
  "compute the magnitudes of the complex results"
  "note: the results are in bottom half; the upper half is just its mirror image"
  real := realData copyFrom: 1 to: (n / 2).
  imag := imagData copyFrom: 1 to: (n / 2).
  out := (real * real) + (imag * imag).
  1 to: out size do: [:i | out at: i put: (out at: i) sqrt].
  ^ out
  !