Chip

A sound chip: a fixed set of channels that sound in one audio context and are mixed into its output, behind a master volume.

Import

import { Chip } from '@halleyfante/chiptune';

Two notes at once

Constructor

new Chip({ context: BaseAudioContext, channels: readonly Channel<unknown>[] })
OptionDescription
contextThe audio context the chip sounds in. A browser only lets one make sound when it is created or resumed during a click or a key press.
channelsThe sound generators of the chip, which stay the same for as long as it exists.

Properties

NameTypeDescription
contextBaseAudioContext
sizenumberHow many channels the chip has.
volumenumberFrom 0, silent, to 1, where a single channel at full volume already reaches full scale.

Methods

MethodDescription
hush(): voidEnds at once every note that is sounding or was handed to the chip to sound later.
play(options: ChipPlayOptions): voidSounds a note on one of the channels.