scribbletune 5.1.2 → 5.4.0
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.
- package/dist/browser.cjs +1183 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.js +1135 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +571 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +323 -0
- package/dist/index.d.ts +303 -350
- package/dist/index.js +524 -1
- package/dist/index.js.map +1 -1
- package/dist/scribbletune.global.js +1944 -0
- package/dist/scribbletune.global.js.map +1 -0
- package/package.json +32 -45
- package/dist/scribbletune.es.js +0 -588
- package/dist/scribbletune.js +0 -2
- package/dist/scribbletune.js.map +0 -1
- package/dist/scribbletune.umd.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,370 +1,323 @@
|
|
|
1
|
-
|
|
2
|
-
// Dependencies for this module:
|
|
3
|
-
// ../harmonics
|
|
4
|
-
|
|
5
|
-
import { scales, chords, scale, chord } from 'harmonics';
|
|
6
|
-
|
|
7
|
-
export { scale, scale as mode, scales, scales as modes, chord, chords, clip, getChordDegrees, getChordsByProgression, progression, arp, midi, };
|
|
8
|
-
|
|
9
|
-
export const clip: (params: ClipParams) => NoteObject[];
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get the chords that go with a given scale/mode
|
|
13
|
-
* This is useful only in case you want to check what chords work with a scale/mode
|
|
14
|
-
* so that you can come up with chord progressions
|
|
15
|
-
* @param {String} mode e.g. major
|
|
16
|
-
* @return {Array} e.g.['I', 'ii', 'iii', 'IV', 'V', 'vi', 'vii°']
|
|
17
|
-
*/
|
|
18
|
-
export const getChordDegrees: (mode: string) => string[];
|
|
19
|
-
/**
|
|
20
|
-
* Take the specified scale and degrees and return the chord names for them
|
|
21
|
-
* These can be used as the value for the `notes` param of the `clip` method
|
|
22
|
-
* @param {String} noteOctaveScale e.g. 'C4 major'
|
|
23
|
-
* @param {String} chordDegress e.g. 'I IV V IV'
|
|
24
|
-
* @return {String} e.g. 'CM FM GM FM'
|
|
25
|
-
*/
|
|
26
|
-
export const getChordsByProgression: (noteOctaveScale: string, chordDegress: string) => string;
|
|
27
|
-
/**
|
|
28
|
-
* Generate a chord progression based on basic music theory
|
|
29
|
-
* where we follow tonic to optionally predominant and then dominant
|
|
30
|
-
* and then randomly to predominant and continue this till we reach `count`
|
|
31
|
-
* @param scaleType e.g. M (for major chord progression), m (for minor chord progression)
|
|
32
|
-
* @param count e.g. 4
|
|
33
|
-
*/
|
|
34
|
-
export const progression: (scaleType: ProgressionScale, count?: number) => any[];
|
|
1
|
+
export { chord, chords, scale as mode, scales as modes, scale, scales } from 'harmonics';
|
|
35
2
|
|
|
3
|
+
type SizzleStyle = 'sin' | 'cos' | 'rampUp' | 'rampDown';
|
|
4
|
+
type ProgressionScale = 'major' | 'minor' | 'M' | 'm';
|
|
5
|
+
type SeqFn = (time: string, el: string) => void;
|
|
36
6
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* For e.g. arp({count: 8, order: '10325476', chords: 'FM_4 Gm7b5_4 AbM_4 Bbm_4 Cm_5 DbM_5 EbM_5})
|
|
43
|
-
*/
|
|
44
|
-
export const arp: (chordsOrParams: string | ArpParams) => string[];
|
|
45
|
-
|
|
7
|
+
* Callback function triggered when channel has a new event.
|
|
8
|
+
* @param event - one of ['loaded', 'error']
|
|
9
|
+
* @param params - object with event data
|
|
10
|
+
*/
|
|
11
|
+
type EventFn = (event: string, params: Record<string, unknown>) => void;
|
|
46
12
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
13
|
+
* Callback function triggered when a note is played.
|
|
14
|
+
* @param params - object with player data
|
|
15
|
+
*/
|
|
16
|
+
type PlayerObserverFn = (params: Record<string, unknown>) => void;
|
|
17
|
+
/** Recursive pattern element produced by expandStr */
|
|
18
|
+
type PatternElement = string | PatternElement[];
|
|
19
|
+
interface NVP<T> {
|
|
20
|
+
[key: string]: T;
|
|
21
|
+
}
|
|
22
|
+
interface NoteObject {
|
|
23
|
+
note: string[] | null;
|
|
24
|
+
length: number;
|
|
25
|
+
level: number;
|
|
26
|
+
}
|
|
57
27
|
interface ArpParams {
|
|
58
28
|
count: number;
|
|
59
29
|
order?: string;
|
|
60
|
-
chords: string |
|
|
30
|
+
chords: string | string[][];
|
|
61
31
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
* This use is depreceated: The name of a synthesizer, listed in `Tone.js`.
|
|
81
|
-
* - Example: `'PolySynth'`.
|
|
82
|
-
* - See: [GitHub ~ Tone.js/Tone/instrument](https://github.com/Tonejs/Tone.js/tree/dev/Tone/instrument)
|
|
83
|
-
*
|
|
84
|
-
* New use going forward: SynthParams
|
|
85
|
-
*/
|
|
86
|
-
synth?: string | SynthParams;
|
|
87
|
-
/**
|
|
88
|
-
* A `Tone.Instrument` instance or the name of a synthesizer, listed in `Tone.js`. Only in the browser.
|
|
89
|
-
* - Example: `'Synth'`
|
|
90
|
-
* - Example: `new Tone.Synth()`
|
|
91
|
-
* - Example: `getToneMonoSynth('MonoSynth:BassGuitar')`
|
|
92
|
-
* - See: https://github.com/scribbletune/sampler#tone-monosynths
|
|
93
|
-
*/
|
|
94
|
-
instrument?: any;
|
|
95
|
-
/**
|
|
96
|
-
* The `URL` of an audio file containing an instrument sample. Supports `WAV` format.
|
|
97
|
-
* - Example: `'https://scribbletune.com/sounds/kick.wav'`
|
|
98
|
-
*/
|
|
99
|
-
sample?: any;
|
|
100
|
-
/**
|
|
101
|
-
* A `Tone` buffer or any audio buffer.
|
|
102
|
-
* - See: https://tonejs.github.io/docs/13.8.25/Buffer
|
|
103
|
-
*/
|
|
104
|
-
buffer?: any;
|
|
105
|
-
/**
|
|
106
|
-
* A dictionary of audio samples expressed as a `{ 'Note' : 'URI', ... }` object.
|
|
107
|
-
* - Example: `{ 'C3': 'https://.../piano48.wav', 'C#3': '/Path/to/piano49.wav', ... }`
|
|
108
|
-
*/
|
|
109
|
-
samples?: any;
|
|
110
|
-
/**
|
|
111
|
-
* A `Promise` that resolves to a `Tone.Sampler`.
|
|
112
|
-
* - Example: `{ sampler: getSampler('korgBass') }`
|
|
113
|
-
* - See: https://github.com/scribbletune/sampler#sampler
|
|
114
|
-
*/
|
|
115
|
-
sampler?: any;
|
|
116
|
-
/**
|
|
117
|
-
* A `Tone.Player` instance.
|
|
118
|
-
* - See: https://tonejs.github.io/docs/13.8.25/Player
|
|
119
|
-
*/
|
|
120
|
-
player?: any;
|
|
121
|
-
/**
|
|
122
|
-
* External sound producer object / module
|
|
123
|
-
*/
|
|
124
|
-
external?: any;
|
|
125
|
-
/**
|
|
126
|
-
* Name of an effect listed in `Tone.js` or `Tone.Effect` instance. Single value or Array.
|
|
127
|
-
* - Example: `'Chorus'`
|
|
128
|
-
* - Example: `new Tone.AutoFilter()`
|
|
129
|
-
* - Example: `[ 'Chorus' ]`
|
|
130
|
-
* - Example: `[ 'Chorus', 'AutoFilter' ]`
|
|
131
|
-
* - Example: `[ 'Chorus', new Tone.AutoFilter() ]`
|
|
132
|
-
* - See: [GitHub ~ Tone.js/Tone/effect](https://github.com/Tonejs/Tone.js/tree/dev/Tone/effect)
|
|
133
|
-
*/
|
|
134
|
-
effects?: any | any[];
|
|
135
|
-
/**
|
|
136
|
-
* The volume in decibels, in the range `-60` to `+12`.
|
|
137
|
-
* _(Note, not applicable to sample — it gives an error.)_
|
|
138
|
-
* - Default: `0` (?)
|
|
139
|
-
* - Example: `-18`
|
|
140
|
-
* - See: https://tonejs.github.io/docs/13.8.25/Volume
|
|
141
|
-
*/
|
|
142
|
-
volume?: number;
|
|
143
|
-
/**
|
|
144
|
-
* Callback function triggered when a note is played.
|
|
145
|
-
*/
|
|
146
|
-
eventCb?: EventFn;
|
|
147
|
-
/**
|
|
148
|
-
* Callback function triggered when a note is played.
|
|
149
|
-
*/
|
|
150
|
-
playerCb?: PlayerObserverFn;
|
|
32
|
+
/**
|
|
33
|
+
* Definition of a synthesizer from `Tone.js`.
|
|
34
|
+
*/
|
|
35
|
+
interface SynthParams {
|
|
36
|
+
/**
|
|
37
|
+
* The name of the synthesizer, listed in `Tone.js`.
|
|
38
|
+
* - Example: `'PolySynth'`.
|
|
39
|
+
* - See: [GitHub ~ Tone.js/Tone/instrument](https://github.com/Tonejs/Tone.js/tree/dev/Tone/instrument)
|
|
40
|
+
*/
|
|
41
|
+
synth: string;
|
|
42
|
+
/**
|
|
43
|
+
* Descriptive name of the preset.
|
|
44
|
+
*/
|
|
45
|
+
presetName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Object with parameters for passing to `new Tone[synth](preset)`.
|
|
48
|
+
*/
|
|
49
|
+
preset: Record<string, unknown>;
|
|
151
50
|
}
|
|
152
|
-
export type { ChannelParams };
|
|
153
|
-
|
|
154
|
-
type ChannelPattern = {
|
|
155
|
-
/**
|
|
156
|
-
* Channel index to apply the playing pattern.
|
|
157
|
-
* If no index (`idx`) is given at the creation of the Channel, it's a number, starting with 0.
|
|
158
|
-
* If index is given manually, several channels can have the same index, to be played simultaneously.
|
|
159
|
-
* - Example: `0`
|
|
160
|
-
* - Example: `1`
|
|
161
|
-
* - Example: `'beat'`
|
|
162
|
-
* - Example: `'synth'`
|
|
163
|
-
*/
|
|
164
|
-
channelIdx: string;
|
|
165
|
-
/**
|
|
166
|
-
* The song structure for one channel, saying which clip to play at each step,
|
|
167
|
-
* Only the 10 first clips of each channel are available through this pattern.
|
|
168
|
-
* Those numbered by a single char between 0 and 9.
|
|
169
|
-
* `'-'` means 'silence for 1 step'.
|
|
170
|
-
* `'_'` means 'extend the last clip by 1 step'.
|
|
171
|
-
* If index is given manually, several channels can have the same index, to be played simultaneously.
|
|
172
|
-
* - Contains: `0123456789_-`
|
|
173
|
-
* - Example: `'0___1___----'`
|
|
174
|
-
*/
|
|
175
|
-
pattern: string;
|
|
176
|
-
};
|
|
177
|
-
export type { ChannelPattern };
|
|
178
|
-
|
|
179
51
|
interface ClipParams {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Callback function triggered when channel has a new event.
|
|
285
|
-
* @param event - one of ['loaded', 'error']
|
|
286
|
-
* @param params - object with event data
|
|
287
|
-
*/
|
|
288
|
-
type EventFn = (event: string, params: any) => void;
|
|
289
|
-
export type { EventFn };
|
|
290
|
-
|
|
291
|
-
interface NoteObject {
|
|
292
|
-
note: string[];
|
|
293
|
-
length: number;
|
|
294
|
-
level: number;
|
|
52
|
+
/**
|
|
53
|
+
* A string or array of notes or chords names.
|
|
54
|
+
* - Default: `[ 'C4' ]`
|
|
55
|
+
* - Example: `'C4 D4 C4 D#4 C4 D4 C4 Bb3'`
|
|
56
|
+
*/
|
|
57
|
+
notes?: string | (string | string[])[];
|
|
58
|
+
/**
|
|
59
|
+
* A musical rhythm, expressed using Scribbletune's pattern language,
|
|
60
|
+
* which can be adapted to output MIDI files or `Tone.js` sequences.
|
|
61
|
+
* - Default: `'x'`
|
|
62
|
+
* - Contains: `x_-R[]`
|
|
63
|
+
* - Example: `'x_x_'`
|
|
64
|
+
*/
|
|
65
|
+
pattern: string;
|
|
66
|
+
/**
|
|
67
|
+
* Randomize the order of the `notes` set in the clip.
|
|
68
|
+
* - Default: `false`
|
|
69
|
+
*/
|
|
70
|
+
shuffle?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to apply arpeggiation.
|
|
73
|
+
* - Default: `false`
|
|
74
|
+
*/
|
|
75
|
+
arpegiate?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Sub-division — each `x` is a quarter note by default.
|
|
78
|
+
* - Default: `'4n'`
|
|
79
|
+
* - Example: `'1m'`
|
|
80
|
+
* - See: [Tone.js wiki ~ Time](https://github.com/Tonejs/Tone.js/wiki/Time#notation)
|
|
81
|
+
*/
|
|
82
|
+
subdiv?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Align start of clip playing to specific time grid.
|
|
85
|
+
* - Default: `'1m'`
|
|
86
|
+
* - Example: `'4m'` will align the clip to every 4 measures
|
|
87
|
+
*/
|
|
88
|
+
align?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Offset start of clip playing from the time grid defined by `align` parameter.
|
|
91
|
+
* - Default: `'0'`
|
|
92
|
+
* - Example: `'0.75m'` will offset the clip to start at 3rd beat of 4:4 measure
|
|
93
|
+
*/
|
|
94
|
+
alignOffset?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The default MIDI amplitube/ level/ volume of a note.
|
|
97
|
+
* Used as the upper bound for accents and sizzles (where the lower bound is `accentLow`).
|
|
98
|
+
* - Default: `100`
|
|
99
|
+
* - Example: `127`
|
|
100
|
+
*/
|
|
101
|
+
amp?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Add a "sizzle" (in a manner of speaking) applied to the levels/ volumes.
|
|
104
|
+
* - Default: `false`
|
|
105
|
+
*/
|
|
106
|
+
sizzle?: boolean | SizzleStyle;
|
|
107
|
+
/**
|
|
108
|
+
* Accentuate the specified notes in the clip, expressed using `x-` (on/off).
|
|
109
|
+
* - Example: `'x--x'`
|
|
110
|
+
*/
|
|
111
|
+
accent?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The minimum level used for accents.
|
|
114
|
+
* - Default: `70`
|
|
115
|
+
*/
|
|
116
|
+
accentLow?: number;
|
|
117
|
+
/**
|
|
118
|
+
* The number of sizzle repetitions.
|
|
119
|
+
* - Default: `1`
|
|
120
|
+
*/
|
|
121
|
+
sizzleReps?: number;
|
|
122
|
+
/**
|
|
123
|
+
* A string or array of random notes or chords.
|
|
124
|
+
* - Default: `null`
|
|
125
|
+
* - Example: `'C4 D4 C4 D#4 C4 D4 C4 Bb3'`
|
|
126
|
+
*/
|
|
127
|
+
randomNotes?: null | string | (string | string[])[];
|
|
128
|
+
/**
|
|
129
|
+
* The duration of an individual sample that is used in a browser `clip`.
|
|
130
|
+
* - Example: `'32n'`, `'1m'`, `2.3`
|
|
131
|
+
* - See: [Tone.js wiki ~ Time](https://github.com/Tonejs/Tone.js/wiki/Time#notation)
|
|
132
|
+
*/
|
|
133
|
+
dur?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Durations of notes in a browser `clip` as a number of quarter notes.
|
|
136
|
+
* Internal usage only, please use the pattern notation (`x`,`-`,`_`) instead.
|
|
137
|
+
* - Example: `[1, 1, 0.5, 0.25]`
|
|
138
|
+
*/
|
|
139
|
+
durations?: number[];
|
|
140
|
+
/**
|
|
141
|
+
* Boolean parameter to trigger offline rendering.
|
|
142
|
+
* If true, `scribbletune.clip` returns a `Tone.Player` with a buffer containing a pre-rendered sound of the sequence
|
|
143
|
+
* If false, it returns a `Tone.Sequence` which does live rendering.
|
|
144
|
+
*/
|
|
145
|
+
offlineRendering?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Callback function triggered when offline rendering is finished. Ignored when `offlineRendering: false`.
|
|
148
|
+
*/
|
|
149
|
+
offlineRenderingCallback?: () => void;
|
|
150
|
+
/**
|
|
151
|
+
* URL of an audio sample for standalone clip usage (without Channel).
|
|
152
|
+
* - Example: `'https://scribbletune.com/sounds/kick.wav'`
|
|
153
|
+
*/
|
|
154
|
+
sample?: string;
|
|
295
155
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
[
|
|
156
|
+
interface ChannelParams {
|
|
157
|
+
idx?: number | string;
|
|
158
|
+
name?: string;
|
|
159
|
+
clips?: ClipParams[];
|
|
160
|
+
/**
|
|
161
|
+
* Audio context (e.g. Tone.getContext())
|
|
162
|
+
*/
|
|
163
|
+
context?: ToneAudioContext;
|
|
164
|
+
/**
|
|
165
|
+
* The default MIDI amplitube/ level/ volume of a note.
|
|
166
|
+
* Used as the upper bound for accents and sizzles (where the lower bound is `accentLow`).
|
|
167
|
+
* - Default: `100`
|
|
168
|
+
* - Example: `127`
|
|
169
|
+
*/
|
|
170
|
+
amp?: number;
|
|
171
|
+
/**
|
|
172
|
+
* This use is depreceated: The name of a synthesizer, listed in `Tone.js`.
|
|
173
|
+
* - Example: `'PolySynth'`.
|
|
174
|
+
*
|
|
175
|
+
* New use going forward: SynthParams
|
|
176
|
+
*/
|
|
177
|
+
synth?: string | SynthParams;
|
|
178
|
+
/**
|
|
179
|
+
* A `Tone.Instrument` instance or the name of a synthesizer, listed in `Tone.js`. Only in the browser.
|
|
180
|
+
* - Example: `'Synth'`
|
|
181
|
+
* - Example: `new Tone.Synth()`
|
|
182
|
+
*/
|
|
183
|
+
instrument?: string | ToneInstrument;
|
|
184
|
+
/**
|
|
185
|
+
* The `URL` of an audio file containing an instrument sample. Supports `WAV` format.
|
|
186
|
+
* - Example: `'https://scribbletune.com/sounds/kick.wav'`
|
|
187
|
+
*/
|
|
188
|
+
sample?: string;
|
|
189
|
+
/**
|
|
190
|
+
* A `Tone` buffer or any audio buffer.
|
|
191
|
+
* - See: https://tonejs.github.io/docs/13.8.25/Buffer
|
|
192
|
+
*/
|
|
193
|
+
buffer?: string | ToneLoadable;
|
|
194
|
+
/**
|
|
195
|
+
* A dictionary of audio samples expressed as a `{ 'Note' : 'URI', ... }` object.
|
|
196
|
+
* - Example: `{ 'C3': 'https://.../piano48.wav', 'C#3': '/Path/to/piano49.wav', ... }`
|
|
197
|
+
*/
|
|
198
|
+
samples?: Record<string, string>;
|
|
199
|
+
/**
|
|
200
|
+
* A `Promise` that resolves to a `Tone.Sampler`.
|
|
201
|
+
* - Example: `{ sampler: getSampler('korgBass') }`
|
|
202
|
+
* - See: https://github.com/scribbletune/sampler#sampler
|
|
203
|
+
*/
|
|
204
|
+
sampler?: ToneInstrument;
|
|
205
|
+
/**
|
|
206
|
+
* A `Tone.Player` instance.
|
|
207
|
+
* - See: https://tonejs.github.io/docs/13.8.25/Player
|
|
208
|
+
*/
|
|
209
|
+
player?: ToneInstrument;
|
|
210
|
+
/**
|
|
211
|
+
* External sound producer object / module
|
|
212
|
+
*/
|
|
213
|
+
external?: ExternalOutput;
|
|
214
|
+
/**
|
|
215
|
+
* Name of an effect listed in `Tone.js` or `Tone.Effect` instance. Single value or Array.
|
|
216
|
+
* - Example: `'Chorus'`
|
|
217
|
+
* - Example: `new Tone.AutoFilter()`
|
|
218
|
+
* - Example: `[ 'Chorus', 'AutoFilter' ]`
|
|
219
|
+
*/
|
|
220
|
+
effects?: string | ToneNode | (string | ToneNode)[];
|
|
221
|
+
/**
|
|
222
|
+
* The volume in decibels, in the range `-60` to `+12`.
|
|
223
|
+
* - Default: `0`
|
|
224
|
+
* - Example: `-18`
|
|
225
|
+
*/
|
|
226
|
+
volume?: number;
|
|
227
|
+
/**
|
|
228
|
+
* Callback function triggered when a note is played.
|
|
229
|
+
*/
|
|
230
|
+
eventCb?: EventFn;
|
|
231
|
+
/**
|
|
232
|
+
* Callback function triggered when a note is played.
|
|
233
|
+
*/
|
|
234
|
+
playerCb?: PlayerObserverFn;
|
|
300
235
|
}
|
|
301
|
-
|
|
302
|
-
|
|
236
|
+
type ChannelPattern = {
|
|
237
|
+
/**
|
|
238
|
+
* Channel index to apply the playing pattern.
|
|
239
|
+
* - Example: `0`
|
|
240
|
+
* - Example: `'beat'`
|
|
241
|
+
*/
|
|
242
|
+
channelIdx: string;
|
|
243
|
+
/**
|
|
244
|
+
* The song structure for one channel, saying which clip to play at each step.
|
|
245
|
+
* - Contains: `0123456789_-`
|
|
246
|
+
* - Example: `'0___1___----'`
|
|
247
|
+
*/
|
|
248
|
+
pattern: string;
|
|
249
|
+
};
|
|
303
250
|
interface PlayParams {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
251
|
+
/**
|
|
252
|
+
* An array of ChannelPattern
|
|
253
|
+
*/
|
|
254
|
+
channelPatterns: ChannelPattern[];
|
|
255
|
+
/**
|
|
256
|
+
* The time duration to play each clip in the patterns. Default is 4 bars.
|
|
257
|
+
* - Default: `'4:0:0'`
|
|
258
|
+
* - Example: `'1:0:0'`
|
|
259
|
+
*/
|
|
260
|
+
clipDuration?: string;
|
|
261
|
+
}
|
|
262
|
+
interface TPD {
|
|
263
|
+
/** Tonic */
|
|
264
|
+
T: string[];
|
|
265
|
+
/** Predominant (or subdominant) */
|
|
266
|
+
P: string[];
|
|
267
|
+
/** Dominant */
|
|
268
|
+
D: string[];
|
|
315
269
|
}
|
|
316
|
-
export type { PlayParams };
|
|
317
270
|
|
|
318
271
|
/**
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
272
|
+
*
|
|
273
|
+
* @param chordsOrParams a string that denotes space (comma?) separated chords to be used or an object with additional properties
|
|
274
|
+
* By default, if this is a string, the count of notes generated is 8 and the order is ascending.
|
|
275
|
+
* For instance arp('CM FM') will result in an array of notes [C4, E4, G4, F4, A4, C4, C5, E5]
|
|
276
|
+
* You can even provide Params as an object.
|
|
277
|
+
* For e.g. arp({count: 8, order: '10325476', chords: 'FM_4 Gm7b5_4 AbM_4 Bbm_4 Cm_5 DbM_5 EbM_5})
|
|
278
|
+
*/
|
|
279
|
+
declare const arp: (chordsOrParams: string | ArpParams) => string[];
|
|
327
280
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Generate an array of note objects from clip parameters (for MIDI export).
|
|
283
|
+
* Applies the pattern to notes, then optionally adds sizzle and accent dynamics.
|
|
284
|
+
*/
|
|
285
|
+
declare const clip: (params: ClipParams) => NoteObject[];
|
|
333
286
|
|
|
334
287
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Descriptive name of the preset.
|
|
346
|
-
*/
|
|
347
|
-
presetName?: string;
|
|
348
|
-
/**
|
|
349
|
-
* Object with parameters for passing to `new Tone[synth](preset)`.
|
|
350
|
-
*/
|
|
351
|
-
preset: any;
|
|
352
|
-
}
|
|
353
|
-
export type { SynthParams };
|
|
288
|
+
* Take an array of note objects to generate a MIDI file in the same location as this method is called
|
|
289
|
+
* @param {NoteObject[]} notes Notes are in the format: {note: ['c3'], level: 127, length: 64}
|
|
290
|
+
* @param {String | null} fileName If a filename is not provided, then `music.mid` is used by default
|
|
291
|
+
* If `null` is passed for `fileName`, bytes are returned instead of creating a file
|
|
292
|
+
* If this method is called from a browser then it will return a HTML link that you can append in your page
|
|
293
|
+
* This link will enable the generated MIDI as a downloadable file.
|
|
294
|
+
* @param {Number | null} bpm If a value is provided, the generated midi file will be set to this bpm value.
|
|
295
|
+
*/
|
|
296
|
+
declare const midi: (notes: NoteObject[], fileName?: string | null, bpm?: number) => string | HTMLAnchorElement | undefined;
|
|
354
297
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Get the chords that go with a given scale/mode
|
|
300
|
+
* This is useful only in case you want to check what chords work with a scale/mode
|
|
301
|
+
* so that you can come up with chord progressions
|
|
302
|
+
* @param {String} mode e.g. major
|
|
303
|
+
* @return {Array} e.g.['I', 'ii', 'iii', 'IV', 'V', 'vi', 'vii°']
|
|
304
|
+
*/
|
|
305
|
+
declare const getChordDegrees: (mode: string) => string[];
|
|
306
|
+
/**
|
|
307
|
+
* Take the specified scale and degrees and return the chord names for them
|
|
308
|
+
* These can be used as the value for the `notes` param of the `clip` method
|
|
309
|
+
* @param {String} noteOctaveScale e.g. 'C4 major'
|
|
310
|
+
* @param {String} chordDegress e.g. 'I IV V IV'
|
|
311
|
+
* @return {String} e.g. 'CM FM GM FM'
|
|
312
|
+
*/
|
|
313
|
+
declare const getChordsByProgression: (noteOctaveScale: string, chordDegress: string) => string;
|
|
314
|
+
/**
|
|
315
|
+
* Generate a chord progression based on basic music theory
|
|
316
|
+
* where we follow tonic to optionally predominant and then dominant
|
|
317
|
+
* and then randomly to predominant and continue this till we reach `count`
|
|
318
|
+
* @param scaleType e.g. M (for major chord progression), m (for minor chord progression)
|
|
319
|
+
* @param count e.g. 4
|
|
320
|
+
*/
|
|
321
|
+
declare const progression: (scaleType: ProgressionScale, count?: number) => string[];
|
|
370
322
|
|
|
323
|
+
export { type ArpParams, type ChannelParams, type ChannelPattern, type ClipParams, type EventFn, type NVP, type NoteObject, type PatternElement, type PlayParams, type PlayerObserverFn, type ProgressionScale, type SeqFn, type SizzleStyle, type SynthParams, type TPD, arp, clip, getChordDegrees, getChordsByProgression, midi, progression };
|