Karl Ramberg uploaded a new version of MorphicExtras to project Etoys:
http://source.squeak.org/etoys/MorphicExtras-kfr.78.mcz==================== Summary ====================
Name: MorphicExtras-kfr.78
Author: kfr
Time: 16 February 2013, 10:41:28 pm
UUID: 6eca10ef-24bd-664b-be0a-a4d727ea7de6
Ancestors: MorphicExtras-kfr.77
Fix playing between cursor position and a given position
=============== Diff against MorphicExtras-kfr.77 ===============
Item was changed:
----- Method: GraphMorph>>playOnce (in category 'commands') -----
playOnce
| scale absV scaledData |
data isEmpty ifTrue: [^ self]. "nothing to play"
scale _ 1.
data do: [:v | (absV _ v abs) > scale ifTrue: [scale _ absV]].
scale _ 32767.0 / scale.
scaledData _ SoundBuffer newMonoSampleCount: data size.
+ 1 to: data size do: [:i | scaledData at: i put: (scale * (data at: i)) truncated].
+ SoundService default playSampledSound: scaledData rate: 11025.
- cursor to: data size do: [:i | scaledData at: i put: (scale * (data at: i)) truncated].
- SoundService default playSampledSound: scaledData rate: samplingRate.
!
Item was changed:
----- Method: GraphMorph>>playOnce: (in category 'commands') -----
+ playOnce: aSampleNumber
+ | scale absV scaledData sampleNumber |
+ sampleNumber := aSampleNumber.
+ data isEmpty
+ ifTrue: [^ self]. "nothing to play"
+ sampleNumber < cursor ifTrue: [^ self].
+ scale := 1.
+ data
+ do: [:v | (absV := v abs) > scale
+ ifTrue: [scale := absV]].
+ scale := 32767.0 / scale.
+ scaledData := SoundBuffer newMonoSampleCount: sampleNumber - cursor.
+ 1
+ to: sampleNumber - cursor
+ do: [:i | scaledData at: i put: (scale
+ * (data
+ at: (i + cursor min: data size max: 1))) truncated].
+ SoundService default playSampledSound: scaledData rate: samplingRate!
- playOnce: aSampleNumber
-
- | scale absV scaledData |
- data isEmpty ifTrue: [^ self]. "nothing to play"
- scale _ 1.
- data do: [:v | (absV _ v abs) > scale ifTrue: [scale _ absV]].
- scale _ 32767.0 / scale.
- scaledData _ SoundBuffer newMonoSampleCount: data size.
- cursor to: aSampleNumber do: [:i | scaledData at: i put: (scale * (data at: i)) truncated].
- SoundService default playSampledSound: scaledData rate: samplingRate.
- !
_______________________________________________
etoys-dev mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/etoys-dev