[squeak-dev] The Trunk: Sound-nice.69.mcz

commits at source.squeak.org commits at source.squeak.org
Sun May 10 16:23:47 UTC 2020


Nicolas Cellier uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-nice.69.mcz

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

Name: Sound-nice.69
Author: nice
Time: 10 May 2020, 6:23:44.99374 pm
UUID: 9ac78f43-a8a1-40c2-a03c-1015a62cb643
Ancestors: Sound-dtl.68

Use Float32Array explicitely

=============== Diff against Sound-dtl.68 ===============

Item was changed:
  ----- Method: FFT>>initializeHammingWindow: (in category 'bulk processing') -----
  initializeHammingWindow: alpha
  	"Initialize the windowing function to the generalized Hamming window. See F. Richard Moore, Elements of Computer Music, p. 100. An alpha of 0.54 gives the Hamming window, 0.5 gives the hanning window."
  
  	| v midPoint |
+ 	window := Float32Array new: n.
- 	window := FloatArray new: n.
  	midPoint := (n + 1) / 2.0.
  	1 to: n do: [:i |
  		v := alpha + ((1.0 - alpha) * (2.0 * Float pi * ((i - midPoint) / n)) cos).
  		window at: i put: v].
  
  !

Item was changed:
  ----- Method: FFT>>initializeTriangularWindow (in category 'bulk processing') -----
  initializeTriangularWindow
  	"Initialize the windowing function to the triangular, or Parzen, window. See F. Richard Moore, Elements of Computer Music, p. 100."
  
  	| v |
+ 	window := Float32Array new: n.
- 	window := FloatArray new: n.
  	0 to: (n // 2) - 1 do: [:i |
  		v := i / ((n // 2) - 1).
  		window at: (i + 1) put: v.
  		window at: (n - i) put: v].
  !

Item was changed:
  ----- Method: FFT>>pluginPrepareData (in category 'plugin-testing') -----
  pluginPrepareData
  	"The FFT plugin requires data to be represented in WordArrays or FloatArrays"
+ 	sinTable := sinTable asFloat32Array.
- 	sinTable := sinTable asFloatArray.
  	permTable := permTable asWordArray.
+ 	realData := realData asFloat32Array.
+ 	imagData := imagData asFloat32Array.!
- 	realData := realData asFloatArray.
- 	imagData := imagData asFloatArray.!

Item was changed:
  ----- Method: FFT>>setSize: (in category 'bulk processing') -----
  setSize: anIntegerPowerOfTwo
  	"Initialize variables and tables for performing an FFT on the given number of samples. The number of samples must be an integral power of two (e.g. 1024). Prepare data for use with the fast primitive."
  
  	self nu: (anIntegerPowerOfTwo log: 2) asInteger.
  	n = anIntegerPowerOfTwo ifFalse: [self error: 'size must be a power of two'].
+ 	sinTable := sinTable asFloat32Array.
- 	sinTable := sinTable asFloatArray.
  	permTable := permTable asWordArray.
+ 	realData := Float32Array new: n.
+ 	imagData := Float32Array new: n.
- 	realData := FloatArray new: n.
- 	imagData := FloatArray new: n.
  	self initializeHammingWindow: 0.54.  "0.54 for Hamming, 0.5 for hanning"
  !

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 := Float32Array new: n.
- 	imagData := FloatArray new: n.
  	self transformForward: 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
  !



More information about the Squeak-dev mailing list