@huffduff/midi-writer-ts 3.2.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/.editorconfig +24 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +18 -0
- package/.nvmrc +1 -0
- package/.travis.yml +3 -0
- package/LICENSE +21 -0
- package/README.md +200 -0
- package/browser/midiwriter.js +1367 -0
- package/build/index.cjs +1219 -0
- package/build/index.mjs +1217 -0
- package/build/types/abstract-event.d.ts +7 -0
- package/build/types/chunks/chunk.d.ts +5 -0
- package/build/types/chunks/header.d.ts +13 -0
- package/build/types/chunks/track.d.ts +139 -0
- package/build/types/constants.d.ts +16 -0
- package/build/types/main.d.ts +56 -0
- package/build/types/meta-events/copyright-event.d.ts +18 -0
- package/build/types/meta-events/cue-point-event.d.ts +18 -0
- package/build/types/meta-events/end-track-event.d.ts +16 -0
- package/build/types/meta-events/instrument-name-event.d.ts +18 -0
- package/build/types/meta-events/key-signature-event.d.ts +13 -0
- package/build/types/meta-events/lyric-event.d.ts +18 -0
- package/build/types/meta-events/marker-event.d.ts +18 -0
- package/build/types/meta-events/meta-event.d.ts +5 -0
- package/build/types/meta-events/tempo-event.d.ts +20 -0
- package/build/types/meta-events/text-event.d.ts +18 -0
- package/build/types/meta-events/time-signature-event.d.ts +13 -0
- package/build/types/meta-events/track-name-event.d.ts +18 -0
- package/build/types/midi-events/controller-change-event.d.ts +22 -0
- package/build/types/midi-events/midi-event.d.ts +7 -0
- package/build/types/midi-events/note-event.d.ts +31 -0
- package/build/types/midi-events/note-off-event.d.ts +36 -0
- package/build/types/midi-events/note-on-event.d.ts +36 -0
- package/build/types/midi-events/pitch-bend-event.d.ts +17 -0
- package/build/types/midi-events/program-change-event.d.ts +20 -0
- package/build/types/utils.d.ts +105 -0
- package/build/types/vexflow.d.ts +30 -0
- package/build/types/writer.d.ts +45 -0
- package/examples/chopin-prelude-e-minor.js +143 -0
- package/examples/hot-cross-buns.js +24 -0
- package/examples/mauro.giuliani-op.47-main-theme.js +136 -0
- package/examples/notes-by-start-tick.js +45 -0
- package/examples/zelda-main-theme.js +435 -0
- package/jsdoc.json +5 -0
- package/package.json +79 -0
- package/postinstall.js +1 -0
- package/rollup.config.js +22 -0
- package/runkit.js +18 -0
- package/test/main.js +339 -0
- package/test/vexflow.js +165 -0
- package/test/writer.js +59 -0
- package/tsconfig.json +13 -0
- package/typedoc.json +5 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static utility functions used throughout the library.
|
|
3
|
+
*/
|
|
4
|
+
declare class Utils {
|
|
5
|
+
/**
|
|
6
|
+
* Gets MidiWriterJS version number.
|
|
7
|
+
* @return {string}
|
|
8
|
+
*/
|
|
9
|
+
static version(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Convert a string to an array of bytes
|
|
12
|
+
* @param {string} string
|
|
13
|
+
* @return {array}
|
|
14
|
+
*/
|
|
15
|
+
static stringToBytes(string: string): number[];
|
|
16
|
+
/**
|
|
17
|
+
* Checks if argument is a valid number.
|
|
18
|
+
* @param {*} n - Value to check
|
|
19
|
+
* @return {boolean}
|
|
20
|
+
*/
|
|
21
|
+
static isNumeric(n: any): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the correct MIDI number for the specified pitch.
|
|
24
|
+
* Uses Tonal Midi - https://github.com/danigb/tonal/tree/master/packages/midi
|
|
25
|
+
* @param {(string|number)} pitch - 'C#4' or midi note code
|
|
26
|
+
* @param {string} middleC
|
|
27
|
+
* @return {number}
|
|
28
|
+
*/
|
|
29
|
+
static getPitch(pitch: string | number, middleC?: string | number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Translates number of ticks to MIDI timestamp format, returning an array of
|
|
32
|
+
* hex strings with the time values. Midi has a very particular time to express time,
|
|
33
|
+
* take a good look at the spec before ever touching this function.
|
|
34
|
+
* Thanks to https://github.com/sergi/jsmidi
|
|
35
|
+
*
|
|
36
|
+
* @param {number} ticks - Number of ticks to be translated
|
|
37
|
+
* @return {array} - Bytes that form the MIDI time value
|
|
38
|
+
*/
|
|
39
|
+
static numberToVariableLength(ticks: number): number[];
|
|
40
|
+
/**
|
|
41
|
+
* Counts number of bytes in string
|
|
42
|
+
* @param {string} s
|
|
43
|
+
* @return {number}
|
|
44
|
+
*/
|
|
45
|
+
static stringByteCount(s: string): number;
|
|
46
|
+
/**
|
|
47
|
+
* Get an int from an array of bytes.
|
|
48
|
+
* @param {array} bytes
|
|
49
|
+
* @return {number}
|
|
50
|
+
*/
|
|
51
|
+
static numberFromBytes(bytes: number[]): number;
|
|
52
|
+
/**
|
|
53
|
+
* Takes a number and splits it up into an array of bytes. Can be padded by passing a number to bytesNeeded
|
|
54
|
+
* @param {number} number
|
|
55
|
+
* @param {number} bytesNeeded
|
|
56
|
+
* @return {array} - Array of bytes
|
|
57
|
+
*/
|
|
58
|
+
static numberToBytes(number: number, bytesNeeded: number): number[];
|
|
59
|
+
/**
|
|
60
|
+
* Converts value to array if needed.
|
|
61
|
+
* @param {any} value
|
|
62
|
+
* @return {array}
|
|
63
|
+
*/
|
|
64
|
+
static toArray(value: any): any[];
|
|
65
|
+
/**
|
|
66
|
+
* Converts velocity to value 0-127
|
|
67
|
+
* @param {number} velocity - Velocity value 1-100
|
|
68
|
+
* @return {number}
|
|
69
|
+
*/
|
|
70
|
+
static convertVelocity(velocity: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the total number of ticks of a specified duration.
|
|
73
|
+
* Note: type=='note' defaults to quarter note, type==='rest' defaults to 0
|
|
74
|
+
* @param {(string|array)} duration
|
|
75
|
+
* @return {number}
|
|
76
|
+
*/
|
|
77
|
+
static getTickDuration(duration: (string | string[] | number)): number;
|
|
78
|
+
/**
|
|
79
|
+
* Due to rounding errors in JavaScript engines,
|
|
80
|
+
* it's safe to round when we're very close to the actual tick number
|
|
81
|
+
*
|
|
82
|
+
* @static
|
|
83
|
+
* @param {number} tick
|
|
84
|
+
* @return {number}
|
|
85
|
+
*/
|
|
86
|
+
static getRoundedIfClose(tick: number): number;
|
|
87
|
+
/**
|
|
88
|
+
* Due to low precision of MIDI,
|
|
89
|
+
* we need to keep track of rounding errors in deltas.
|
|
90
|
+
* This function will calculate the rounding error for a given duration.
|
|
91
|
+
*
|
|
92
|
+
* @static
|
|
93
|
+
* @param {number} tick
|
|
94
|
+
* @return {number}
|
|
95
|
+
*/
|
|
96
|
+
static getPrecisionLoss(tick: number): number;
|
|
97
|
+
/**
|
|
98
|
+
* Gets what to multiple ticks/quarter note by to get the specified duration.
|
|
99
|
+
* Note: type=='note' defaults to quarter note, type==='rest' defaults to 0
|
|
100
|
+
* @param {string} duration
|
|
101
|
+
* @return {number}
|
|
102
|
+
*/
|
|
103
|
+
static getDurationMultiplier(duration: string): number;
|
|
104
|
+
}
|
|
105
|
+
export { Utils };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Track } from './chunks/track';
|
|
2
|
+
declare class VexFlow {
|
|
3
|
+
/**
|
|
4
|
+
* Support for converting VexFlow voice into MidiWriterJS track
|
|
5
|
+
* @return MidiWriter.Track object
|
|
6
|
+
*/
|
|
7
|
+
trackFromVoice(voice: any, options?: {
|
|
8
|
+
addRenderedAccidentals: boolean;
|
|
9
|
+
}): Track;
|
|
10
|
+
/**
|
|
11
|
+
* Converts VexFlow pitch syntax to MidiWriterJS syntax
|
|
12
|
+
* @param pitch string
|
|
13
|
+
* @param index pitch index
|
|
14
|
+
* @param note struct from Vexflow
|
|
15
|
+
* @param addRenderedAccidentals adds Vexflow rendered accidentals
|
|
16
|
+
*/
|
|
17
|
+
convertPitch(pitch: any, index: any, note: any, addRenderedAccidentals?: boolean): any;
|
|
18
|
+
/**
|
|
19
|
+
* Converts VexFlow duration syntax to MidiWriterJS syntax
|
|
20
|
+
* @param note struct from VexFlow
|
|
21
|
+
*/
|
|
22
|
+
convertDuration(note: any): string;
|
|
23
|
+
/**
|
|
24
|
+
* Converts VexFlow base duration syntax to MidiWriterJS syntax
|
|
25
|
+
* @param duration Vexflow duration
|
|
26
|
+
* @returns MidiWriterJS duration
|
|
27
|
+
*/
|
|
28
|
+
convertBaseDuration(duration: string): string;
|
|
29
|
+
}
|
|
30
|
+
export { VexFlow };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Track } from './chunks/track';
|
|
2
|
+
/**
|
|
3
|
+
* Object that puts together tracks and provides methods for file output.
|
|
4
|
+
* @param {array|Track} tracks - A single {Track} object or an array of {Track} objects.
|
|
5
|
+
* @param {object} options - {middleC: 'C4'}
|
|
6
|
+
* @return {Writer}
|
|
7
|
+
*/
|
|
8
|
+
declare class Writer {
|
|
9
|
+
tracks: Track[];
|
|
10
|
+
options: object;
|
|
11
|
+
constructor(tracks: any, options?: {});
|
|
12
|
+
/**
|
|
13
|
+
* Builds array of data from chunkschunks.
|
|
14
|
+
* @return {array}
|
|
15
|
+
*/
|
|
16
|
+
buildData(): any[];
|
|
17
|
+
/**
|
|
18
|
+
* Builds the file into a Uint8Array
|
|
19
|
+
* @return {Uint8Array}
|
|
20
|
+
*/
|
|
21
|
+
buildFile(): Uint8Array;
|
|
22
|
+
/**
|
|
23
|
+
* Convert file buffer to a base64 string. Different methods depending on if browser or node.
|
|
24
|
+
* @return {string}
|
|
25
|
+
*/
|
|
26
|
+
base64(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get the data URI.
|
|
29
|
+
* @return {string}
|
|
30
|
+
*/
|
|
31
|
+
dataUri(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Set option on instantiated Writer.
|
|
34
|
+
* @param {string} key
|
|
35
|
+
* @param {any} value
|
|
36
|
+
* @return {Writer}
|
|
37
|
+
*/
|
|
38
|
+
setOption(key: string, value: number | string): Writer;
|
|
39
|
+
/**
|
|
40
|
+
* Output to stdout
|
|
41
|
+
* @return {string}
|
|
42
|
+
*/
|
|
43
|
+
stdout(): boolean;
|
|
44
|
+
}
|
|
45
|
+
export { Writer };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
var MidiWriter = require('..');
|
|
2
|
+
|
|
3
|
+
var tracks = [];
|
|
4
|
+
tracks[0] = new MidiWriter.Track();
|
|
5
|
+
|
|
6
|
+
// You can chain track methods.
|
|
7
|
+
tracks[0]
|
|
8
|
+
.setTempo(60)
|
|
9
|
+
.addEvent([
|
|
10
|
+
// addEvent() accepts an array of event objects like this...
|
|
11
|
+
new MidiWriter.ProgramChangeEvent({instrument : 1}),
|
|
12
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd2'}),
|
|
13
|
+
new MidiWriter.NoteEvent({pitch: ['C5'], duration: '4'}),
|
|
14
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd2'}),
|
|
15
|
+
new MidiWriter.NoteEvent({pitch: ['C5'], duration: '4'}),
|
|
16
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd2'}),
|
|
17
|
+
new MidiWriter.NoteEvent({pitch: ['C5'], duration: '4'}),
|
|
18
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd2'}),
|
|
19
|
+
new MidiWriter.NoteEvent({pitch: ['Bb4'], duration: '4'}),
|
|
20
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: 'd2'}),
|
|
21
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: '4'}),
|
|
22
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: 'd2'}),
|
|
23
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: '4'}),
|
|
24
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: 'd2'}),
|
|
25
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd8'}),
|
|
26
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: '16'}),
|
|
27
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: 'd2'}),
|
|
28
|
+
new MidiWriter.NoteEvent({pitch: ['Ab4'], duration: '2'}),
|
|
29
|
+
new MidiWriter.NoteEvent({pitch: ['A4', 'B4', 'D5', 'C5', 'E4', 'A4'], duration: '8', sequential:true}),
|
|
30
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: 'd2'}),
|
|
31
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: '4'}),
|
|
32
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: 'd2'}),
|
|
33
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: '4'}),
|
|
34
|
+
new MidiWriter.NoteEvent({pitch: ['G4', 'Gb4', 'C4', 'B3', 'Eb4', 'Gb4'], duration: '8', sequential:true}),
|
|
35
|
+
new MidiWriter.NoteEvent({pitch: ['D5', 'C5', 'B4'], duration: '8t', sequential:true}),
|
|
36
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd2'}),
|
|
37
|
+
new MidiWriter.NoteEvent({pitch: ['C5'], duration: '4'}),
|
|
38
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd2'}),
|
|
39
|
+
new MidiWriter.NoteEvent({pitch: ['C5'], duration: '4'}),
|
|
40
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd2'}),
|
|
41
|
+
new MidiWriter.NoteEvent({pitch: ['C5'], duration: '4'}),
|
|
42
|
+
new MidiWriter.NoteEvent({pitch: ['B4'], duration: 'd8'}),
|
|
43
|
+
new MidiWriter.NoteEvent({pitch: ['Bb4'], duration: '16'}),
|
|
44
|
+
new MidiWriter.NoteEvent({pitch: ['Bb4'], duration: '4'}),
|
|
45
|
+
new MidiWriter.NoteEvent({pitch: ['G5'], duration: '4'}),
|
|
46
|
+
new MidiWriter.NoteEvent({pitch: ['Gb5'], duration: 'd8'}),
|
|
47
|
+
new MidiWriter.NoteEvent({pitch: ['E5'], duration: '16'}),
|
|
48
|
+
new MidiWriter.NoteEvent({pitch: ['E5', 'D#5', 'C6', 'D#5', 'D#5', 'E5', 'G5', 'B4'], duration: '8', sequential:true}),
|
|
49
|
+
new MidiWriter.NoteEvent({pitch: ['D5', 'C5'], duration: '8', sequential:true}),
|
|
50
|
+
new MidiWriter.NoteEvent({pitch: ['E5', 'E4', 'A4'], duration: '8t', sequential:true}),
|
|
51
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: 'd4'}),
|
|
52
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: '8'}),
|
|
53
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: 'd2'}),
|
|
54
|
+
new MidiWriter.NoteEvent({pitch: ['A4'], duration: '4'}),
|
|
55
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: 'd2'}),
|
|
56
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: 'd8'}),
|
|
57
|
+
new MidiWriter.NoteEvent({pitch: ['E4'], duration: '16'}),
|
|
58
|
+
new MidiWriter.NoteEvent({pitch: ['E4'], duration: 'd2'}),
|
|
59
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: '4'}),
|
|
60
|
+
new MidiWriter.NoteEvent({pitch: ['E4'], duration: 'd2'}),
|
|
61
|
+
new MidiWriter.NoteEvent({pitch: ['Gb4'], duration: '4'}),
|
|
62
|
+
new MidiWriter.NoteEvent({pitch: ['E4'], duration: '2'}),
|
|
63
|
+
new MidiWriter.NoteEvent({pitch: ['C6', 'G5', 'D5', 'C5'], duration: '2', wait: '2'}),
|
|
64
|
+
new MidiWriter.NoteEvent({pitch: ['C6', 'G5', 'D5', 'C5'], duration: '2'}),
|
|
65
|
+
new MidiWriter.NoteEvent({pitch: ['C6', 'G5', 'E5', 'C5'], duration: '4'})
|
|
66
|
+
], function(index, event) {
|
|
67
|
+
return {velocity: 100};
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// You can optionally pass a single event object to addEvent() if you wish
|
|
72
|
+
tracks[1] = new MidiWriter.Track();
|
|
73
|
+
tracks[1].addEvent(new MidiWriter.ProgramChangeEvent({instrument : 1}));
|
|
74
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8', repeat: 8}));
|
|
75
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'A3', 'F#3'], duration: '8', repeat: 4}));
|
|
76
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D#4', 'A3', 'F#3'], duration: '8', repeat: 4}));
|
|
77
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D#4', 'A3', 'F3'], duration: '8', repeat: 4}));
|
|
78
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D4', 'A3', 'F3'], duration: '8', repeat: 2}));
|
|
79
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D4', 'G#3', 'F3'], duration: '8', repeat: 2}));
|
|
80
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D4', 'G#3', 'E3'], duration: '8', repeat: 4}));
|
|
81
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D4', 'G3', 'E3'], duration: '8', repeat: 2}));
|
|
82
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C#4', 'G3', 'E3'], duration: '8', repeat: 2}));
|
|
83
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C4', 'G3', 'E3'], duration: '8', repeat: 4}));
|
|
84
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C4', 'F#3', 'E3'], duration: '8', repeat: 8}));
|
|
85
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C4', 'F#3', 'D#3'], duration: '8', repeat: 4}));
|
|
86
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C4', 'F#3', 'D3'], duration: '8', repeat: 8}));
|
|
87
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C4', 'F3', 'D3'], duration: '8', repeat: 4}));
|
|
88
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B4', 'F3', 'D3'], duration: '8', repeat: 4}));
|
|
89
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B4', 'E3', 'C3'], duration: '8', repeat: 2}));
|
|
90
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'E3', 'C3'], duration: '8', repeat: 6}));
|
|
91
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'E3', 'B3'], duration: '8', repeat: 2}));
|
|
92
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'D#3', 'B3'], duration: '8', repeat: 2}));
|
|
93
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'E3', 'C3'], duration: '8', repeat: 4}));
|
|
94
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'D#3', 'B3'], duration: '8', repeat: 4}));
|
|
95
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'E3', 'C3'], duration: '8', repeat: 4}));
|
|
96
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'D#3', 'B3'], duration: '4'}));
|
|
97
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8', wait: 'd2'}));
|
|
98
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8'}));
|
|
99
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8'}));
|
|
100
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8'}));
|
|
101
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8'}));
|
|
102
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8'}));
|
|
103
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8'}));
|
|
104
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'B3', 'G3'], duration: '8'}));
|
|
105
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E4', 'A3', 'F#3'], duration: '8', repeat: 4}));
|
|
106
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D#4', 'A3', 'F3'], duration: '8', repeat: 4}));
|
|
107
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D#4', 'G#3', 'F3'], duration: '8', repeat: 2}));
|
|
108
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D4', 'G#3', 'F3'], duration: '8', repeat: 2}));
|
|
109
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D4', 'G3', 'E3'], duration: '8', repeat: 4}));
|
|
110
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['D4', 'G3', 'E3'], duration: '8', repeat: 2}));
|
|
111
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C#4', 'G3', 'E3'], duration: '8', repeat: 2}));
|
|
112
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A#4', 'E3', 'C#3'], duration: '8', repeat: 2}));
|
|
113
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'E3', 'C3'], duration: '8', repeat: 2}));
|
|
114
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B3', 'B2'], duration: '8'}));
|
|
115
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A5', 'F#5', 'C4', 'A4'], duration: '8', repeat: 3}));
|
|
116
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['F#5', 'D#5', 'B4', 'G4'], duration: '8'}));
|
|
117
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E5', 'B4', 'G4'], duration: '8', repeat: 3}));
|
|
118
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E5', 'C4', 'A4'], duration: '8', repeat: 2}));
|
|
119
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A3'], duration: '8'}));
|
|
120
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['C4', 'F#3', 'E3'], duration: '8'}));
|
|
121
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B4', 'E3', 'B3'], duration: '8', repeat: 2}));
|
|
122
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A4', 'E3', 'C3'], duration: '8', repeat: 2}));
|
|
123
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B3', 'E3', 'B2'], duration: '8', repeat: 4}));
|
|
124
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A3', 'E3', 'C3'], duration: '8', repeat: 4}));
|
|
125
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B3', 'E3', 'B2'], duration: '8', repeat: 4}));
|
|
126
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B3', 'D#3', 'B3'], duration: '8', repeat: 2}));
|
|
127
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A3', 'D#3', 'B3'], duration: '8', repeat: 2}));
|
|
128
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['G3', 'E3', 'C3'], duration: '8', repeat: 4}));
|
|
129
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['Bb3', 'E3', 'C3'], duration: '8', repeat: 2}));
|
|
130
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A3', 'E3', 'C3'], duration: '8', repeat: 2}));
|
|
131
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['A3', 'E3', 'B3'], duration: '8', repeat: 2}));
|
|
132
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['G#3', 'E3', 'B3'], duration: '8', repeat: 2}));
|
|
133
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['G3', 'E3', 'B3'], duration: '8', repeat: 4}));
|
|
134
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['G3', 'C3', 'A#3'], duration: '2'}));
|
|
135
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B3', 'B2'], duration: '2', wait: '2'}));
|
|
136
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['B3', 'F#3', 'B2'], duration: '2'}));
|
|
137
|
+
tracks[1].addEvent(new MidiWriter.NoteEvent({pitch: ['E2', 'E1'], duration: '1'}));
|
|
138
|
+
|
|
139
|
+
var write = new MidiWriter.Writer(tracks);
|
|
140
|
+
console.log(write.dataUri());
|
|
141
|
+
//write.stdout();
|
|
142
|
+
|
|
143
|
+
module.exports = write;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var MidiWriter = require('..');
|
|
2
|
+
|
|
3
|
+
var track = new MidiWriter.Track();
|
|
4
|
+
|
|
5
|
+
track.addEvent([
|
|
6
|
+
new MidiWriter.NoteEvent({pitch: ['E4','D4'], duration: '4'}),
|
|
7
|
+
new MidiWriter.NoteEvent({pitch: 'C4', duration: '2'}),
|
|
8
|
+
new MidiWriter.NoteEvent({pitch: ['E4','D4'], duration: '4'}),
|
|
9
|
+
new MidiWriter.NoteEvent({pitch: 'C4', duration: '2'}),
|
|
10
|
+
new MidiWriter.NoteEvent({pitch: ['C4', 'C4', 'C4', 'C4', 'D4', 'D4', 'D4', 'D4'], duration: '8'}),
|
|
11
|
+
new MidiWriter.NoteEvent({pitch: ['E4','D4'], duration: '4'}),
|
|
12
|
+
new MidiWriter.NoteEvent({pitch: 'C4', duration: '2'})
|
|
13
|
+
], function(event, index) {
|
|
14
|
+
return {sequential:true};
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var write = new MidiWriter.Writer(track);
|
|
20
|
+
//console.log(track);
|
|
21
|
+
//console.log(write.base64())
|
|
22
|
+
console.log(write.dataUri());
|
|
23
|
+
|
|
24
|
+
module.exports = write;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
VARIATIONS
|
|
3
|
+
Faciles
|
|
4
|
+
Pour la Guitare
|
|
5
|
+
Sur un air National Autrichien
|
|
6
|
+
Composées
|
|
7
|
+
PAR
|
|
8
|
+
MAURO GIULIANI
|
|
9
|
+
Oev: 47 Prix 3f
|
|
10
|
+
à Paris
|
|
11
|
+
chez RICHAULT...
|
|
12
|
+
Boulevard Poissonièr No 16, au 1er
|
|
13
|
+
[N.] 1303. R.
|
|
14
|
+
|
|
15
|
+
This is the main theme, the pubblication comes along with 12
|
|
16
|
+
variations, it´s a pretty good start for classical guitarists.
|
|
17
|
+
**/
|
|
18
|
+
var MidiWriter = require('..');
|
|
19
|
+
var tracks = [];
|
|
20
|
+
|
|
21
|
+
tracks[0] = new MidiWriter.Track();
|
|
22
|
+
tracks[0].setTimeSignature(3, 4);
|
|
23
|
+
tracks[0].setTempo(100);
|
|
24
|
+
|
|
25
|
+
var notes;
|
|
26
|
+
|
|
27
|
+
// melody
|
|
28
|
+
tracks[1] = new MidiWriter.Track();
|
|
29
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '2'});
|
|
30
|
+
tracks[1].addEvent(notes);
|
|
31
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '4'});
|
|
32
|
+
tracks[1].addEvent(notes);
|
|
33
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '2'});
|
|
34
|
+
tracks[1].addEvent(notes);
|
|
35
|
+
notes = new MidiWriter.NoteEvent({pitch:['A4', 'C#5'], duration: '4'});
|
|
36
|
+
tracks[1].addEvent(notes);
|
|
37
|
+
notes = new MidiWriter.NoteEvent({pitch:['B4', 'D5'], duration: '2'});
|
|
38
|
+
tracks[1].addEvent(notes);
|
|
39
|
+
notes = new MidiWriter.NoteEvent({pitch:['G#4', 'E5'], duration: '4'});
|
|
40
|
+
tracks[1].addEvent(notes);
|
|
41
|
+
notes = new MidiWriter.NoteEvent({pitch:['A4', 'C#5'], duration: '2'});
|
|
42
|
+
tracks[1].addEvent(notes);
|
|
43
|
+
notes = new MidiWriter.NoteEvent({pitch:['A4'], duration: '4'});
|
|
44
|
+
tracks[1].addEvent(notes);
|
|
45
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '2'});
|
|
46
|
+
tracks[1].addEvent(notes);
|
|
47
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '4'});
|
|
48
|
+
tracks[1].addEvent(notes);
|
|
49
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '2'});
|
|
50
|
+
tracks[1].addEvent(notes);
|
|
51
|
+
notes = new MidiWriter.NoteEvent({pitch:['A4', 'C#5'], duration: '4'});
|
|
52
|
+
tracks[1].addEvent(notes);
|
|
53
|
+
notes = new MidiWriter.NoteEvent({pitch:['B4', 'D5'], duration: '2'});
|
|
54
|
+
tracks[1].addEvent(notes);
|
|
55
|
+
notes = new MidiWriter.NoteEvent({pitch:['G#4', 'E5'], duration: '4'});
|
|
56
|
+
tracks[1].addEvent(notes);
|
|
57
|
+
notes = new MidiWriter.NoteEvent({pitch:['A4', 'C#5'], duration: '2'});
|
|
58
|
+
tracks[1].addEvent(notes);
|
|
59
|
+
// note how the previous rest is handled: it became the wait
|
|
60
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch:['E5', 'E5'], duration: '4'});
|
|
61
|
+
tracks[1].addEvent(notes);
|
|
62
|
+
notes = new MidiWriter.NoteEvent({pitch:['D#5', 'F#5'], duration: '4'});
|
|
63
|
+
tracks[1].addEvent(notes);
|
|
64
|
+
notes = new MidiWriter.NoteEvent({pitch:['D5', 'G#5'], duration: '4'});
|
|
65
|
+
tracks[1].addEvent(notes);
|
|
66
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'A5'], duration: '2'});
|
|
67
|
+
tracks[1].addEvent(notes);
|
|
68
|
+
notes = new MidiWriter.NoteEvent({pitch:['E5'], duration: '4'});
|
|
69
|
+
tracks[1].addEvent(notes);
|
|
70
|
+
notes = new MidiWriter.NoteEvent({pitch:['E5', 'E5'], duration: '4'});
|
|
71
|
+
tracks[1].addEvent(notes);
|
|
72
|
+
notes = new MidiWriter.NoteEvent({pitch:['D#5', 'F#5'], duration: '4'});
|
|
73
|
+
tracks[1].addEvent(notes);
|
|
74
|
+
notes = new MidiWriter.NoteEvent({pitch:['D5', 'G#5'], duration: '4'});
|
|
75
|
+
tracks[1].addEvent(notes);
|
|
76
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'A5'], duration: '2'});
|
|
77
|
+
tracks[1].addEvent(notes);
|
|
78
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch:['C#5', 'E5'], duration: '2'});
|
|
79
|
+
tracks[1].addEvent(notes);
|
|
80
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '4'});
|
|
81
|
+
tracks[1].addEvent(notes);
|
|
82
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '4'});
|
|
83
|
+
tracks[1].addEvent(notes);
|
|
84
|
+
notes = new MidiWriter.NoteEvent({pitch:['A5'], duration: '4'});
|
|
85
|
+
tracks[1].addEvent(notes);
|
|
86
|
+
notes = new MidiWriter.NoteEvent({pitch:['A4', 'C#5'], duration: '4'});
|
|
87
|
+
tracks[1].addEvent(notes);
|
|
88
|
+
notes = new MidiWriter.NoteEvent({pitch:['C#5', 'E5'], duration: '4'});
|
|
89
|
+
tracks[1].addEvent(notes);
|
|
90
|
+
notes = new MidiWriter.NoteEvent({pitch:['B4', 'D5'], duration: '4'});
|
|
91
|
+
tracks[1].addEvent(notes);
|
|
92
|
+
notes = new MidiWriter.NoteEvent({pitch:['G#4', 'B4'], duration: '4'});
|
|
93
|
+
tracks[1].addEvent(notes);
|
|
94
|
+
notes = new MidiWriter.NoteEvent({pitch:['A4'], duration: '2'});
|
|
95
|
+
tracks[1].addEvent(notes);
|
|
96
|
+
|
|
97
|
+
// bass
|
|
98
|
+
tracks[2] = new MidiWriter.Track();
|
|
99
|
+
notes = new MidiWriter.NoteEvent({pitch:['A3'], duration: '2'});
|
|
100
|
+
tracks[2].addEvent(notes);
|
|
101
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
102
|
+
tracks[2].addEvent(notes);
|
|
103
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['E3'], duration: '2'});
|
|
104
|
+
tracks[2].addEvent(notes);
|
|
105
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
106
|
+
tracks[2].addEvent(notes);
|
|
107
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
108
|
+
tracks[2].addEvent(notes);
|
|
109
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
110
|
+
tracks[2].addEvent(notes);
|
|
111
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['E3'], duration: '2'});
|
|
112
|
+
tracks[2].addEvent(notes);
|
|
113
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
114
|
+
tracks[2].addEvent(notes);
|
|
115
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['E3'], duration: '2'});
|
|
116
|
+
tracks[2].addEvent(notes);
|
|
117
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
118
|
+
tracks[2].addEvent(notes);
|
|
119
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['E3'], duration: '2'});
|
|
120
|
+
tracks[2].addEvent(notes);
|
|
121
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
122
|
+
tracks[2].addEvent(notes);
|
|
123
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
124
|
+
tracks[2].addEvent(notes);
|
|
125
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
126
|
+
tracks[2].addEvent(notes);
|
|
127
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['E3'], duration: '2'});
|
|
128
|
+
tracks[2].addEvent(notes);
|
|
129
|
+
notes = new MidiWriter.NoteEvent({wait: '4', pitch: ['A3'], duration: '2'});
|
|
130
|
+
tracks[2].addEvent(notes);
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
var write = new MidiWriter.Writer(tracks);
|
|
134
|
+
|
|
135
|
+
console.log(write.dataUri());
|
|
136
|
+
module.exports = write;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var MidiWriter = require('..');
|
|
2
|
+
|
|
3
|
+
var track = new MidiWriter.Track();
|
|
4
|
+
|
|
5
|
+
track.addEvent([
|
|
6
|
+
new MidiWriter.NoteEvent({
|
|
7
|
+
pitch: 'C4',
|
|
8
|
+
duration: 'T50',
|
|
9
|
+
tick: 0
|
|
10
|
+
}),
|
|
11
|
+
new MidiWriter.NoteEvent({
|
|
12
|
+
pitch: 'E4',
|
|
13
|
+
duration: 'T50',
|
|
14
|
+
tick: 50
|
|
15
|
+
}),
|
|
16
|
+
new MidiWriter.NoteEvent({
|
|
17
|
+
pitch: ['G4', 'B4'],
|
|
18
|
+
duration: 'T50',
|
|
19
|
+
tick: 100
|
|
20
|
+
}),
|
|
21
|
+
new MidiWriter.NoteEvent({
|
|
22
|
+
pitch: 'C5',
|
|
23
|
+
duration: 'T50',
|
|
24
|
+
tick: 150
|
|
25
|
+
}),
|
|
26
|
+
new MidiWriter.NoteEvent({
|
|
27
|
+
pitch: 'D5',
|
|
28
|
+
duration: 'T50',
|
|
29
|
+
tick: 200
|
|
30
|
+
}),
|
|
31
|
+
new MidiWriter.NoteEvent({
|
|
32
|
+
pitch: 'F5',
|
|
33
|
+
duration: 'T50',
|
|
34
|
+
tick: 250
|
|
35
|
+
}),
|
|
36
|
+
new MidiWriter.NoteEvent({
|
|
37
|
+
pitch: 'A5',
|
|
38
|
+
duration: 'T50',
|
|
39
|
+
tick: 300
|
|
40
|
+
}),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
var write = new MidiWriter.Writer(track);
|
|
44
|
+
console.log(write.dataUri());
|
|
45
|
+
module.exports = write;
|