The Trunk: Sound-eem.81.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-eem.81.mcz

commits-2
Eliot Miranda uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-eem.81.mcz

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

Name: Sound-eem.81
Author: eem
Time: 26 May 2021, 12:03:03.709521 pm
UUID: 43c1e089-1145-4a27-b5b8-f35e872fc99a
Ancestors: Sound-eem.80

Better meterFrom:count:in:

=============== Diff against Sound-eem.80 ===============

Item was changed:
  ----- Method: SoundRecorder>>meterFrom:count:in: (in category 'private') -----
  meterFrom: start count: count in: buffer
  "Update the meter level with the maximum signal level in the given range of the given buffer."
 
+ | max sample min |
+ count = 0 ifTrue: [^self].  "no new samples"
+ max := min := 0.
+ start to: start + count - 1 do:
+ [:i |
- | last max sample |
- count = 0 ifTrue: [^ self].  "no new samples"
- last := start + count - 1.
- max := 0.
- start to: last do: [:i |
  sample := buffer at: i.
+ sample > max
+ ifTrue: [max := sample]
+ ifFalse:
+ [sample < min ifTrue: [min := sample]]].
+ meterLevel := max max: min negated!
- sample < 0 ifTrue: [sample := sample negated].
- sample > max ifTrue: [max := sample]].
- meterLevel := max.
- !