<commit_before>import Ember from 'ember';
import Sound from './sound';
import BeatObject from './beat-object';

const {
  computed
} = Ember;


const Beat = Sound.extend({
  numBeats: 4,
  playingTime: 100,

  beats: computed('numBeats', function() {
    const beats = [];
    const numBeats = this.get('numBeats');

    for (let i = 0; i < numBeats; i++) {
      beats.push(BeatObject.create({
        playingTime: this.get('playingTime'),
        duration: this.get('audioBuffer.duration'),
        parentPlay: this.play.bind(this),
        audioContext: this.get('audioContext')
      }));
    }

    return beats;
  }),

  playBeats(bpm) {
    const bps = 60 / bpm;

    this.get('beats').map((beat, beatIndex) => {
      // Get the offset for each beat by multiplying it's index by the beats per second
      beat.play(beatIndex * bps);
    });
  }
});

export default Beat;<commit_msg>playBeats now takes optional beatLength and beatsInMeasure<commit_after>import Ember from 'ember';
import Sound from './sound';
import BeatObject from './beat-object';

const {
  computed
} = Ember;


const Beat = Sound.extend({
  numBeats: 4,
  playingTime: 100,

  beats: computed('numBeats', function() {
    const beats = [];
    const numBeats = this.get('numBeats');

    for (let i = 0; i < numBeats; i++) {
      beats.push(BeatObject.create({
        playingTime: this.get('playingTime'),
        duration: this.get('audioBuffer.duration'),
        parentPlay: this.play.bind(this),
        audioContext: this.get('audioContext')
      }));
    }

    return beats;
  }),

  playBeats(bpm, beatLength=1/4, beatsInMeasure=4) {
    const bps = 60 / bpm;

    this.get('beats').map((beat, beatIndex) => {
      beat.play(beatIndex * bps * beatLength * beatsInMeasure);
    });
  }
});

export default Beat;
{'fraction_non_alphanumeric': 0.1497504159733777, 'fraction_numerical': 0.009428729894620078, 'mean_word_length': 3.008888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7086961', 'n_tokens_mistral': 617, 'n_tokens_neox': 579, 'n_words': 144}