From 71e0c350307e1d447c61941615bce15c4ba3ab9e Mon Sep 17 00:00:00 2001 From: henz Date: Sun, 10 Sep 2023 17:30:00 +0800 Subject: [PATCH] fixes after sayomaki's review --- src/bundles/sound/functions.ts | 19 +++---------------- src/bundles/stereo_sound/functions.ts | 16 ++++++++-------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/bundles/sound/functions.ts b/src/bundles/sound/functions.ts index 673e1d26b..f1d296e73 100644 --- a/src/bundles/sound/functions.ts +++ b/src/bundles/sound/functions.ts @@ -336,7 +336,7 @@ export function play_wave(wave: Wave, duration: number): Sound { * * @param sound the Sound to play * @return the given Sound - * @example play(sine_sound(440, 5)); + * @example play_in_tab(sine_sound(440, 5)); */ export function play_in_tab(sound: Sound): Sound { // Type-check sound @@ -392,19 +392,6 @@ export function play_in_tab(sound: Sound): Sound { riffwave.header.bitsPerSample = 16; riffwave.Make(channel); - /* - const audio = new Audio(riffwave.dataURI); - const source2 = audioplayer.createMediaElementSource(audio); - source2.connect(audioplayer.destination); - - // Connect data to output destination - isPlaying = true; - audio.play(); - audio.onended = () => { - source2.disconnect(audioplayer.destination); - isPlaying = false; - }; */ - const soundToPlay = { toReplString: () => '', dataUri: riffwave.dataURI, @@ -420,7 +407,7 @@ export function play_in_tab(sound: Sound): Sound { * * @param sound the Sound to play * @return the given Sound - * @example play_concurrently(sine_sound(440, 5)); + * @example play(sine_sound(440, 5)); */ export function play(sound: Sound): Sound { // Type-check sound @@ -518,7 +505,7 @@ export function silence_sound(duration: number): Sound { * * @param freq the frequency of the sine wave Sound * @param duration the duration of the sine wave Sound - * @return resulting sine wave sound + * @return resulting sine wave Sound * @example sine_sound(440, 5); */ export function sine_sound(freq: number, duration: number): Sound { diff --git a/src/bundles/stereo_sound/functions.ts b/src/bundles/stereo_sound/functions.ts index 398e3e2e9..8088a7747 100644 --- a/src/bundles/stereo_sound/functions.ts +++ b/src/bundles/stereo_sound/functions.ts @@ -250,10 +250,10 @@ export function record_for(duration: number, buffer: number): () => Sound { * that takes in a non-negative input time and returns an amplitude * between -1 and 1. * - * @param left_wave wave function of the left channel of the sound - * @param right_wave wave function of the right channel of the sound - * @param duration duration of the sound - * @return resulting stereo sound + * @param left_wave wave function of the left channel of the Sound + * @param right_wave wave function of the right channel of the Sound + * @param duration duration of the Sound + * @return resulting stereo Sound * @example const s = make_stereo_sound(t => math_sin(2 * math_PI * 440 * t), t => math_sin(2 * math_PI * 300 * t), 5); */ export function make_stereo_sound( @@ -276,9 +276,9 @@ export function make_stereo_sound( * that takes in a non-negative input time and returns an amplitude * between -1 and 1. * - * @param wave wave function of the sound - * @param duration duration of the sound - * @return with wave as wave function and duration as duration + * @param wave wave function of the Sound + * @param duration duration of the Sound + * @return Sound with the given `wave` function for both channels and `duration` as duration * @example const s = make_sound(t => math_sin(2 * math_PI * 440 * t), 5); */ export function make_sound(wave: Wave, duration: number): Sound { @@ -366,7 +366,7 @@ export function play_waves( /** * Plays the given Sound using the computer’s sound device. - * The sound is added to a list of sounds to be played one-at-a-time + * The sound is added to a list of Sounds to be played one-at-a-time * in a Source Academy tab. * * @param sound the sound to play