scribbletune 5.2.0 → 5.5.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/README.md +276 -22
- 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/cli.cjs +813 -0
- package/dist/{index.mjs → index.cjs} +225 -169
- 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 -40
- package/dist/lib/arp.d.ts +0 -10
- package/dist/lib/browser-clip.d.ts +0 -14
- package/dist/lib/browser-index.d.ts +0 -7
- package/dist/lib/channel.d.ts +0 -61
- package/dist/lib/clip.d.ts +0 -2
- package/dist/lib/index.d.ts +0 -7
- package/dist/lib/midi.d.ts +0 -11
- package/dist/lib/progression.d.ts +0 -25
- package/dist/lib/session.d.ts +0 -14
- package/dist/lib/types/arp-params.d.ts +0 -6
- package/dist/lib/types/channel-params.d.ts +0 -92
- package/dist/lib/types/channel-pattern.d.ts +0 -24
- package/dist/lib/types/clip-params.d.ts +0 -104
- package/dist/lib/types/event-fn.d.ts +0 -7
- package/dist/lib/types/index.d.ts +0 -14
- package/dist/lib/types/note-object.d.ts +0 -6
- package/dist/lib/types/nvp.d.ts +0 -4
- package/dist/lib/types/play-params.d.ts +0 -15
- package/dist/lib/types/player-observer-fn.d.ts +0 -6
- package/dist/lib/types/progression-scale.d.ts +0 -2
- package/dist/lib/types/seq-fn.d.ts +0 -2
- package/dist/lib/types/sizzle-style.d.ts +0 -2
- package/dist/lib/types/synth-params.d.ts +0 -20
- package/dist/lib/types/tpd.d.ts +0 -15
- package/dist/lib/utils.d.ts +0 -56
- package/dist/scribbletune.js +0 -2
- package/dist/scribbletune.js.map +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { EventFn } from './event-fn';
|
|
2
|
-
import type { PlayerObserverFn } from './player-observer-fn';
|
|
3
|
-
import type { SynthParams } from './synth-params';
|
|
4
|
-
interface ChannelParams {
|
|
5
|
-
idx?: number | string;
|
|
6
|
-
name?: string;
|
|
7
|
-
clips?: any;
|
|
8
|
-
/**
|
|
9
|
-
* Audio context (e.g. Tone.getContext())
|
|
10
|
-
*/
|
|
11
|
-
context?: any;
|
|
12
|
-
/**
|
|
13
|
-
* The default MIDI amplitube/ level/ volume of a note.
|
|
14
|
-
* Used as the upper bound for accents and sizzles (where the lower bound is `accentLow`).
|
|
15
|
-
* - Default: `100`
|
|
16
|
-
* - Example: `127`
|
|
17
|
-
*/
|
|
18
|
-
amp?: number;
|
|
19
|
-
/**
|
|
20
|
-
* This use is depreceated: The name of a synthesizer, listed in `Tone.js`.
|
|
21
|
-
* - Example: `'PolySynth'`.
|
|
22
|
-
* - See: [GitHub ~ Tone.js/Tone/instrument](https://github.com/Tonejs/Tone.js/tree/dev/Tone/instrument)
|
|
23
|
-
*
|
|
24
|
-
* New use going forward: SynthParams
|
|
25
|
-
*/
|
|
26
|
-
synth?: string | SynthParams;
|
|
27
|
-
/**
|
|
28
|
-
* A `Tone.Instrument` instance or the name of a synthesizer, listed in `Tone.js`. Only in the browser.
|
|
29
|
-
* - Example: `'Synth'`
|
|
30
|
-
* - Example: `new Tone.Synth()`
|
|
31
|
-
* - Example: `getToneMonoSynth('MonoSynth:BassGuitar')`
|
|
32
|
-
* - See: https://github.com/scribbletune/sampler#tone-monosynths
|
|
33
|
-
*/
|
|
34
|
-
instrument?: any;
|
|
35
|
-
/**
|
|
36
|
-
* The `URL` of an audio file containing an instrument sample. Supports `WAV` format.
|
|
37
|
-
* - Example: `'https://scribbletune.com/sounds/kick.wav'`
|
|
38
|
-
*/
|
|
39
|
-
sample?: any;
|
|
40
|
-
/**
|
|
41
|
-
* A `Tone` buffer or any audio buffer.
|
|
42
|
-
* - See: https://tonejs.github.io/docs/13.8.25/Buffer
|
|
43
|
-
*/
|
|
44
|
-
buffer?: any;
|
|
45
|
-
/**
|
|
46
|
-
* A dictionary of audio samples expressed as a `{ 'Note' : 'URI', ... }` object.
|
|
47
|
-
* - Example: `{ 'C3': 'https://.../piano48.wav', 'C#3': '/Path/to/piano49.wav', ... }`
|
|
48
|
-
*/
|
|
49
|
-
samples?: any;
|
|
50
|
-
/**
|
|
51
|
-
* A `Promise` that resolves to a `Tone.Sampler`.
|
|
52
|
-
* - Example: `{ sampler: getSampler('korgBass') }`
|
|
53
|
-
* - See: https://github.com/scribbletune/sampler#sampler
|
|
54
|
-
*/
|
|
55
|
-
sampler?: any;
|
|
56
|
-
/**
|
|
57
|
-
* A `Tone.Player` instance.
|
|
58
|
-
* - See: https://tonejs.github.io/docs/13.8.25/Player
|
|
59
|
-
*/
|
|
60
|
-
player?: any;
|
|
61
|
-
/**
|
|
62
|
-
* External sound producer object / module
|
|
63
|
-
*/
|
|
64
|
-
external?: any;
|
|
65
|
-
/**
|
|
66
|
-
* Name of an effect listed in `Tone.js` or `Tone.Effect` instance. Single value or Array.
|
|
67
|
-
* - Example: `'Chorus'`
|
|
68
|
-
* - Example: `new Tone.AutoFilter()`
|
|
69
|
-
* - Example: `[ 'Chorus' ]`
|
|
70
|
-
* - Example: `[ 'Chorus', 'AutoFilter' ]`
|
|
71
|
-
* - Example: `[ 'Chorus', new Tone.AutoFilter() ]`
|
|
72
|
-
* - See: [GitHub ~ Tone.js/Tone/effect](https://github.com/Tonejs/Tone.js/tree/dev/Tone/effect)
|
|
73
|
-
*/
|
|
74
|
-
effects?: any | any[];
|
|
75
|
-
/**
|
|
76
|
-
* The volume in decibels, in the range `-60` to `+12`.
|
|
77
|
-
* _(Note, not applicable to sample — it gives an error.)_
|
|
78
|
-
* - Default: `0` (?)
|
|
79
|
-
* - Example: `-18`
|
|
80
|
-
* - See: https://tonejs.github.io/docs/13.8.25/Volume
|
|
81
|
-
*/
|
|
82
|
-
volume?: number;
|
|
83
|
-
/**
|
|
84
|
-
* Callback function triggered when a note is played.
|
|
85
|
-
*/
|
|
86
|
-
eventCb?: EventFn;
|
|
87
|
-
/**
|
|
88
|
-
* Callback function triggered when a note is played.
|
|
89
|
-
*/
|
|
90
|
-
playerCb?: PlayerObserverFn;
|
|
91
|
-
}
|
|
92
|
-
export type { ChannelParams };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
declare type ChannelPattern = {
|
|
2
|
-
/**
|
|
3
|
-
* Channel index to apply the playing pattern.
|
|
4
|
-
* If no index (`idx`) is given at the creation of the Channel, it's a number, starting with 0.
|
|
5
|
-
* If index is given manually, several channels can have the same index, to be played simultaneously.
|
|
6
|
-
* - Example: `0`
|
|
7
|
-
* - Example: `1`
|
|
8
|
-
* - Example: `'beat'`
|
|
9
|
-
* - Example: `'synth'`
|
|
10
|
-
*/
|
|
11
|
-
channelIdx: string;
|
|
12
|
-
/**
|
|
13
|
-
* The song structure for one channel, saying which clip to play at each step,
|
|
14
|
-
* Only the 10 first clips of each channel are available through this pattern.
|
|
15
|
-
* Those numbered by a single char between 0 and 9.
|
|
16
|
-
* `'-'` means 'silence for 1 step'.
|
|
17
|
-
* `'_'` means 'extend the last clip by 1 step'.
|
|
18
|
-
* If index is given manually, several channels can have the same index, to be played simultaneously.
|
|
19
|
-
* - Contains: `0123456789_-`
|
|
20
|
-
* - Example: `'0___1___----'`
|
|
21
|
-
*/
|
|
22
|
-
pattern: string;
|
|
23
|
-
};
|
|
24
|
-
export type { ChannelPattern };
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { SizzleStyle } from './sizzle-style';
|
|
2
|
-
interface ClipParams {
|
|
3
|
-
/**
|
|
4
|
-
* A string or array of notes or chords names.
|
|
5
|
-
* - Default: `[ 'C4' ]`
|
|
6
|
-
* - Example: `'C4 D4 C4 D#4 C4 D4 C4 Bb3'`
|
|
7
|
-
*/
|
|
8
|
-
notes?: string | (string | string[])[];
|
|
9
|
-
/**
|
|
10
|
-
* A musical rhythm, expressed using Scribbletune's pattern language,
|
|
11
|
-
* which can be adapted to output MIDI files or `Tone.js` sequences.
|
|
12
|
-
* - Default: `'x'`
|
|
13
|
-
* - Contains: `x_-R[]`
|
|
14
|
-
* - Example: `'x_x_'`
|
|
15
|
-
*/
|
|
16
|
-
pattern: string;
|
|
17
|
-
/**
|
|
18
|
-
* Randomize the order of the `notes` set in the clip.
|
|
19
|
-
* - Default: `false`
|
|
20
|
-
*/
|
|
21
|
-
shuffle?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Whether to apply arpeggiation.
|
|
24
|
-
* - Default: `false`
|
|
25
|
-
*/
|
|
26
|
-
arpegiate?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Sub-division — each `x` is a quarter note by default.
|
|
29
|
-
* - Default: `'4n'`
|
|
30
|
-
* - Example: `'1m'`
|
|
31
|
-
* - See: [Tone.js wiki ~ Time](https://github.com/Tonejs/Tone.js/wiki/Time#notation)
|
|
32
|
-
*/
|
|
33
|
-
subdiv?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Align start of clip playing to specific time grid.
|
|
36
|
-
* - Default: `'1m'`
|
|
37
|
-
* - Example: `'4m'` will align the clip to every 4 measures
|
|
38
|
-
*/
|
|
39
|
-
align?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Offset start of clip playing from the time grid defined by `align` parameter.
|
|
42
|
-
* - Default: `'0'`
|
|
43
|
-
* - Example: `'0.75m'` will offset the clip to start at 3rd beat of 4:4 measure
|
|
44
|
-
* 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.
|
|
45
|
-
*/
|
|
46
|
-
alignOffset?: string;
|
|
47
|
-
/**
|
|
48
|
-
* The default MIDI amplitube/ level/ volume of a note.
|
|
49
|
-
* Used as the upper bound for accents and sizzles (where the lower bound is `accentLow`).
|
|
50
|
-
* - Default: `100`
|
|
51
|
-
* - Example: `127`
|
|
52
|
-
*/
|
|
53
|
-
amp?: number;
|
|
54
|
-
/**
|
|
55
|
-
* Add a “sizzle” (in a manner of speaking) applied to the levels/ volumes.
|
|
56
|
-
* - Default: `false`
|
|
57
|
-
*/
|
|
58
|
-
sizzle?: boolean | SizzleStyle;
|
|
59
|
-
/**
|
|
60
|
-
* Accentuate the specified notes in the clip, expressed using `x-` (on/off).
|
|
61
|
-
* - Example: `'x--x'`
|
|
62
|
-
*/
|
|
63
|
-
accent?: string;
|
|
64
|
-
/**
|
|
65
|
-
* The minimum level used for accents.
|
|
66
|
-
* - Default: `70`
|
|
67
|
-
*/
|
|
68
|
-
accentLow?: number;
|
|
69
|
-
/**
|
|
70
|
-
* The number of sizzle repetitions.
|
|
71
|
-
* - Default: `1`
|
|
72
|
-
*/
|
|
73
|
-
sizzleReps?: number;
|
|
74
|
-
/**
|
|
75
|
-
* A string or array of random notes or chords.
|
|
76
|
-
* - Default: `null`
|
|
77
|
-
* - Example: `'C4 D4 C4 D#4 C4 D4 C4 Bb3'`
|
|
78
|
-
*/
|
|
79
|
-
randomNotes?: null | string | (string | string[])[];
|
|
80
|
-
/**
|
|
81
|
-
* The duration of an individual sample that is used in a browser `clip`.
|
|
82
|
-
* - Example: `'32n'`, `'1m'`, `2.3`
|
|
83
|
-
* - See: [Tone.js wiki ~ Time](https://github.com/Tonejs/Tone.js/wiki/Time#notation)
|
|
84
|
-
*/
|
|
85
|
-
dur?: string;
|
|
86
|
-
/**
|
|
87
|
-
* Durations of notes in a browser `clip` as a number of quarter notes.
|
|
88
|
-
* Internal usage only, please use the pattern notation (`x`,`-`,`_`) instead.
|
|
89
|
-
* - Example: `[1, 1, 0.5, 0.25]`
|
|
90
|
-
*/
|
|
91
|
-
durations?: number[];
|
|
92
|
-
/**
|
|
93
|
-
* Boolean parameter to trigger offline rendering.
|
|
94
|
-
* If true, `scribbletune.clip` returns a `Tone.Player` with a buffer containing a pre-rendered sound of the sequence
|
|
95
|
-
* If false, it returns a `Tone.Sequence` which does live rendering.
|
|
96
|
-
* Note: The rendering needs some time to complete & be saved in the buffer, before being able to playing.
|
|
97
|
-
*/
|
|
98
|
-
offlineRendering?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Callback function triggered when offline rendering is finished. Ignored when `offlineRendering: false`.
|
|
101
|
-
*/
|
|
102
|
-
offlineRenderingCallback?: any;
|
|
103
|
-
}
|
|
104
|
-
export type { ClipParams };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type { ArpParams } from './arp-params';
|
|
2
|
-
export type { ChannelParams } from './channel-params';
|
|
3
|
-
export type { ChannelPattern } from './channel-pattern';
|
|
4
|
-
export type { ClipParams } from './clip-params';
|
|
5
|
-
export type { EventFn } from './event-fn';
|
|
6
|
-
export type { NoteObject } from './note-object';
|
|
7
|
-
export type { NVP } from './nvp';
|
|
8
|
-
export type { PlayParams } from './play-params';
|
|
9
|
-
export type { PlayerObserverFn } from './player-observer-fn';
|
|
10
|
-
export type { ProgressionScale } from './progression-scale';
|
|
11
|
-
export type { SeqFn } from './seq-fn';
|
|
12
|
-
export type { SizzleStyle } from './sizzle-style';
|
|
13
|
-
export type { SynthParams } from './synth-params';
|
|
14
|
-
export type { TPD } from './tpd';
|
package/dist/lib/types/nvp.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ChannelPattern } from "./channel-pattern";
|
|
2
|
-
interface PlayParams {
|
|
3
|
-
/**
|
|
4
|
-
* An array of ChannelPattern
|
|
5
|
-
*/
|
|
6
|
-
channelPatterns: ChannelPattern[];
|
|
7
|
-
/**
|
|
8
|
-
* The time duration to play each clip in the patterns. Default is 4 bars.
|
|
9
|
-
* - Default: `'4:0:0'`
|
|
10
|
-
* - Example: `'1:0:0'`
|
|
11
|
-
* - See: https://github.com/Tonejs/Tone.js/wiki/Time#transport-time
|
|
12
|
-
*/
|
|
13
|
-
clipDuration?: string;
|
|
14
|
-
}
|
|
15
|
-
export type { PlayParams };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Definition of a synthesizer from `Tone.js`.
|
|
3
|
-
*/
|
|
4
|
-
interface SynthParams {
|
|
5
|
-
/**
|
|
6
|
-
* The name of the synthesizer, listed in `Tone.js`.
|
|
7
|
-
* - Example: `'PolySynth'`.
|
|
8
|
-
* - See: [GitHub ~ Tone.js/Tone/instrument](https://github.com/Tonejs/Tone.js/tree/dev/Tone/instrument)
|
|
9
|
-
*/
|
|
10
|
-
synth: string;
|
|
11
|
-
/**
|
|
12
|
-
* Descriptive name of the preset.
|
|
13
|
-
*/
|
|
14
|
-
presetName?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Object with parameters for passing to `new Tone[synth](preset)`.
|
|
17
|
-
*/
|
|
18
|
-
preset: any;
|
|
19
|
-
}
|
|
20
|
-
export type { SynthParams };
|
package/dist/lib/types/tpd.d.ts
DELETED
package/dist/lib/utils.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper for bracket notation object property access
|
|
3
|
-
*/
|
|
4
|
-
export interface IIndexable<T = any> {
|
|
5
|
-
[key: string]: T;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Take a string input and check if it s a note name or not
|
|
9
|
-
* @param {String} str Note name e.g. c4
|
|
10
|
-
* @return {Boolean} Return true for c4 or return false for something like CM
|
|
11
|
-
*/
|
|
12
|
-
export declare const isNote: (str: string) => boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Take a String input such as xxx[xx[xx]]
|
|
15
|
-
* and return an Array as ['x', 'x', 'x', ['x', 'x', ['x', 'x']]]
|
|
16
|
-
* @param {String} str
|
|
17
|
-
* @return {Array}
|
|
18
|
-
*/
|
|
19
|
-
export declare const expandStr: (str: string) => any;
|
|
20
|
-
/**
|
|
21
|
-
* Basic Array randomizer
|
|
22
|
-
* @param {Array} arr
|
|
23
|
-
* @param {boolean} fullShuffle Ensure no elements remain in old place
|
|
24
|
-
* @return {Array}
|
|
25
|
-
*/
|
|
26
|
-
export declare const shuffle: (arr: any[], fullShuffle?: boolean) => string[];
|
|
27
|
-
/**
|
|
28
|
-
* Return an array of numbers relative to maxLevel || 127 ordered in a Sine wave format
|
|
29
|
-
* This is used by the `sizzle` param of the `clip` method to add a rudimentary variation to the accent of each note
|
|
30
|
-
* @param {Number} maxLevel A number between not more than 127
|
|
31
|
-
* @return {Array} Example output [63, 90, 110, 127, 110, 90, 63, 0, 63, 90, 110, 127, 110, 90, 63, 0]
|
|
32
|
-
*/
|
|
33
|
-
export declare const sizzleMap: (maxLevel?: number) => number[];
|
|
34
|
-
/**
|
|
35
|
-
* Pick one item randomly from an array and return it
|
|
36
|
-
* @param arr
|
|
37
|
-
*/
|
|
38
|
-
export declare const pickOne: <T = any>(arr: T[]) => T;
|
|
39
|
-
/**
|
|
40
|
-
* Boolean generator
|
|
41
|
-
*/
|
|
42
|
-
export declare const dice: () => boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Polyfill for Array.prototype.flat
|
|
45
|
-
*/
|
|
46
|
-
export declare const flat: (arr: any[][]) => any[];
|
|
47
|
-
export declare const errorHasMessage: (x: any) => x is {
|
|
48
|
-
message: string;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* 'el' could be an inlineChord() e.g. Cmaj7 or Dbsus2_5
|
|
52
|
-
* or a chord() e.g. 'C3 M'
|
|
53
|
-
*/
|
|
54
|
-
export declare const convertChordToNotes: (el: string) => string[];
|
|
55
|
-
export declare const convertChordsToNotes: (el: string | (string | string[])[]) => string[];
|
|
56
|
-
export declare const randomInt: (num?: number) => number;
|
package/dist/scribbletune.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("fs")):"function"==typeof define&&define.amd?define(["fs"],e):"object"==typeof exports?exports.scribble=e(require("fs")):t.scribble=e(t.fs)}(self,t=>(()=>{"use strict";var e={712(t){var e,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a={};((t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})})(a,{chord:()=>m,chords:()=>d,getIndicesFromScale:()=>v,inlineChord:()=>p,scale:()=>y,scales:()=>f}),t.exports=(e=a,((t,e,a,s)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let a of o(e))i.call(t,a)||void 0===a||n(t,a,{get:()=>e[a],enumerable:!(s=r(e,a))||s.enumerable});return t})(n({},"__esModule",{value:!0}),e));var s={"C#":"Db","D#":"Eb","F#":"Gb","G#":"Ab","A#":"Bb",CB:"B",FB:"E","E#":"F","B#":"C"},c=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],u={"major pentatonic":"101010010100","ionian pentatonic":"100011010001","mixolydian pentatonic":"100011010010",ritusen:"101001010100",egyptian:"101001010010","neopolitan major pentatonic":"100011100010","vietnamese 1":"100101011000",pelog:"110100011000",kumoijoshi:"110001011000",hirajoshi:"101100011000",iwato:"110001100010","in-sen":"110001010010","lydian pentatonic":"100010110001","malkos raga":"100101001010","locrian pentatonic":"100101100010","minor pentatonic":"100101010010","minor six pentatonic":"100101010100","flat three pentatonic":"101100010100","flat six pentatonic":"101010011000",scriabin:"110010010100","whole tone pentatonic":"100010101010","lydian #5P pentatonic":"100010101001","lydian dominant pentatonic":"100010110010","minor #7M pentatonic":"100101010001","super locrian pentatonic":"100110100010","minor hexatonic":"101101010001",augmented:"100110011001","major blues":"101110010100",piongio:"101001010110","prometheus neopolitan":"110010100110",prometheus:"101010100110","mystery #1":"110010101010","six tone symmetric":"110011001100","whole tone":"101010101010","messiaen's mode #5":"110001110001","minor blues":"100101110010","locrian major":"101011101010","double harmonic lydian":"110010111001","harmonic minor":"101101011001",altered:"110110101010","locrian #2":"101101101010","mixolydian b6":"101011011010","lydian dominant":"101010110110",lydian:"101010110101","lydian augmented":"101010101101","dorian b2":"110101010110","melodic minor":"101101010101",locrian:"110101101010",ultralocrian:"110110101100","locrian 6":"110101100110","augmented heptatonic":"100111011001","romanian minor":"101100110110","dorian #4":"101100110110","lydian diminished":"101100110101",phrygian:"110101011010","leading whole tone":"101010101011","lydian minor":"101010111010","phrygian dominant":"110011011010",balinese:"110101011001","neopolitan major":"110101010101",aeolian:"101101011010","harmonic major":"101011011001","double harmonic major":"110011011001",dorian:"101101010110","hungarian minor":"101100111001","hungarian major":"100110110110",oriental:"110011100110",flamenco:"110110110010","todi raga":"110100111001",mixolydian:"101011010110",persian:"110011101001",major:"101011010101",enigmatic:"110010101011","major augmented":"101011001101","lydian #9":"100110110101","messiaen's mode #4":"111001111001","purvi raga":"110011111001","spanish heptatonic":"110111011010",bebop:"101011010111","bebop minor":"101111010110","bebop major":"101011011101","bebop locrian":"110101111010","minor bebop":"101101011011",diminished:"101101101101",ichikosucho:"101011110101","minor six diminished":"101101011101","half-whole diminished":"110110110110","kafi raga":"100111010111","messiaen's mode #6":"101011101011","composite blues":"101111110110","messiaen's mode #3":"101110111011","messiaen's mode #7":"111101111101",chromatic:"111111111111",ionian:"101011010101",minor:"101101011010",Kanakangi:"111001011100",Ratnangi:"111001011010",Ganamurti:"111001011001",Vanaspati:"111001010110",Manavati:"111001010101",Tanarupi:"111001010011",Senavati:"110101011100",Hanumatodi:"110101011010",Dhenuka:"110101011001",Natakapriya:"110101010110",Kokilapriya:"110101010101",Rupavati:"110101010011",Gayakapriya:"110011011100",Vakulabharanam:"110011011010",Mayamalavagowla:"110011011001",Chakravakam:"110011010110",Suryakantam:"110011010101",Hatakambari:"110011010011",Jhankaradhwani:"101101011100",Natabhairavi:"101101011010",Keeravani:"101101011001",Kharaharapriya:"101101010110",Gourimanohari:"101101010101",Varunapriya:"101101010011",Mararanjani:"101011011100",Charukesi:"101011011010",Sarasangi:"101011011001",Harikambhoji:"101011010110",Dheerasankarabaranam:"101011010101",Naganandini:"101011010011",Yagapriya:"100111011100",Ragavardhini:"100111011010",Gangeyabhushani:"100111011001",Vagadheeswari:"100111010110",Shulini:"100111010101",Chalanata:"100111010011",Salagam:"111000111100",Jalarnavam:"111000111010",Jhalavarali:"111000111001",Navaneetam:"111000110110",Pavani:"111000110101",Raghupriya:"111000110011",Gavambhodi:"110100111100",Bhavapriya:"110100111010",Shubhapantuvarali:"110100111001",Shadvidamargini:"110100110110",Suvarnangi:"110100110101",Divyamani:"110100110011",Dhavalambari:"110010111100",Namanarayani:"110010111010",Kamavardhini:"110010111001",Ramapriya:"110010110110",Gamanashrama:"110010110101",Vishwambari:"110010110011",Shamalangi:"101100111100",Shanmukhapriya:"101100111010",Simhendramadhyamam:"101100111001",Hemavati:"101100110110",Dharmavati:"101100110101",Neetimati:"101100110011",Kantamani:"101010111100",Rishabhapriya:"101010111010",Latangi:"101010111001",Vachaspati:"101010110110",Mechakalyani:"101010110101",Chitrambari:"101010110011",Sucharitra:"100110111100","Jyoti swarupini":"100110111010",Dhatuvardani:"100110111001",Nasikabhushini:"100110110110",Kosalam:"100110110101",Rasikapriya:"100110110011"},l={"5th":"100000010000","M7#5sus4":"100001001001","7#5sus4":"100001001010",sus4:"100001010000",M7sus4:"100001010001","7sus4":"100001010010","7no5":"100010000010",aug:"100010001000",M7b6:"100010001001","maj7#5":"100010001001","7#5":"100010001010","7b13":"100010001010",M:"100010010000",maj7:"100010010001","7th":"100010010010","6th":"100010010100","7add6":"100010010110","7b6":"100010011010",Mb5:"100010100000",M7b5:"100010100001","7b5":"100010100010","maj#4":"100010110001","7#11":"100010110010","M6#11":"100010110100","7#11b13":"100010111010","m#5":"100100001000",mb6M7:"100100001001","m7#5":"100100001010",m:"100100010000","m/ma7":"100100010001",m7:"100100010010",m6:"100100010100",mMaj7b6:"100100011001",dim:"100100100000",oM7:"100100100001",m7b5:"100100100010",dim7:"100100100100",o7M7:"100100100101","4th":"100101000010",madd4:"100101010000",m7add11:"100101010010","+add#9":"100110001000","7#5#9":"100110001010","7#9":"100110010010","13#9":"100110010110","7#9b13":"100110011010","maj7#9#11":"100110110001","7#9#11":"100110110010","13#9#11":"100110110110","7#9#11b13":"100110111010",sus2:"101000010000","M9#5sus4":"101001001001",sus24:"101001010000",M9sus4:"101001010001","11th":"101001010010","9sus4":"101001010010","13sus4":"101001010110","9no5":"101010000010","13no5":"101010000110","M#5add9":"101010001000","maj9#5":"101010001001","9#5":"101010001010","9b13":"101010001010",Madd9:"101010010000",maj9:"101010010001","9th":"101010010010","6/9":"101010010100",maj13:"101010010101",M7add13:"101010010101","13th":"101010010110",M9b5:"101010100001","9b5":"101010100010","13b5":"101010100110","9#5#11":"101010101010","maj9#11":"101010110001","9#11":"101010110010","69#11":"101010110100","M13#11":"101010110101","13#11":"101010110110","9#11b13":"101010111010","m9#5":"101100001010",madd9:"101100010000",mM9:"101100010001",m9:"101100010010",m69:"101100010100",m13:"101100010110",mMaj9b6:"101100011001",m9b5:"101100100010",m11A:"101101001010",m11:"101101010010",b9sus:"110001010010","11b9":"110001010010","7sus4b9b13":"110001011010",alt7:"110010000010","7#5b9":"110010001010",Maddb9:"110010010000",M7b9:"110010010001","7b9":"110010010010","13b9":"110010010110","7b9b13":"110010011010","7#5b9#11":"110010101010","7b9#11":"110010110010","13b9#11":"110010110110","7b9b13#11":"110010111010",mb6b9:"110100001000","7b9#9":"110110010010"};function h({scale:t,chord:e}){const n=t||e,r=t?"scale":"chord";if("string"!=typeof n)throw new Error(`${n} is not a valid input for ${r}`);const o=n.trim(),i=o.indexOf(" ");let a,h;-1===i?(a=o.slice(1),h=o[0],"b"!==o[1]&&"#"!==o[1]||(a=o.slice(2),h+=o[1])):(a=o.slice(-1===i?1:i+1),h=o.slice(0,i));const p=function(t){return s[t.toUpperCase()]||t.charAt(0).toUpperCase()+t.slice(1)}(h.replace(/\d/g,"")),d=""!==h.replace(/\D/g,"")?+h.replace(/\D/g,""):4;if(isNaN(d))throw new Error(`${h[0]} does not have a valid octave`);if(!u[a]&&!l[a])throw new Error(`${o} is not a valid ${r}`);const f=function(t,e){const n=c.indexOf(t);if(-1===n)throw new Error(`${t} is not a valid root note`);const r=c.map(t=>t+e),o=c.map(t=>t+(e+1));return r.concat(o).slice(n)}(p,d),m=[];let y=0,v=0;const b=t?u:l;for(;y<b[a].length;)"1"===b[a][y]&&m.push(f[v]),y++,v++;return m}function p(t){const e="b9sus";let n,r,o=4;return t.includes(e)?(r=e,n=t.slice(0,t.indexOf(e))):(n=t[0],r=t.slice(1),"b"!==t[1]&&"#"!==t[1]||(n+=t[1],r=t.slice(2))),t.includes("_")&&(o=+t.split("_")[1],r=r.slice(0,r.indexOf("_"))),h({chord:n+o+" "+r})}function d(){return Object.keys(l)}function f(){return Object.keys(u)}function m(t){return h({chord:t})}function y(t){return h({scale:t})}function v(t){const e=u[t]||t,n=[];for(let t=0;t<e.length;t++)"1"===e[t]&&n.push(t);return n.push(12),n}},716(t,e,n){var r=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.arp=void 0;var o=n(712),i=n(552),a=function(t,e){var n=function(t){if(!t)throw new Error("Empty element");var e=t.replace(/\d/,""),n=t.replace(/\D/g,"")||4;if(!e)throw new Error("Incorrect note");return e+(+n+1)},o=t.map(n),i=o.map(n);return r(r(r([],t,!0),o,!0),i,!0).slice(0,e)};e.arp=function(t){var e=[],n={count:4,order:"0123",chords:""};if("string"==typeof t)n.chords=t;else{if(t.order&&t.order.match(/\D/g))throw new TypeError("Invalid value for order");if(t.count>8||t.count<2)throw new TypeError("Invalid value for count");t.count&&!t.order&&(n.order=Array.from(Array(t.count).keys()).join("")),Object.assign(n,t)}if("string"==typeof n.chords)n.chords.split(" ").forEach(function(t,i){try{var s=a((0,o.inlineChord)(t),n.count),c=n.order.split("").map(function(t){return s[t]});e=r(r([],e,!0),c,!0)}catch(e){throw new Error("Cannot decode chord ".concat(i+1,' "').concat(t,'" in given "').concat(n.chords,'"'))}});else{if(!Array.isArray(n.chords))throw new TypeError("Invalid value for chords");n.chords.forEach(function(t,o){try{var s=a(t,n.count),c=n.order.split("").map(function(t){return s[t]});e=r(r([],e,!0),c,!0)}catch(e){throw new Error("".concat((0,i.errorHasMessage)(e)?e.message:e," in chord ").concat(o+1,' "').concat(t,'"'))}})}return e}},76(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.clip=e.renderingDuration=e.totalPatternDuration=e.recursivelyApplyPatternToDurations=e.getDuration=e.getNote=void 0;var a=n(552),s="4n";e.getNote=function(t,e,n){return"R"===t&&e.randomNotes&&e.randomNotes.length>0?e.randomNotes[(0,a.randomInt)(e.randomNotes.length-1)]:e.notes?e.notes[n%(e.notes.length||1)]:""},e.getDuration=function(t,e){return t.durations?t.durations[e%t.durations.length]:t.dur||t.subdiv||"8n"},e.recursivelyApplyPatternToDurations=function(t,n,r){return void 0===r&&(r=[]),t.forEach(function(t){"string"==typeof t&&("x"!==t&&"R"!==t||r.push(n),"_"===t&&r.length&&(r[r.length-1]+=n)),Array.isArray(t)&&(0,e.recursivelyApplyPatternToDurations)(t,n/t.length,r)}),r};var c=function(t,n,r){if(r=r||Tone.getContext(),!t.pattern)throw new Error("No pattern provided!");return t.durations||t.dur||(t.durations=(0,e.recursivelyApplyPatternToDurations)((0,a.expandStr)(t.pattern),Tone.Ticks(t.subdiv||s).toSeconds())),new Tone.Sequence({callback:n.getSeqFn(t),events:(0,a.expandStr)(t.pattern),subdivision:t.subdiv||s,context:r})};e.totalPatternDuration=function(t,e){return"number"==typeof e?e*(0,a.expandStr)(t).length:Tone.Ticks(e).toSeconds()*(0,a.expandStr)(t).length},e.renderingDuration=function(t,n,r,o){var i=t.split("").filter(function(t){return"x"===t}).length,a=t.split("").filter(function(t){return"R"===t}).length,s=(null==o?void 0:o.length)?i:i+a,c=r.length||1;return(0,e.totalPatternDuration)(t,n)/s*function(t,e){for(var n=t<e?[t,e]:[e,t],r=n[0],o=n[1],i=o;i%r!==0;)i+=o;return i}(c,s)};var u,l=0;e.clip=function(t,n){if("string"==typeof(t=r(r({},{notes:["C4"],pattern:"x",shuffle:!1,sizzle:!1,sizzleReps:1,arpegiate:!1,subdiv:"4n",align:"1m",alignOffset:"0",amp:100,accentLow:70,randomNotes:null,offlineRendering:!1}),t||{})).notes&&(t.notes=t.notes.replace(/\s{2,}/g," "),t.notes=t.notes.split(" ")),t.notes=t.notes?t.notes.map(a.convertChordsToNotes):[],/[^x\-_[\]R]/.test(t.pattern))throw new TypeError("pattern can only comprise x - _ [ ] R, found ".concat(t.pattern));return t.shuffle&&(t.notes=(0,a.shuffle)(t.notes)),t.randomNotes&&"string"==typeof t.randomNotes&&(t.randomNotes=t.randomNotes.replace(/\s{2,}/g," ").split(/\s/)),t.randomNotes&&(t.randomNotes=t.randomNotes.map(a.convertChordsToNotes)),t.offlineRendering?function(t,e){u||(u=Tone.getContext()),l++;var n=new Tone.Player({context:u,loop:!0});return Tone.Offline(function(e){return o(void 0,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return n=c(t,e),[4,Tone.loaded()];case 1:return r.sent(),n.start(),e.transport.start(),[2]}})})},e).then(function(e){var r;n.buffer=e,0===--l&&(Tone.setContext(u),null===(r=t.offlineRenderingCallback)||void 0===r||r.call(t))}),n.toDestination(),n.sync(),n}(t,(0,e.renderingDuration)(t.pattern,t.subdiv||s,t.notes,t.randomNotes)):c(t,n,u)}},376(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.Session=e.midi=e.arp=e.progression=e.getChordsByProgression=e.getChordDegrees=e.clip=e.chords=e.chord=e.modes=e.scales=e.mode=e.scale=void 0;var i=n(712);Object.defineProperty(e,"scales",{enumerable:!0,get:function(){return i.scales}}),Object.defineProperty(e,"modes",{enumerable:!0,get:function(){return i.scales}}),Object.defineProperty(e,"chords",{enumerable:!0,get:function(){return i.chords}}),Object.defineProperty(e,"scale",{enumerable:!0,get:function(){return i.scale}}),Object.defineProperty(e,"mode",{enumerable:!0,get:function(){return i.scale}}),Object.defineProperty(e,"chord",{enumerable:!0,get:function(){return i.chord}});var a=n(76);Object.defineProperty(e,"clip",{enumerable:!0,get:function(){return a.clip}});var s=n(514);Object.defineProperty(e,"getChordDegrees",{enumerable:!0,get:function(){return s.getChordDegrees}}),Object.defineProperty(e,"getChordsByProgression",{enumerable:!0,get:function(){return s.getChordsByProgression}}),Object.defineProperty(e,"progression",{enumerable:!0,get:function(){return s.progression}});var c=n(716);Object.defineProperty(e,"arp",{enumerable:!0,get:function(){return c.arp}});var u=n(884);Object.defineProperty(e,"midi",{enumerable:!0,get:function(){return u.midi}});var l=n(185);Object.defineProperty(e,"Session",{enumerable:!0,get:function(){return l.Session}}),o(n(491),e)},126(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.Channel=void 0;var i=n(76),a=n(552),s=function(t){var e=Tone.Transport.position.split(":");if("0"===e[0]&&"0"===e[1])return 0;var n=Tone.Transport.ticks,r=(null==t?void 0:t.align)||"1m",o=(null==t?void 0:t.alignOffset)||"0",i=Tone.Ticks(r).toTicks(),a=Tone.Ticks(o).toTicks();return Tone.Ticks(Math.floor(n/i+1)*i+a)},c=function(){function t(t){var e=this;this.idx=t.idx||0,this.name=t.name||"ch "+t.idx,this.activePatternIdx=-1,this.channelClips=[],this.clipNoteCount=0,t.clips,t.samples,t.sample,t.synth;var n=o(t,["clips","samples","sample","synth"]),i=(n.external,n.sampler,n.buffer,o(n,["external","sampler","buffer"])),s=(i.player,i.instrument,i.volume,o(i,["player","instrument","volume"])),c=s.eventCb,u=s.playerCb,l=(s.effects,o(s,["eventCb","playerCb","effects"])),h=l.context,p=void 0===h?Tone.getContext():h,d=o(l,["context"]);this.eventCbFn=c,this.playerCbFn=u,this.hasLoaded=!1,this.hasFailed=!1,this.initializerTask=this.initOutputProducer(p,t).then(function(){return e.initInstrument(p,t).then(function(){return e.adjustInstrument(p,t).then(function(){return e.initEffects(p,t)})})});var f=!1;try{t.clips.forEach(function(t,n){try{e.addClip(r(r({},t),d))}catch(t){throw new Error("".concat((0,a.errorHasMessage)(t)?t.message:t," in clip ").concat(n+1))}},this)}catch(t){f=t}this.initializerTask.then(function(){if(f)throw f;e.hasLoaded=!0,e.eventCb("loaded",{})}).catch(function(t){e.hasFailed=t,e.eventCb("error",{e:t})})}return t.setTransportTempo=function(t){Tone.Transport.bpm.value=t},t.startTransport=function(){Tone.start(),Tone.Transport.start()},t.stopTransport=function(t){void 0===t&&(t=!0),Tone.Transport.stop(),t&&Tone.Transport.cancel()},t.prototype.setVolume=function(t){var e,n;this.instrument&&(this.instrument.volume.value=t),this.external&&(null===(n=(e=this.external).setVolume)||void 0===n||n.call(e,t))},t.prototype.startClip=function(t,e){var n=this,r=this.channelClips[t];e=e||(0===e?0:s(r)),this.activePatternIdx>-1&&this.activePatternIdx!==t&&this.stopClip(this.activePatternIdx,e),r&&"started"!==r.state&&(this.counterResetTask=Tone.Transport.scheduleOnce(function(){n.clipNoteCount=0},e),this.activePatternIdx=t,null==r||r.start(e))},t.prototype.stopClip=function(t,e){var n=this.channelClips[t];e=e||(0===e?0:s(n)),null==n||n.stop(e),t===this.activePatternIdx&&(this.activePatternIdx=-1)},t.prototype.addClip=function(t,e){var n=this;e=e||this.channelClips.length,t.pattern?(this.channelClips[e]=(0,i.clip)(r({},t),this),["align","alignOffset"].forEach(function(r){t[r]&&(n.channelClips[e][r]=t[r])})):this.channelClips[e]=null},t.prototype.getSeqFn=function(t){var e=this;return this.external?function(n,r){var o,a;if("x"===r||"R"===r){var s=e.clipNoteCount;if(e.hasLoaded){var c=(0,i.getNote)(r,t,s)[0],u=(0,i.getDuration)(t,s),l=Tone.Time(u).toSeconds();e.playerCb({note:c,duration:u,time:n,counter:s});try{null===(a=(o=e.external).triggerAttackRelease)||void 0===a||a.call(o,c,l,n)}catch(t){e.eventCb("error",{e:t})}}e.clipNoteCount++}}:this.instrument instanceof Tone.Player?function(t,n){if("x"===n||"R"===n){var r=e.clipNoteCount;if(e.hasLoaded){e.playerCb({note:"",duration:"",time:t,counter:r});try{e.instrument.start(t)}catch(t){e.eventCb("error",{e:t})}}e.clipNoteCount++}}:this.instrument instanceof Tone.PolySynth||this.instrument instanceof Tone.Sampler?function(n,r){if("x"===r||"R"===r){var o=e.clipNoteCount;if(e.hasLoaded){var a=(0,i.getNote)(r,t,o),s=(0,i.getDuration)(t,o);e.playerCb({note:a,duration:s,time:n,counter:o});try{e.instrument.triggerAttackRelease(a,s,n)}catch(t){e.eventCb("error",{e:t})}}e.clipNoteCount++}}:this.instrument instanceof Tone.NoiseSynth?function(n,r){if("x"===r||"R"===r){var o=e.clipNoteCount;if(e.hasLoaded){var a=(0,i.getDuration)(t,o);e.playerCb({note:"",duration:a,time:n,counter:o});try{e.instrument.triggerAttackRelease(a,n)}catch(t){e.eventCb("error",{e:t})}}e.clipNoteCount++}}:function(n,r){if("x"===r||"R"===r){var o=e.clipNoteCount;if(e.hasLoaded){var a=(0,i.getNote)(r,t,o)[0],s=(0,i.getDuration)(t,o);e.playerCb({note:a,duration:s,time:n,counter:o});try{e.instrument.triggerAttackRelease(a,s,n)}catch(t){e.eventCb("error",{e:t})}}e.clipNoteCount++}}},t.prototype.eventCb=function(t,e){"function"==typeof this.eventCbFn&&(e.channel=this,this.eventCbFn(t,e))},t.prototype.playerCb=function(t){"function"==typeof this.playerCbFn&&(t.channel=this,this.playerCbFn(t))},t.prototype.checkToneObjLoaded=function(t,e){var n=this,r=t instanceof Tone.Sampler;if("loaded"in t){if(t.loaded)return void e();if(r)return;var o=!1;if(["buffer","_buffer","_buffers"].forEach(function(r){r in t&&(n.checkToneObjLoaded(t[r],e),o=!0)}),o)return}if(t instanceof Tone.ToneAudioBuffer||t instanceof Tone.ToneBufferSource||"loaded"in t&&"onload"in t){var i=t.onload;t.onload=function(){i&&"function"==typeof i&&(t.onload=i,i()),e()}}else e()},t.prototype.recreateToneObjectInContext=function(t,e){var n=this;return e=e||Tone.getContext(),new Promise(function(o,i){if(t instanceof Tone.PolySynth){var a=Tone.PolySynth(Tone[t._dummyVoice.name],r(r({},t.get()),{context:e}));n.checkToneObjLoaded(a,function(){return o(a)})}else if(t instanceof Tone.Player)var s=Tone.Player({url:t._buffer,context:e,onload:function(){return n.checkToneObjLoaded(s,function(){return o(s)})}});else if(t instanceof Tone.Sampler)var c=t.get(),u={attack:c.attack,curve:c.curve,release:c.release,volume:c.volume},l={baseUrl:t._buffers.baseUrl,urls:Object.fromEntries(t._buffers._buffers.entries())},h=Tone.Sampler(r(r(r({},u),l),{context:e,onload:function(){return n.checkToneObjLoaded(h,function(){return o(h)})}}));else{var p=Tone[t.name](r(r({},t.get()),{context:e,onload:function(){return n.checkToneObjLoaded(p,function(){return o(p)})}}));n.checkToneObjLoaded(p,function(){return o(p)})}})},t.prototype.initOutputProducer=function(t,e){var n=this;return t=t||Tone.getContext(),new Promise(function(o,i){if(e.synth){if(e.instrument)throw new Error("Either synth or instrument can be provided, but not both.");if(e.synth.synth){var a=e.synth.synth,s=e.synth.preset||{};n.instrument=new Tone[a](r(r({},s),{context:t,onload:function(){return n.checkToneObjLoaded(n.instrument,o)}})),n.checkToneObjLoaded(n.instrument,o)}else n.instrument=e.synth,console.warn('The "synth" parameter with instrument will be deprecated in the future. Please use the "instrument" parameter instead.'),n.checkToneObjLoaded(n.instrument,o)}else if("string"==typeof e.instrument)n.instrument=new Tone[e.instrument]({context:t}),n.checkToneObjLoaded(n.instrument,o);else if(e.instrument)n.instrument=e.instrument,n.checkToneObjLoaded(n.instrument,o);else if(e.sample||e.buffer)n.instrument=new Tone.Player({url:e.sample||e.buffer,context:t,onload:function(){return n.checkToneObjLoaded(n.instrument,o)}});else if(e.samples)n.instrument=new Tone.Sampler({urls:e.samples,context:t,onload:function(){return n.checkToneObjLoaded(n.instrument,o)}});else if(e.sampler)n.instrument=e.sampler,n.checkToneObjLoaded(n.instrument,o);else if(e.player)n.instrument=e.player,n.checkToneObjLoaded(n.instrument,o);else{if(!e.external)throw new Error("One of required synth|instrument|sample|sampler|samples|buffer|player|external is not provided!");if(n.external=r({},e.external),n.instrument={context:t,volume:{value:0}},e.external.init)return e.external.init(t.rawContext).then(function(){o()}).catch(function(t){var e;i(new Error("".concat(t.message," loading external output module of channel idx ").concat(n.idx,", ").concat(null!==(e=n.name)&&void 0!==e?e:"(no name)")))});o()}if(!n.instrument)throw new Error("Failed instantiating instrument from given params.")})},t.prototype.initInstrument=function(t,e){var n,r=this;return t=t||Tone.getContext(),e.external||(null===(n=this.instrument)||void 0===n?void 0:n.context)===t?new Promise(function(t,e){t()}):this.recreateToneObjectInContext(this.instrument,t).then(function(t){r.instrument=t})},t.prototype.adjustInstrument=function(t,e){var n=this;return t=t||Tone.getContext(),new Promise(function(t,r){e.volume&&n.setVolume(e.volume),t()})},t.prototype.initEffects=function(t,e){var n=this;t=t||Tone.getContext();var r,o=function(t){return"function"==typeof t.start?t.start():t},i=(r=e.effects)?Array.isArray(r)?r:[r]:[];if(e.external){if(0!==i.length)throw new Error("Effects cannot be used with external output");return Promise.resolve()}return Promise.all(i.map(function(e){return new Promise(function(r,o){if("string"==typeof e)r(new Tone[e]({context:t}));else{if(e.context!==t)return n.recreateToneObjectInContext(e,t);r(e)}}).then(function(t){return t.toDestination()})})).then(function(t){return t.map(o)}).then(function(t){var e;(e=n.instrument).chain.apply(e,t).toDestination()})},Object.defineProperty(t.prototype,"clips",{get:function(){return this.channelClips},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeClipIdx",{get:function(){return this.activePatternIdx},enumerable:!1,configurable:!0}),t}();e.Channel=c},884(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.midi=void 0;var o=r(n(947)),i=n(142);e.midi=function(t,e,n){void 0===e&&(e="music.mid");var r=s(t,n).toBytes();return null===e?r:(e.endsWith(".mid")||(e+=".mid"),"undefined"!=typeof window&&window.URL&&"function"==typeof window.URL.createObjectURL?a(r,e):(o.default.writeFileSync(e,r,"binary"),void console.log("MIDI file generated: ".concat(e,"."))))};var a=function(t,e){for(var n=new Uint8Array(t.length),r=0;r<t.length;r++){var o=t.charCodeAt(r);n[r]=o}var i=new Blob([n],{type:"audio/midi"}),a=document.createElement("a");return a.href="undefined"!=typeof window&&void 0!==window.URL&&void 0!==window.URL.createObjectURL&&window.URL.createObjectURL(i)||"",a.download=e,a.innerText="Download MIDI file",a},s=function(t,e){var n=new i.File,r=new i.Track;"number"==typeof e&&r.setTempo(e),n.addTrack(r);for(var o=0,a=t;o<a.length;o++){var s=a[o],c=s.level||127;s.note?"string"==typeof s.note?(r.noteOn(0,s.note,s.length,c),r.noteOff(0,s.note,s.length,c)):r.addChord(0,s.note,s.length,c):r.noteOff(0,"",s.length)}return n}},514(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.progression=e.getChordsByProgression=e.getChordDegrees=void 0;var r=n(712),o=n(552);e.getChordDegrees=function(t){var e={ionian:["I","ii","iii","IV","V","vi","vii°"],dorian:["i","ii","III","IV","v","vi°","VII"],phrygian:["i","II","III","iv","v°","VI","vii"],lydian:["I","II","iii","iv°","V","vi","vii"],mixolydian:["I","ii","iii°","IV","v","vi","VII"],aeolian:["i","ii°","III","iv","v","VI","VII"],locrian:["i°","II","iii","iv","V","VI","vii"],"melodic minor":["i","ii","III+","IV","V","vi°","vii°"],"harmonic minor":["i","ii°","III+","iv","V","VI","vii°"]};return e.major=e.ionian,e.minor=e.aeolian,e[t]||[]};var i={i:0,ii:1,iii:2,iv:3,v:4,vi:5,vii:6};e.getChordsByProgression=function(t,e){var n=t.split(" ");n[0].match(/\d/)||(n[0]+="4",t=n.join(" "));var o=(0,r.scale)(t);return e.replace(/\s*,+\s*/g," ").split(" ").map(function(t){var e=function(t){var e=t.replace(/\W/g,""),n="M";return e.toLowerCase()===e&&(n="m"),t.indexOf("°")>-1?n+"7b5":t.indexOf("+")>-1?n+"#5":t.indexOf("7")>-1?"M"===n?"maj7":"m7":n}(t),n=i[t.replace(/\W|\d/g,"").toLowerCase()],r=o[n],a=r.replace(/\D+/,"");return r.replace(/\d/,"")+e+"_"+a}).toString().replace(/,/g," ")};var a=function(t){var e=t.T,n=t.P,r=t.D;return function(t){void 0===t&&(t=4);var i=[];i.push((0,o.pickOne)(e));var a=1;for(a<t-1&&(i.push((0,o.pickOne)(n)),a++),a<t-1&&(0,o.dice)()&&(i.push((0,o.pickOne)(n)),a++),a<t-1&&(i.push((0,o.pickOne)(r)),a++),a<t-1&&(i.push((0,o.pickOne)(n)),a++),a<t-1&&(i.push((0,o.pickOne)(r)),a++),a<t-1&&(0,o.dice)()&&(i.push((0,o.pickOne)(n)),a++);a<t;)i.push((0,o.pickOne)(r)),a++;return i}},s=a({T:["I","vi"],P:["ii","IV"],D:["V"]}),c=a({T:["i","VI"],P:["ii","iv"],D:["V"]});e.progression=function(t,e){return void 0===e&&(e=4),"major"===t||"M"===t?s(e):"minor"===t||"m"===t?c(e):[]}},185(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.Session=void 0;var r=n(126),o=function(){function t(t){var e=this;t=t||[],this.sessionChannels=t.map(function(t,n){return t.idx=t.idx||n,t.idx=e.uniqueIdx(e.sessionChannels,t.idx),new r.Channel(t)})}return t.prototype.uniqueIdx=function(t,e){if(!t)return e||0;var n=t.reduce(function(t,e){return!t.find(function(t){return t===e.idx})&&t.concat(e.idx)||t},[]);if(!e||n.find(function(t){return t===e})){for(var r=t.length;n.find(function(t){return t===r});)r+=1;return r}return e},t.prototype.createChannel=function(t){t.idx=this.uniqueIdx(this.sessionChannels,t.idx);var e=new r.Channel(t);return this.sessionChannels.push(e),e},Object.defineProperty(t.prototype,"channels",{get:function(){return this.sessionChannels},enumerable:!1,configurable:!0}),t.prototype.setTransportTempo=function(t){r.Channel.setTransportTempo(t)},t.prototype.startTransport=function(){r.Channel.startTransport()},t.prototype.stopTransport=function(t){void 0===t&&(t=!0),r.Channel.stopTransport(t)},t.prototype.startRow=function(t){this.sessionChannels.forEach(function(e){e.startClip(t)})},t.prototype.play=function(t){var e=this,n=t.channelPatterns,r=t.clipDuration||"4:0:0",o=Tone.Time(r).toSeconds(),i=function(t,e){t.forEach(function(t){return t.stop(e)})};n.forEach(function(t){var n=t.channelIdx,r=t.pattern,a=[],s=0,c="-";r.split("").forEach(function(t){t!==c&&"_"!==t&&(i(a,s),a=function(t,n,r){return"-"===n?[]:e.channels.filter(function(e){return e.idx===t}).map(function(t){var e;return null===(e=t.clips[n])||void 0===e?void 0:e.start(r)})}(n,t,s)),c=t,s+=o}),i(a,s)})},t}();e.Session=o},491(t,e){Object.defineProperty(e,"__esModule",{value:!0})},552(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.randomInt=e.convertChordsToNotes=e.convertChordToNotes=e.errorHasMessage=e.flat=e.dice=e.pickOne=e.sizzleMap=e.shuffle=e.expandStr=e.isNote=void 0;var r=n(712);e.isNote=function(t){return/^[a-gA-G](?:#|b)?\d$/.test(t)},e.expandStr=function(t){return t=(t=(t=(t=JSON.stringify(t.split(""))).replace(/,"\[",/g,", [")).replace(/"\[",/g,"[")).replace(/,"\]"/g,"]"),JSON.parse(t)},e.shuffle=function(t,e){void 0===e&&(e=!0);var n=t.length-1;return t.forEach(function(r,o){if(!(o>=n)){var i=e?Math.floor(Math.random()*(n-o))+1+o:Math.floor(Math.random()*(n+1-o))+o;t[o]=t[i],t[i]=r}}),t},e.sizzleMap=function(t){void 0===t&&(t=127);var e=Math.PI,n=[e/6,e/4,e/3,e/2,2*e/3,3*e/4,5*e/6,e],r=[0,e/6,e/4,e/3,e/2,2*e/3,3*e/4,5*e/6];return r.reverse(),n.concat(r).map(function(e){return Math.round(Math.sin(e)*t)})},e.pickOne=function(t){return t.length>1?t[Math.round(Math.random())]:t[0]},e.dice=function(){return!!Math.round(Math.random())},e.flat=function(t){return t.reduce(function(t,e){return t.concat(e)},[])},e.errorHasMessage=function(t){return"string"==typeof t.message},e.convertChordToNotes=function(t){var e,n,o,i;try{e=(0,r.inlineChord)(t)}catch(t){o=t}try{n=(0,r.chord)(t.replace(/_/g," "))}catch(t){i=t}if(!o&&!i){if(e.toString()!==n.toString())throw new Error("Chord ".concat(t," cannot decode, guessing ").concat(e," or ").concat(n));return e}return o?i?(0,r.chord)(t):n:e},e.convertChordsToNotes=function(t){if("string"==typeof t&&(0,e.isNote)(t))return[t];if(Array.isArray(t))return t.forEach(function(t){if(Array.isArray(t))t.forEach(function(t){if("string"!=typeof t||!(0,e.isNote)(t))throw new TypeError("array of arrays must comprise valid notes")});else if("string"!=typeof t||!(0,e.isNote)(t))throw new TypeError("array must comprise valid notes")}),t;if(!Array.isArray(t)){var n=(0,e.convertChordToNotes)(t);if(n&&n.length)return n}throw new Error("Chord ".concat(t," not found"))},e.randomInt=function(t){return void 0===t&&(t=1),Math.round(Math.random()*t)}},947(e){e.exports=t},142(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n={a:21,b:23,c:12,d:14,e:16,f:17,g:19},r={12:"c",13:"c#",14:"d",15:"d#",16:"e",17:"f",18:"f#",19:"g",20:"g#",21:"a",22:"a#",23:"b"},o={"a#":"bb","c#":"db","d#":"eb","f#":"gb","g#":"ab"};function i(t){const e=/([a-g])(#+|b+)?([0-9]+)$/i.exec(t);if(!e)throw new Error(`Invalid note name: ${t}`);const r=e[1].toLowerCase(),o=e[2]||"";return 12*parseInt(e[3],10)+n[r]+("#"===o.substring(0,1)?1:-1)*o.length}function a(t){return"number"!=typeof t&&/[^0-9]/.test(t)?i(t):parseInt(String(t),10)}function s(t){let e=Math.floor(6e7/t);const n=[];do{n.unshift(255&e),e>>=8}while(e);for(;n.length<3;)n.push(0);return n}function c(t){return String.fromCharCode(...t)}function u(t,e){let n=t;if(e)for(;n.length/2<e;)n="0"+n;const r=[];for(let t=n.length-1;t>=0;t-=2){const e=0===t?n[t]:n[t-1]+n[t];r.unshift(parseInt(e,16))}return r}function l(t){let e=127&t,n=t>>7;for(;n;)e<<=8,e|=127&n|128,n>>=7;const r=[];for(;r.push(255&e),128&e;)e>>=8;return r}var h={midi_letter_pitches:n,midi_pitches_letter:r,midi_flattened_notes:o,midiPitchFromNote:i,ensureMidiPitch:a,noteFromMidiPitch:function(t,e){let n=0,i=t;t>23&&(n=Math.floor(t/12)-1,i=t-12*n);let a=r[String(i)];if(!a)throw new Error(`Invalid MIDI pitch: ${t}`);return e&&a.indexOf("#")>0&&(a=o[a]),a+n},mpqnFromBpm:s,bpmFromMpqn:function(t){let e;if(Array.isArray(t)){e=0;for(let n=0,r=t.length-1;r>=0;++n,--r)e|=t[n]<<8*r}else e=t;return Math.floor(6e7/e)},codes2Str:c,str2Bytes:u,translateTickTime:l},p={NOTE_OFF:128,NOTE_ON:144,AFTER_TOUCH:160,CONTROLLER:176,PROGRAM_CHANGE:192,CHANNEL_AFTERTOUCH:208,PITCH_BEND:224},d={SEQUENCE:0,TEXT:1,COPYRIGHT:2,TRACK_NAME:3,INSTRUMENT:4,LYRIC:5,MARKER:6,CUE_POINT:7,CHANNEL_PREFIX:32,END_OF_TRACK:47,TEMPO:81,SMPTE:84,TIME_SIG:88,KEY_SIG:89,SEQ_EVENT:127},f=class t{static NOTE_OFF=p.NOTE_OFF;static NOTE_ON=p.NOTE_ON;static AFTER_TOUCH=p.AFTER_TOUCH;static CONTROLLER=p.CONTROLLER;static PROGRAM_CHANGE=p.PROGRAM_CHANGE;static CHANNEL_AFTERTOUCH=p.CHANNEL_AFTERTOUCH;static PITCH_BEND=p.PITCH_BEND;time;type;channel;param1;param2;constructor(t){this.setTime(t.time),this.setType(t.type),this.setChannel(t.channel),this.setParam1(t.param1),void 0!==t.param2&&this.setParam2(t.param2)}setTime(t){this.time=l(t||0)}setType(e){if(e<t.NOTE_OFF||e>t.PITCH_BEND)throw new Error("Trying to set an unknown event: "+e);this.type=e}setChannel(t){if(t<0||t>15)throw new Error("Channel is out of bounds.");this.channel=t}setParam1(t){this.param1=t}setParam2(t){this.param2=t}toBytes(){const t=[],e=this.type|15&this.channel;return t.push(...this.time),t.push(e),t.push(this.param1),void 0!==this.param2&&null!==this.param2&&t.push(this.param2),t}},m=class{static SEQUENCE=d.SEQUENCE;static TEXT=d.TEXT;static COPYRIGHT=d.COPYRIGHT;static TRACK_NAME=d.TRACK_NAME;static INSTRUMENT=d.INSTRUMENT;static LYRIC=d.LYRIC;static MARKER=d.MARKER;static CUE_POINT=d.CUE_POINT;static CHANNEL_PREFIX=d.CHANNEL_PREFIX;static END_OF_TRACK=d.END_OF_TRACK;static TEMPO=d.TEMPO;static SMPTE=d.SMPTE;static TIME_SIG=d.TIME_SIG;static KEY_SIG=d.KEY_SIG;static SEQ_EVENT=d.SEQ_EVENT;time;type;data;constructor(t){this.time=l(0),this.type=0,this.setTime(t.time),this.setType(t.type),this.setData(t.data)}setTime(t){this.time=l(t||0)}setType(t){this.type=t}setData(t){this.data=t}toBytes(){if(!this.type)throw new Error("Type for meta-event not specified.");const t=[];if(t.push(...this.time),t.push(255,this.type),Array.isArray(this.data))t.push(this.data.length),t.push(...this.data);else if("number"==typeof this.data)t.push(1,this.data);else if(null!==this.data&&void 0!==this.data){t.push(this.data.length);const e=this.data.split("").map(t=>t.charCodeAt(0));t.push(...e)}else t.push(0);return t}},y=class t{static START_BYTES=[77,84,114,107];static END_BYTES=[0,255,47,0];events;constructor(t){this.events=t?.events??[]}addEvent(t){return this.events.push(t),this}addNoteOn(t,e,n,r){return this.events.push(new f({type:f.NOTE_ON,channel:t,param1:a(e),param2:r||90,time:n||0})),this}addNoteOff(t,e,n,r){return this.events.push(new f({type:f.NOTE_OFF,channel:t,param1:a(e),param2:r||90,time:n||0})),this}addNote(t,e,n,r,o){return this.addNoteOn(t,e,r,o),n&&this.addNoteOff(t,e,n,o),this}addChord(t,e,n,r){if(!Array.isArray(e)||0===e.length)throw new Error("Chord must be a non-empty array of pitches");return e.forEach(e=>{this.addNoteOn(t,e,0,r)}),e.forEach((e,r)=>{0===r?this.addNoteOff(t,e,n):this.addNoteOff(t,e)}),this}setInstrument(t,e,n){return this.events.push(new f({type:f.PROGRAM_CHANGE,channel:t,param1:e,time:n||0})),this}setTempo(t,e){return this.events.push(new m({type:m.TEMPO,data:s(t),time:e||0})),this}setTimeSignature(t,e,n){const r=Math.log2(e);if(r!==Math.floor(r))throw new Error("Time signature denominator must be an exact power of 2!");return this.events.push(new m({type:m.TIME_SIG,data:[255&t,255&Math.floor(r),24,8],time:n||0})),this}setKeySignature(t,e,n){return this.events.push(new m({type:m.KEY_SIG,data:[255&t,e?1:0],time:n||0})),this}toBytes(){let e=0;const n=[],r=t.START_BYTES,o=t.END_BYTES;this.events.forEach(t=>{const r=t.toBytes();e+=r.length,n.push(...r)}),e+=o.length;const i=u(e.toString(16),4);return r.concat(i,n,o)}};y.prototype.noteOn=y.prototype.addNoteOn,y.prototype.noteOff=y.prototype.addNoteOff,y.prototype.note=y.prototype.addNote,y.prototype.chord=y.prototype.addChord,y.prototype.instrument=y.prototype.setInstrument,y.prototype.tempo=y.prototype.setTempo,y.prototype.timeSignature=y.prototype.setTimeSignature,y.prototype.keySignature=y.prototype.setKeySignature;var v=class t{static HDR_CHUNKID="MThd";static HDR_CHUNK_SIZE="\0\0\0";static HDR_TYPE0="\0\0";static HDR_TYPE1="\0";ticks;tracks;constructor(t){const e=t||{};if(void 0!==e.ticks){if("number"!=typeof e.ticks)throw new Error("Ticks per beat must be a number!");if(e.ticks<=0||e.ticks>=32768||e.ticks%1!=0)throw new Error("Ticks per beat must be an integer between 1 and 32767!")}this.ticks=e.ticks||128,this.tracks=[]}addTrack(t){if(t)return this.tracks.push(t),this;{const t=new y;return this.tracks.push(t),t}}toBytes(){const e=this.tracks.length.toString(16);let n=t.HDR_CHUNKID+t.HDR_CHUNK_SIZE;return parseInt(e,16)>1?n+=t.HDR_TYPE1:n+=t.HDR_TYPE0,n+=c(u(e,2)),n+=String.fromCharCode(this.ticks/256,this.ticks%256),this.tracks.forEach(t=>{n+=c(t.toBytes())}),n}toUint8Array(){const t=this.toBytes(),e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}toBlob(t){return new Blob([this.toUint8Array()],{type:t?"application/octet-stream":"audio/x-midi"})}},b={Util:h,File:v,Track:y,Event:f,MetaEvent:m,DEFAULT_VOLUME:90,DEFAULT_DURATION:128,DEFAULT_CHANNEL:0};e.DEFAULT_CHANNEL=0,e.DEFAULT_DURATION=128,e.DEFAULT_VOLUME=90,e.Event=f,e.File=v,e.MetaEvent=m,e.MetaEventType=d,e.MidiEvent=f,e.MidiEventType=p,e.Track=y,e.Util=h,e.default=b}},n={};return function t(r){var o=n[r];if(void 0!==o)return o.exports;var i=n[r]={exports:{}};return e[r].call(i.exports,i,i.exports,t),i.exports}(376)})());
|
|
2
|
-
//# sourceMappingURL=scribbletune.js.map
|