<commit_before>/**
 * Jdigi
 *
 * Copyright 2014, <NAME>
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


var Complex = require("./math").Complex;

var ncoTable = (function() {

    var twopi = Math.PI * 2.0;
    var two16 = 65536;
    var delta = twopi / two16;
    
    var xs = [];
    
    for (var idx = 0 ; idx < two16 ; idx++) {
        var angle = delta * idx;
        xs.push(new Complex( Math.cos(angle), Math.sin(angle) )); 
    }
    return xs;  
})();

/**
 * A sine generator with a 32-bit accumulator and a 16-bit
 * lookup table.  Much faster than Math.whatever
 */
function Nco(frequency, sampleRate)
{
    var freq = 0|0;
    function setFrequency(frequency) {
        freq  = (4294967296.0 * frequency / sampleRate)|0;
    }
    this.setFrequency = setFrequency;
    setFrequency(frequency);
    
    var phase = 0|0;
    var table = ncoTable;
    
    this.next = function() {
        phase = (phase + freq) & 0xffffffff;<commit_msg>Ability to change freqs dynamically<commit_after>/**
 * Jdigi
 *
 * Copyright 2014, <NAME>
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


var Complex = require("./math").Complex;

var ncoTable = (function() {

    var twopi = Math.PI * 2.0;
    var two16 = 65536;
    var delta = twopi / two16;
    
    var xs = [];
    
    for (var idx = 0 ; idx < two16 ; idx++) {
        var angle = delta * idx;
        xs.push(new Complex( Math.cos(angle), Math.sin(angle) )); 
    }
    return xs;  
})();

/**
 * A sine generator with a 32-bit accumulator and a 16-bit
 * lookup table.  Much faster than Math.whatever
 */
function Nco(frequency, sampleRate)
{
    var freq = 0|0;
    function setFrequency(frequency) {
        freq  = (4294967296.0 * frequency / sampleRate)|0;
		return freq;
    }
    this.setFrequency = setFrequency;
    setFrequency(frequency);
    
    var phase = 0|0;
    var table = ncoTable;
    
    this.next = function() {
        phase = (phase + freq) & 0xffffffff;
{'fraction_non_alphanumeric': 0.10108864696734059, 'fraction_numerical': 0.024883359253499222, 'mean_word_length': 2.5773081201334818, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '42345', 'n_tokens_mistral': 1036, 'n_tokens_neox': 947, 'n_words': 371}