spessasynth_lib 3.25.7 → 3.25.8

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.
@@ -44,38 +44,10 @@ class BasicMIDI extends MIDISequenceData
44
44
  static copyFrom(mid)
45
45
  {
46
46
  const m = new BasicMIDI();
47
+ m._copyFromSequence(mid);
47
48
 
48
- m.midiName = mid.midiName;
49
- m.midiNameUsesFileName = mid.midiNameUsesFileName;
50
- m.fileName = mid.fileName;
51
- m.timeDivision = mid.timeDivision;
52
- m.duration = mid.duration;
53
- m.copyright = mid.copyright;
54
- m.tracksAmount = mid.tracksAmount;
55
- m.firstNoteOn = mid.firstNoteOn;
56
- m.keyRange = { ...mid.keyRange }; // Deep copy of keyRange
57
- m.lastVoiceEventTick = mid.lastVoiceEventTick;
58
- m.loop = { ...mid.loop }; // Deep copy of loop
59
- m.format = mid.format;
60
- m.bankOffset = mid.bankOffset;
61
- m.isKaraokeFile = mid.isKaraokeFile;
62
- m.isMultiPort = mid.isMultiPort;
63
49
  m.isDLSRMIDI = mid.isDLSRMIDI;
64
-
65
- // Copying arrays
66
- m.tempoChanges = [...mid.tempoChanges]; // Shallow copy
67
- m.lyrics = mid.lyrics.map(arr => new Uint8Array(arr)); // Deep copy of each binary chunk
68
- m.lyricsTicks = [...mid.lyricsTicks]; // Shallow copy
69
- m.midiPorts = [...mid.midiPorts]; // Shallow copy
70
- m.midiPortChannelOffsets = [...mid.midiPortChannelOffsets]; // Shallow copy
71
- m.usedChannelsOnTrack = mid.usedChannelsOnTrack.map(set => new Set(set)); // Deep copy
72
- m.rawMidiName = mid.rawMidiName ? new Uint8Array(mid.rawMidiName) : undefined; // Deep copy
73
50
  m.embeddedSoundFont = mid.embeddedSoundFont ? mid.embeddedSoundFont.slice(0) : undefined; // Deep copy
74
-
75
- // Copying RMID Info object (deep copy)
76
- m.RMIDInfo = { ...mid.RMIDInfo };
77
-
78
- // Copying track data (deep copy of each track)
79
51
  m.tracks = mid.tracks.map(track => [...track]); // Shallow copy of each track array
80
52
 
81
53
  return m;
@@ -310,21 +282,27 @@ class BasicMIDI extends MIDISequenceData
310
282
  }
311
283
  }
312
284
  break;
285
+
286
+ case messageTypes.trackName:
287
+ break;
313
288
  }
314
289
  }
315
290
  // add used channels
316
291
  this.usedChannelsOnTrack.push(usedChannels);
317
292
 
318
- // If the track has no voice messages, its "track name" event (if it has any)
319
- // is some metadata.
320
- // Add it to copyright
321
- if (!trackHasVoiceMessages)
293
+ // track name
294
+ this.trackNames[i] = "";
295
+ const trackName = track.find(e => e.messageStatusByte === messageTypes.trackName);
296
+ if (trackName)
322
297
  {
323
- const trackName = track.find(e => e.messageStatusByte === messageTypes.trackName);
324
- if (trackName)
298
+ trackName.messageData.currentIndex = 0;
299
+ const name = readBytesAsString(trackName.messageData, trackName.messageData.length);
300
+ this.trackNames[i] = name;
301
+ // If the track has no voice messages, its "track name" event (if it has any)
302
+ // is some metadata.
303
+ // Add it to copyright
304
+ if (!trackHasVoiceMessages)
325
305
  {
326
- trackName.messageData.currentIndex = 0;
327
- const name = readBytesAsString(trackName.messageData, trackName.messageData.length);
328
306
  copyrightComponents.push(name);
329
307
  }
330
308
  }
@@ -22,29 +22,7 @@ export class MIDIData extends MIDISequenceData
22
22
  constructor(midi)
23
23
  {
24
24
  super();
25
- this.timeDivision = midi.timeDivision;
26
- this.duration = midi.duration;
27
- this.tempoChanges = midi.tempoChanges;
28
- this.copyright = midi.copyright;
29
- this.tracksAmount = midi.tracksAmount;
30
- this.lyrics = midi.lyrics;
31
- this.lyricsTicks = midi.lyricsTicks;
32
- this.firstNoteOn = midi.firstNoteOn;
33
- this.keyRange = midi.keyRange;
34
- this.lastVoiceEventTick = midi.lastVoiceEventTick;
35
- this.midiPorts = midi.midiPorts;
36
- this.midiPortChannelOffsets = midi.midiPortChannelOffsets;
37
- this.usedChannelsOnTrack = midi.usedChannelsOnTrack;
38
- this.loop = midi.loop;
39
- this.midiName = midi.midiName;
40
- this.midiNameUsesFileName = midi.midiNameUsesFileName;
41
- this.fileName = midi.fileName;
42
- this.rawMidiName = midi.rawMidiName;
43
- this.format = midi.format;
44
- this.RMIDInfo = midi.RMIDInfo;
45
- this.bankOffset = midi.bankOffset;
46
- this.isKaraokeFile = midi.isKaraokeFile;
47
- this.isMultiPort = midi.isMultiPort;
25
+ this._copyFromSequence(midi);
48
26
 
49
27
  // Set isEmbedded based on the presence of an embeddedSoundFont
50
28
  this.isEmbedded = midi.embeddedSoundFont !== undefined;
@@ -38,6 +38,12 @@ class MIDISequenceData
38
38
  */
39
39
  tracksAmount = 0;
40
40
 
41
+ /**
42
+ * The track names in the MIDI file, an empty string if not set.
43
+ * @type {[]}
44
+ */
45
+ trackNames = [];
46
+
41
47
  /**
42
48
  * An array containing the lyrics of the sequence, stored as binary chunks (Uint8Array).
43
49
  * @type {Uint8Array[]}
@@ -175,6 +181,45 @@ class MIDISequenceData
175
181
 
176
182
  return totalSeconds;
177
183
  }
184
+
185
+ /**
186
+ * INTERNAL USE ONLY!
187
+ * DO NOT USE IN SPESSASYNTH_LIB
188
+ * @param sequence {MIDISequenceData}
189
+ * @protected
190
+ */
191
+ _copyFromSequence(sequence)
192
+ {
193
+ // properties can be assigned
194
+ this.midiName = sequence.midiName;
195
+ this.midiNameUsesFileName = sequence.midiNameUsesFileName;
196
+ this.fileName = sequence.fileName;
197
+ this.timeDivision = sequence.timeDivision;
198
+ this.duration = sequence.duration;
199
+ this.copyright = sequence.copyright;
200
+ this.tracksAmount = sequence.tracksAmount;
201
+ this.firstNoteOn = sequence.firstNoteOn;
202
+ this.lastVoiceEventTick = sequence.lastVoiceEventTick;
203
+ this.format = sequence.format;
204
+ this.bankOffset = sequence.bankOffset;
205
+ this.isKaraokeFile = sequence.isKaraokeFile;
206
+ this.isMultiPort = sequence.isMultiPort;
207
+
208
+ // copying arrays
209
+ this.tempoChanges = [...sequence.tempoChanges];
210
+ this.lyrics = sequence.lyrics.map(arr => new Uint8Array(arr));
211
+ this.lyricsTicks = [...sequence.lyricsTicks];
212
+ this.midiPorts = [...sequence.midiPorts];
213
+ this.trackNames = [...sequence.trackNames];
214
+ this.midiPortChannelOffsets = [...sequence.midiPortChannelOffsets];
215
+ this.usedChannelsOnTrack = sequence.usedChannelsOnTrack.map(set => new Set(set));
216
+ this.rawMidiName = sequence.rawMidiName ? new Uint8Array(sequence.rawMidiName) : undefined;
217
+
218
+ // copying objects
219
+ this.loop = { ...sequence.loop };
220
+ this.keyRange = { ...sequence.keyRange };
221
+ this.RMIDInfo = { ...sequence.RMIDInfo };
222
+ }
178
223
  }
179
224
 
180
225
  export { MIDISequenceData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.25.7",
3
+ "version": "3.25.8",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "browser": "index.js",
6
6
  "type": "module",