<commit_before>(function() {
	window.AudioEngine = {};

	AudioEngine.DELAY_FACTOR = 0.02;
	AudioEngine.DELAY_STEP = 1; //millis
	AudioEngine.DELAY_MIN_VALUE = 0.2;
	AudioEngine.DELAY_NORMAL_VALUE = 40;

	var soundPath = "js/core/sound/";
	AudioEngine.soundModules = [
		"js/core/audio/beat", //parent
		"js/core/audio/sound",
		"js/core/audio/ambientSound"
	];

	AudioEngine.numSound = 0;
	AudioEngine.soundLoaded = 0;
	AudioEngine.load = function() {

		requirejs(AudioEngine.soundModules, function() {

			AudioEngine.map = new HashMap();
			AudioEngine.sounds = [];

			AudioEngine.AudioContext = window.AudioContext || window.webkitAudioContext || null;

			if (AudioEngine.AudioContext) {
				//creating a new audio context if it's available.
				AudioEngine.context = new AudioEngine.AudioContext();
				//creating a gain node to control volume
				AudioEngine.volume = AudioEngine.context.createGain();
				AudioEngine.volume.gain.value = 50;
				//connecting volume node to context destination
				AudioEngine.volume.connect(AudioEngine.context.destination);
			} else {
				console.error("No Audio Context available, sorry.");
			}

			for (var audio in Assets.Audio) {
				AudioEngine.numSound++;
				setTimeout(function() {
					AudioEngine.loadSingleFile(audio, Assets.Audio[audio]);
				}, 0);
			}

		});
	};

	AudioEngine.get = function(id) {
		//returning stored buffer;
		return AudioEngine.map.get(id) || false;
	}

	AudioEngine.loadSingleFile = function(id, path) {
		// Load a sound file using an ArrayBuffer XMLHttpRequest.
		var request = new XMLHttpRequest();
		request.open("GET", path, true);
		request.responseType = "arraybuffer";
		request.onload = function(e) {

			// Create a buffer from the response ArrayBuffer.
			AudioEngine.context.decodeAudioData(this.response, function onSuccess(buffer) {
				//storing audio buffer inside map
				AudioEngine.map.put(id, buffer);
				AudioEngine.soundLoaded++;
				AudioEngine.checkLoad();
			}, function onFailure() {
				AudioEngine.map.put(id, null);
				AudioEngine.soundLoaded++;
				console.error("Decoding the audio buffer failed");
			});

		};
		request.send();
	};

	AudioEngine.checkLoad = function() {
		if (AudioEngine.soundLoaded == AudioEngine.numSound) {
			AssetsManager.completed.sound = true;
		}
	},

	//add method
	AudioEngine.add = function(sound) {
		AudioEngine.sounds.push(sound);
	},

	AudioEngine.update = function() {
		var start = new Date();
		for (var index in AudioEngine.sounds) {
			var sound = AudioEngine.sounds[index];
			with(sound) {
				setTimeout(function() {
					update(core.clock.getDelta());
				}, 0);
			}
			//now handling listener
			core.camera.object.updateMatrixWorld();
			var p = new THREE.Vector3();
			p.setFromMatrixPosition(core.camera.object.matrixWorld);

			//setting audio engine context listener position on camera position
			AudioEngine.context.listener.setPosition(p.x, p.y, p.z);


			//this is to add up and down vector to our camera
			// The camera's world matrix is named "matrix".
			var m = core.camera.object.matrix;

			mx = m.elements[12], my = m.elements[13], mz = m.elements[14];
			m.elements[12] = m.elements[13] = m.elements[14] = 0;

			// Multiply the orientation vector by the world matrix of the camera.
			var vec = new THREE.Vector3(0,0,1);
			vec.applyProjection(m);
			vec.normalize();

			// Multiply the up vector by the world matrix.
			var up = new THREE.Vector3(0,-1,0);
			up.applyProjection(m);
			up.normalize();

			// Set the orientation and the up-vector for the listener.
			AudioEngine.context.listener.setOrientation(vec.x, vec.y, vec.z, up.x, up.y, up.z);

			m.elements[12] = mx;
			m.elements[13] = my;
			m.elements[14] = mz;
			
			if ((+new Date() - start) > 50) return;
		}
	}

})();<commit_msg>fixed bug in audio engine<commit_after>(function() {
	window.AudioEngine = {};

	AudioEngine.DELAY_FACTOR = 0.02;
	AudioEngine.DELAY_STEP = 1; //millis
	AudioEngine.DELAY_MIN_VALUE = 0.2;
	AudioEngine.DELAY_NORMAL_VALUE = 40;

	var soundPath = "js/core/sound/";
	AudioEngine.soundModules = [
		"js/core/audio/beat", //parent
		"js/core/audio/sound",
		"js/core/audio/ambientSound"
	];

	AudioEngine.numSound = 0;
	AudioEngine.soundLoaded = 0;
	AudioEngine.load = function() {

		requirejs(AudioEngine.soundModules, function() {

			AudioEngine.map = new HashMap();
			AudioEngine.sounds = [];

			AudioEngine.AudioContext = window.AudioContext || window.webkitAudioContext || null;

			if (AudioEngine.AudioContext) {
				//creating a new audio context if it's available.
				AudioEngine.context = new AudioEngine.AudioContext();
				//creating a gain node to control volume
				AudioEngine.volume = AudioEngine.context.createGain();
				AudioEngine.volume.gain.value = 50;
				//connecting volume node to context destination
				AudioEngine.volume.connect(AudioEngine.context.destination);
			} else {
				console.error("No Audio Context available, sorry.");
			}

			for (var audio in Assets.Audio) {
				AudioEngine.numSound++;
				AudioEngine.loadSingleFile(audio, Assets.Audio[audio]);
			}

		});
	};

	AudioEngine.get = function(id) {
		//returning stored buffer;
		return AudioEngine.map.get(id) || false;
	}

	AudioEngine.loadSingleFile = function(id, path) {
		// Load a sound file using an ArrayBuffer XMLHttpRequest.
		var request = new XMLHttpRequest();
		request.open("GET", path, true);
		request.responseType = "arraybuffer";
		request.onload = function(e) {

			// Create a buffer from the response ArrayBuffer.
			AudioEngine.context.decodeAudioData(this.response, function onSuccess(buffer) {
				//storing audio buffer inside map
				AudioEngine.map.put(id, buffer);
				AudioEngine.soundLoaded++;
				AudioEngine.checkLoad();
			}, function onFailure() {
				AudioEngine.map.put(id, null);
				AudioEngine.soundLoaded++;
				console.error("Decoding the audio buffer failed");
			});

		};
		request.send();
	};

	AudioEngine.checkLoad = function() {
		if (AudioEngine.soundLoaded == AudioEngine.numSound) {
			AssetsManager.completed.sound = true;
		}
	},

	//add method
	AudioEngine.add = function(sound) {
		AudioEngine.sounds.push(sound);
	},

	AudioEngine.update = function() {
		var start = new Date();
		for (var index in AudioEngine.sounds) {
			var sound = AudioEngine.sounds[index];
			with(sound) {
				setTimeout(function() {
					update(core.clock.getDelta());
				}, 0);
			}
			//now handling listener
			core.camera.object.updateMatrixWorld();
			var p = new THREE.Vector3();
			p.setFromMatrixPosition(core.camera.object.matrixWorld);

			//setting audio engine context listener position on camera position
			AudioEngine.context.listener.setPosition(p.x, p.y, p.z);


			//this is to add up and down vector to our camera
			// The camera's world matrix is named "matrix".
			var m = core.camera.object.matrix;

			mx = m.elements[12], my = m.elements[13], mz = m.elements[14];
			m.elements[12] = m.elements[13] = m.elements[14] = 0;

			// Multiply the orientation vector by the world matrix of the camera.
			var vec = new THREE.Vector3(0,0,1);
			vec.applyProjection(m);
			vec.normalize();

			// Multiply the up vector by the world matrix.
			var up = new THREE.Vector3(0,-1,0);
			up.applyProjection(m);
			up.normalize();

			// Set the orientation and the up-vector for the listener.
			AudioEngine.context.listener.setOrientation(vec.x, vec.y, vec.z, up.x, up.y, up.z);

			m.elements[12] = mx;
			m.elements[13] = my;
			m.elements[14] = mz;
			
			if ((+new Date() - start) > 50) return;
		}
	}

})();
{'fraction_non_alphanumeric': 0.13522848034006377, 'fraction_numerical': 0.011556854410201912, 'mean_word_length': 3.476218787158145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6484066', 'n_tokens_mistral': 2842, 'n_tokens_neox': 2397, 'n_words': 566}