From 43035e6a0d519cf2238071477970663645dd2780 Mon Sep 17 00:00:00 2001 From: ganicke Date: Thu, 5 Sep 2024 22:37:44 -0700 Subject: [PATCH 1/5] update v2 tutorials to new sound api --- docs/projects/v2-cat-napping.md | 6 +++--- docs/projects/v2-morse-chat.md | 30 ++++++++++++++++++------------ docs/projects/v2-pet-hamster.md | 22 +++++++++++----------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/docs/projects/v2-cat-napping.md b/docs/projects/v2-cat-napping.md index 45b8adba6d7..a4b8a10160e 100644 --- a/docs/projects/v2-cat-napping.md +++ b/docs/projects/v2-cat-napping.md @@ -74,7 +74,7 @@ input.onButtonPressed(Button.A, function () { Let's now add an auditory indicator that your @boardname@ is logging data! ► From the ``||music:Music||`` category, grab a ``||music:play sound [giggle] [until done]||`` block and snap it into the **bottom** of the **top container** of your ``||logic:if then / else||`` statement. -► Click on the ``giggle`` dropdown and select ``hello``. Your block should now say ``||music:play sound [hello] [until done]||``. +► Click on the ``giggle`` dropdown and select ``hello``. Your block should now say ``||music:play melody [nyab] [until done]||``. ```blocks let logging = false @@ -82,7 +82,7 @@ input.onButtonPressed(Button.A, function () { logging = !(logging) if (logging) { basic.showIcon(IconNames.Target) - music.playSoundEffect(music.builtinSoundEffect(soundExpression.hello), SoundExpressionPlayMode.UntilDone) + music.play(music.builtInPlayableMelody(Melodies.Nyan), music.PlaybackMode.UntilDone) } else { } }) @@ -98,7 +98,7 @@ input.onButtonPressed(Button.A, function () { logging = !(logging) if (logging) { basic.showIcon(IconNames.Target) - music.playSoundEffect(music.builtinSoundEffect(soundExpression.hello), SoundExpressionPlayMode.UntilDone) + music.play(music.builtInPlayableMelody(Melodies.Nyan), music.PlaybackMode.UntilDone) } else { basic.clearScreen() } diff --git a/docs/projects/v2-morse-chat.md b/docs/projects/v2-morse-chat.md index 706017ca89d..aea25eacac5 100644 --- a/docs/projects/v2-morse-chat.md +++ b/docs/projects/v2-morse-chat.md @@ -107,7 +107,7 @@ radio.onReceivedNumber(function (receivedNumber) { ## {Playing a sound pt. 1} -► From the ``||music:Music||`` category, grab a ``||music:play tone [Middle C] for [1 beat]||`` block and snap it at the **end** of the **bottom container** in your ``||logic:if then / else||`` statement. +► From the ``||music:Music||`` category, grab a ``||music:play tone [Middle C] for [1 beat] [until done]||`` block and snap it at the **end** of the **bottom container** in your ``||logic:if then / else||`` statement. ```blocks radio.onReceivedNumber(function (receivedNumber) { @@ -121,7 +121,7 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . `) // @highlight - music.playTone(262, music.beat(BeatFraction.Whole)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) } }) ``` @@ -150,14 +150,14 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Whole)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) } }) ``` ## {Playing a sound pt. 2} -► From the ``||music:Music||`` category, grab ``||music:play tone [Middle C] for [1 beat]||`` and snap it in at the **end** of the **top container** in your ``||logic:if then / else||`` statement. +► From the ``||music:Music||`` category, grab ``||music:play tone [Middle C] for [1 beat] [until done]||`` and snap it in at the **end** of the **top container** in your ``||logic:if then / else||`` statement. ► Dots are shorter than dashes! Set the tone to play for ``1/4 beat``. ```blocks @@ -171,7 +171,7 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . `) // @highlight - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) } else { basic.showLeds(` . . . . . @@ -180,7 +180,7 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Whole)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) } }) ``` @@ -199,7 +199,8 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) + } else { basic.showLeds(` . . . . . @@ -208,7 +209,8 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Whole)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) + } // @highlight basic.clearScreen() @@ -232,7 +234,8 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) + } else { basic.showLeds(` . . . . . @@ -241,7 +244,8 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Whole)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) + } basic.clearScreen() }) @@ -270,7 +274,8 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) + } else { basic.showLeds(` . . . . . @@ -279,7 +284,8 @@ radio.onReceivedNumber(function (receivedNumber) { . . . . . . . . . . `) - music.playTone(262, music.beat(BeatFraction.Whole)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) + } basic.clearScreen() }) diff --git a/docs/projects/v2-pet-hamster.md b/docs/projects/v2-pet-hamster.md index 678d22c9c83..cdecc13628f 100644 --- a/docs/projects/v2-pet-hamster.md +++ b/docs/projects/v2-pet-hamster.md @@ -33,13 +33,13 @@ input.onLogoEvent(TouchButtonEvent.Pressed, function () { ## {Tickle sound} -► From the ``||music:Music||`` category, get a ``||music:play sound [giggle] until done||`` and add it to the **bottom** of your ``||input:on logo [pressed]||`` container. +► From the ``||music:Music||`` category, get a ``||music:play melody [jump up] [in background]||`` and add it to the **bottom** of your ``||input:on logo [pressed]||`` container. Change the playback mode to ``||music:[until done]||``. ```blocks input.onLogoEvent(TouchButtonEvent.Pressed, function () { basic.showIcon(IconNames.Happy) //@highlight - soundExpression.giggle.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.JumpUp), music.PlaybackMode.UntilDone) }) ``` @@ -60,14 +60,14 @@ input.onGesture(Gesture.Shake, function () { ## {Dizzy sound} -► From the ``||music:Music||`` category, find the ``||music:play sound [giggle] until done||`` block and add it to the **bottom** of your ``||input:on [shake]||`` container. -► Click on the **dropdown** and set it so Cyrus plays a ``||music:sad||`` sound until done. +► From the ``||music:Music||`` category, find the ``||music:play melody [dadadum] [in background]||`` block and add it to the **bottom** of your ``||input:on [shake]||`` container. Change the playback mode to ``||music:[until done]||``. +► Click on the **dropdown** and set it so Cyrus plays a sad sound until done. ```blocks input.onGesture(Gesture.Shake, function () { basic.showIcon(IconNames.Sad) //@highlight - soundExpression.sad.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.Wawawawaa), music.PlaybackMode.UntilDone) }) ``` @@ -81,13 +81,13 @@ Let's ensure that Cyrus will always go back to sleep after being shaken or tickl ```blocks input.onGesture(Gesture.Shake, function () { basic.showIcon(IconNames.Sad) - soundExpression.sad.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.Wawawawaa), music.PlaybackMode.UntilDone) //@highlight basic.showIcon(IconNames.Asleep) }) input.onLogoEvent(TouchButtonEvent.Pressed, function () { basic.showIcon(IconNames.Happy) - soundExpression.giggle.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.JumpUp), music.PlaybackMode.UntilDone) }) basic.showIcon(IconNames.Asleep) ``` @@ -99,12 +99,12 @@ basic.showIcon(IconNames.Asleep) ```blocks input.onGesture(Gesture.Shake, function () { basic.showIcon(IconNames.Sad) - soundExpression.sad.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.Wawawawaa), music.PlaybackMode.UntilDone) basic.showIcon(IconNames.Asleep) }) input.onLogoEvent(TouchButtonEvent.Pressed, function () { basic.showIcon(IconNames.Happy) - soundExpression.giggle.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.JumpUp), music.PlaybackMode.UntilDone) //@highlight basic.showIcon(IconNames.Asleep) }) @@ -124,12 +124,12 @@ If you have a new @boardname@ (the one with the **shiny gold** logo at the top), ```blocks input.onGesture(Gesture.Shake, function () { basic.showIcon(IconNames.Sad) - soundExpression.sad.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.Wawawawaa), music.PlaybackMode.UntilDone) basic.showIcon(IconNames.Asleep) }) input.onLogoEvent(TouchButtonEvent.Pressed, function () { basic.showIcon(IconNames.Happy) - soundExpression.giggle.playUntilDone() + music.play(music.builtInPlayableMelody(Melodies.JumpUp), music.PlaybackMode.UntilDone) basic.showIcon(IconNames.Asleep) }) basic.showIcon(IconNames.Asleep) From 6076445e8a15824f9883854e4f49b6f22e68dc86 Mon Sep 17 00:00:00 2001 From: ganicke Date: Thu, 5 Sep 2024 22:43:31 -0700 Subject: [PATCH 2/5] correct the sound name --- docs/projects/v2-cat-napping.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/projects/v2-cat-napping.md b/docs/projects/v2-cat-napping.md index a4b8a10160e..d8a59355a78 100644 --- a/docs/projects/v2-cat-napping.md +++ b/docs/projects/v2-cat-napping.md @@ -73,8 +73,8 @@ input.onButtonPressed(Button.A, function () { Let's now add an auditory indicator that your @boardname@ is logging data! -► From the ``||music:Music||`` category, grab a ``||music:play sound [giggle] [until done]||`` block and snap it into the **bottom** of the **top container** of your ``||logic:if then / else||`` statement. -► Click on the ``giggle`` dropdown and select ``hello``. Your block should now say ``||music:play melody [nyab] [until done]||``. +► From the ``||music:Music||`` category, grab a ``||music:play sound [dadadum] [in background]||`` block and snap it into the **bottom** of the **top container** of your ``||logic:if then / else||`` statement. +► Click on the ``[dadadum]`` dropdown and select ``nyab``, then set the playback mode to ``||music:[until done]||``. Your block should now say ``||music:play melody [nyab] [until done]||``. ```blocks let logging = false From fd6ebc3db2a92127a0419a6d3e240017d470ed25 Mon Sep 17 00:00:00 2001 From: ganicke Date: Thu, 5 Sep 2024 22:45:08 -0700 Subject: [PATCH 3/5] spell 'nyab' correctly --- docs/projects/v2-cat-napping.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/projects/v2-cat-napping.md b/docs/projects/v2-cat-napping.md index d8a59355a78..f02bae22b48 100644 --- a/docs/projects/v2-cat-napping.md +++ b/docs/projects/v2-cat-napping.md @@ -82,7 +82,7 @@ input.onButtonPressed(Button.A, function () { logging = !(logging) if (logging) { basic.showIcon(IconNames.Target) - music.play(music.builtInPlayableMelody(Melodies.Nyan), music.PlaybackMode.UntilDone) + music.play(music.builtInPlayableMelody(Melodies.Nyab), music.PlaybackMode.UntilDone) } else { } }) @@ -98,7 +98,7 @@ input.onButtonPressed(Button.A, function () { logging = !(logging) if (logging) { basic.showIcon(IconNames.Target) - music.play(music.builtInPlayableMelody(Melodies.Nyan), music.PlaybackMode.UntilDone) + music.play(music.builtInPlayableMelody(Melodies.Nyab), music.PlaybackMode.UntilDone) } else { basic.clearScreen() } From d9af779d8f1291fdd9f087d59d6eb2e8733c2c46 Mon Sep 17 00:00:00 2001 From: ganicke Date: Thu, 5 Sep 2024 22:50:40 -0700 Subject: [PATCH 4/5] change tone to playable in 'countdown' --- docs/projects/v2-countdown.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/projects/v2-countdown.md b/docs/projects/v2-countdown.md index 9b9711e17db..d06c39bb6cb 100644 --- a/docs/projects/v2-countdown.md +++ b/docs/projects/v2-countdown.md @@ -26,14 +26,14 @@ for (let index = 0; index <= 2; index++) { ## {Play music} -► From ``||music:Music||``, grab ``||music:play tone [Middle C] for [1 beat]||`` and snap it into your empty ``for`` loop. +► From ``||music:Music||``, grab ``||music:play tone [Middle C] for [1 beat] [until done]||`` and snap it into your empty ``for`` loop. 💡 Your simulator might start playing music. You can mute it if distracting. ► 1 beat is a little long. Use the **dropdown** to set the tone to play for ``||music:1/4 beat||``. ```blocks for (let index = 0; index <= 2; index++) { // @highlight - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) } ``` @@ -47,7 +47,7 @@ With every tone, we also want to **display** our countdown. ```blocks for (let index = 0; index <= 2; index++) { - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) // @highlight basic.showNumber(index) } @@ -66,7 +66,7 @@ If you take a look at your simulator, you'll notice the @boardname@ flashing 0-1 ```blocks for (let index = 0; index <= 2; index++) { - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) // @highlight basic.showNumber(3 - index) } @@ -79,7 +79,7 @@ for (let index = 0; index <= 2; index++) { ```blocks for (let index = 0; index <= 2; index++) { - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) basic.showNumber(3 - index) } // @highlight @@ -88,18 +88,18 @@ basic.showString("GO!") ## {Adding a "GO!" noise} -► From the ``||music:Music||`` category, grab ``||music:play tone [Middle C] for [1 beat]||`` and place it **above** your ``||basic:show string ["GO!"]||`` block and **below** your ``||loops:for||`` loop. +► From the ``||music:Music||`` category, grab ``||music:play tone [Middle C] for [1 beat] [until done]||`` and place it **above** your ``||basic:show string ["GO!"]||`` block and **below** your ``||loops:for||`` loop. 💡 This will let your @boardname@ play the sound and show ``GO!`` at the same time. ► Set the ``||music:tone||`` to be ``Middle G``. 💡 ``Middle G`` is also tone ``392``. ```blocks for (let index = 0; index <= 2; index++) { - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) basic.showNumber(3 - index) } // @highlight -music.playTone(392, music.beat(BeatFraction.Whole)) +music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) basic.showString("GO!") ``` @@ -111,10 +111,10 @@ If you have a @boardname@ with sound (the one with the **shiny gold** logo at th ```blocks for (let index = 0; index <= 2; index++) { - music.playTone(262, music.beat(BeatFraction.Quarter)) + music.play(music.tonePlayable(262, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone) basic.showNumber(3 - index) } -music.playTone(392, music.beat(BeatFraction.Whole)) +music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) basic.showString("GO!") ``` From 458ab656a0044dd856ed553ab5c1a83e170db4c0 Mon Sep 17 00:00:00 2001 From: ganicke Date: Thu, 5 Sep 2024 22:59:54 -0700 Subject: [PATCH 5/5] well it's actually 'nyan' --- docs/projects/v2-cat-napping.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/projects/v2-cat-napping.md b/docs/projects/v2-cat-napping.md index f02bae22b48..3df24640e77 100644 --- a/docs/projects/v2-cat-napping.md +++ b/docs/projects/v2-cat-napping.md @@ -74,7 +74,7 @@ input.onButtonPressed(Button.A, function () { Let's now add an auditory indicator that your @boardname@ is logging data! ► From the ``||music:Music||`` category, grab a ``||music:play sound [dadadum] [in background]||`` block and snap it into the **bottom** of the **top container** of your ``||logic:if then / else||`` statement. -► Click on the ``[dadadum]`` dropdown and select ``nyab``, then set the playback mode to ``||music:[until done]||``. Your block should now say ``||music:play melody [nyab] [until done]||``. +► Click on the ``[dadadum]`` dropdown and select ``nyan``, then set the playback mode to ``||music:[until done]||``. Your block should now say ``||music:play melody [nyan] [until done]||``. ```blocks let logging = false @@ -82,7 +82,7 @@ input.onButtonPressed(Button.A, function () { logging = !(logging) if (logging) { basic.showIcon(IconNames.Target) - music.play(music.builtInPlayableMelody(Melodies.Nyab), music.PlaybackMode.UntilDone) + music.play(music.builtInPlayableMelody(Melodies.Nyan), music.PlaybackMode.UntilDone) } else { } }) @@ -98,7 +98,7 @@ input.onButtonPressed(Button.A, function () { logging = !(logging) if (logging) { basic.showIcon(IconNames.Target) - music.play(music.builtInPlayableMelody(Melodies.Nyab), music.PlaybackMode.UntilDone) + music.play(music.builtInPlayableMelody(Melodies.Nyan), music.PlaybackMode.UntilDone) } else { basic.clearScreen() }