<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/>.
 */

import {FskBase} from "./fsk";
import {FIR} from "../filter";



/**
 * These are the ITU codes for 5-bit Baudot code and 7-bit SITOR
 * in the same table
 */
var Baudot = {

    t : [
        [  0,    0], // 0x00 NUL
        ['E',  '3'], // 0x01
        ['\n','\n'], // 0x02 LF
        ['A',  '-'], // 0x03
        [' ',  ' '], // 0x04 SPACE
        ['S', '\''], // 0x05
        ['I',  '8'], // 0x06
        ['U',  '7'], // 0x07
        ['\n','\n'], // 0x08 CR
        ['D',  '$'], // 0x09
        ['R',  '4'], // 0x0a
        ['J',    7], // 0x0b 7=bell
        ['N',  ','], // 0x0c
        ['F',  '!'], // 0x0d
        ['C',  ':'], // 0x0e
        ['K',  '['], // 0x0f
        ['T',  '5'], // 0x10
        ['Z',  '+'], // 0x11
        ['L',  ']'], // 0x12
        ['W',  '2'], // 0x13
        ['H',  '#'], // 0x14
        ['Y',  '6'], // 0x15
        ['P',  '0'], // 0x16
        ['Q',  '1'], // 0x17
        ['O',  '9'], // 0x18
        ['B',  '?'], // 0x19
        ['G',  '&'], // 0x1a
        [  0,    0], // 0x1b FIGS   
        ['M',  '.'], // 0x1c
        ['X',  '/'], // 0x1d
        ['V',  '='], // 0x1e
        [  0,    0]  // 0x1f LTRS
    ],
    NUL   : 0x00,
    SPACE : 0x04,
    CR    : 0x08,
    LF    : 0x02,
    LTRS  : 0x1f,
    FIGS  : 0x1b
};


/**
 * Enumerations for parity types
 */
var ParityNone = 0;
var ParityOne  = 1;
var ParityZero = 2;
var ParityOdd  = 3;
var ParityEven = 4;



/**
 * Mode for Radio teletype.  Sends a standard
 * async code with a start bit, 5 data bits and
 * a stop bit.  Whether a parity bit is sent or
 * interpreted should be adjustable.
 *
 * @see http://en.wikipedia.org/wiki/Radioteletype
 * @see http://en.wikipedia.org/wiki/Asynchronous_serial_communication
 *
 */
function RttyMode(par) {
    var self = this;

    var props = {
        name: "rtty",
        tooltip: "radio teletype",
        controls : [
            {
            name: "rate",
            type: "choice",
            tooltip: "rtty baud rate",
            get value() { return self.getRate(); },
            set value(v) { self.setRate(parseFloat(v)); },
            values : [
                { name :  "45", value :  45.45 },
                { name :  "50", value :  50.00 },
                { name :  "75", value :  75.00 },
                { name : "100", value : 100.00 }
                ]
            },
            {
            name: "shift",
            type: "choice",
            tooltip: "frequency distance between mark and space",
            get value() { return self.getShift(); },
            set value(v) { self.setShift(parseFloat(v)); },
            values : [
                { name :  "85", value :  85.0 },
                { name : "170", value : 170.0 },
                { name : "450", value : 450.0 },
                { name : "850", value : 850.0 }
                ]
             },
            {
            name: "inv",
            type: "boolean",
            get value() { return self.getInverted(); },
            set value(v) { self.setInverted(v); }
            },
            {
            name: "UoS",
            type: "boolean",
            get value() { return self.getUnshiftOnSpace(); },
            set value(v) { self.setUnshiftOnSpace(v); }
            }
        ]
    };
    FskBase.call(this, par, props, 1000.0);

    var unshiftOnSpace = false;
    this.getUnshiftOnSpace = function() {
        return unshiftOnSpace;
    };
    this.setUnshiftOnSpace = function(v) {
        unshiftOnSpace = v;
    };
    
    var symbollen, halfsym, symarray, symptr=0;
    
    var super_setRate = this.setRate;
    this.setRate = function(rate) {
        super_setRate(rate);
        symbollen = Math.round(self.getSamplesPerSymbol());
        halfsym = symbollen>>1;
        symarray = new Array(symbollen);
        for (var pp=0 ; pp<symbollen ; pp++) {
            symarray[pp] = false;
        }
    };

    this.setRate(45.0); //makes all rate/shift dependent vars initialize

    var parityType = ParityNone;

    function countbits(n) {
        var c = 0;
        while (n) {
            n &= n-1;
            c++;
        }
        return c;
    }

    function parityOf(c) {
        switch (parityType) {
            case ParityOdd  : return (countbits(c) & 1) !== 0;
            case ParityEven : return (countbits(c) & 1) === 0;
            case ParityZero : return false;
            case ParityOne  : return true;
            default         : return false;   //None or unknown
        }
    }
    
    
    var RxIdle   = 0;
    var RxStart  = 1;<commit_msg>Make sure 45 baud button is enabled on rtty startup<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/>.
 */

import {FskBase} from "./fsk";
import {FIR} from "../filter";



/**
 * These are the ITU codes for 5-bit Baudot code and 7-bit SITOR
 * in the same table
 */
var Baudot = {

    t : [
        [  0,    0], // 0x00 NUL
        ['E',  '3'], // 0x01
        ['\n','\n'], // 0x02 LF
        ['A',  '-'], // 0x03
        [' ',  ' '], // 0x04 SPACE
        ['S', '\''], // 0x05
        ['I',  '8'], // 0x06
        ['U',  '7'], // 0x07
        ['\n','\n'], // 0x08 CR
        ['D',  '$'], // 0x09
        ['R',  '4'], // 0x0a
        ['J',    7], // 0x0b 7=bell
        ['N',  ','], // 0x0c
        ['F',  '!'], // 0x0d
        ['C',  ':'], // 0x0e
        ['K',  '['], // 0x0f
        ['T',  '5'], // 0x10
        ['Z',  '+'], // 0x11
        ['L',  ']'], // 0x12
        ['W',  '2'], // 0x13
        ['H',  '#'], // 0x14
        ['Y',  '6'], // 0x15
        ['P',  '0'], // 0x16
        ['Q',  '1'], // 0x17
        ['O',  '9'], // 0x18
        ['B',  '?'], // 0x19
        ['G',  '&'], // 0x1a
        [  0,    0], // 0x1b FIGS   
        ['M',  '.'], // 0x1c
        ['X',  '/'], // 0x1d
        ['V',  '='], // 0x1e
        [  0,    0]  // 0x1f LTRS
    ],
    NUL   : 0x00,
    SPACE : 0x04,
    CR    : 0x08,
    LF    : 0x02,
    LTRS  : 0x1f,
    FIGS  : 0x1b
};


/**
 * Enumerations for parity types
 */
var ParityNone = 0;
var ParityOne  = 1;
var ParityZero = 2;
var ParityOdd  = 3;
var ParityEven = 4;



/**
 * Mode for Radio teletype.  Sends a standard
 * async code with a start bit, 5 data bits and
 * a stop bit.  Whether a parity bit is sent or
 * interpreted should be adjustable.
 *
 * @see http://en.wikipedia.org/wiki/Radioteletype
 * @see http://en.wikipedia.org/wiki/Asynchronous_serial_communication
 *
 */
function RttyMode(par) {
    var self = this;

    var props = {
        name: "rtty",
        tooltip: "radio teletype",
        controls : [
            {
            name: "rate",
            type: "choice",
            tooltip: "rtty baud rate",
            get value() { return self.getRate(); },
            set value(v) { self.setRate(parseFloat(v)); },
            values : [
                { name :  "45", value :  45.45 },
                { name :  "50", value :  50.00 },
                { name :  "75", value :  75.00 },
                { name : "100", value : 100.00 }
                ]
            },
            {
            name: "shift",
            type: "choice",
            tooltip: "frequency distance between mark and space",
            get value() { return self.getShift(); },
            set value(v) { self.setShift(parseFloat(v)); },
            values : [
                { name :  "85", value :  85.0 },
                { name : "170", value : 170.0 },
                { name : "450", value : 450.0 },
                { name : "850", value : 850.0 }
                ]
             },
            {
            name: "inv",
            type: "boolean",
            get value() { return self.getInverted(); },
            set value(v) { self.setInverted(v); }
            },
            {
            name: "UoS",
            type: "boolean",
            get value() { return self.getUnshiftOnSpace(); },
            set value(v) { self.setUnshiftOnSpace(v); }
            }
        ]
    };
    FskBase.call(this, par, props, 1000.0);

    var unshiftOnSpace = false;
    this.getUnshiftOnSpace = function() {
        return unshiftOnSpace;
    };
    this.setUnshiftOnSpace = function(v) {
        unshiftOnSpace = v;
    };
    
    var symbollen, halfsym, symarray, symptr=0;
    
    var super_setRate = this.setRate;
    this.setRate = function(rate) {
        super_setRate(rate);
        symbollen = Math.round(self.getSamplesPerSymbol());
        halfsym = symbollen>>1;
        symarray = new Array(symbollen);
        for (var pp=0 ; pp<symbollen ; pp++) {
            symarray[pp] = false;
        }
    };

    this.setRate(45.45); //makes all rate/shift dependent vars initialize

    var parityType = ParityNone;

    function countbits(n) {
        var c = 0;
        while (n) {
            n &= n-1;
            c++;
        }
        return c;
    }

    function parityOf(c) {
        switch (parityType) {
            case ParityOdd  : return (countbits(c) & 1) !== 0;
            case ParityEven : return (countbits(c) & 1) === 0;
            case ParityZero : return false;
            case ParityOne  : return true;
            default         : return false;   //None or unknown
        }
    }
    
    
    var RxIdle   = 0;
    var RxStart  = 1;
{'fraction_non_alphanumeric': 0.15693671602376685, 'fraction_numerical': 0.03838536263321701, 'mean_word_length': 1.4810481984089845, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6370059', 'n_tokens_mistral': 3815, 'n_tokens_neox': 3474, 'n_words': 970}