<commit_before>(function($, Waveform, Ciseaux){

	var sampleDbPath = "./../audio/sample-db/";

	var AudioContext = window.AudioContext || window.webkitAudioContext;
	var daAudioContext;
	if (!AudioContext){
		this.alert("Oh NO! Your Browser does not suppert AudioContext!?. Take a look at supported browser list to use this website. Maybe one day your browser will support new web technologies. o.O");
		window.location = "https://github.com/s-a/beatproducer#browser-support";
	} else {
		daAudioContext = new AudioContext();
	}
	var uniqueId = 0;

	var onPlayBackIntervalInMilliseconds = 100;





	/* ******************** HELPER FUNCTIONS ************************************************************  */
		var id = function function_name (argument) {
			uniqueId++;
			return uniqueId;
		}

		$.ajaxTransport("+binary", function(options, originalOptions, jqXHR){
				// check for conditions and support for blob / arraybuffer response type
				if (window.FormData && ((options.dataType && (options.dataType === 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || (window.Blob && options.data instanceof Blob))))){
						return {
								// create new XMLHttpRequest
								send: function(headers, callback){
									// setup all variables
									var xhr = new XMLHttpRequest(),
									url = options.url,
									type = options.type,
									async = options.async || true,
									// blob or arraybuffer. Default is blob
									dataType = options.responseType || "blob",
									data = options.data || null,
									username = options.username || null,
									password = options.password || <PASSWORD>;

									xhr.addEventListener('load', function(){
									var data = {};
									data[options.dataType] = xhr.response;
									// make callback and send data
									callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
								});

								xhr.open(type, url, async, username, password);

									// setup custom headers
									for (var i in headers ) {
										xhr.setRequestHeader(i, headers[i] );
									}

									xhr.responseType = dataType;
									xhr.send(data);
								},
								abort: function(){
									jqXHR.abort();
								}
						};
				}
		});

		var Speech = function() {
			this.say = function(text, done) {
				if (window.SpeechSynthesisUtterance && window.speechSynthesis){
					var msg = new SpeechSynthesisUtterance();
					//msg.voice = voices[1]; // Note: some voices don't support altering params
					msg.voiceURI = 'native';
					msg.volume = 1; // 0 to 1
					// msg.rate = 0; // 0.1 to 10
					// msg.pitch = 1; //0 to 2
					msg.text = text;
					msg.lang = 'en-US';
					var callbackDone = false;
					msg.onend = function() {
						callbackDone = true;
						console.log("DONE!");
						if (done) {
							done();
						}
					};

					window.speechSynthesis.speak(msg);

					window.setTimeout(function() {
						if (!callbackDone){
							if (done) {
								done();
							}
						}
					},2000);
				} else {
					if (done) {
						done();
					}
				}
			};

			return this;
		};

		function toFixed(value, count) {
			var precision = count || 0,
				power = Math.pow(10, precision),
				absValue = Math.abs(Math.round(value * power)),
				result = (value < 0 ? '-' : '') + String(Math.floor(absValue / power));

				if (precision > 0) {
				var fraction = String(absValue % power), padding = new Array(Math.max(precision - fraction.length, 0) + 1).join('0');
				result += '.' + padding + fraction;
			}
			return result;
		}

	/* ******************** FX controller ************************************************************  */
		var EffectController = function  (device) {
			this.device = device;
			this.effects = [];
			this.computedEffects = [];

			this.add({
				id : "MAINSIGNAL",
				type : "Compressor",
				//connectTo : "MAIN",
				config : {
					threshold: -18, 
					knee: 8
				}
			});

			return this;
		}

		EffectController.prototype.add = function(fxConfig) {
			this.effects.push(fxConfig);
		};

		EffectController.prototype.Effect = function(device, settings) {
			this.device = device;

		  	var source = null;
		  	if (settings.source === "MAINSIGNAL"){ // TODO: fetch from effect list by ID;
		  		source = this.device.effectController.computedEffects[0].output; // _comp
		  	}


			var ctx = this.device.audioContext;
			if (!window.sa.webAudioFX[settings.type]){
				throw "Effect " + settings.type + " not found!";
			}
			this.effect = new window.sa.webAudioFX[settings.type](ctx, this.device.audioContext.destination, settings.config);
			if (source){
				source.connect(this.effect.output);
			}

			if (settings.id === "MAINSIGNAL"){
				this.device.destination = this.effect.output; // compressor.output;
			}
			return this.effect;
		};
<commit_msg>fixed source selector in EffectController<commit_after>(function($, Waveform, Ciseaux){

	var sampleDbPath = "./../audio/sample-db/";

	var AudioContext = window.AudioContext || window.webkitAudioContext;
	var daAudioContext;
	if (!AudioContext){
		this.alert("Oh NO! Your Browser does not suppert AudioContext!?. Take a look at supported browser list to use this website. Maybe one day your browser will support new web technologies. o.O");
		window.location = "https://github.com/s-a/beatproducer#browser-support";
	} else {
		daAudioContext = new AudioContext();
	}
	var uniqueId = 0;

	var onPlayBackIntervalInMilliseconds = 100;





	/* ******************** HELPER FUNCTIONS ************************************************************  */
		var id = function function_name (argument) {
			uniqueId++;
			return uniqueId;
		}

		$.ajaxTransport("+binary", function(options, originalOptions, jqXHR){
				// check for conditions and support for blob / arraybuffer response type
				if (window.FormData && ((options.dataType && (options.dataType === 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || (window.Blob && options.data instanceof Blob))))){
						return {
								// create new XMLHttpRequest
								send: function(headers, callback){
									// setup all variables
									var xhr = new XMLHttpRequest(),
									url = options.url,
									type = options.type,
									async = options.async || true,
									// blob or arraybuffer. Default is blob
									dataType = options.responseType || "blob",
									data = options.data || null,
									username = options.username || null,
									password = options.password || <PASSWORD>;

									xhr.addEventListener('load', function(){
									var data = {};
									data[options.dataType] = xhr.response;
									// make callback and send data
									callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
								});

								xhr.open(type, url, async, username, password);

									// setup custom headers
									for (var i in headers ) {
										xhr.setRequestHeader(i, headers[i] );
									}

									xhr.responseType = dataType;
									xhr.send(data);
								},
								abort: function(){
									jqXHR.abort();
								}
						};
				}
		});

		var Speech = function() {
			this.say = function(text, done) {
				if (window.SpeechSynthesisUtterance && window.speechSynthesis){
					var msg = new SpeechSynthesisUtterance();
					//msg.voice = voices[1]; // Note: some voices don't support altering params
					msg.voiceURI = 'native';
					msg.volume = 1; // 0 to 1
					// msg.rate = 0; // 0.1 to 10
					// msg.pitch = 1; //0 to 2
					msg.text = text;
					msg.lang = 'en-US';
					var callbackDone = false;
					msg.onend = function() {
						callbackDone = true;
						console.log("DONE!");
						if (done) {
							done();
						}
					};

					window.speechSynthesis.speak(msg);

					window.setTimeout(function() {
						if (!callbackDone){
							if (done) {
								done();
							}
						}
					},2000);
				} else {
					if (done) {
						done();
					}
				}
			};

			return this;
		};

		function toFixed(value, count) {
			var precision = count || 0,
				power = Math.pow(10, precision),
				absValue = Math.abs(Math.round(value * power)),
				result = (value < 0 ? '-' : '') + String(Math.floor(absValue / power));

				if (precision > 0) {
				var fraction = String(absValue % power), padding = new Array(Math.max(precision - fraction.length, 0) + 1).join('0');
				result += '.' + padding + fraction;
			}
			return result;
		}

	/* ******************** FX controller ************************************************************  */
		var EffectController = function  (device) {
			this.device = device;
			this.effects = [];
			this.computedEffects = [];

			this.add({
				id : "MAINSIGNAL",
				type : "Compressor",
				//connectTo : "MAIN",
				config : {
					threshold: -18, 
					knee: 8
				}
			});

			return this;
		}

		EffectController.prototype.add = function(fxConfig) {
			this.effects.push(fxConfig);
		};

		EffectController.prototype.Effect = function(device, settings) {
			this.device = device;

		  	var source = null;
		  	if (settings.source){ 
		  		
		  		for (var i = 0; i < this.device.effectController.effects.length; i++) {
		  			var fx = this.device.effectController.effects[i];
		  			if (fx.id === settings.source) {// eg main signal
		  				source = this.device.effectController.computedEffects[i].output; // _comp
		  				break;
		  			}
		  		}
		  	}


			var ctx = this.device.audioContext;
			if (!window.sa.webAudioFX[settings.type]){
				throw "Effect " + settings.type + " not found!";
			}
			this.effect = new window.sa.webAudioFX[settings.type](ctx, this.device.audioContext.destination, settings.config);
			if (source){
				source.connect(this.effect.output);
			}

			if (settings.id === "MAINSIGNAL"){
				this.device.destination = this.effect.output; // compressor.output;
			}
			return this.effect;
		};

{'fraction_non_alphanumeric': 0.1679172581626445, 'fraction_numerical': 0.006489555871020077, 'mean_word_length': 2.540201005025126, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '886302', 'n_tokens_mistral': 4071, 'n_tokens_neox': 2894, 'n_words': 707}