scribbletune 5.2.0 → 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.
Files changed (40) hide show
  1. package/dist/browser.cjs +1183 -0
  2. package/dist/browser.cjs.map +1 -0
  3. package/dist/browser.js +1135 -1
  4. package/dist/browser.js.map +1 -1
  5. package/dist/{index.mjs → index.cjs} +225 -169
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.cts +323 -0
  8. package/dist/index.d.ts +303 -350
  9. package/dist/index.js +524 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/scribbletune.global.js +1944 -0
  12. package/dist/scribbletune.global.js.map +1 -0
  13. package/package.json +29 -40
  14. package/dist/lib/arp.d.ts +0 -10
  15. package/dist/lib/browser-clip.d.ts +0 -14
  16. package/dist/lib/browser-index.d.ts +0 -7
  17. package/dist/lib/channel.d.ts +0 -61
  18. package/dist/lib/clip.d.ts +0 -2
  19. package/dist/lib/index.d.ts +0 -7
  20. package/dist/lib/midi.d.ts +0 -11
  21. package/dist/lib/progression.d.ts +0 -25
  22. package/dist/lib/session.d.ts +0 -14
  23. package/dist/lib/types/arp-params.d.ts +0 -6
  24. package/dist/lib/types/channel-params.d.ts +0 -92
  25. package/dist/lib/types/channel-pattern.d.ts +0 -24
  26. package/dist/lib/types/clip-params.d.ts +0 -104
  27. package/dist/lib/types/event-fn.d.ts +0 -7
  28. package/dist/lib/types/index.d.ts +0 -14
  29. package/dist/lib/types/note-object.d.ts +0 -6
  30. package/dist/lib/types/nvp.d.ts +0 -4
  31. package/dist/lib/types/play-params.d.ts +0 -15
  32. package/dist/lib/types/player-observer-fn.d.ts +0 -6
  33. package/dist/lib/types/progression-scale.d.ts +0 -2
  34. package/dist/lib/types/seq-fn.d.ts +0 -2
  35. package/dist/lib/types/sizzle-style.d.ts +0 -2
  36. package/dist/lib/types/synth-params.d.ts +0 -20
  37. package/dist/lib/types/tpd.d.ts +0 -15
  38. package/dist/lib/utils.d.ts +0 -56
  39. package/dist/scribbletune.js +0 -2
  40. package/dist/scribbletune.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,370 +1,323 @@
1
- // Generated by dts-bundle v0.7.3
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
- * @param chordsOrParams a string that denotes space (comma?) separated chords to be used or an object with additional properties
39
- * By default, if this is a string, the count of notes generated is 8 and the order is ascending.
40
- * For instance arp('CM FM') will result in an array of notes [C4, E4, G4, F4, A4, C4, C5, E5]
41
- * You can even provide Params as an object.
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
- * Take an array of note objects to generate a MIDI file in the same location as this method is called
48
- * @param {NoteObject[]} notes Notes are in the format: {note: ['c3'], level: 127, length: 64}
49
- * @param {String | null} fileName If a filename is not provided, then `music.mid` is used by default
50
- * If `null` is passed for `fileName`, bytes are returned instead of creating a file
51
- * If this method is called from a browser then it will return a HTML link that you can append in your page
52
- * This link will enable the generated MIDI as a downloadable file.
53
- * @param {Number | null} bpm If a value is provided, the generated midi file will be set to this bpm value.
54
- */
55
- export const midi: (notes: NoteObject[], fileName?: string | null, bpm?: number) => string | HTMLAnchorElement | undefined;
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 | any[];
30
+ chords: string | string[][];
61
31
  }
62
- export type { ArpParams };
63
-
64
- interface ChannelParams {
65
- idx?: number | string;
66
- name?: string;
67
- clips?: any;
68
- /**
69
- * Audio context (e.g. Tone.getContext())
70
- */
71
- context?: any;
72
- /**
73
- * The default MIDI amplitube/ level/ volume of a note.
74
- * Used as the upper bound for accents and sizzles (where the lower bound is `accentLow`).
75
- * - Default: `100`
76
- * - Example: `127`
77
- */
78
- amp?: number;
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
- * A string or array of notes or chords names.
182
- * - Default: `[ 'C4' ]`
183
- * - Example: `'C4 D4 C4 D#4 C4 D4 C4 Bb3'`
184
- */
185
- notes?: string | (string | string[])[];
186
- /**
187
- * A musical rhythm, expressed using Scribbletune's pattern language,
188
- * which can be adapted to output MIDI files or `Tone.js` sequences.
189
- * - Default: `'x'`
190
- * - Contains: `x_-R[]`
191
- * - Example: `'x_x_'`
192
- */
193
- pattern: string;
194
- /**
195
- * Randomize the order of the `notes` set in the clip.
196
- * - Default: `false`
197
- */
198
- shuffle?: boolean;
199
- /**
200
- * Whether to apply arpeggiation.
201
- * - Default: `false`
202
- */
203
- arpegiate?: boolean;
204
- /**
205
- * Sub-division — each `x` is a quarter note by default.
206
- * - Default: `'4n'`
207
- * - Example: `'1m'`
208
- * - See: [Tone.js wiki ~ Time](https://github.com/Tonejs/Tone.js/wiki/Time#notation)
209
- */
210
- subdiv?: string;
211
- /**
212
- * Align start of clip playing to specific time grid.
213
- * - Default: `'1m'`
214
- * - Example: `'4m'` will align the clip to every 4 measures
215
- */
216
- align?: string;
217
- /**
218
- * Offset start of clip playing from the time grid defined by `align` parameter.
219
- * - Default: `'0'`
220
- * - Example: `'0.75m'` will offset the clip to start at 3rd beat of 4:4 measure
221
- * well, `'0.75m'` won't really work... Tone.js@14.8.0 does not support fractional measures (for no good reason). Will be sending a PR to Tone.js.
222
- */
223
- alignOffset?: string;
224
- /**
225
- * The default MIDI amplitube/ level/ volume of a note.
226
- * Used as the upper bound for accents and sizzles (where the lower bound is `accentLow`).
227
- * - Default: `100`
228
- * - Example: `127`
229
- */
230
- amp?: number;
231
- /**
232
- * Add a “sizzle” (in a manner of speaking) applied to the levels/ volumes.
233
- * - Default: `false`
234
- */
235
- sizzle?: boolean | SizzleStyle;
236
- /**
237
- * Accentuate the specified notes in the clip, expressed using `x-` (on/off).
238
- * - Example: `'x--x'`
239
- */
240
- accent?: string;
241
- /**
242
- * The minimum level used for accents.
243
- * - Default: `70`
244
- */
245
- accentLow?: number;
246
- /**
247
- * The number of sizzle repetitions.
248
- * - Default: `1`
249
- */
250
- sizzleReps?: number;
251
- /**
252
- * A string or array of random notes or chords.
253
- * - Default: `null`
254
- * - Example: `'C4 D4 C4 D#4 C4 D4 C4 Bb3'`
255
- */
256
- randomNotes?: null | string | (string | string[])[];
257
- /**
258
- * The duration of an individual sample that is used in a browser `clip`.
259
- * - Example: `'32n'`, `'1m'`, `2.3`
260
- * - See: [Tone.js wiki ~ Time](https://github.com/Tonejs/Tone.js/wiki/Time#notation)
261
- */
262
- dur?: string;
263
- /**
264
- * Durations of notes in a browser `clip` as a number of quarter notes.
265
- * Internal usage only, please use the pattern notation (`x`,`-`,`_`) instead.
266
- * - Example: `[1, 1, 0.5, 0.25]`
267
- */
268
- durations?: number[];
269
- /**
270
- * Boolean parameter to trigger offline rendering.
271
- * If true, `scribbletune.clip` returns a `Tone.Player` with a buffer containing a pre-rendered sound of the sequence
272
- * If false, it returns a `Tone.Sequence` which does live rendering.
273
- * Note: The rendering needs some time to complete & be saved in the buffer, before being able to playing.
274
- */
275
- offlineRendering?: boolean;
276
- /**
277
- * Callback function triggered when offline rendering is finished. Ignored when `offlineRendering: false`.
278
- */
279
- offlineRenderingCallback?: any;
280
- }
281
- export type { ClipParams };
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
- export type { NoteObject };
297
-
298
- interface NVP<T> {
299
- [key: string]: T;
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
- export type { NVP };
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
- * An array of ChannelPattern
306
- */
307
- channelPatterns: ChannelPattern[];
308
- /**
309
- * The time duration to play each clip in the patterns. Default is 4 bars.
310
- * - Default: `'4:0:0'`
311
- * - Example: `'1:0:0'`
312
- * - See: https://github.com/Tonejs/Tone.js/wiki/Time#transport-time
313
- */
314
- clipDuration?: string;
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
- * Callback function triggered when a note is played.
320
- * @param params - object with player data
321
- */
322
- type PlayerObserverFn = (params: any) => void;
323
- export type { PlayerObserverFn };
324
-
325
- type ProgressionScale = 'major' | 'minor' | 'M' | 'm';
326
- export type { ProgressionScale };
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
- type SeqFn = (time: string, el: string) => void;
329
- export type { SeqFn };
330
-
331
- type SizzleStyle = 'sin' | 'cos' | 'rampUp' | 'rampDown';
332
- export type { SizzleStyle };
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
- * Definition of a synthesizer from `Tone.js`.
336
- */
337
- interface SynthParams {
338
- /**
339
- * The name of the synthesizer, listed in `Tone.js`.
340
- * - Example: `'PolySynth'`.
341
- * - See: [GitHub ~ Tone.js/Tone/instrument](https://github.com/Tonejs/Tone.js/tree/dev/Tone/instrument)
342
- */
343
- synth: string;
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
- interface TPD {
356
- /**
357
- * Tonic
358
- */
359
- T: string[];
360
- /**
361
- * Predominant (or subdominant)
362
- */
363
- P: string[];
364
- /**
365
- * Dominant
366
- */
367
- D: string[];
368
- }
369
- export type { TPD };
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 };