-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sonification code review #426
Comments
Overall I'd say it looks like it's on the right track. Here are some comments:
|
It was initially
I was using "view" as opposed to "model" but maybe that is unnecessary? Should I go with WavesScreenSounds?
I haven't yet looked into how difficult this would be to implement, but in further testing, this effect did seem minor and transient, so I'm not convinced it would be worth a lot of effort to change. But would you expect it to work properly if I change the playback rate and output level while playing? I'm not sure if there will be artifacts or other concerns to deal with.
done
Yes, that's the problem that I saw. I didn't try to replicate the problem recently--let me know if you are able to replicate the problem or not.
I'll give it a try, thanks!
Looks good, thanks!
Addressed all but one in the above commit. |
I tried this but was unable to call UPDATE: here is my patch in case I return to it: Index: js/waves/view/WavesScreenSoundView.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/waves/view/WavesScreenSoundView.js (revision 653a7106b151fc0c1a13b4805f07df5e3996464a)
+++ js/waves/view/WavesScreenSoundView.js (date 1565814397883)
@@ -10,6 +10,7 @@
// modules
const DerivedProperty = require( 'AXON/DerivedProperty' );
+ const MultiClip = require( 'TAMBO/sound-generators/MultiClip' );
const Property = require( 'AXON/Property' );
const ResetAllSoundGenerator = require( 'TAMBO/sound-generators/ResetAllSoundGenerator' );
const SineWaveGenerator = require( 'WAVE_INTERFERENCE/waves/view/SineWaveGenerator' );
@@ -67,23 +68,18 @@
initialOutputLevel: 0.7
} ) );
if ( model.waterScene ) {
- const waterDropSoundClip0 = new SoundClip( waterDropSound0 );
- const waterDropSoundClip1 = new SoundClip( waterDropSound1 );
- const waterDropSoundClip2 = new SoundClip( waterDropSound2 );
- const waterDropSoundClip3 = new SoundClip( waterDropSound3 );
- soundManager.addSoundGenerator( waterDropSoundClip0 );
- soundManager.addSoundGenerator( waterDropSoundClip1 );
- soundManager.addSoundGenerator( waterDropSoundClip2 );
- soundManager.addSoundGenerator( waterDropSoundClip3 );
- const soundClips = [
- waterDropSoundClip0,
- waterDropSoundClip1,
- waterDropSoundClip2,
- waterDropSoundClip3
+ const multiClipData = [
+ { value: 0, soundInfo: waterDropSound0 },
+ { value: 1, soundInfo: waterDropSound1 },
+ { value: 2, soundInfo: waterDropSound2 },
+ { value: 3, soundInfo: waterDropSound3 }
];
+ const waterDropMultiClip = new MultiClip( multiClipData );
+ soundManager.addSoundGenerator( waterDropMultiClip );
+ const soundClipValues = multiClipData.map( v => v.value );
- // The water drop SoundClip that was most recently played, to avoid repeats
- let lastPlayedWaterDropSoundClip = null;
+ // {number} The water drop SoundClip that was most recently played, to avoid repeats
+ let lastWaterDropValue = -1;
// When a water drop is absorbed, play a water drop sound.
model.waterScene.waterDropAbsorbedEmitter.addListener( waterDrop => {
@@ -96,10 +92,11 @@
);
// Select water drop sounds randomly, but do not let the same sound go twice in a row
- const availableClips = _.without( soundClips, lastPlayedWaterDropSoundClip );
- lastPlayedWaterDropSoundClip = phet.joist.random.sample( availableClips );
- lastPlayedWaterDropSoundClip.setPlaybackRate( amplitude );
- lastPlayedWaterDropSoundClip.play();
+ const availableValues = _.without( soundClipValues, lastWaterDropValue );
+ lastWaterDropValue = phet.joist.random.sample( availableValues );
+ waterDropMultiClip.setPlaybackRate( amplitude );
+ console.log( lastWaterDropValue );
+ waterDropMultiClip.play( lastWaterDropValue );
} );
}
|
Ah, I hadn't thought about the fact that playback rate changes are needed. How about leave it as is, i.e. don't use MultiClip, and I'll give this some thought. |
I've been creating sounds in the view type, since I think of it as "presentation" and not just view. If we decide that we'd like to separate out the "sound view" into a separate class, we should really add support for this to the framework, specifically to the I think this is the only outstanding comment, assign back to me as needed if not or if there is more to discuss on this. |
@samreid - is this still relevant, or perhaps a new issue for a new review? Not sure what the typical practice is on this sort of thing...but just noticed this seemed old and possibly out-of-date. |
I'll need to make another cleanup pass once the sound design is finalized. Then review with or by @jbphet would be good. Leaving open and on hold until then. |
@jbphet would you like to review this sonification code before we go to dev testing? Please be aware of phetsims/tambo#74 which is under discussion. It's ready if you are. For the scope of the review, the sonification parts of these files:
Perhaps also skim the files checked in to sounds/ and make sure their metadata (mono vs stereo/bitrate/etc) is appropriate. Anything else you can think of that should be reviewed for sonification? |
Review complete, see Also, on the topic of |
Thanks for the code review, @jbphet, good suggestions! I addressed them in the commits. Ready for your re-review. |
@samreid - most of the commits look good. One question: In #426 (comment), as part of this review, I suggested a different way to handle the initialization of the sound view rather that using an init function that is called from |
Thanks, I neglected to comment on that part. I don't like the existing pattern: WavesScreenSoundView.init( model, this, options ); The proposal from the comment is to add a new Screen.js method like function Screen( createModel, createView, options ) { to function Screen( createModel, createView, createSoundView, options ) { I do not agree with this proposal. The One way forward would be to have For // @private
this.wavesScreenSoundView = new WavesScreenSoundView( model, this, options ); ? |
@samreid - what you responded to is not quite what I proposed. I proposed an option called If so, I'd say go ahead with assigning |
Thanks for the correction, I did write my comment based on a required parameter, but all of the same comments apply equally well to an option. To be clear, I do not think there should be an option to create a sound view, and that |
I converted WavesScreenSoundView from static init to constructor, @jbphet can you please review and check the last few comments. Anything else to do here? |
Looks good to me. I think we're done here. Closing. |
We may still make changes during design meeting, but it seems the existing implementation for sonification is stable and ready for code review. @jbphet are you available to take a look? SineWaveGenerator.js was already reviewed so I think the remaining work to review is just WavesScreenSoundView.js
Also note I marked some TODOs in the file for discussion with the reviewer.
The text was updated successfully, but these errors were encountered: