Skip to content

Commit

Permalink
fixes after sayomaki's review
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-henz committed Sep 10, 2023
1 parent 7d74800 commit 71e0c35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
19 changes: 3 additions & 16 deletions src/bundles/sound/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: () => '<AudioPlayed>',
dataUri: riffwave.dataURI,
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions src/bundles/stereo_sound/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 71e0c35

Please sign in to comment.