Melody events (#391)
* support for custom playTone * added music.onEvent, music.setPlayTone * updated docs * updated sample
This commit is contained in:
		@@ -164,15 +164,16 @@
 | 
			
		||||
  "led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
 | 
			
		||||
  "led.unplot|param|x": "TODO",
 | 
			
		||||
  "led.unplot|param|y": "TODO",
 | 
			
		||||
  "music": "Generation of music tones through pin ``P0``.",
 | 
			
		||||
  "music": "Generation of music tones.",
 | 
			
		||||
  "music.beat": "Returns the duration of a beat in milli-seconds",
 | 
			
		||||
  "music.beginMelody": "Starts playing a melody through pin ``P0``.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
 | 
			
		||||
  "music.beginMelody": "Starts playing a melody.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
 | 
			
		||||
  "music.beginMelody|param|options": "melody options, once / forever, in the foreground / background",
 | 
			
		||||
  "music.builtInMelody": "Gets the melody array of a built-in melody.",
 | 
			
		||||
  "music.changeTempoBy": "Change the tempo by the specified amount",
 | 
			
		||||
  "music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
 | 
			
		||||
  "music.noteFrequency": "Gets the frequency of a note.",
 | 
			
		||||
  "music.noteFrequency|param|name": "the note name, eg: Note.C",
 | 
			
		||||
  "music.onEvent": "Registers code to run on various melody events",
 | 
			
		||||
  "music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
 | 
			
		||||
  "music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
 | 
			
		||||
  "music.playTone|param|ms": "tone duration in milliseconds (ms)",
 | 
			
		||||
@@ -180,6 +181,7 @@
 | 
			
		||||
  "music.rest|param|ms": "rest duration in milliseconds (ms)",
 | 
			
		||||
  "music.ringTone": "Plays a tone through pin ``P0``.",
 | 
			
		||||
  "music.ringTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
 | 
			
		||||
  "music.setPlayTone": "Sets a custom playTone function for playing melodies",
 | 
			
		||||
  "music.setTempo": "Sets the tempo to the specified amount",
 | 
			
		||||
  "music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
 | 
			
		||||
  "music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
 | 
			
		||||
 
 | 
			
		||||
@@ -149,6 +149,16 @@
 | 
			
		||||
  "MelodyOptions.Forever|block": "forever",
 | 
			
		||||
  "MelodyOptions.OnceInBackground|block": "once in background",
 | 
			
		||||
  "MelodyOptions.Once|block": "once",
 | 
			
		||||
  "MusicEvent.BackgroundMelodyEnded|block": "background melody ended",
 | 
			
		||||
  "MusicEvent.BackgroundMelodyNotePlayed|block": "background melody note played",
 | 
			
		||||
  "MusicEvent.BackgroundMelodyPaused|block": "background melody paused",
 | 
			
		||||
  "MusicEvent.BackgroundMelodyRepeated|block": "background melody repeated",
 | 
			
		||||
  "MusicEvent.BackgroundMelodyResumed|block": "background melody resumed",
 | 
			
		||||
  "MusicEvent.BackgroundMelodyStarted|block": "background melody started",
 | 
			
		||||
  "MusicEvent.MelodyEnded|block": "melody ended",
 | 
			
		||||
  "MusicEvent.MelodyNotePlayed|block": "melody note played",
 | 
			
		||||
  "MusicEvent.MelodyRepeated|block": "melody repeated",
 | 
			
		||||
  "MusicEvent.MelodyStarted|block": "melody started",
 | 
			
		||||
  "Note.CSharp3|block": "C#3",
 | 
			
		||||
  "Note.CSharp4|block": "C#4",
 | 
			
		||||
  "Note.CSharp5|block": "C#5",
 | 
			
		||||
@@ -234,10 +244,11 @@
 | 
			
		||||
  "led.unplot|block": "unplot|x %x|y %y",
 | 
			
		||||
  "led|block": "led",
 | 
			
		||||
  "music.beat|block": "%fraction|beat",
 | 
			
		||||
  "music.beginMelody|block": "start|melody %melody=device_builtin_melody| repeating %options",
 | 
			
		||||
  "music.beginMelody|block": "start melody %melody=device_builtin_melody| repeating %options",
 | 
			
		||||
  "music.builtInMelody|block": "%melody",
 | 
			
		||||
  "music.changeTempoBy|block": "change tempo by (bpm)|%value",
 | 
			
		||||
  "music.noteFrequency|block": "%note",
 | 
			
		||||
  "music.onEvent|block": "music on %value",
 | 
			
		||||
  "music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
 | 
			
		||||
  "music.rest|block": "rest(ms)|%duration=device_beat",
 | 
			
		||||
  "music.ringTone|block": "ring tone (Hz)|%note=device_note",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user