<commit_before>/**!
 * File audio-synthesis.js
 */

var oscillatorTypeDropdown = document.getElementById('oscillator-type-dropdown');
var oscillatorsType = Array.prototype.slice.call(oscillatorTypeDropdown.getElementsByClassName('link'));
var oscillatorTypeLabel = document.getElementById('current-oscillator-type');
var oscillatorTypeName = null;
var sequenceContainer = document.getElementById('resulted-sequence');

oscillatorsType.forEach( function( oscillator ) {

 		oscillator.addEventListener('click', function(e){

 			  var oscillatorTypeName = this.getAttribute('data-oscillator');
        oscillatorTypeLabel.innerHTML = oscillatorTypeName;
        make_sound();

    }, false);
});

if( !oscillatorTypeName ) {

  oscillatorTypeName = 'pwm';
  oscillatorTypeLabel.innerHTML = oscillatorTypeName;

}


function make_sound() {

    var synth = new Tone.PolySynth(3, Tone.Synth, {
        'oscillator' : {
          'type' : oscillatorTypeName,
          'count' : 3,
          'spread' : 30
        },
        'envelope': {
          'attack': 0.01,
          'decay': 0.1,
          'sustain': 0.5,
          'release': 0.4,
          'attackCurve' : 'exponential'
        },
      }).toMaster();

    var notes = [];
    var duration = 0;

    for ( var n = 1; n < transmitanceHit.length; n++ ) {

        var time =  Math.round(1000*transmitanceHit[n].transmitance)/1000;
        
        var note = {
          //'note': new Tone.Frequency(transmitanceHit[n].frequency, 'midi').toNote(),
          'note': transmitanceHit[n].frequency,
          'time': time
        };
        notes.push(note);
        duration = duration + time;

    }

    //console.log(notes);

    var now = Tone.now();
    var currentTime = now;
    var currentNote = 0;
    var part = new Tone.Part(function(time, note){

      var visualNote = document.createElement('span');
      visualNote.innerHTML = note.note;
      visualNote.style.width = ((note.time / duration) * 100) + '%';
      sequenceContainer.appendChild( visualNote );

			synth.triggerAttackRelease(note.note, (time + note.time), time);<commit_msg>added a menu to choose the type of oscillator<commit_after>/**!
 * File audio-synthesis.js
 */

var frequencyRange = { min: 0, max: 1200 };

var oscillatorTypeDropdown = document.getElementById('oscillator-type-dropdown');
var oscillatorsType        = Array.prototype.slice.call(oscillatorTypeDropdown.getElementsByClassName('link'));
var oscillatorTypeLabel    = document.getElementById('current-oscillator-type-output');
var oscillatorTypeName     = null;
var sequenceContainer      = document.getElementById('resulted-sequence');
var playButton             = document.getElementById('playSound');

oscillatorsType.forEach( function( oscillator ) {

 		oscillator.addEventListener('click', function(e){

 			  var oscillatorTypeName = this.getAttribute('data-oscillator');
        oscillatorTypeLabel.innerHTML = oscillatorTypeName;

    }, false);
});

if( !oscillatorTypeName ) {

  oscillatorTypeName = 'pwm';
  oscillatorTypeLabel.innerHTML = oscillatorTypeName;

}

playButton.addEventListener('click', function(e) {

  make_sound();

  if( playButton.classList.contains('active')) {

    make_sound();
    playButton.innerHTML = 'Stop';
    playButton.classList = 'active';
    
  } else {

    Tone.Transport.stop();

  }
});


function make_sound() {

    var synth = new Tone.PolySynth(3, Tone.Synth, {
        'oscillator' : {
          'type' : oscillatorTypeName,
          'count' : 3,
          'spread' : 30
        },
        'envelope': {
          'attack': 0.01,
          'decay': 0.1,
          'sustain': 0.5,
          'release': 0.4,
          'attackCurve' : 'exponential'
        },
      }).toMaster();

    var notes = [];
    var duration = 0;

    for ( var n = 1; n < transmitanceHit.length; n++ ) {

        var time =  Math.round(1000*transmitanceHit[n].transmitance)/1000;

        var note = {
          //'note': new Tone.Frequency(transmitanceHit[n].frequency, 'midi').toNote(),
          'note': transmitanceHit[n].frequency,
          'time': time
        };

        notes.push(note);
        duration = duration + time;

    }

    //console.log(notes);
    sequenceContainer.innerHTML = '';

    var now = Tone.now();
    var currentTime = now;
    var currentNote = 0;
    var part = new Tone.Part( function(time, note) {

      var visualNote = document.createElement('span');
      visualNote.innerHTML = note.note;
      visualNote.style.width = ((note.time / duration) * 100) + '%';
      sequenceContainer.appendChild( visualNote );

			synth.triggerAttackRelease(note.note, (time + note.time), time);
{'fraction_non_alphanumeric': 0.13804207814512667, 'fraction_numerical': 0.012666380420781451, 'mean_word_length': 2.8251231527093594, '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': '2470201', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1372, 'n_words': 271}