From 1359081b23daf00719395297d3845e1d47b2b972 Mon Sep 17 00:00:00 2001 From: GrandpaBond <89019204+GrandpaBond@users.noreply.github.com> Date: Fri, 4 Aug 2023 07:24:14 +0100 Subject: [PATCH] Restore '8/3/2023, 12:26:13 PM 1.0.0' --- flexFX.ts | 26 ++++++++++---------------- pxt.json | 2 +- test.ts | 23 ++++++++++++----------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/flexFX.ts b/flexFX.ts index 182734e..c4cd349 100644 --- a/flexFX.ts +++ b/flexFX.ts @@ -273,19 +273,13 @@ namespace flexFX { function player() { let play = new Play; while (playList.length > 0) { // play everything on the playList in turn - let sound = ""; play = playList.shift(); - if (play.parts[0].charAt(0) == 'p'){ - // this is just a pause, so doesn't count as "PLAYING" - sound = play.parts.shift(); - pause(parseInt(sound.slice(1, sound.length))); - } else { + let sound = ""; control.raiseEvent(FLEXFX_ACTIVITY_ID, PLAYER.STARTING); playerPlaying = true; while (play.parts.length > 0) { // play its sounds in turn sound = play.parts.shift(); if (sound.charAt(0) == ' ') { - // this is a gap within a sound, so DOES count as still "PLAYING" pause(parseInt(sound.slice(1, sound.length))); } else { music.playSoundEffect(sound, SoundExpressionPlayMode.UntilDone) @@ -297,19 +291,19 @@ namespace flexFX { control.raiseEvent(FLEXFX_ACTIVITY_ID, PLAYER.ALLPLAYED); playerActive = false; } - } + // ---- UI BLOCKS ---- /** * Add a silent pause to the play-list */ export function performSilence(ms: number, waiting: boolean) { - let play = new Play; - play.parts.push("p"+ convertToText(Math.floor(ms))); - playList.push(play); - activatePlayer(); // make sure it gets played - if (waiting) { // ours was the lastest Play, so simply await completion of player. - control.waitForEvent(FLEXFX_ACTIVITY_ID, PLAYER.ALLPLAYED); - } + let play = new Play; + play.parts.push(" "+ convertToText(Math.floor(ms))); + playList.push(play); + activatePlayer(); // make sure it gets played + if (waiting) { // ours was the lastest Play, so simply await completion of player. + control.waitForEvent(FLEXFX_ACTIVITY_ID, PLAYER.ALLPLAYED); + } } /** @@ -489,4 +483,4 @@ namespace flexFX { target.silentPartB(startPitchBPercent / 100, startVolBPercent / 100, timeGapPercent / 100); target.setPartC(waveB, attackB, effectB, endPitchBPercent / 100, endVolBPercent / 100, (100 - timePercentA - timeGapPercent) / 100); } -} +} \ No newline at end of file diff --git a/pxt.json b/pxt.json index c49bab3..18cbc51 100644 --- a/pxt.json +++ b/pxt.json @@ -1,5 +1,5 @@ { - "name": "pxt-flexFX", + "name": "pxt-newflexFX", "version": "1.0.0", "description": "", "dependencies": { diff --git a/test.ts b/test.ts index c9d8e3d..84c814a 100644 --- a/test.ts +++ b/test.ts @@ -87,10 +87,10 @@ flexFX.performFlexFX("Violin", Note.A4, 250, 900, false); //flexFX.startPlaying(); while (flexFX.isActive()) { // jiggle a note around - images.iconImage(IconNames.QuarterNote).showImage(-2, 150); images.iconImage(IconNames.QuarterNote).showImage(-1, 150); images.iconImage(IconNames.QuarterNote).showImage(0, 150); - images.iconImage(IconNames.QuarterNote).showImage(-1, 150); + images.iconImage(IconNames.QuarterNote).showImage(1, 150); + images.iconImage(IconNames.QuarterNote).showImage(0, 150); } //flexFX.finish(); // make sure everything has finished playing @@ -110,12 +110,13 @@ flexFX.performSilence(400, false); flexFX.performFlexFX("SIREN", 600, 250, 1000, false); flexFX.performSilence(400, false); flexFX.performFlexFX("SIREN", 800, 250, 1000, false); - -// choreograph faces to sounds: -while (flexFX.isActive) { - basic.showIcon(IconNames.Happy); - control.waitForEvent(FLEXFX_ACTIVITY_ID, PLAYER.STARTING); - basic.showIcon(IconNames.Surprised); - control.waitForEvent(FLEXFX_ACTIVITY_ID, PLAYER.FINISHED); -} -basic.showIcon(IconNames.Happy); \ No newline at end of file +// choreograph faces to sounds: 600ms for icon display + 800ms = 1000ms + 400ms +basic.showIcon(IconNames.Happy); +pause(800); +basic.showIcon(IconNames.Sad); +pause(800); +basic.showIcon(IconNames.Confused); +pause(800); +basic.showIcon(IconNames.Angry); +pause(800); +basic.showIcon(IconNames.Surprised);