-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# string Playable | ||
|
||
Created a short melody of notes composed in a string. | ||
|
||
```sig | ||
music.stringPlayable("D F E A E A C B ", 120) | ||
``` | ||
|
||
The **melody** is short series of notes composed in a string. The melody is played at a rate set by the **tempo** value you give. The melody string contains a sequence of notes formatted like this: | ||
|
||
``"E B C5 A B G A F "`` | ||
|
||
The melody is shown in the ``||music:melody||`` block as note symbols which also appear in the Melody Editor. | ||
|
||
```block | ||
music.stringPlayable("E F G F E G B C5 ", 120) | ||
``` | ||
|
||
The melodies are most often created in the Melody Editor from the block so that valid notes are chosen and the correct melody length is set. | ||
|
||
## Parameters | ||
|
||
* **melody**: a [string](/types/string) which contains the notes of the melody. | ||
* **tempo**: a [number](/types/number) which is the rate to play the melody at in beats per minute. | ||
|
||
## Returns | ||
|
||
* a [playable](/types/playable) object that contains the **melody** and **tempo**. | ||
|
||
## Example | ||
|
||
Play the ``Mystery`` melody continuously. | ||
|
||
```blocks | ||
music.play(music.stringPlayable("E F G F E G B C5 ", 120), music.PlaybackMode.LoopingInBackground) | ||
``` | ||
|
||
## See also | ||
|
||
[tone playable](/reference/music/tone-playable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# tone Playable | ||
|
||
Create a musical tone that will play for some amount of time. | ||
|
||
```sig | ||
music.tonePlayable(262, music.beat(BeatFraction.Whole)) | ||
``` | ||
|
||
## Parameters | ||
|
||
* **note**: is the note frequency as a [number](/types/number) of [Hertz](https://wikipedia.org/wiki/Hertz) (how high or low the tone is, also known as _pitch_). If **note** is less or equal to zero, no sound is played. | ||
* **duration**: is the [number](/types/number) of milliseconds (one-thousandth of a second) that the tone lasts for. If **duration** is negative or zero, the sound will play continuously. | ||
|
||
## Returns | ||
|
||
* a [playable](/types/playable) object that contains the tone. | ||
|
||
## Example | ||
|
||
Store the musical note 'C' in the variable `note` and play that note for 1000 milliseconds (one second). | ||
|
||
```blocks | ||
let note = music.noteFrequency(Note.C); | ||
music.play(music.tonePlayable(note, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone) | ||
``` | ||
|
||
## See also | ||
|
||
[string playable](/reference/music/string-playable) |