メインコンテンツまでスキップ

piano

Interfaces

PianoInputInstance

Defined in: dom/src/piano/index.ts:44

Properties

activeNotes
activeNotes: () => number[];

Defined in: dom/src/piano/index.ts:63

The notes currently sounding, ascending.

Returns

number[]

destroy
destroy: () => void;

Defined in: dom/src/piano/index.ts:65

Returns

void

noteOff
noteOff: (note, options?) => void;

Defined in: dom/src/piano/index.ts:60

Release a note held by source.

Parameters
ParameterType
notenumber
options?{ source?: string; }
options.source?string
Returns

void

noteOn
noteOn: (note, options?) => void;

Defined in: dom/src/piano/index.ts:55

Start a note from something other than a pointer: a keyboard shortcut, a MIDI message, an imperative call.

Parameters
ParameterType
notenumber
options?{ source?: string; velocity?: number; }
options.source?string
options.velocity?number
Returns

void

update
update: (options) => void;

Defined in: dom/src/piano/index.ts:49

Replace the given options. Lets a wrapper feed a fresh layout in without tearing down the listeners, which would abort a drag in progress.

Parameters
ParameterType
optionsPartial<PianoInputOptions>
Returns

void


PianoInputOptions

Defined in: dom/src/piano/index.ts:16

Properties

glissando?
optional glissando?: boolean;

Defined in: dom/src/piano/index.ts:26

Let a pointer slide from one key to the next while it is down. With it off, the key that was pressed keeps sounding until the pointer is released.

Default
true
layout
layout: PianoLayout;

Defined in: dom/src/piano/index.ts:18

Geometry of the drawn keyboard, used to find the note under a pointer.

midiMax?
optional midiMax?: number;

Defined in: dom/src/piano/index.ts:34

Highest note that can sound. Above it a note is refused, whichever source asks for it.

Default
127
onActiveNotesChange?
optional onActiveNotesChange?: (notes) => void;

Defined in: dom/src/piano/index.ts:41

Called whenever PianoInputInstance.activeNotes would change.

Parameters
ParameterType
notesnumber[]
Returns

void

onPlayNote?
optional onPlayNote?: (note, velocity?) => void;

Defined in: dom/src/piano/index.ts:37

Called when a note starts sounding, not for each source that asks.

Parameters
ParameterType
notenumber
velocity?number
Returns

void

onStopNote?
optional onStopNote?: (note) => void;

Defined in: dom/src/piano/index.ts:39

Called once the last source holding a note has let go.

Parameters
ParameterType
notenumber
Returns

void

Type Aliases

NoteSource

type NoteSource = string;

Defined in: dom/src/piano/index.ts:14

What asked for a note to sound.

A note stops only once everything that asked for it has let go, so two fingers on one key, or a key held by both the mouse and a MIDI keyboard, behave the way they look.

Pointers use pointer:<pointerId>; everything else names its own source.

Functions

createPianoInput()

function createPianoInput(element, options): PianoInputInstance;

Defined in: dom/src/piano/index.ts:80

Drive a piano keyboard with pointers, and own what is sounding.

Every way of playing a note goes through the one instance — pointers here, keyboard shortcuts and MIDI through PianoInputInstance.noteOn — so there is a single answer to what is currently held, and drawing the keys is left entirely to the wrapper.

Tracks every pointer at once, so a chord can be played with several fingers.

Parameters

ParameterType
elementElement
optionsPianoInputOptions

Returns

PianoInputInstance