You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using tambo out of phetlib in the paper programming project (the repo for this is called papyrus at the moment, but there is talk of changing it). It was a bit challenging to get it working, and I think we could probably make it easier, but I'm not sure how much of a priority that is.
For reference, here is the code that was needed to initialize the sound manager and enable sound generation:
This code is basically faking out all of the mechanisms that prevent tambo from producing sound when we don't want it to, like when the user has turned sound off, or the tab isn't showing, and so forth.
Also, it is a bit tricky to use a sound clip and other types that rely on pre-recorded sounds (generally MP3 files) because we use something called a WrappedAudioBuffer to handle the asynchronous decode and loading of audio samples. The code to make this work looked like this:
/** * Create an instance of WrappedAudioBuffer and return it, and start the process of decoding the audio file from the * provided path and load it into the buffer when complete. Instances of WrappedAudioBuffer are often needed for * creating sounds using the tambo library. * @param {string} pathToAudioFile */constcreateAndLoadWrappedAudioBuffer=pathToAudioFile=>{constwrappedAudioBuffer=newtambo.WrappedAudioBuffer();window.fetch(pathToAudioFile).then(response=>response.arrayBuffer()).then(arrayBuffer=>tambo.phetAudioContext.decodeAudioData(arrayBuffer)).then(audioBuffer=>{wrappedAudioBuffer.audioBufferProperty.value=audioBuffer;});returnwrappedAudioBuffer;};consttestSoundClip=newSoundClip(createAndLoadWrappedAudioBuffer(someFile.mp3);constonButtonClicked=()=>{testSoundClip.play();};
We could probably add some sort of method like initializeForLibraryUse that creates the stub properties, and we could potentially provide the createAndLoadWrappedAudioBuffer function, and there may some other improvements as well.
I'll put this up for discussion at the next developer meeting since, as mentioned above, I have no idea if this is important enough to spend time on.
The text was updated successfully, but these errors were encountered:
I am currently using tambo out of phetlib in the paper programming project (the repo for this is called papyrus at the moment, but there is talk of changing it). It was a bit challenging to get it working, and I think we could probably make it easier, but I'm not sure how much of a priority that is.
For reference, here is the code that was needed to initialize the sound manager and enable sound generation:
This code is basically faking out all of the mechanisms that prevent tambo from producing sound when we don't want it to, like when the user has turned sound off, or the tab isn't showing, and so forth.
Also, it is a bit tricky to use a sound clip and other types that rely on pre-recorded sounds (generally MP3 files) because we use something called a
WrappedAudioBuffer
to handle the asynchronous decode and loading of audio samples. The code to make this work looked like this:We could probably add some sort of method like
initializeForLibraryUse
that creates the stub properties, and we could potentially provide thecreateAndLoadWrappedAudioBuffer
function, and there may some other improvements as well.I'll put this up for discussion at the next developer meeting since, as mentioned above, I have no idea if this is important enough to spend time on.
The text was updated successfully, but these errors were encountered: