[squeak-dev] The Inbox: Sound-dtl.67.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Wed Dec 11 09:25:51 UTC 2019


Hi Christoph,
I don't know about /// but we have \\\

\\\ has been deprecated for some time now (huh, it's still in Kernel, but
not recommended!).
Once upon a time, large integer division was slow enough that we would
prefer to skip the final attempt to normalize LargeInteger -> SmallInteger
that normally has to happen on both quotient and remainder.
For example, if we just want the quotient or just the remainder, we can get
a slight speed up by not normalizing the one we do not use...
But then it's programmer's responsibility to apply the normalization.
That's what \\\ did, same as \\ but omitting final normalization.

When I have accelerated the LargeInteger arithmetic, the minor speed up was
not of any value, it would just complexify programmation at best (the
normalization step was sender responsibility), or lead to broken contracts
at worse (it prevents optimizations like a LargeInteger is not zero, can be
compared very quickly with a SmallInteger etc...).

So maybe /// is to // what \\\ is to \\  ...

Le mer. 11 déc. 2019 à 09:12, Thiede, Christoph <
Christoph.Thiede at student.hpi.uni-potsdam.de> a écrit :

> Hi Dave,
>
>
> I can take a look at it, but I have never really dived into sounds yet - I
> only polished a few interfaces so far.
>
>
> However: Nice extension. I did not read the affected methods before, but
> the changes look reasonable to me :-)
>
> What is #///? My image does not know it.
>
>
> Best,
>
> Christoph
> ------------------------------
> *Von:* David T. Lewis <lewis at mail.msen.com>
> *Gesendet:* Mittwoch, 11. Dezember 2019 05:08:09
> *An:* squeak-dev at lists.squeakfoundation.org
> *Cc:* Thiede, Christoph
> *Betreff:* Re: [squeak-dev] The Inbox: Sound-dtl.67.mcz
>
> This commit harvests a fix by St?phane Rollandin, discussed on the
> squeak-dev list.
>
> We are in 5.3 feature freeze now, but it may be reasonable to move
> this to trunk because the fix is of high value to the small number
> of people who are affected by it.
>
> @Christoph,
> You have a number of other inbox submissions for the Sound package.
> If you have the time, would you mind reviewing and commenting on
> this one?
>
> Thanks,
> Dave
>
>
> On Wed, Dec 11, 2019 at 03:51:05AM +0000, commits at source.squeak.org wrote:
> > David T. Lewis uploaded a new version of Sound to project The Inbox:
> > http://source.squeak.org/inbox/Sound-dtl.67.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Sound-dtl.67
> > Author: dtl
> > Time: 10 December 2019, 10:51:04.985835 pm
> > UUID: ca970845-8428-41f9-b83c-f64a6cc732c1
> > Ancestors: Sound-eem.66
> >
> > Sound mixing improvements by St?phane Rollandin (spfa).
> > Allow adjusting volume of mixed sounds while playing.
> > Original discussion at
> http://forum.world.st/Adjusting-the-volume-of-a-sound-as-it-s-playing-td5102562.html
> > Patches posted to squeak-dev at
> http://lists.squeakfoundation.org/pipermail/squeak-dev/2019-December/205440.html
> >
> > =============== Diff against Sound-eem.66 ===============
> >
> > Item was changed:
> >   ----- Method: AbstractSound>>loudness (in category 'volume') -----
> >   loudness
> >        "Answer the current volume setting for this sound."
> >
> > +      self hasVolumeEnvelope ifTrue: [^ self volumeEnvelope scale].
> > +
> > +      ^ scaledVol asFloat / ScaleFactor!
> > -      ^ scaledVol asFloat / ScaleFactor asFloat!
> >
> > Item was changed:
> >   ----- Method:
> MixedSound>>mixSampleCount:into:startingAt:leftVol:rightVol: (in category
> 'sound generation') -----
> >   mixSampleCount: n into: aSoundBuffer startingAt: startIndex leftVol:
> leftVol rightVol: rightVol
> >        "Play a number of sounds concurrently. The level of each sound
> can be set independently for the left and right channels."
> >
> >        | snd left right |
> >        1 to: sounds size do: [:i |
> >                (soundDone at: i) ifFalse: [
> >                        snd := sounds at: i.
> > +                      left := (leftVol * (leftVols at: i) * scaledVol /
> ScaleFactor) // ScaleFactor.
> > +                      right := (rightVol * (rightVols at: i) *
> scaledVol / ScaleFactor) // ScaleFactor.
> > -                      left := (leftVol * (leftVols at: i)) //
> ScaleFactor.
> > -                      right := (rightVol * (rightVols at: i)) //
> ScaleFactor.
> >                        snd samplesRemaining > 0
> >                                ifTrue: [
> >                                        snd mixSampleCount: n into:
> aSoundBuffer startingAt: startIndex leftVol: left rightVol: right]
> >                                ifFalse: [soundDone at: i put: true]]].
> >   !
> >
> > Item was changed:
> >   ----- Method:
> RepeatingSound>>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."
> >        "(RepeatingSound new
> >                setSound: FMSound majorScale
> >                iterations: 2) play"
> >
> >        | i count samplesNeeded |
> >        iteration <= 0 ifTrue: [^ self].
> >        i := startIndex.
> >        samplesNeeded := n.
> >        [samplesNeeded > 0] whileTrue: [
> >                count := sound samplesRemaining min: samplesNeeded.
> >                count = 0 ifTrue: [
> >                        iterationCount == #forever
> >                                ifFalse: [
> >                                        iteration := iteration - 1.
> >                                        iteration <= 0 ifTrue: [^
> self]].  "done"
> >                        sound reset.
> >                        count := sound samplesRemaining min:
> samplesNeeded.
> >                        count = 0 ifTrue: [^ self]].  "zero length sound"
> >                sound mixSampleCount: count
> >                        into: aSoundBuffer
> >                        startingAt: i
> > +                      leftVol: leftVol * scaledVol // ScaleFactor
> > +                      rightVol: rightVol * scaledVol // ScaleFactor.
> > -                      leftVol: leftVol
> > -                      rightVol: rightVol.
> >                i := i + count.
> >                samplesNeeded := samplesNeeded - count].
> >   !
> >
> > 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 |
> > -      | finalIndex i snd remaining count |
> >        currentIndex = 0 ifTrue: [^ self].  "already done"
> > +
> > +      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.
> > -              snd mixSampleCount: count into: aSoundBuffer startingAt:
> i leftVol: leftVol rightVol: rightVol.
> >                i := i + count].
> >   !
> >
>
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191211/4c4e2d3d/attachment.html>


More information about the Squeak-dev mailing list