<commit_before>mini.Module(
		"basic/audio/sound"
)
.requires(
		"basic/audio/audio"
)
.defines(function() {
	var Sound = function(audio, path) {
		this._audio = audio;
		this._bufferPath = path;
		this.load(path);
	};

	Sound.prototype.load = function(path) {
		var audio = this._audio;

		// return if file already loaded
		if(typeof audio.buffers[path] !== "undefined") return;
		
		var request = new XMLHttpRequest();
		request.open('GET', path, true);
		request.responseType = 'arraybuffer';
		
		// Decode asynchronously
		request.onload = function () {
			audio.context.decodeAudioData(request.response, function (buffer) {
		    	audio.buffers[path] = buffer;
		    }, console.log);
		};
		request.send();
	};

	Sound.prototype.play = function() {
		// creates a sound source
		var sourceNode = this._audio.context.createBufferSource(); 
		// tell the sourceNode which sound to play
		sourceNode.buffer = this._audio.buffers[this._bufferPath];
		
	    var positionNode = this._audio.context.createPanner();
	    positionNode.setPosition(0, 0, 0);
		
		// connect the sourceNode to the positionNode to the context's destination (the speakers)
		sourceNode.connect(positionNode);
	    positionNode.connect(this._audio.soundParent);

		// play the source now
		sourceNode.start(0);

	    return {position: positionNode, source: sourceNode};
	};
	
	Bloob.Sound = Sound;
	
	return Sound;
});
<commit_msg>Sound as class<commit_after>mini.Module(
	"basic/audio/sound"
)
.requires(
	"basic/audio/audio"
)
.defines(function(Audio) {
	var Sound = mini.Class.subclass({
		initialize: function(audio, path) {
			this._audio = audio;
			this._bufferPath = path;
			this.load(path);
		},
		load: function(path) {
			var audio = this._audio;

			// return if file already loaded
			if(typeof audio.buffers[path] !== "undefined") return;
			
			var request = new XMLHttpRequest();
			request.open('GET', path, true);
			request.responseType = 'arraybuffer';
			
			// Decode asynchronously
			request.onload = function () {
				audio.context.decodeAudioData(request.response, function (buffer) {
			    	audio.buffers[path] = buffer;
			    }, console.log);
			};
			request.send();
		},
		play: function() {
			// creates a sound source
			var sourceNode = this._audio.context.createBufferSource(); 
			// tell the sourceNode which sound to play
			sourceNode.buffer = this._audio.buffers[this._bufferPath];
			
		    var positionNode = this._audio.context.createPanner();
		    positionNode.setPosition(0, 0, 0);
			
			// connect the sourceNode to the positionNode to the context's destination (the speakers)
			sourceNode.connect(positionNode);
		    positionNode.connect(this._audio.soundParent);

			// play the source now
			sourceNode.start(0);

		    return {position: positionNode, source: sourceNode};
		}
	});

	return Sound;
});

{'fraction_non_alphanumeric': 0.1257647858599592, 'fraction_numerical': 0.002719238613188307, 'mean_word_length': 2.966307277628032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3709342', 'n_tokens_mistral': 1031, 'n_tokens_neox': 873, 'n_words': 202}