<commit_before><template>
  <div class="recording-indicator-wrapper">
    <div v-bind:style="{ transform: `scale(${pulseScale})`}"
         v-bind:class="[{'background-enabled pulse' : enablePulse}]"></div>
    <div class="fa-microphone"></div>
  </div>
</template>

<script>
  /**
   * Settings for processing average microphone frequency into a scaled value.
   */
  const settings = {
    lowerFreqBound: 4,
    upperFreqBound: 30,
    minPulseScale: 0.8,
    maxPulseScale: 1.4,
    pulseScaleStep: 0.005
  };

  /**
   * Transform microphone frequency to a reasonable scale value for pulsating background element
   *
   * @param {number} frequency Average microphone frequency input
   * @return {number} A transformed scale for the pulsating element, determined by settings
   */
  const micFrequencyToPulseScale = (frequency) => {
    // Set outer bounds
    if (frequency > settings.upperFreqBound) {
      frequency = settings.upperFreqBound;
    }
    else if (frequency < settings.lowerFreqBound) {
      frequency = settings.lowerFreqBound;
    }

    // Normalize within min/max scale
    const normalized = (frequency - settings.lowerFreqBound) / settings.upperFreqBound;
    const deltaScale = settings.maxPulseScale - settings.minPulseScale;
    const vuScaled = (deltaScale * normalized) + settings.minPulseScale;

    // Round to nearest step to reduce jitter
    return Math.round(vuScaled / settings.pulseScaleStep) * settings.pulseScaleStep;
  };

  export default {
    props: ['avgMicFrequency', 'enablePulse'],
    computed: {
      pulseScale: function () {
        return micFrequencyToPulseScale(this.avgMicFrequency);
      }
    }
  }

</script>

<style>
  .recording-indicator-wrapper {
    height: 9.375em;
    width: 9.375em;
    margin-left: auto;
    margin-right: auto;
    line-height: 9.375em;
    color: #8e8e8e;
    position: relative;
    margin-bottom: 1em;
  }

  .background-enabled {
    height: 100%;
    width: 100%;
    background-image: url('../images/recording-indicator.svg');
    position: absolute;
  }

  .pulse {
    transform: scale(0.8);
  }
</style><commit_msg>Reduced max scale of vu meter slightly to not overflow text<commit_after><template>
  <div class="recording-indicator-wrapper">
    <div v-bind:style="{ transform: `scale(${pulseScale})`}"
         v-bind:class="[{'hidden' : !enablePulse}]"
         class="h5p-audio-recorder-vu-meter"
    ></div>
    <div class="fa-microphone"></div>
  </div>
</template>

<script>
  /**
   * Settings for processing average microphone frequency into a scaled value.
   */
  const settings = {
    lowerFreqBound: 4,
    upperFreqBound: 30,
    minPulseScale: 0.7,
    maxPulseScale: 1.3,
    pulseScaleStep: 0.005
  };

  /**
   * Transform microphone frequency to a reasonable scale value for pulsating background element
   *
   * @param {number} frequency Average microphone frequency input
   * @return {number} A transformed scale for the pulsating element, determined by settings
   */
  const micFrequencyToPulseScale = (frequency) => {
    // Set outer bounds
    if (frequency > settings.upperFreqBound) {
      frequency = settings.upperFreqBound;
    }
    else if (frequency < settings.lowerFreqBound) {
      frequency = settings.lowerFreqBound;
    }

    // Normalize within min/max scale
    const normalized = (frequency - settings.lowerFreqBound) / settings.upperFreqBound;
    const deltaScale = settings.maxPulseScale - settings.minPulseScale;
    const vuScaled = (deltaScale * normalized) + settings.minPulseScale;

    // Round to nearest step to reduce jitter
    return Math.round(vuScaled / settings.pulseScaleStep) * settings.pulseScaleStep;
  };

  export default {
    props: ['avgMicFrequency', 'enablePulse'],
    computed: {
      pulseScale: function () {
        return micFrequencyToPulseScale(this.avgMicFrequency);
      }
    }
  }

</script>

<style lang="scss">
  .recording-indicator-wrapper {
    height: 9.375em;
    width: 9.375em;
    margin-left: auto;
    margin-right: auto;
    line-height: 9.375em;
    color: #8e8e8e;
    position: relative;
    margin-bottom: 1em;
  }

  .h5p-audio-recorder-vu-meter {
    height: 100%;
    width: 100%;
    background-image: url('../images/recording-indicator.svg');
    position: absolute;
    transform: scale(0.8);

    &.hidden {
      display: none;
    }
  }
</style>
{'fraction_non_alphanumeric': 0.12050400916380298, 'fraction_numerical': 0.016494845360824743, 'mean_word_length': 3.1033834586466167, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, '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': '2604022', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1336, 'n_words': 325}