@@ -6,7 +6,7 @@ var MidiWriter = (function () {
66 * @return {Constants }
77 */
88 var Constants = {
9- VERSION : '3.0.1 ' ,
9+ VERSION : '3.1.0 ' ,
1010 HEADER_CHUNK_TYPE : [ 0x4d , 0x54 , 0x68 , 0x64 ] ,
1111 HEADER_CHUNK_LENGTH : [ 0x00 , 0x00 , 0x00 , 0x06 ] ,
1212 HEADER_CHUNK_FORMAT0 : [ 0x00 , 0x00 ] ,
@@ -786,7 +786,7 @@ var MidiWriter = (function () {
786786 this . status = 0xC0 ;
787787 this . name = 'ProgramChangeEvent' ;
788788 // delta time defaults to 0.
789- this . data = Utils . numberToVariableLength ( this . delta ) . concat ( this . status | this . channel - 1 , this . instrument ) ;
789+ this . data = Utils . numberToVariableLength ( this . delta ) . concat ( this . status | this . channel , this . instrument ) ;
790790 }
791791 return ProgramChangeEvent ;
792792 } ( ) ) ;
@@ -1300,7 +1300,13 @@ var MidiWriter = (function () {
13001300 */
13011301 Writer . prototype . base64 = function ( ) {
13021302 if ( typeof btoa === 'function' ) {
1303- return btoa ( String . fromCharCode . apply ( null , this . buildFile ( ) ) ) ;
1303+ var binary = '' ;
1304+ var bytes = this . buildFile ( ) ;
1305+ var len = bytes . byteLength ;
1306+ for ( var i = 0 ; i < len ; i ++ ) {
1307+ binary += String . fromCharCode ( bytes [ i ] ) ;
1308+ }
1309+ return btoa ( binary ) ;
13041310 }
13051311 return Buffer . from ( this . buildFile ( ) ) . toString ( 'base64' ) ;
13061312 } ;
0 commit comments