Large MIDI files cause `RangeError: Maximum call stack size exceeded` when writing to bytes
Opened this issue · 0 comments
Deleted user commented
When writing a large midi file using File.prototype.toBytes()
, an error is thrown::
/Users/me/node_modules/jsmidgen/lib/jsmidgen.js:122
return String.fromCharCode.apply(null, byteArray);
^
RangeError: Maximum call stack size exceeded
at Object.codes2Str (/Users/me/node_modules/jsmidgen/lib/jsmidgen.js:122:31)
at /Users/me/node_modules/jsmidgen/lib/jsmidgen.js:658:18
at Array.forEach (<anonymous>)
at File.toBytes (/Users/me/node_modules/jsmidgen/lib/jsmidgen.js:657:15)
at end (/Users/me/Desktop/mpp2midi/main.js:72:48)
at ReadStream.<anonymous> (/Users/me/Desktop/mpp2midi/main.js:123:34)
at emitOne (events.js:116:13)
at ReadStream.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
I personally solved it by replacing the following code
Lines 121 to 123 in 97c1270
with this
codes2Str: function(byteArray) {
var string = "";
byteArray.forEach(byte => string += String.fromCharCode(byte));
return string;
},