<commit_before># tick or sq refer to semi-quaver

tempoMs = (t) -> ((60/t) * 1000)/4

drum.controller("MainCtrl", ($scope, $interval, $location, $alert, Sound, Track, Keyboard) ->
  $scope.instruments = instruments

  # Track
  trackRawData = $location.path().split("/")[1]
  $scope.t = new Track(trackRawData)
  if $scope.t.invalidRawData
    $location.path("")
    $alert(
      title: 'Error'
      content: 'The track data in the url was invalid!'
      placement: 'top-right'
      container: '#alerts'
      type: 'danger'
      duration: 8
    )

  $scope.deleteChannel = (inst) ->
    delete $scope.t.channels[inst]

  strike = ->
    # Play sounds
    angular.forEach($scope.t.channels, (notes, inst) ->
      Sound.play(inst) if notes[$scope.seq.semi]
    )
  Keyboard.register(83, strike)
  $scope.seq =
    ticks: -1
    beat: -1
    semi: -1
  $scope.advance = ->
    $scope.seq.ticks += 1
    recalculate()
    strike()
  retreat = ->
    return if $scope.seq.ticks <= 0
    $scope.seq.ticks -= 1
    recalculate()
    strike()
  Keyboard.register(39, $scope.advance) # right arrow
  Keyboard.register(76, $scope.advance) # l
  Keyboard.register(37, retreat) # left arrow
  Keyboard.register(72, retreat) # h

  recalculate = ->
    $scope.seq.semi = $scope.seq.ticks % ($scope.t.beatCount * 4)
    $scope.seq.beat = Math.floor($scope.seq.semi / 4)

  $scope.testPlay = (inst) ->
    Sound.play(inst)

  lastDataGenerated = ""
  $scope.generateRawData = ->
    $scope.t.cleanup()
    rawData = $scope.t.getPath()
    lastDataGenerated = rawData
  $scope.permalink = ->
    $location.path(lastDataGenerated)
    $location.absUrl()

  $scope.keyPressed = (e) ->
    Keyboard.callFn(e)

  # Random helpers
  $scope.isEmpty = (obj) ->
    !obj || angular.equals({}, obj)
)

drum.controller("PlayCtrl", ($scope, $interval, Keyboard) ->
  $scope.heartbeat = null
  $scope.reset = ->
    $scope.off()
    $scope.seq.ticks = -1
    $scope.seq.beat = -1
    $scope.seq.semi = -1
  Keyboard.register(115, $scope.reset)

  $scope.toggle = -> if $scope.heartbeat then $scope.off() else $scope.on()
  Keyboard.register(32, $scope.toggle)
  Keyboard.register(80, $scope.toggle)

  $scope.on = ->
    return if $scope.heartbeat
    $scope.heartbeat = $interval($scope.advance, (tempoMs($scope.t.tempo)))

  $scope.off = ->
    return unless $scope.heartbeat
    $interval.cancel($scope.heartbeat)
    $scope.heartbeat = null

  $scope.addChannel = (inst) ->
    return if !$scope.instruments[inst] || $scope.t.channels[inst]
    $scope.t.channels[inst] = [0]

  $scope.changeTempo = (diff) ->
    if diff
      $scope.t.tempo += diff
    $scope.t.tempo = 1 if $scope.t.tempo < 1
    $scope.t.tempo = 350 if $scope.t.tempo > 350
    if $scope.heartbeat
      $scope.off()
      $scope.on()
    no<commit_msg>changed some more movement stuff<commit_after># tick or sq refer to semi-quaver

tempoMs = (t) -> ((60/t) * 1000)/4

drum.controller("MainCtrl", ($scope, $interval, $location, $alert, Sound, Track, Keyboard) ->
  $scope.instruments = instruments

  # Track
  trackRawData = $location.path().split("/")[1]
  $scope.t = new Track(trackRawData)
  if $scope.t.invalidRawData
    $location.path("")
    $alert(
      title: 'Error'
      content: 'The track data in the url was invalid!'
      placement: 'top-right'
      container: '#alerts'
      type: 'danger'
      duration: 8
    )

  $scope.deleteChannel = (inst) ->
    delete $scope.t.channels[inst]

  strike = ->
    # Play sounds
    angular.forEach($scope.t.channels, (notes, inst) ->
      Sound.play(inst) if notes[$scope.seq.semi]
    )
  Keyboard.register(80, strike)
  $scope.seq =
    ticks: -1
    beat: -1
    semi: -1
  $scope.advance = ->
    $scope.seq.ticks += 1
    recalculate()
    strike()
  retreat = ->
    if $scope.seq.ticks <= 0
      $scope.seq.ticks = $scope.t.len()
    $scope.seq.ticks -= 1
    recalculate()
    strike()
  Keyboard.register(39, $scope.advance) # right arrow
  Keyboard.register(76, $scope.advance) # l
  Keyboard.register(37, retreat) # left arrow
  Keyboard.register(72, retreat) # h
  recalculate = ->
    $scope.seq.semi = $scope.seq.ticks % ($scope.t.beatCount * 4)
    $scope.seq.beat = Math.floor($scope.seq.semi / 4)

  $scope.testPlay = (inst) ->
    Sound.play(inst)

  lastDataGenerated = ""
  $scope.generateRawData = ->
    $scope.t.cleanup()
    rawData = $scope.t.getPath()
    lastDataGenerated = rawData
  $scope.permalink = ->
    $location.path(lastDataGenerated)
    $location.absUrl()

  $scope.keyPressed = (e) ->
    Keyboard.callFn(e)

  # Random helpers
  $scope.isEmpty = (obj) ->
    !obj || angular.equals({}, obj)
)

drum.controller("PlayCtrl", ($scope, $interval, Keyboard) ->
  $scope.heartbeat = null
  $scope.reset = ->
    $scope.off()
    $scope.seq.ticks = -1
    $scope.seq.beat = -1
    $scope.seq.semi = -1
  Keyboard.register(83, $scope.reset)

  $scope.toggle = -> if $scope.heartbeat then $scope.off() else $scope.on()
  Keyboard.register(32, $scope.toggle)

  $scope.on = ->
    return if $scope.heartbeat
    $scope.heartbeat = $interval($scope.advance, (tempoMs($scope.t.tempo)))

  $scope.off = ->
    return unless $scope.heartbeat
    $interval.cancel($scope.heartbeat)
    $scope.heartbeat = null

  $scope.addChannel = (inst) ->
    return if !$scope.instruments[inst] || $scope.t.channels[inst]
    $scope.t.channels[inst] = [0]

  $scope.changeTempo = (diff) ->
    if diff
      $scope.t.tempo += diff
    $scope.t.tempo = 1 if $scope.t.tempo < 1
    $scope.t.tempo = 350 if $scope.t.tempo > 350
    if $scope.heartbeat
      $scope.off()
      $scope.on()
    no
{'fraction_non_alphanumeric': 0.16734839053885825, 'fraction_numerical': 0.015827849902187444, 'mean_word_length': 2.81029810298103, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, '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': '7030487', 'n_tokens_mistral': 2112, 'n_tokens_neox': 2038, 'n_words': 404}