From 903c0ec6bd5a3b6e538e7d85a0fd3014e9e9421f Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 15 Nov 2016 22:28:05 -0800 Subject: [PATCH] fixing music simulator --- libs/core/music.cpp | 13 +------------ libs/core/music.ts | 10 ++++++++++ libs/core/shims.d.ts | 11 +---------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/libs/core/music.cpp b/libs/core/music.cpp index 3311cc19..867e4a23 100644 --- a/libs/core/music.cpp +++ b/libs/core/music.cpp @@ -8,21 +8,10 @@ namespace music { */ //% help=music/play-tone weight=90 //% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8 - //% parts="speaker" + //% parts="speaker" async void playTone(int freqency, int ms) { uBit.soundmotor.soundOn(freqency); if(ms > 0) uBit.sleep(ms); uBit.soundmotor.soundOff(); } - - /** - * Plays a tone through ``speaker``. - * @param frequency pitch of the tone to play in Hertz (Hz) - */ - //% help=music/ring-tone weight=80 - //% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8 - //% parts="speaker" - void ringTone(int frequency) { - playTone(frequency, 0); - } } diff --git a/libs/core/music.ts b/libs/core/music.ts index 9ad9b3a3..a554015d 100644 --- a/libs/core/music.ts +++ b/libs/core/music.ts @@ -140,6 +140,16 @@ namespace music { playTone(0, ms); } + /** + * Plays a tone through ``speaker``. + * @param frequency pitch of the tone to play in Hertz (Hz) + */ + //% help=music/ring-tone weight=80 + //% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8 + //% parts="speaker" async + export function ringTone(frequency: number) { + playTone(frequency, 0); + } /** * Gets the frequency of a note. diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 3369024b..5a9fea3a 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -554,17 +554,8 @@ declare namespace music { */ //% help=music/play-tone weight=90 //% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8 - //% parts="speaker" shim=music::playTone + //% parts="speaker" async shim=music::playTone function playTone(freqency: number, ms: number): void; - - /** - * Plays a tone through ``speaker``. - * @param frequency pitch of the tone to play in Hertz (Hz) - */ - //% help=music/ring-tone weight=80 - //% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8 - //% parts="speaker" shim=music::ringTone - function ringTone(frequency: number): void; } declare namespace pins {