<commit_before>// Vex Music Notation
// <NAME> <<EMAIL>>
//
// Copyright <NAME> 2010

/** @constructor */
Vex.Flow.Formatter = function(){
  this.minTotalWidth = 0;
  this.hasMinTotalWidth = false;
  this.minTicks = null;
  this.pixelsPerTick = 0;
  this.totalTicks = new Vex.Flow.Fraction(0, 1);
  this.tContexts = null;
  this.mContexts = null;

  this.render_options = {
    perTickableWidth: 15,
    maxExtraWidthPerTickable: 40
  };
}

  // Helper function to format and draw a single voice. Returns a bounding box for the notation.
Vex.Flow.Formatter.FormatAndDraw = function(ctx, stave, notes, params) {
  var voice = new Vex.Flow.Voice(Vex.Flow.TIME4_4).
    setMode(Vex.Flow.Voice.Mode.SOFT);
  voice.addTickables(notes)

  // For backward compatability, params has three forms:
  //   1. Setting autobeam only (context, stave, notes, true) or (ctx, stave, notes, {autobeam: true})
  //   2. Setting align_rests a struct is needed (context, stave, notes, {align_rests: true})
  //   3. Setting both a struct is needed (context, stave, notes, {autobeam: true, align_rests: true});
  //
  // The default for autobam and align_rests is false
  //
  var opts = {
    auto_beam: false,
    align_rests: false
  };

  if (typeof params == "object") {
    Vex.Merge(opts, params);
  } else if (typeof params == "boolean") {
    opts.auto_beam = params;
  }

  var beams = null;

  if (opts.auto_beam == true) {
    beams = Vex.Flow.Beam.applyAndGetBeams(voice);
  }

  var formatter = new Vex.Flow.Formatter().
    joinVoices([voice], {align_rests: opts.align_rests}).
    formatToStave([voice], stave, {align_rests: opts.align_rests});

  voice.setStave(stave);

  voice.draw(ctx, stave);
  if (beams != null) {
    for (var i=0; i<beams.length; ++i) {
      beams[i].setContext(ctx).draw();
    }
  }

  return voice.getBoundingBox();
}

// Helper function to format and draw a single voice
Vex.Flow.Formatter.FormatAndDrawTab = function(ctx,
    tabstave, stave, tabnotes, notes, autobeam) {

  var notevoice = new Vex.Flow.Voice(Vex.Flow.TIME4_4).
    setMode(Vex.Flow.Voice.Mode.SOFT);
  notevoice.addTickables(notes);

  var tabvoice = new Vex.Flow.Voice(Vex.Flow.TIME4_4).
    setMode(Vex.Flow.Voice.Mode.SOFT);
  tabvoice.addTickables(tabnotes);

  // For backward compatability, params has three forms:
  //   1. Setting autobeam only (context, stave, notes, true) or (ctx, stave, notes, {autobeam: true})
  //   2. Setting align_rests a struct is needed (context, stave, notes, {align_rests: true})
  //   3. Setting both a struct is needed (context, stave, notes, {autobeam: true, align_rests: true});
  //
  // The default for autobam and align_rests is false
  //
  var opts = {
    auto_beam: false,
    align_rests: false
  };

  if (typeof params == "object") {
    Vex.Merge(opts, params);
  } else if (typeof params == "boolean") {
    opts.auto_beam = params;
  }

  var beams = null;

  if (opts.auto_beam == true) {
    beams = Vex.Flow.Beam.applyAndGetBeams(voice);
  }


  var formatter = new Vex.Flow.Formatter().
    joinVoices([notevoice], {align_rests: opts.align_rests}).
    joinVoices([tabvoice]).
    formatToStave([notevoice,tabvoice], stave, {align_rests: opts.align_rests});

  notevoice.draw(ctx, stave);
  tabvoice.draw(ctx, tabstave);
  if (beams != null) {
    for (var i=0; i<beams.length; ++i) {
      beams[i].setContext(ctx).draw();
    }
  }

  // Draw a connector between tab and note staves.
  (new Vex.Flow.StaveConnector(stave, tabstave)).setContext(ctx).draw();
}

// Helper function to locate the next non-rest note(s)
Vex.Flow.Formatter.LookAhead = function(notes, rest_line, i, compare) {
  // If no valid next note group, next_rest_line is same as current
  var next_rest_line = rest_line;
  // get the rest line for next valid non-rest note group
  i++;
  while (i < notes.length) {
    if (!notes[i].isRest()) {
      next_rest_line = notes[i].getLineForRest();
      break;
    }
    i++;
  }

  // locate the mid point between two lines
  if (compare && rest_line != next_rest_line) {
    var top = Vex.Max(rest_line, next_rest_line);
    var bot = Vex.Min(rest_line, next_rest_line);<commit_msg>Ignore barlines and other non-tickables for rest alignment.<commit_after>// Vex Music Notation
// <NAME> <<EMAIL>>
//
// Copyright <NAME> 2010

/** @constructor */
Vex.Flow.Formatter = function(){
  this.minTotalWidth = 0;
  this.hasMinTotalWidth = false;
  this.minTicks = null;
  this.pixelsPerTick = 0;
  this.totalTicks = new Vex.Flow.Fraction(0, 1);
  this.tContexts = null;
  this.mContexts = null;

  this.render_options = {
    perTickableWidth: 15,
    maxExtraWidthPerTickable: 40
  };
}

  // Helper function to format and draw a single voice. Returns a bounding box for the notation.
Vex.Flow.Formatter.FormatAndDraw = function(ctx, stave, notes, params) {
  var voice = new Vex.Flow.Voice(Vex.Flow.TIME4_4).
    setMode(Vex.Flow.Voice.Mode.SOFT);
  voice.addTickables(notes)

  // For backward compatability, params has three forms:
  //   1. Setting autobeam only (context, stave, notes, true) or (ctx, stave, notes, {autobeam: true})
  //   2. Setting align_rests a struct is needed (context, stave, notes, {align_rests: true})
  //   3. Setting both a struct is needed (context, stave, notes, {autobeam: true, align_rests: true});
  //
  // The default for autobam and align_rests is false
  //
  var opts = {
    auto_beam: false,
    align_rests: false
  };

  if (typeof params == "object") {
    Vex.Merge(opts, params);
  } else if (typeof params == "boolean") {
    opts.auto_beam = params;
  }

  var beams = null;

  if (opts.auto_beam == true) {
    beams = Vex.Flow.Beam.applyAndGetBeams(voice);
  }

  var formatter = new Vex.Flow.Formatter().
    joinVoices([voice], {align_rests: opts.align_rests}).
    formatToStave([voice], stave, {align_rests: opts.align_rests});

  voice.setStave(stave);

  voice.draw(ctx, stave);
  if (beams != null) {
    for (var i=0; i<beams.length; ++i) {
      beams[i].setContext(ctx).draw();
    }
  }

  return voice.getBoundingBox();
}

// Helper function to format and draw a single voice
Vex.Flow.Formatter.FormatAndDrawTab = function(ctx,
    tabstave, stave, tabnotes, notes, autobeam) {

  var notevoice = new Vex.Flow.Voice(Vex.Flow.TIME4_4).
    setMode(Vex.Flow.Voice.Mode.SOFT);
  notevoice.addTickables(notes);

  var tabvoice = new Vex.Flow.Voice(Vex.Flow.TIME4_4).
    setMode(Vex.Flow.Voice.Mode.SOFT);
  tabvoice.addTickables(tabnotes);

  // For backward compatability, params has three forms:
  //   1. Setting autobeam only (context, stave, notes, true) or (ctx, stave, notes, {autobeam: true})
  //   2. Setting align_rests a struct is needed (context, stave, notes, {align_rests: true})
  //   3. Setting both a struct is needed (context, stave, notes, {autobeam: true, align_rests: true});
  //
  // The default for autobam and align_rests is false
  //
  var opts = {
    auto_beam: false,
    align_rests: false
  };

  if (typeof params == "object") {
    Vex.Merge(opts, params);
  } else if (typeof params == "boolean") {
    opts.auto_beam = params;
  }

  var beams = null;

  if (opts.auto_beam == true) {
    beams = Vex.Flow.Beam.applyAndGetBeams(voice);
  }


  var formatter = new Vex.Flow.Formatter().
    joinVoices([notevoice], {align_rests: opts.align_rests}).
    joinVoices([tabvoice]).
    formatToStave([notevoice,tabvoice], stave, {align_rests: opts.align_rests});

  notevoice.draw(ctx, stave);
  tabvoice.draw(ctx, tabstave);
  if (beams != null) {
    for (var i=0; i<beams.length; ++i) {
      beams[i].setContext(ctx).draw();
    }
  }

  // Draw a connector between tab and note staves.
  (new Vex.Flow.StaveConnector(stave, tabstave)).setContext(ctx).draw();
}

// Helper function to locate the next non-rest note(s)
Vex.Flow.Formatter.LookAhead = function(notes, rest_line, i, compare) {
  // If no valid next note group, next_rest_line is same as current
  var next_rest_line = rest_line;
  // get the rest line for next valid non-rest note group
  i++;
  while (i < notes.length) {
    if (!notes[i].isRest() && !notes[i].shouldIgnoreTicks()) {
      next_rest_line = notes[i].getLineForRest();
      break;
    }
    i++;
  }

  // locate the mid point between two lines
  if (compare && rest_line != next_rest_line) {
    var top = Vex.Max(rest_line, next_rest_line);
    var bot = Vex.Min(rest_line, next_rest_line);
{'fraction_non_alphanumeric': 0.13807082389412187, 'fraction_numerical': 0.0062000715392869915, 'mean_word_length': 3.366475793857366, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, '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': '3989116', 'n_tokens_mistral': 3072, 'n_tokens_neox': 2976, 'n_words': 765}