<commit_before>var audioContext = null;
var myBuffer = null;

var osc = null;
function setDutyCycle(amt) {
	this.delay.delayTime.value = amt/this.frequency;	
	this.dcGain.gain.value = 1.7*(0.5-amt);
}
function start(time) {
	this.osc1.start(time);
	this.osc2.start(time);
	this.dcOffset.start(time);
}
function stop(time) {
	this.osc1.stop(time);
	this.osc2.stop(time);
	this.dcOffset.stop(time);
}

function createDCOffset() {
	var buffer=audioContext.createBuffer(1,1024,audioContext.sampleRate);
	var data = buffer.getChannelData(0);
	for (var i=0; i<1024; i++)
		data[i]=1.0;
	var bufferSource=audioContext.createBufferSource();
	bufferSource.buffer=buffer;
	bufferSource.loop=true;
	return bufferSource;
}

function createPWMOsc(freq, dutyCycle) {
	var pwm = new Object();
	var osc1 = audioContext.createOscillator();
	var osc2 = audioContext.createOscillator();
	var inverter = audioContext.createGain();
	var output = audioContext.createGain();
	var delay = audioContext.createDelay();
	inverter.gain.value=-1;
	osc1.type="sawtooth";
	osc2.type="sawtooth";
	osc1.frequency.value=freq;
	osc1.frequency.value=freq;
	osc1.connect(output);
	osc2.connect(inverter);
	inverter.connect(delay);<commit_msg>Only need a 1-sample buffer.<commit_after>var audioContext = null;
var myBuffer = null;

var osc = null;
function setDutyCycle(amt) {
	this.delay.delayTime.value = amt/this.frequency;	
	this.dcGain.gain.value = 1.7*(0.5-amt);
}
function start(time) {
	this.osc1.start(time);
	this.osc2.start(time);
	this.dcOffset.start(time);
}
function stop(time) {
	this.osc1.stop(time);
	this.osc2.stop(time);
	this.dcOffset.stop(time);
}

function createDCOffset() {
	var buffer=audioContext.createBuffer(1,1,audioContext.sampleRate);
	var data = buffer.getChannelData(0);
	for (var i=0; i<1; i++)
		data[i]=1;
	var bufferSource=audioContext.createBufferSource();
	bufferSource.buffer=buffer;
	bufferSource.loop=true;
	return bufferSource;
}

function createPWMOsc(freq, dutyCycle) {
	var pwm = new Object();
	var osc1 = audioContext.createOscillator();
	var osc2 = audioContext.createOscillator();
	var inverter = audioContext.createGain();
	var output = audioContext.createGain();
	var delay = audioContext.createDelay();
	inverter.gain.value=-1;
	osc1.type="sawtooth";
	osc2.type="sawtooth";
	osc1.frequency.value=freq;
	osc1.frequency.value=freq;
	osc1.connect(output);
	osc2.connect(inverter);
	inverter.connect(delay);
{'fraction_non_alphanumeric': 0.14853123707074886, 'fraction_numerical': 0.022341745966073644, 'mean_word_length': 5.754189944134078, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2517252', 'n_tokens_mistral': 916, 'n_tokens_neox': 904, 'n_words': 151}