<commit_before>importScripts('lib/requirejs/require.js');

require.config({
	baseUrl: 'util'
});

require(['riff'], function(Riff) {

	postMessage('ready');

	onmessage = function(msg) {
		
		var arr = JSON.parse(msg.data);

		var len = 48000 * 10;                // 10 seconds
		var fsize = len + 44;
		var buffer = new ArrayBuffer(fsize);
		var dataView = new DataView(buffer);

		var riff = new Riff(dataView);

		// RIFF chunk (12 bytes)
		riff.appendUTFBytes('RIFF');         // ID
		riff.appendUint32(fsize);            // total size
		riff.appendUTFBytes('WAVE');         // type

		// FORMAT chunk (24 bytes)
		riff.appendUTFBytes('fmt ');
		riff.appendUint32(0x10);             // size (16 bytes)
		riff.appendUint16(0x01);
		riff.appendUint16(0x01);             // mono
		riff.appendUint32(44800);            // sample rate Hz
		riff.appendUint32(44800);            // bytes per second
		riff.appendUint16(1);                // 1 byte per sample
		riff.appendUint16(8);                // 8 bits per sample

		// DATA chunk (8 bytes)
		riff.appendUTFBytes('data');
		riff.appendUint32(len);

		// data
		for(var i=0;i<len;i++) {
			riff.appendUint8(arr[i] * 256 * 0.7);   // 8 bit music
		}

		var blob = new Blob([riff.view], {
			type: "audio/wav"
		});

		var fd = new FormData();
		fd.append('fname', '8bit.wav');
		fd.append('data', blob);		

		var req = new XMLHttpRequest();
		req.open("POST", '/daw/upload.php', true);

		/*
		req.setRequestHeader('Content-Type',
		'application/x-www-form-urlencoded');
		*/
		
		req.onreadystatechange = function() {
			if(req.readyState === 4) {
				postMessage('done');
			}
		};

		req.send(fd);

	};<commit_msg>Improved portability<commit_after>importScripts('lib/requirejs/require.js');

require.config({
	baseUrl: 'util'
});

require(['riff'], function(Riff) {

	postMessage('ready');

	onmessage = function(msg) {
		
		var arr = JSON.parse(msg.data);

		var len = 48000 * 10;                // 10 seconds
		var fsize = len + 44;
		var buffer = new ArrayBuffer(fsize);
		var dataView = new DataView(buffer);

		var riff = new Riff(dataView);

		// RIFF chunk (12 bytes)
		riff.appendUTFBytes('RIFF');         // ID
		riff.appendUint32(fsize);            // total size
		riff.appendUTFBytes('WAVE');         // type

		// FORMAT chunk (24 bytes)
		riff.appendUTFBytes('fmt ');
		riff.appendUint32(0x10);             // size (16 bytes)
		riff.appendUint16(0x01);
		riff.appendUint16(0x01);             // mono
		riff.appendUint32(44800);            // sample rate Hz
		riff.appendUint32(44800);            // bytes per second
		riff.appendUint16(1);                // 1 byte per sample
		riff.appendUint16(8);                // 8 bits per sample

		// DATA chunk (8 bytes)
		riff.appendUTFBytes('data');
		riff.appendUint32(len);

		// data
		for(var i=0;i<len;i++) {
			riff.appendUint8(arr[i] * 256 * 0.7);   // 8 bit music
		}

		var blob = new Blob([riff.view], {
			type: "audio/wav"
		});

		var fd = new FormData();
		fd.append('fname', '8bit.wav');
		fd.append('data', blob);		

		var req = new XMLHttpRequest();
		req.open("POST", '../upload.php', true);

		/*
		req.setRequestHeader('Content-Type',
		'application/x-www-form-urlencoded');
		*/
		
		req.onreadystatechange = function() {
			if(req.readyState === 4) {
				postMessage('done');
			}
		};

		req.send(fd);

	};
{'fraction_non_alphanumeric': 0.16501946690625935, 'fraction_numerical': 0.04132973944294699, 'mean_word_length': 2.490073145245559, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4703971', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1174, 'n_words': 239}