This function only works on the micro:bit and in some browsers.
Play Tone
Play a musical tone through pin P0 of the micro:bit for as long as you say.
music.playTone(440, 120)
Parameters
frequencyis the number of Hertz (how high or low the tone is).msis the number of milliseconds that the tone lasts
Example
This example stores the musical note C in the variable freq.
Next, it plays that note for 1000 milliseconds (one second).
let freq = music.noteFrequency(Note.C)
music.playTone(freq, 1000)
Using other pins
Use analogSetPitchPin to change that pin used to generate music.
pins.analogSetPitchPin(AnalogPin.P1);