namespace sounds {
    //% fixedInstance jres block="animals cat purr"
    export const animalsCatPurr = music.fromWAV(hex``);
    //% fixedInstance jres block="animals dog bark 1"
    export const animalsDogBark1 = music.fromWAV(hex``);
    //% fixedInstance jres block="animals dog bark 2"
    export const animalsDogBark2 = music.fromWAV(hex``);
    //% fixedInstance jres block="animals dog growl"
    export const animalsDogGrowl = music.fromWAV(hex``);
    //% fixedInstance jres block="animals dog sniff"
    export const animalsDogSniff = music.fromWAV(hex``);
    //% fixedInstance jres block="animals dog whine"
    export const animalsDogWhine = music.fromWAV(hex``);
    //% fixedInstance jres block="animals elephant call"
    export const animalsElephantCall = music.fromWAV(hex``);
    //% fixedInstance jres block="animals insect buzz1"
    export const animalsInsectBuzz1 = music.fromWAV(hex``);
    //% fixedInstance jres block="animals insect buzz2"
    export const animalsInsectBuzz2 = music.fromWAV(hex``);
    //% fixedInstance jres block="animals insect chirp"
    export const animalsInsectChirp = music.fromWAV(hex``);
    //% fixedInstance jres block="animals snake hiss"
    export const animalsSnakeHiss = music.fromWAV(hex``);
    //% fixedInstance jres block="animals snake rattle"
    export const animalsSnakeRattle = music.fromWAV(hex``);
    //% fixedInstance jres block="animals trex roar"
    export const animalsTRexRoar = music.fromWAV(hex``);
    //% fixedInstance jres block="colors black"
    export const colorsBlack = music.fromWAV(hex``);
    //% fixedInstance jres block="colors blue"
    export const colorsBlue = music.fromWAV(hex``);
    //% fixedInstance jres block="colors brown"
    export const colorsBrown = music.fromWAV(hex``);
    //% fixedInstance jres block="colors green"
    export const colorsGreen = music.fromWAV(hex``);
    //% fixedInstance jres block="colors red"
    export const colorsRed = music.fromWAV(hex``);
    //% fixedInstance jres block="colors white"
    export const colorsWhite = music.fromWAV(hex``);
    //% fixedInstance jres block="colors yellow"
    export const colorsYellow = music.fromWAV(hex``);
    //% fixedInstance jres block="communication bravo"
    export const communicationBravo = music.fromWAV(hex``);
    //% fixedInstance jres block="communication ev3"
    export const communicationEv3 = music.fromWAV(hex``);
    //% fixedInstance jres block="communication fantastic"
    export const communicationFantastic = music.fromWAV(hex``);
    //% fixedInstance jres block="communication game over"
    export const communicationGameOver = music.fromWAV(hex``);
    //% fixedInstance jres block="communication go"
    export const communicationGo = music.fromWAV(hex``);
    //% fixedInstance jres block="communication good job"
    export const communicationGoodJob = music.fromWAV(hex``);
    //% fixedInstance jres block="communication good"
    export const communicationGood = music.fromWAV(hex``);
    //% fixedInstance jres block="communication goodbye"
    export const communicationGoodbye = music.fromWAV(hex``);
    //% fixedInstance jres block="communication hello"
    export const communicationHello = music.fromWAV(hex``);
    //% fixedInstance jres block="communication hi"
    export const communicationHi = music.fromWAV(hex``);
    //% fixedInstance jres block="communication lego"
    export const communicationLego = music.fromWAV(hex``);
    //% fixedInstance jres block="communication mindstorms"
    export const communicationMindstorms = music.fromWAV(hex``);
    //% fixedInstance jres block="communication morning"
    export const communicationMorning = music.fromWAV(hex``);
    //% fixedInstance jres block="communication no"
    export const communicationNo = music.fromWAV(hex``);
    //% fixedInstance jres block="communication okay"
    export const communicationOkay = music.fromWAV(hex``);
    //% fixedInstance jres block="communication okey dokey"
    export const communicationOkeyDokey = music.fromWAV(hex``);
    //% fixedInstance jres block="communication sorry"
    export const communicationSorry = music.fromWAV(hex``);
    //% fixedInstance jres block="communication thank you"
    export const communicationThankYou = music.fromWAV(hex``);
    //% fixedInstance jres block="communication yes"
    export const communicationYes = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions boing"
    export const expressionsBoing = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions boo"
    export const expressionsBoo = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions cheering"
    export const expressionsCheering = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions crunching"
    export const expressionsCrunching = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions crying"
    export const expressionsCrying = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions fanfare"
    export const expressionsFanfare = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions kung fu"
    export const expressionsKungFu = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions laughing1"
    export const expressionsLaughing1 = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions laughing2"
    export const expressionsLaughing2 = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions magic wand"
    export const expressionsMagicWand = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions ouch"
    export const expressionsOuch = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions shouting"
    export const expressionsShouting = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions smack"
    export const expressionsSmack = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions sneezing"
    export const expressionsSneezing = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions snoring"
    export const expressionsSnoring = music.fromWAV(hex``);
    //% fixedInstance jres block="expressions uh oh"
    export const expressionsUhOh = music.fromWAV(hex``);
    //% fixedInstance jres block="information activate"
    export const informationActivate = music.fromWAV(hex``);
    //% fixedInstance jres block="information analyze"
    export const informationAnalyze = music.fromWAV(hex``);
    //% fixedInstance jres block="information backwards"
    export const informationBackwards = music.fromWAV(hex``);
    //% fixedInstance jres block="information color"
    export const informationColor = music.fromWAV(hex``);
    //% fixedInstance jres block="information detected"
    export const informationDetected = music.fromWAV(hex``);
    //% fixedInstance jres block="information down"
    export const informationDown = music.fromWAV(hex``);
    //% fixedInstance jres block="information error alarm"
    export const informationErrorAlarm = music.fromWAV(hex``);
    //% fixedInstance jres block="information error"
    export const informationError = music.fromWAV(hex``);
    //% fixedInstance jres block="information flashing"
    export const informationFlashing = music.fromWAV(hex``);
    //% fixedInstance jres block="information forward"
    export const informationForward = music.fromWAV(hex``);
    //% fixedInstance jres block="information left"
    export const informationLeft = music.fromWAV(hex``);
    //% fixedInstance jres block="information object"
    export const informationObject = music.fromWAV(hex``);
    //% fixedInstance jres block="information right"
    export const informationRight = music.fromWAV(hex``);
    //% fixedInstance jres block="information searching"
    export const informationSearching = music.fromWAV(hex``);
    //% fixedInstance jres block="information start"
    export const informationStart = music.fromWAV(hex``);
    //% fixedInstance jres block="information stop"
    export const informationStop = music.fromWAV(hex``);
    //% fixedInstance jres block="information touch"
    export const informationTouch = music.fromWAV(hex``);
    //% fixedInstance jres block="information turn"
    export const informationTurn = music.fromWAV(hex``);
    //% fixedInstance jres block="information up"
    export const informationUp = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical air release"
    export const mechanicalAirRelease = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical airbrake"
    export const mechanicalAirbrake = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical backing alert"
    export const mechanicalBackingAlert = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical blip1"
    export const mechanicalBlip1 = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical blip2"
    export const mechanicalBlip2 = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical blip3"
    export const mechanicalBlip3 = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical blip4"
    export const mechanicalBlip4 = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical horn1"
    export const mechanicalHorn1 = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical horn2"
    export const mechanicalHorn2 = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical laser"
    export const mechanicalLaser = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical motor idle"
    export const mechanicalMotorIdle = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical motor start"
    export const mechanicalMotorStart = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical motor stop"
    export const mechanicalMotorStop = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical ratchet"
    export const mechanicalRatchet = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical sonar"
    export const mechanicalSonar = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical tick tack"
    export const mechanicalTickTack = music.fromWAV(hex``);
    //% fixedInstance jres block="mechanical walk"
    export const mechanicalWalk = music.fromWAV(hex``);
    //% fixedInstance jres block="movements arm1"
    export const movementsArm1 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements arm2"
    export const movementsArm2 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements arm3"
    export const movementsArm3 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements arm4"
    export const movementsArm4 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements drop load"
    export const movementsDropLoad = music.fromWAV(hex``);
    //% fixedInstance jres block="movements lift load"
    export const movementsLiftLoad = music.fromWAV(hex``);
    //% fixedInstance jres block="movements servo1"
    export const movementsServo1 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements servo2"
    export const movementsServo2 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements servo3"
    export const movementsServo3 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements servo4"
    export const movementsServo4 = music.fromWAV(hex``);
    //% fixedInstance jres block="movements slide load"
    export const movementsSlideLoad = music.fromWAV(hex``);
    //% fixedInstance jres block="movements snap"
    export const movementsSnap = music.fromWAV(hex``);
    //% fixedInstance jres block="movements speed down"
    export const movementsSpeedDown = music.fromWAV(hex``);
    //% fixedInstance jres block="movements speed idle"
    export const movementsSpeedIdle = music.fromWAV(hex``);
    //% fixedInstance jres block="movements speed up"
    export const movementsSpeedUp = music.fromWAV(hex``);
    //% fixedInstance jres block="movements speeding"
    export const movementsSpeeding = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers eight"
    export const numbersEight = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers five"
    export const numbersFive = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers four"
    export const numbersFour = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers nine"
    export const numbersNine = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers one"
    export const numbersOne = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers seven"
    export const numbersSeven = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers six"
    export const numbersSix = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers ten"
    export const numbersTen = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers three"
    export const numbersThree = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers two"
    export const numbersTwo = music.fromWAV(hex``);
    //% fixedInstance jres block="numbers zero"
    export const numbersZero = music.fromWAV(hex``);
    //% fixedInstance jres block="system click"
    export const systemClick = music.fromWAV(hex``);
    //% fixedInstance jres block="system confirm"
    export const systemConfirm = music.fromWAV(hex``);
    //% fixedInstance jres block="system connect"
    export const systemConnect = music.fromWAV(hex``);
    //% fixedInstance jres block="system download"
    export const systemDownload = music.fromWAV(hex``);
    //% fixedInstance jres block="system general alert"
    export const systemGeneralAlert = music.fromWAV(hex``);
    //% fixedInstance jres block="system overpower"
    export const systemOverpower = music.fromWAV(hex``);
    //% fixedInstance jres block="system power down"
    export const systemPowerDown = music.fromWAV(hex``);
    //% fixedInstance jres block="system ready"
    export const systemReady = music.fromWAV(hex``);
    //% fixedInstance jres block="system start up"
    export const systemStartUp = music.fromWAV(hex``);
}

namespace music {
    let numSoundsPlaying = 0;
    const soundsLimit = 1;

    /**
     * Play a sound and wait until it finishes
     * @param sound the sound to play
     */
    //% blockId=music_play_sound_effect_until_done block="play sound effect %sound=music_sound_picker|until done"
    //% weight=98 blockGap=8
    //% help=music/play-sound-effect-until-done
    export function playSoundEffectUntilDone(sound: Sound) {
        if (!sound || numSoundsPlaying >= soundsLimit) return;
        numSoundsPlaying++;
        sound.play();
        numSoundsPlaying--;
    }

    /**
     * A sound
     * @param sound the sound
     */
    //% blockId=music_sound_picker block="%sound" shim=TD_ID
    //% sound.fieldEditor="music"
    //% weight=0 blockHidden=1
    export function __soundPicker(sound: Sound): Sound {
        return sound;
    }

    /**
     * Start playing a sound and don't wait for it to finish.
     * @param sound the sound to play
     */
    //% blockId=music_play_sound_effect block="play sound effect %sound=music_sound_picker"
    //% weight=99 blockGap=8
    //% help=music/play-sound-effect
    export function playSoundEffect(sound: Sound) {
        if (!sound || numSoundsPlaying >= soundsLimit) return;
        numSoundsPlaying++;
        control.runInParallel(() => {
            sound.play();
            numSoundsPlaying--;
        });
    }
}
