2017-03-01 09:38:12 +01:00
|
|
|
# Begin Melody
|
2017-03-01 00:23:32 +01:00
|
|
|
|
2017-03-01 09:38:12 +01:00
|
|
|
Begin playing a musical melody through pin ``P0`` of the @boardname@.
|
2017-03-01 00:23:32 +01:00
|
|
|
|
|
|
|
## Simulator
|
|
|
|
|
|
|
|
This function only works on the @boardname@ and in some browsers.
|
|
|
|
|
|
|
|
```sig
|
2017-03-01 09:34:31 +01:00
|
|
|
music.beginMelody(music.builtInMelody(Melodies.Entertainer), MelodyOptions.Once)
|
2017-03-01 00:23:32 +01:00
|
|
|
```
|
2017-11-30 05:08:29 +01:00
|
|
|
or in the format ``NOTE[octave][:duration] eg: ['g5:1']``
|
|
|
|
```sig
|
|
|
|
music.beginMelody(['g4:1', 'c5', 'e', 'g:2', 'e:1', 'g:3'], MelodyOptions.Once)
|
|
|
|
```
|
2017-03-01 00:23:32 +01:00
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Parameters
|
2017-03-01 00:23:32 +01:00
|
|
|
|
2017-03-01 09:38:12 +01:00
|
|
|
* ``melody`` is the array representation of a melody you wish to play
|
2017-03-01 00:23:32 +01:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
2017-03-01 09:38:12 +01:00
|
|
|
This example plays the ``Entertainer`` built-in melody.
|
2017-03-01 00:23:32 +01:00
|
|
|
|
|
|
|
```blocks
|
2017-03-01 09:34:31 +01:00
|
|
|
music.beginMelody(music.builtInMelody(Melodies.Entertainer), MelodyOptions.Once)
|
2017-03-01 00:23:32 +01:00
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## See also
|
2017-03-01 00:23:32 +01:00
|
|
|
|
|
|
|
[play tone](/reference/music/play-tone), [rest](/reference/music/rest), [ring tone](/reference/music/ring-tone) , [tempo](/reference/music/tempo), [set tempo](/reference/music/set-tempo),
|
|
|
|
[change tempo by](/reference/music/change-tempo-by)
|
|
|
|
|