Add sounds (only simulator for now)
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
{
|
||||
"Sound.buffer": "Returns the underlaying Buffer object.",
|
||||
"Sound.play": "Play sound with given volume.",
|
||||
"music": "Generation of music tones.",
|
||||
"music.beat": "Return the duration of a beat in milliseconds (the beat fraction).",
|
||||
"music.beat|param|fraction": "the fraction of the current whole note, eg: BeatFraction.Half",
|
||||
"music.changeTempoBy": "Change the tempo up or down by some amount of beats per minute (bpm).",
|
||||
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
||||
"music.fromWAV": "Makes a sound bound to a buffer in WAV format.",
|
||||
"music.noteFrequency": "Get the frequency of a note.",
|
||||
"music.noteFrequency|param|name": "the note name, eg: Note.C",
|
||||
"music.playSound": "Start playing a sound and don't wait for it to finish.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
|
||||
|
@ -42,5 +42,7 @@
|
||||
"music.stopAllSounds|block": "stop all sounds",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "music",
|
||||
"{id:category}Music": "Music"
|
||||
"{id:category}Music": "Music",
|
||||
"{id:category}Sound": "Sound",
|
||||
"{id:category}Sounds": "Sounds"
|
||||
}
|
@ -6,7 +6,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#define NOTE_PAUSE 20
|
||||
|
||||
namespace music {
|
||||
@ -51,8 +50,7 @@ static void _stopSound() {
|
||||
writeDev(&cmd, sizeof(cmd));
|
||||
}
|
||||
|
||||
static void _playTone(uint16_t frequency, uint16_t duration, uint8_t volume)
|
||||
{
|
||||
static void _playTone(uint16_t frequency, uint16_t duration, uint8_t volume) {
|
||||
ToneCmd cmd;
|
||||
cmd.cmd = SOUND_CMD_TONE;
|
||||
cmd.vol = volume;
|
||||
@ -90,4 +88,31 @@ void playTone(int frequency, int ms) {
|
||||
}
|
||||
sleep_ms(1);
|
||||
}
|
||||
|
||||
|
||||
/** Makes a sound bound to a buffer in WAV format. */
|
||||
//%
|
||||
Sound fromWAV(Buffer buf) {
|
||||
incrRC(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//% fixedInstances
|
||||
namespace SoundMethods {
|
||||
|
||||
/** Returns the underlaying Buffer object. */
|
||||
//% property
|
||||
Buffer buffer(Sound snd) {
|
||||
incrRC(snd);
|
||||
return snd;
|
||||
}
|
||||
|
||||
/** Play sound with given volume. */
|
||||
//% promise
|
||||
void play(Sound snd, int volume) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,8 @@
|
||||
"shims.d.ts",
|
||||
"melodies.ts",
|
||||
"music.ts",
|
||||
"sounds.jres",
|
||||
"sounds.ts",
|
||||
"ns.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
|
17
libs/music/shims.d.ts
vendored
17
libs/music/shims.d.ts
vendored
@ -24,6 +24,23 @@ declare namespace music {
|
||||
//% blockNamespace=music
|
||||
//% weight=76 blockGap=8 shim=music::playTone
|
||||
function playTone(frequency: int32, ms: int32): void;
|
||||
|
||||
/** Makes a sound bound to a buffer in WAV format. */
|
||||
//% shim=music::fromWAV
|
||||
function fromWAV(buf: Buffer): Sound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% fixedInstances
|
||||
declare interface Sound {
|
||||
/** Returns the underlaying Buffer object. */
|
||||
//% property shim=SoundMethods::buffer
|
||||
buffer: Buffer;
|
||||
|
||||
/** Play sound with given volume. */
|
||||
//% promise shim=SoundMethods::play
|
||||
play(volume: int32): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
||||
|
134
libs/music/sounds.jres
Normal file
134
libs/music/sounds.jres
Normal file
File diff suppressed because one or more lines are too long
256
libs/music/sounds.ts
Normal file
256
libs/music/sounds.ts
Normal file
@ -0,0 +1,256 @@
|
||||
namespace sounds {
|
||||
//% fixedInstance jres
|
||||
export const animalsCatPurr = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsDogBark1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsDogBark2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsDogGrowl = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsDogSniff = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsDogWhine = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsElephantCall = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsInsectBuzz1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsInsectBuzz2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsInsectChirp = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsSnakeHiss = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsSnakeRattle = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const animalsTRexRoar = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const colorsBlack = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const colorsBlue = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const colorsBrown = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const colorsGreen = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const colorsRed = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const colorsWhite = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const colorsYellow = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationBravo = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationEv3 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationFantastic = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationGameOver = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationGo = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationGoodJob = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationGood = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationGoodbye = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationHello = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationHi = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationLego = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationMindstorms = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationMorning = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationNo = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationOkay = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationOkeyDokey = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationSorry = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationThankYou = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const communicationYes = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsBoing = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsBoo = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsCheering = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsCrunching = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsCrying = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsFanfare = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsKungFu = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsLaughing1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsLaughing2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsMagicWand = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsOuch = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsShouting = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsSmack = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsSneezing = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsSnoring = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const expressionsUhOh = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationActivate = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationAnalyze = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationBackwards = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationColor = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationDetected = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationDown = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationErrorAlarm = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationError = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationFlashing = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationForward = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationLeft = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationObject = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationRight = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationSearching = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationStart = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationStop = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationTouch = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationTurn = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const informationUp = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalAirRelease = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalAirbrake = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalBackingAlert = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalBlip1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalBlip2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalBlip3 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalBlip4 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalHorn1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalHorn2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalLaser = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalMotorIdle = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalMotorStart = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalMotorStop = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalRatchet = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalSonar = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalTickTack = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const mechanicalWalk = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsArm1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsArm2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsArm3 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsArm4 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsDropLoad = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsLiftLoad = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsServo1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsServo2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsServo3 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsServo4 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsSlideLoad = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsSnap = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsSpeedDown = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsSpeedIdle = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsSpeedUp = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const movementsSpeeding = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersEight = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersFive = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersFour = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersNine = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersOne = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersSeven = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersSix = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersTen = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersThree = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersTwo = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const numbersZero = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemClick = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemConfirm = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemConnect = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemDownload = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemGeneralAlert = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemOverpower = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemPowerDown = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemReady = music.fromWAV(hex``);
|
||||
//% fixedInstance jres
|
||||
export const systemStartUp = music.fromWAV(hex``);
|
||||
}
|
Reference in New Issue
Block a user