The Inbox: Sound-dtl.68.mcz

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

The Inbox: Sound-dtl.68.mcz

commits-2
David T. Lewis uploaded a new version of Sound to project The Inbox:
http://source.squeak.org/inbox/Sound-dtl.68.mcz

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

Name: Sound-dtl.68
Author: dtl
Time: 12 December 2019, 7:20:38.226903 am
UUID: c7b5a141-2b1b-4d24-ab88-0a96dd78600b
Ancestors: Sound-dtl.67

Resolve unimplemented calls in the previous update.
Discussion on squeak-dev http://lists.squeakfoundation.org/pipermail/squeak-dev/2019-December/205515.html

=============== Diff against Sound-dtl.67 ===============

Item was changed:
  ----- Method: AbstractSound>>loudness (in category 'volume') -----
  loudness
  "Answer the current volume setting for this sound."
 
+ ^ envelopes detect: [:e | e isKindOf: VolumeEnvelope]
+ ifFound: [ :envelope | envelope scale ]
+ ifNone: [scaledVol asFloat / FloatScaleFactor]
+ !
- self hasVolumeEnvelope ifTrue: [^ self volumeEnvelope scale].
-
- ^ scaledVol asFloat / ScaleFactor!

Item was changed:
  ----- Method: SequentialSound>>mixSampleCount:into:startingAt:leftVol:rightVol: (in category 'sound generation') -----
  mixSampleCount: n into: aSoundBuffer startingAt: startIndex leftVol: leftVol rightVol: rightVol
  "Play a collection of sounds in sequence."
  "PluckedSound chromaticScale play"
 
  | finalIndex i snd remaining count leftScaledVol rightScaledVol |
  currentIndex = 0 ifTrue: [^ self].  "already done"
 
+ leftScaledVol := leftVol * scaledVol / ScaleFactor asFloat.
+ rightScaledVol := rightVol * scaledVol / ScaleFactor asFloat.
- leftScaledVol := leftVol * scaledVol /// ScaleFactor.
- rightScaledVol := rightVol * scaledVol /// ScaleFactor.
 
  finalIndex := (startIndex + n) - 1.
  i := startIndex.
  [i <= finalIndex] whileTrue: [
  snd := (sounds at: currentIndex).
  [(remaining := snd samplesRemaining) <= 0] whileTrue: [
  "find next undone sound"
  currentIndex < sounds size
  ifTrue: [
  currentIndex := currentIndex + 1.
  snd := (sounds at: currentIndex)]
  ifFalse: [
  currentIndex := 0.
  ^ self]].  "no more sounds"
  count := (finalIndex - i) + 1.
  remaining < count ifTrue: [count := remaining].
  snd mixSampleCount: count into: aSoundBuffer startingAt: i
  leftVol: leftScaledVol
  rightVol: rightScaledVol.
  i := i + count].
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Sound-dtl.68.mcz

marcel.taeumel
Hi Dave,

+1 for 5.3

Best,
Marcel

Am 12.12.2019 13:20:46 schrieb [hidden email] <[hidden email]>:

David T. Lewis uploaded a new version of Sound to project The Inbox:
http://source.squeak.org/inbox/Sound-dtl.68.mcz

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

Name: Sound-dtl.68
Author: dtl
Time: 12 December 2019, 7:20:38.226903 am
UUID: c7b5a141-2b1b-4d24-ab88-0a96dd78600b
Ancestors: Sound-dtl.67

Resolve unimplemented calls in the previous update.
Discussion on squeak-dev http://lists.squeakfoundation.org/pipermail/squeak-dev/2019-December/205515.html

=============== Diff against Sound-dtl.67 ===============

Item was changed:
----- Method: AbstractSound>>loudness (in category 'volume') -----
loudness
"Answer the current volume setting for this sound."

+ ^ envelopes detect: [:e | e isKindOf: VolumeEnvelope]
+ ifFound: [ :envelope | envelope scale ]
+ ifNone: [scaledVol asFloat / FloatScaleFactor]
+ !
- self hasVolumeEnvelope ifTrue: [^ self volumeEnvelope scale].
-
- ^ scaledVol asFloat / ScaleFactor!

Item was changed:
----- Method: SequentialSound>>mixSampleCount:into:startingAt:leftVol:rightVol: (in category 'sound generation') -----
mixSampleCount: n into: aSoundBuffer startingAt: startIndex leftVol: leftVol rightVol: rightVol
"Play a collection of sounds in sequence."
"PluckedSound chromaticScale play"

| finalIndex i snd remaining count leftScaledVol rightScaledVol |
currentIndex = 0 ifTrue: [^ self]. "already done"

+ leftScaledVol := leftVol * scaledVol / ScaleFactor asFloat.
+ rightScaledVol := rightVol * scaledVol / ScaleFactor asFloat.
- leftScaledVol := leftVol * scaledVol /// ScaleFactor.
- rightScaledVol := rightVol * scaledVol /// ScaleFactor.

finalIndex := (startIndex + n) - 1.
i := startIndex.
[i <= finalindex]="" whiletrue:="">
snd := (sounds at: currentIndex).
[(remaining := snd samplesRemaining) <= 0]="" whiletrue:="">
"find next undone sound"
currentIndex < sounds="">
ifTrue: [
currentIndex := currentIndex + 1.
snd := (sounds at: currentIndex)]
ifFalse: [
currentIndex := 0.
^ self]]. "no more sounds"
count := (finalIndex - i) + 1.
remaining < count="" iftrue:="" [count="" :="">
snd mixSampleCount: count into: aSoundBuffer startingAt: i
leftVol: leftScaledVol
rightVol: rightScaledVol.
i := i + count].
!




Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Sound-dtl.68.mcz

David T. Lewis
In reply to this post by commits-2
This resolves the unimplemented calls. Levente has offered a couple
of additional suggestions that I did not include:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2019-December/205532.html

I have not tested this functionally, I am just collecting the updates
to get them into the inbox. They look right, but if someone can please
confirm that they work properly that would be appreciated.

Dave

On Thu, Dec 12, 2019 at 12:20:39PM +0000, [hidden email] wrote:

> David T. Lewis uploaded a new version of Sound to project The Inbox:
> http://source.squeak.org/inbox/Sound-dtl.68.mcz
>
> ==================== Summary ====================
>
> Name: Sound-dtl.68
> Author: dtl
> Time: 12 December 2019, 7:20:38.226903 am
> UUID: c7b5a141-2b1b-4d24-ab88-0a96dd78600b
> Ancestors: Sound-dtl.67
>
> Resolve unimplemented calls in the previous update.
> Discussion on squeak-dev http://lists.squeakfoundation.org/pipermail/squeak-dev/2019-December/205515.html
>
> =============== Diff against Sound-dtl.67 ===============
>
> Item was changed:
>   ----- Method: AbstractSound>>loudness (in category 'volume') -----
>   loudness
>   "Answer the current volume setting for this sound."
>  
> + ^ envelopes detect: [:e | e isKindOf: VolumeEnvelope]
> + ifFound: [ :envelope | envelope scale ]
> + ifNone: [scaledVol asFloat / FloatScaleFactor]
> + !
> - self hasVolumeEnvelope ifTrue: [^ self volumeEnvelope scale].
> -
> - ^ scaledVol asFloat / ScaleFactor!
>
> Item was changed:
>   ----- Method: SequentialSound>>mixSampleCount:into:startingAt:leftVol:rightVol: (in category 'sound generation') -----
>   mixSampleCount: n into: aSoundBuffer startingAt: startIndex leftVol: leftVol rightVol: rightVol
>   "Play a collection of sounds in sequence."
>   "PluckedSound chromaticScale play"
>  
>   | finalIndex i snd remaining count leftScaledVol rightScaledVol |
>   currentIndex = 0 ifTrue: [^ self].  "already done"
>  
> + leftScaledVol := leftVol * scaledVol / ScaleFactor asFloat.
> + rightScaledVol := rightVol * scaledVol / ScaleFactor asFloat.
> - leftScaledVol := leftVol * scaledVol /// ScaleFactor.
> - rightScaledVol := rightVol * scaledVol /// ScaleFactor.
>  
>   finalIndex := (startIndex + n) - 1.
>   i := startIndex.
>   [i <= finalIndex] whileTrue: [
>   snd := (sounds at: currentIndex).
>   [(remaining := snd samplesRemaining) <= 0] whileTrue: [
>   "find next undone sound"
>   currentIndex < sounds size
>   ifTrue: [
>   currentIndex := currentIndex + 1.
>   snd := (sounds at: currentIndex)]
>   ifFalse: [
>   currentIndex := 0.
>   ^ self]].  "no more sounds"
>   count := (finalIndex - i) + 1.
>   remaining < count ifTrue: [count := remaining].
>   snd mixSampleCount: count into: aSoundBuffer startingAt: i
>   leftVol: leftScaledVol
>   rightVol: rightScaledVol.
>   i := i + count].
>   !
>
>