pxt-common-packages 11.1.1 → 11.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/built/common-sim.d.ts +6 -0
  2. package/built/common-sim.js +62 -29
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/color/built/debug/binary.js +8 -8
  5. package/libs/color-sensor/built/debug/binary.js +8 -8
  6. package/libs/controller/built/debug/binary.js +7986 -7953
  7. package/libs/controller---none/built/debug/binary.js +7965 -7932
  8. package/libs/datalogger/built/debug/binary.js +63 -63
  9. package/libs/edge-connector/built/debug/binary.js +8 -8
  10. package/libs/esp32/built/debug/binary.js +462 -462
  11. package/libs/game/built/debug/binary.js +7878 -7845
  12. package/libs/game/sprite.ts +2 -0
  13. package/libs/game/sprites.ts +1 -0
  14. package/libs/lcd/built/debug/binary.js +8 -8
  15. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  16. package/libs/lora/built/debug/binary.js +8 -8
  17. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  18. package/libs/microphone/sim/state.ts +2 -0
  19. package/libs/mixer/docs/reference/music/create-sound-effect.md +68 -0
  20. package/libs/mixer/docs/reference/music/play-sound-effect.md +59 -0
  21. package/libs/mixer/docs/reference/music/play.md +10 -2
  22. package/libs/mixer/docs/reference/music/randomize-sound.md +30 -0
  23. package/libs/mixer/docs/types/sound-effect.md +136 -0
  24. package/libs/mixer/playable.ts +19 -1
  25. package/libs/mixer/soundEffect.ts +1 -1
  26. package/libs/mqtt/built/debug/binary.js +176 -176
  27. package/libs/net/built/debug/binary.js +176 -176
  28. package/libs/net-game/built/debug/binary.js +9666 -9633
  29. package/libs/palette/built/debug/binary.js +7877 -7844
  30. package/libs/pixel/built/debug/binary.js +8 -8
  31. package/libs/power/built/debug/binary.js +8 -8
  32. package/libs/proximity/built/debug/binary.js +8 -8
  33. package/libs/radio/built/debug/binary.js +8 -8
  34. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  35. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  36. package/libs/screen/_locales/screen-strings.json +1 -1
  37. package/libs/screen/built/debug/binary.js +50 -50
  38. package/libs/screen/fieldeditors.ts +5 -4
  39. package/libs/screen/sim/image.ts +32 -31
  40. package/libs/servo/built/debug/binary.js +8 -8
  41. package/libs/shader/pxt.json +14 -0
  42. package/libs/shader/shader.cpp +140 -0
  43. package/libs/shader/shader.ts +19 -0
  44. package/libs/shader/sim/shader.ts +37 -0
  45. package/libs/sprite-scaling/built/debug/binary.js +7877 -7844
  46. package/libs/storyboard/built/debug/binary.js +7877 -7844
  47. package/package.json +1 -1
@@ -694,6 +694,8 @@ class Sprite extends sprites.BaseSprite {
694
694
  return false
695
695
  if (other.flags & SPRITE_NO_SPRITE_OVERLAPS)
696
696
  return false
697
+ if (this.flags & sprites.Flag.HitboxOverlaps || other.flags & sprites.Flag.HitboxOverlaps)
698
+ return other._hitbox.overlapsWith(this._hitbox);
697
699
  if (!other._hitbox.overlapsWith(this._hitbox))
698
700
  return false;
699
701
  if (!this.isScaled() && !other.isScaled()) {
@@ -196,6 +196,7 @@ namespace sprites {
196
196
  GhostThroughTiles = 1 << 10, // No overlaps with tiles
197
197
  GhostThroughWalls = 1 << 11, // No collisions with walls
198
198
  GhostThroughSprites = 1 << 12, // No overlaps with other sprites
199
+ HitboxOverlaps = 1 << 13, // If set, overlaps with this sprite are based off of both sprites' hitboxes and not pixel perfect
199
200
  Ghost = sprites.Flag.GhostThroughSprites | sprites.Flag.GhostThroughWalls | sprites.Flag.GhostThroughTiles, // doesn't collide with other sprites or walls
200
201
  }
201
202
  }
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48883(s) {
59
+ function _main___P48898(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___49126 = (undefined);
70
- globals._pollEventQueue___49139 = (undefined);
69
+ globals._intervals___49141 = (undefined);
70
+ globals._pollEventQueue___49154 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48883.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48883.continuations = [ ]
75
+ _main___P48898.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48898.continuations = [ ]
77
77
 
78
- function _main___P48883_mk(s) {
78
+ function _main___P48898_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48883, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48898, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P48883_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48883
91
+ return _main___P48898
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P98987(s) {
59
+ function _main___P99032(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___99230 = (undefined);
70
- globals._pollEventQueue___99243 = (undefined);
69
+ globals._intervals___99275 = (undefined);
70
+ globals._pollEventQueue___99288 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P98987.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P98987.continuations = [ ]
75
+ _main___P99032.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P99032.continuations = [ ]
77
77
 
78
- function _main___P98987_mk(s) {
78
+ function _main___P99032_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P98987, depth: s.depth + 1,
81
+ parent: s, fn: _main___P99032, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P98987_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P98987
91
+ return _main___P99032
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P60191(s) {
59
+ function _main___P60206(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___60434 = (undefined);
70
- globals._pollEventQueue___60447 = (undefined);
69
+ globals._intervals___60449 = (undefined);
70
+ globals._pollEventQueue___60462 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P60191.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P60191.continuations = [ ]
75
+ _main___P60206.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P60206.continuations = [ ]
77
77
 
78
- function _main___P60191_mk(s) {
78
+ function _main___P60206_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P60191, depth: s.depth + 1,
81
+ parent: s, fn: _main___P60206, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P60191_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P60191
91
+ return _main___P60206
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P192707(s) {
59
+ function _main___P192812(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___192950 = (undefined);
70
- globals._pollEventQueue___192963 = (undefined);
69
+ globals._intervals___193055 = (undefined);
70
+ globals._pollEventQueue___193068 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P192707.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P192707.continuations = [ ]
75
+ _main___P192812.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P192812.continuations = [ ]
77
77
 
78
- function _main___P192707_mk(s) {
78
+ function _main___P192812_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P192707, depth: s.depth + 1,
81
+ parent: s, fn: _main___P192812, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P192707_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P192707
91
+ return _main___P192812
92
92
  })
@@ -1,3 +1,5 @@
1
+ /// <reference path="../../core/sim/analogSensor.ts" />
2
+
1
3
  namespace pxsim {
2
4
  export interface MicrophoneBoard {
3
5
  microphoneState: MicrophoneState;
@@ -0,0 +1,68 @@
1
+ # create Sound Effect
2
+
3
+ Create a sound expression string for a sound effect.
4
+
5
+ ```sig
6
+ music.createSoundEffect(WaveShape.Sine, 2000, 0, 1023, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear)
7
+ ```
8
+
9
+ A sound expression is set of parameters that describe a **[sound effect](/types/sound-effect)** that will last for some amount of time. These parameters specify a base waveform, frequency range, sound volume, and effects. Sound data is created as a [sound effect](/types/sound-effect) object and can then be [played](/reference/music/play) to the speaker, headphones, or at an output pin.
10
+
11
+ ## Parameters
12
+
13
+ * **waveShape**: the primary shape of the waveform:
14
+ >* `sine`: sine wave shape
15
+ >* `sawtooth`: sawtooth wave shape
16
+ >* `triangle`: triangle wave shape
17
+ >* `square`: square wave shape
18
+ >* `noise`: random noise generated wave shape
19
+ * **startFrequency**: a [number](/types/number) that is the frequency of the waveform when the sound expression starts.
20
+ * **endFrequency**: a [number](/types/number) that is the frequency of the waveform when the sound expression stops.
21
+ * **startVolume**: a [number](/types/number) the initial volume of the sound expression.
22
+ * **endVolume**: a [number](/types/number) the ending volume of the sound expression.
23
+ * **duration**: a [number](/types/number) the duration in milliseconds of the sound expression.
24
+ * **effect**: an effect to add to the waveform. These are:
25
+ >* `tremolo`: add slight changes in volume of the sound expression.
26
+ >* `vibrato`: add slight changes in frequency to the sound expression.
27
+ >* `warble`: similar to `vibrato` but with faster variations in the frequency changes.
28
+ * **interpolation**: controls the rate of frequency change in the sound expression.
29
+ >* `linear`: the change in frequency is constant for the duration of the sound.
30
+ >* `curve`: the change in frequency is faster at the beginning of the sound and slows toward the end.
31
+ >* `logarithmic`: the change in frequency is rapid during the very first part of the sound.
32
+
33
+ ## Returns
34
+
35
+ * a [soundEffect](/types/sound-effect) object with the the desired sound effect parameters.
36
+
37
+ ## Examples
38
+
39
+ ### Sine wave sound
40
+
41
+ Create a sound expression string and assign it to a variable. Play the sound for the sound expression.
42
+
43
+ ```blocks
44
+ let mySound = music.createSoundEffect(WaveShape.Sine, 2000, 0, 1023, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear)
45
+ music.playSoundEffect(mySound, SoundExpressionPlayMode.UntilDone)
46
+ ```
47
+
48
+ ### Complex waveform sound
49
+
50
+ Create a `triangle` wave sound expression with `vibrato` and a `curve` interpolation. Play the sound until it finishes.
51
+
52
+ ```typescript
53
+ let mySound = music.createSoundEffect(
54
+ WaveShape.Triangle,
55
+ 1000,
56
+ 2700,
57
+ 255,
58
+ 255,
59
+ 500,
60
+ SoundExpressionEffect.Vibrato,
61
+ InterpolationCurve.Curve
62
+ )
63
+ music.playSoundEffect(mySound, SoundExpressionPlayMode.UntilDone)
64
+ ```
65
+
66
+ ## See also
67
+
68
+ [play](/reference/music/play)
@@ -0,0 +1,59 @@
1
+ # play Sound Effect
2
+
3
+ Play a sound that is generated from a sound expression.
4
+
5
+ ```sig
6
+ music.playSoundEffect("", SoundExpressionPlayMode.UntilDone)
7
+ ```
8
+
9
+ This will play a **[Sound](/types/sound)** object created from a sound expression. The sound will play for the duration that was set in the sound expression. The sound can play on the speaker or at a pin that is set for sound output.
10
+
11
+ You can also play [built-in sound effects](/reference/music/builtin-sound-effect) like `giggle`, `happy`, or `twinkle`.
12
+
13
+ Your program can wait for the sound to finish before it runs its next step. To do this, set the play mode to `until done`. Otherwise, use `background` for the program to continue immediately after the sound starts.
14
+
15
+ ### ~ reminder
16
+
17
+ #### Works with micro:bit V2
18
+
19
+ ![works with micro:bit V2 only image](/static/v2/v2-only.png)
20
+
21
+ This block requires the [micro:bit V2](/device/v2) hardware. If you use this block with a micro:bit v1 board, you will see the **927** error code on the screen.
22
+
23
+ ### ~
24
+
25
+ ## Parameters
26
+
27
+ * **sound**: a [string](/types/string) that is the sound expression for the sound you want to play.
28
+ * **mode**: the play mode for the sound, either `until done` or `background`.
29
+
30
+ ## Examples
31
+
32
+ ### Simple waveform sound
33
+
34
+ Play the sound effect from a sine wave sound expression for `1` second.
35
+
36
+ ```blocks
37
+ music.playSoundEffect(music.createSoundEffect(WaveShape.Sine, 2000, 0, 1023, 0, 1000, SoundExpressionEffect.None, InterpolationCurve.Linear), SoundExpressionPlayMode.UntilDone)
38
+ ```
39
+
40
+ ### Complex waveform sound
41
+
42
+ Play a `triangle` wave sound effect with `vibrato` and a `curve` interpolation.
43
+
44
+ ```typescript
45
+ music.playSoundEffect(music.createSoundEffect(
46
+ WaveShape.Triangle,
47
+ 1000,
48
+ 2700,
49
+ 255,
50
+ 255,
51
+ 500,
52
+ SoundExpressionEffect.Vibrato,
53
+ InterpolationCurve.Curve
54
+ ), SoundExpressionPlayMode.UntilDone)
55
+ ```
56
+
57
+ ## See also
58
+
59
+ [create sound effect](/reference/music/create-sound-effect)
@@ -1,6 +1,6 @@
1
1
  # play
2
2
 
3
- Play a song, melody, or tone from a playable music source.
3
+ Play a song, melody, tone, or a sound effect from a playable music source.
4
4
 
5
5
  ```sig
6
6
  music.play(music.createSong(hex`00780004080200`), music.PlaybackMode.UntilDone)
@@ -121,6 +121,13 @@ sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSp
121
121
  music.play(music.melodyPlayable(music.zapped), music.PlaybackMode.UntilDone)
122
122
  })
123
123
  ```
124
+ ### Play a sound effect
125
+
126
+ Play a sine wave sound effect for `5` seconds.
127
+
128
+ ```blocks
129
+ music.play(music.createSoundEffect(WaveShape.Sine, 5000, 0, 255, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear), music.PlaybackMode.UntilDone)
130
+ ```
124
131
 
125
132
  ## See also #seealso
126
133
 
@@ -129,4 +136,5 @@ sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSp
129
136
  [melody playable](/reference/music/melody-playable),
130
137
  [create song](/reference/music/create-song),
131
138
  [stop all sounds](/reference/music/stop-all-sounds),
132
- [song editor](/reference/music/song-editor)
139
+ [song editor](/reference/music/song-editor),
140
+ [create sound effect](/reference/music/create-sound-effect)
@@ -0,0 +1,30 @@
1
+ # randomize Sound
2
+
3
+ Make a new sound similar to the original one but with some variations.
4
+
5
+ ```sig
6
+ music.randomizeSound(music.createSoundEffect(WaveShape.Sine, 5000, 0, 255, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear))
7
+ ```
8
+
9
+ The resulting sound effect will randomize some of the parameters of the original sound effect to create differences from the original sound.
10
+
11
+ ## Parameters
12
+
13
+ * **sound**: the original [sound-effect](/types/sound-effect).
14
+
15
+ ## Returns
16
+
17
+ * a new [sound-effect](/types/sound-effect) with some differences from the oringal **sound**.
18
+
19
+ ## Example
20
+
21
+ Randomize and play a sine wave sound effect.
22
+
23
+ ```blocks
24
+ music.play(music.randomizeSound(music.createSoundEffect(WaveShape.Sine, 5000, 0, 255, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear)), music.PlaybackMode.UntilDone)
25
+ ```
26
+
27
+ ## See also
28
+
29
+ [play](/reference/music/play),
30
+ [create sound effect](/reference/music/create-sound-effect)
@@ -0,0 +1,136 @@
1
+ # sound Effect
2
+
3
+ A **sound effect** is a data object that is created from a sound expression. A sound expression is group of parameters that define a sound, such as wave shape, sound volume, frequency, and duration.
4
+
5
+ A sound is generated from an expression based on a fundamental wave shape, or waveform. To make a sound wave, the sound data must change from a high peak to a low trough over a period of time and repeat. The peaks and troughs are the positive amplitudes and negative amplitudes of the wave across the zero line. The volume controls the amplitude of the wave.
6
+
7
+ When the sound is played on a speaker or headphones, the vibrations create the pressures our ears detect as sound.
8
+
9
+ ### ~ hint
10
+
11
+ #### Sounds and Sound Expressions
12
+
13
+ In code, a **sound effect** type is a complex data object that includes data for all the elements that represent a sound. This includes information about the frequencies and volumes at various points in time for the duration of the sound. A **SoundExpression** is another data type that helps create a **sound effect**. It has the elements of how to make the sound. Many of them you specify when you edit a sound.
14
+
15
+ Code for creating and playing a sound from a sound expression could look like this:
16
+
17
+ ```typescript-ignore
18
+ let mySound = music.createSoundEffect(WaveShape.Sine, 2000, 0, 1023, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear)
19
+ music.playSoundEffect(mySound, SoundExpressionPlayMode.UntilDone)
20
+ ```
21
+
22
+ ### ~
23
+
24
+ ## Sound Editing
25
+
26
+ When you click on the waveform in the ``||music:play sound||`` block, the sound editor will display. The sound editor defines the sound expression parameter with choices for the **waveform**, sound **duration** time, **frequency** range, **volume** range, **effect**, and **interpolation**.
27
+
28
+ ![Sound Editor](/static/types/sound/sound-editor.png)
29
+
30
+ Both the frequency and volume can start and end with different values across the duration of the sound.
31
+
32
+ ## Wave shape
33
+
34
+ The wave shape is chosen to create a natural sound or a synthetic sound. Some wave shapes can also serve to generate signals when played to a pin instead of a speaker or headphones.
35
+
36
+ ### Sine wave
37
+
38
+ The waveform that matches natural sound is the sine wave. This is the wave type in music and voice.
39
+
40
+ ![Sine wave](/static/types/sound/sine-wave.png)
41
+
42
+ ### Sawtooth wave
43
+
44
+ A sawtooth wave has a vertical rising edge and a linear falling edge. It's shape looks like the teeth on a saw.
45
+
46
+ ![Sawtooth wave](/static/types/sound/sawtooth-wave.png)
47
+
48
+ ### Triangle wave
49
+
50
+ The triangle wave is has symmetrical a rising and a falling edge. It makes the shape of triangles in the waveform.
51
+
52
+ ![Triangle wave](/static/types/sound/triangle-wave.png)
53
+
54
+ ### Square wave
55
+
56
+ A square wave has both verical rising and falling edges with a flat section on the top and bottom. The flat sections match the volume set for the sound. Square waves are sometimes used to represent digital data and will make an "electronic" sound.
57
+
58
+ ![Square wave](/static/types/sound/square-wave.png)
59
+
60
+ ### Noise wave
61
+
62
+ The noise wave is created using random frequenices and volume. Setting the frequency parameters for the sound expression creates a "tuning" range for the noise sound effect.
63
+
64
+ ![Noise wave](/static/types/sound/noise-wave.png)
65
+
66
+ ## Duration
67
+
68
+ The sound has a length of time that it plays for. This is set as a number of milliseconds (**ms**).
69
+
70
+ ## Volume
71
+
72
+ The volume controls the loudness (amplitude) of the sound. The sound can start with one volume setting and end with another. It can begin loud and end quiet, or the other way around. The volume control has start and end points that can be adjusted higher and lower. Grab them and move them up or down.
73
+
74
+ ### High to low
75
+
76
+ ![Volume from high to low](/static/types/sound/volume-hilo.png)
77
+
78
+ ### Low to High
79
+
80
+ ![Volume from low to high](/static/types/sound/volume-lohi.png)
81
+
82
+ ### Constant volume
83
+
84
+ ![Constant volume](/static/types/sound/volume-constant.png)
85
+
86
+ ## Frequency
87
+
88
+ Frequency is how fast a wave repeats itself from the zero line to its peak down to its trough and back to the zero line. If it does this 1000 times in one second then the frequency has 1000 cycles per second and is measured in units of Hertz (1000 Hz). The frequency of the sound at any point in time is its current _pitch_. Musical notes and parts of speech are different frequecies that last for short periods of time in a sound.
89
+
90
+ A sound expression has both a starting frequency and an ending frequecy. The frequency can start low and end high, start high and end low, or remain the same for the duration of the sound.
91
+
92
+ ### High to low
93
+
94
+ ![Frequency from high to low](/static/types/sound/freq-hilo.png)
95
+
96
+ ### Low to High
97
+
98
+ ![Frequency from low to high](/static/types/sound/freq-lohi.png)
99
+
100
+ ### Effect
101
+
102
+ Effects add small changes to the waveform but can make a big change in how it sounds to a listener. There are a few effects available to apply to a sound.
103
+
104
+ * **Tremolo**: add slight changes in volume of the sound expression.
105
+
106
+ >![Tremolo effect setting](/static/types/sound/effect-tremolo.png)
107
+
108
+ * **Vibrato**: add slight changes in frequency to the sound expression.
109
+
110
+ >![Vibrato effect setting](/static/types/sound/effect-vibrato.png)
111
+
112
+ * **Warble**: similar to Vibrato but with faster variations in the frequency changes.
113
+
114
+ >![Warble effect setting](/static/types/sound/effect-warble.png)
115
+
116
+ ### Interpolation
117
+
118
+ Interpolation is how the sound expression will make the changes in frequency or volume of the sound. These changes can occur at a constant rate along duration of the sound or more suddenly at the beginning.
119
+
120
+ * **Linear**: The change in frequency is constant for the duration of the sound.
121
+
122
+ >![Frequency from low to high](/static/types/sound/interp-linear.png)
123
+
124
+ * **Curve**: The change in frequency is faster at the beginning of the sound and slows toward the end.
125
+
126
+ >![Frequency from low to high](/static/types/sound/interp-curve.png)
127
+
128
+ * **Logarithmic**: The change in frequency is rapid during the very first part of the sound.
129
+
130
+
131
+ >![Frequency from low to high](/static/types/sound/interp-log.png)
132
+
133
+ ## See also
134
+
135
+ [play sound effect](/reference/music/play-sound-effect),
136
+ [create sound effect](/reference/music/create-sound-effect)
@@ -104,6 +104,12 @@ namespace music {
104
104
  }
105
105
  }
106
106
 
107
+ /**
108
+ * Play a song, melody, or other sound. The music plays until finished or can play as a
109
+ * background task.
110
+ * @param toPlay the song or melody to play
111
+ * @param playbackMode play the song or melody until it's finished or as background task
112
+ */
107
113
  //% blockId="music_playable_play"
108
114
  //% block="play $toPlay $playbackMode"
109
115
  //% toPlay.shadow=music_melody_playable
@@ -113,6 +119,10 @@ namespace music {
113
119
  toPlay.play(playbackMode);
114
120
  }
115
121
 
122
+ /**
123
+ * Create a Playable object for a melody.
124
+ * @param melody the melody to make playable
125
+ */
116
126
  //% blockId="music_melody_playable"
117
127
  //% block="sound $melody"
118
128
  //% toolboxParent=music_playable_play
@@ -125,7 +135,10 @@ namespace music {
125
135
  return new MelodyPlayable(melody);
126
136
  }
127
137
 
128
-
138
+ /**
139
+ * Create a Playable object for a melody string containg notes.
140
+ * @param melody the melody string to make playable
141
+ */
129
142
  //% blockId="music_string_playable"
130
143
  //% block="melody $melody at tempo $tempo|(bpm)"
131
144
  //% toolboxParent=music_playable_play
@@ -165,6 +178,11 @@ namespace music {
165
178
  return new MelodyPlayable(new Melody(formattedMelody));
166
179
  }
167
180
 
181
+ /**
182
+ * Create a Playable object for a single tone and its duration.
183
+ * @param note the note or tone frequency to play
184
+ * @param duration the duration of the tone in milliseconds (ms)
185
+ */
168
186
  //% blockId="music_tone_playable"
169
187
  //% block="tone $note for $duration"
170
188
  //% toolboxParent=music_playable_play
@@ -284,7 +284,7 @@ namespace music {
284
284
  //% blockId=soundExpression_generateSimilarSound
285
285
  //% block="randomize $sound"
286
286
  //% sound.shadow=soundExpression_createSoundEffect
287
- //% weight=0 help=music/generate-similar-sound
287
+ //% weight=0 help=music/randomize-sound
288
288
  //% blockGap=8
289
289
  //% group="Sounds"
290
290
  export function randomizeSound(sound: SoundEffect) {