Skip to main content

Sound

WLJS
Wolfram Kernel
Execution environment
Sound[primitives_]

represents sound as a concept composed from primitives. Draws a player widget once appears in the output form - StandardForm

primitives can be a simple primitive or a List of primitives played sequentially

Primitives

SoundNote

SampledSoundList

Examples

Play chord composed from SoundNote

Sound[SoundNote[{"E", "G#", "B"}]]

Play D Major scale up and down doubled in up-octave

major = {2,2,1,2,2,2};
SoundNote[{#, # + 12}] &/@ Accumulate[Join[{2}, major, -major]] // Sound

Emit sound without a widget

It is possible to play the sound programmatically without a widget using FrontSubmit

EventHandler[InputButton[], Function[Null,
FrontSubmit[Sound[SoundNote[RandomInteger[{0, 12}]]]]
]]
tip

If you want to continuously stream raw sound data, consider to use PCMPlayer