UNPKG

2.14 kBTypeScriptView Raw
1import { Loop, LoopOptions } from "./Loop.js";
2import { PatternName } from "./PatternGenerator.js";
3import { ToneEventCallback } from "./ToneEvent.js";
4import { Seconds } from "../core/type/Units.js";
5export interface PatternOptions<ValueType> extends LoopOptions {
6 pattern: PatternName;
7 values: ValueType[];
8 callback: (time: Seconds, value?: ValueType) => void;
9}
10/**
11 * Pattern arpeggiates between the given notes
12 * in a number of patterns.
13 * @example
14 * const pattern = new Tone.Pattern((time, note) => {
15 * // the order of the notes passed in depends on the pattern
16 * }, ["C2", "D4", "E5", "A6"], "upDown");
17 * @category Event
18 */
19export declare class Pattern<ValueType> extends Loop<PatternOptions<ValueType>> {
20 readonly name: string;
21 /**
22 * The pattern generator function
23 */
24 private _pattern;
25 /**
26 * The current index
27 */
28 private _index?;
29 /**
30 * The current value
31 */
32 private _value?;
33 /**
34 * Hold the pattern type
35 */
36 private _type;
37 /**
38 * Hold the values
39 */
40 private _values;
41 /**
42 * The callback to be invoked at a regular interval
43 */
44 callback: (time: Seconds, value?: ValueType) => void;
45 /**
46 * @param callback The callback to invoke with the event.
47 * @param values The values to arpeggiate over.
48 * @param pattern The name of the pattern
49 */
50 constructor(callback?: ToneEventCallback<ValueType>, values?: ValueType[], pattern?: PatternName);
51 constructor(options?: Partial<PatternOptions<ValueType>>);
52 static getDefaults(): PatternOptions<any>;
53 /**
54 * Internal function called when the notes should be called
55 */
56 protected _tick(time: Seconds): void;
57 /**
58 * The array of events.
59 */
60 get values(): ValueType[];
61 set values(val: ValueType[]);
62 /**
63 * The current value of the pattern.
64 */
65 get value(): ValueType | undefined;
66 /**
67 * The current index of the pattern.
68 */
69 get index(): number | undefined;
70 /**
71 * The pattern type.
72 */
73 get pattern(): PatternName;
74 set pattern(pattern: PatternName);
75}