<commit_before>/*jslint node:true, browser:true, bitwise:true */

'use strict';

var hexTypes = {
    noteOff: 0x8,
    noteOn: 0x9,
    noteAftertouch: 0xA,
    controller: 0xB,
    programChange: 0xC,
    channelAftertouch: 0xD,
    pitchBend: 0xE
};

/**
 * Output wrapper
 *
 * Add helper methods to ease working with
 * native MIDI outputs.
 *
 * @param {native: MIDIOutput}  Native MIDI output to wrap
 */
function Output(native) {
    this.native = native;
    
    this.id = native.id;
    this.manufacturer = native.manufacturer;
    this.name = native.name;
    this.version = native.version;
}

exports.Output = Output;

/**
 * Send a MIDI event to the output
 *
 * @param {event: EventChannel} MIDI event to send
 */
Output.prototype.send = function (event) {
    var subtype = event.subtype, data = [],
        lsb, msb, value;
    
    data.push(hexTypes[event.subtype] + event.channel);
    
    switch (subtype) {
    case 8:
    case 9:
        data.push(event.note, event.velocity);
        break;
    case 10:
        data.push(event.note, event.pressure);
        break;
    case 11:
        data.push(event.controller, event.value);
        break;
    case 12:
        data.push(event.program);
        break;
    case 13:
        data.push(event.pressure);
        break;
    case 14:
        value = event.value + 8192;
        lsb = value & 127;
        msb = value >> 7;
        
        data.push(lsb, msb);
        break;<commit_msg>:bug: Fix wrong interpretation of subtype value<commit_after>/*jslint node:true, browser:true, bitwise:true */

'use strict';

var hexTypes = {
    noteOff: 0x8,
    noteOn: 0x9,
    noteAftertouch: 0xA,
    controller: 0xB,
    programChange: 0xC,
    channelAftertouch: 0xD,
    pitchBend: 0xE
};

/**
 * Output wrapper
 *
 * Add helper methods to ease working with
 * native MIDI outputs.
 *
 * @param {native: MIDIOutput}  Native MIDI output to wrap
 */
function Output(native) {
    this.native = native;
    
    this.id = native.id;
    this.manufacturer = native.manufacturer;
    this.name = native.name;
    this.version = native.version;
}

exports.Output = Output;

/**
 * Send a MIDI event to the output
 *
 * @param {event: EventChannel} MIDI event to send
 */
Output.prototype.send = function (event) {
    var subtype = event.subtype, data = [],
        lsb, msb, value;
    
    data.push(hexTypes[subtype] + event.channel);
    
    switch (subtype) {
    case 'noteOn':
    case 'noteOff':
        data.push(event.note, event.velocity);
        break;
    case 'noteAftertouch':
        data.push(event.note, event.pressure);
        break;
    case 'controller':
        data.push(event.controller, event.value);
        break;
    case 'programChange':
        data.push(event.program);
        break;
    case 'channelAftertouch':
        data.push(event.pressure);
        break;
    case 'pitchBend':
        value = event.value + 8192;
        lsb = value & 127;
        msb = value >> 7;
        
        data.push(lsb, msb);
        break;
{'fraction_non_alphanumeric': 0.11996034368803701, 'fraction_numerical': 0.01520158625247852, 'mean_word_length': 2.304585152838428, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3996570', 'n_tokens_mistral': 1040, 'n_tokens_neox': 974, 'n_words': 251}