@werckmeister/components 1.1.6-17 → 1.1.6-170

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.
@@ -0,0 +1,18 @@
1
+ export declare const MidiEventTypes: {
2
+ NoteOn: number;
3
+ NoteOff: number;
4
+ Pc: number;
5
+ Cc: number;
6
+ PitchBend: number;
7
+ };
8
+ export interface IMidiEvent {
9
+ type: number;
10
+ noteName?: string;
11
+ channel: number;
12
+ track: number;
13
+ param1: number;
14
+ param2?: number;
15
+ playTime: number;
16
+ pitchbendValue?: number;
17
+ absPositionTicks?: number;
18
+ }
package/README.md CHANGED
@@ -1,13 +1,14 @@
1
- # werckmeister-component
1
+ # 🎼 werckmeister-component
2
2
 
3
3
  A [web component](https://en.wikipedia.org/wiki/Web_Components) which allows you to embed werckmeister snippets on your website.
4
4
 
5
5
  ## How to use
6
6
 
7
+ ### snippet
7
8
  * include the javascript file
8
9
 
9
10
  ```html
10
- <script src="https://unpkg.com/werckmeister-components@~1.0.0/werckmeister-components.js"></script>
11
+ <script src="https://unpkg.com/@werckmeister/components@1.1.6-41/werckmeister-components.js"></script>
11
12
  ```
12
13
  * embed your snippet
13
14
 
@@ -29,7 +30,8 @@ instrument: lead;
29
30
  ```
30
31
 
31
32
  ## Demo
32
- https://jsfiddle.net/o8tq4ghp/
33
+ https://jsfiddle.net/z8qv5b7j/
34
+
33
35
 
34
36
  ## Options
35
37
 
@@ -37,14 +39,121 @@ https://jsfiddle.net/o8tq4ghp/
37
39
  can be either `default` or `single`. `single` means that the input is treated as one singe voice line such as `c d e f g`.
38
40
  In `default`mode the input has to be a valid `werckmeister` source.
39
41
 
40
- https://jsfiddle.net/6dmoun41/
42
+ https://jsfiddle.net/bh4ugc5q/
41
43
 
42
44
  ### `wm-tempo`
43
45
  Set the tempo of an snippet.
44
46
  ### `wm-style`
45
47
  Inline css rules to set up the apperance of the snippet.
46
- https://jsfiddle.net/aw702vcg/
48
+ https://jsfiddle.net/zxhgyv2p/
47
49
 
48
50
  ### `wm-css-url`
49
51
  Set an url of an css file, to override the default css of the snippet.
50
- https://jsfiddle.net/y53647x8/
52
+ https://jsfiddle.net/m01bzg3f/
53
+
54
+ ### `wm-soundfont-url`
55
+ Set the repo url. See [Soundfont Server](https://github.com/werckme/soundfont-server).
56
+
57
+ ### `wm-workspace-url`
58
+ Uses a workspace url as source. E.g.: "https://sambag.uber.space/api-wm/conductor16thHighHat"
59
+
60
+
61
+ ### workspace
62
+ #### Using `<werckmeister-workspace>` to use several editors (for example in different tabs)
63
+
64
+ ---
65
+
66
+ ## 🔌 Step 1: Include the Component Script
67
+
68
+ Add the Werckmeister Components script to your HTML:
69
+
70
+ ```html
71
+ <script src="https://unpkg.com/@werckmeister/components/werckmeister-components.js"></script>
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 🧱 Step 2: Add a `<werckmeister-workspace>` and Editor
77
+
78
+ Define a workspace `<werckmeister-editor>`. Each editor can contain a werckmeister document.
79
+
80
+ Example:
81
+
82
+ ```html
83
+ <werckmeister-workspace id="workspace"></werckmeister-workspace>
84
+
85
+ <werckmeister-editor
86
+ id="ed1"
87
+ wm-filename="main.sheet"
88
+ wm-style="height: 700px;"
89
+ >
90
+ using "chords/default.chords";
91
+
92
+ tempo: 140;
93
+ device: MyDevice webPlayer _useFont="FluidR3-GM";
94
+ instrumentDef:lead _onDevice=MyDevice _ch=0 _pc=0;
95
+ instrumentDef:rhythm _onDevice=MyDevice _ch=1 _pc=0;
96
+ instrumentDef:bass _onDevice=MyDevice _ch=2 _pc=0;
97
+
98
+ -- melody track
99
+ [
100
+ instrument: lead;
101
+ {
102
+ \p
103
+ r4 e f# g | c'1~ | c'4 d e f# | b2 b2~ |
104
+ }
105
+ ]
106
+ </werckmeister-editor>
107
+
108
+ <a href id="download">Download MIDI</a>
109
+ ```
110
+
111
+ ---
112
+
113
+ ## ⚙️ Step 3: Register the Editor in JavaScript
114
+
115
+ Link your editor to the workspace using JavaScript:
116
+
117
+ ```js
118
+ const workspace = document.getElementById('workspace');
119
+ workspace.registerEditor(document.getElementById('ed1'));
120
+ ```
121
+
122
+ You can also hook into events:
123
+
124
+ ```js
125
+ workspace.onError = (ex) => console.log("Error:", ex);
126
+ workspace.onCompiled = (doc) => console.log("Compiled successfully:", doc);
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 🎵 MIDI Export
132
+
133
+ To trigger MIDI file download:
134
+
135
+ ```js
136
+ const downloadEl = document.querySelector("#download");
137
+ downloadEl.onclick = (ev) => {
138
+ ev.preventDefault();
139
+ workspace.download("myFile.mid");
140
+ }
141
+ ```
142
+
143
+ ## worskapce Options
144
+ ### wm-css-url
145
+ Load a custom CSS file to override the default styling of the editor.
146
+
147
+ ### wm-soundfont-url
148
+ Set the repo url. See [Soundfont Server](https://github.com/werckme/soundfont-server).
149
+
150
+ ### wm-onerror
151
+ sets an error callback
152
+
153
+ ## Editor options
154
+ ### wm-style
155
+ sets the style content to the underlying editor component
156
+ ### wm-css-url
157
+ Load a custom CSS file to override the default styling of the editor.
158
+ ### wm-filename
159
+ Defines a filename for the editor file. This file is accessable for the compiler.
package/index.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { IMidiEvent } from "./IMidiEvent";
2
+ import { ISoundFont } from './SfCompose';
3
+ export declare enum PlayerState {
4
+ Stopped = 0,
5
+ Preparing = 1,
6
+ Playing = 2,
7
+ Stopping = 3
8
+ }
9
+ export interface Task {
10
+ id: string;
11
+ name: string;
12
+ }
13
+ export interface TaskVisitor {
14
+ newTasks(tasks: Task[]): any;
15
+ done(task: Task): any;
16
+ message?(text: string, title?: string): any;
17
+ }
18
+ export declare class WerckmeisterMidiPlayer {
19
+ private static instaces;
20
+ private instanceId;
21
+ private _playerState;
22
+ playedTime: number;
23
+ midifile: any;
24
+ private audioContext;
25
+ private events;
26
+ onPlayerStateChanged: (oldState: PlayerState, newState: PlayerState) => void;
27
+ onMidiEvent: (event: IMidiEvent) => void;
28
+ private sfComposer;
29
+ private _sfRepository;
30
+ private neededInstruments;
31
+ private midiBuffer;
32
+ soundFont: ISoundFont;
33
+ private soundFontHash;
34
+ repoUrl: string;
35
+ private audioNodes;
36
+ rendererBufferSeconds: number;
37
+ gain: number;
38
+ constructor();
39
+ get ppq(): number;
40
+ hasEvents(): boolean;
41
+ private getSfRepository;
42
+ get playerState(): PlayerState;
43
+ set playerState(newState: PlayerState);
44
+ initAudioEnvironment(event: Event): Promise<void>;
45
+ private convertEvent;
46
+ private preprocessEvents;
47
+ private instrumentHash;
48
+ private instrumentsHash;
49
+ private getSoundfont;
50
+ private currentTaskVisitor;
51
+ load(base64MidiFileData: string, taskVisitor?: TaskVisitor | undefined): Promise<void>;
52
+ play(): Promise<void>;
53
+ stop(): void;
54
+ private postWebworker;
55
+ private startPlayback;
56
+ setRepoUrl(url: string): void;
57
+ /**
58
+ * fires the midi events parallel to the playback
59
+ */
60
+ private startEventNotification;
61
+ }