Skip to content

Commit

Permalink
update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
sndrs committed Oct 24, 2024
1 parent ff913c4 commit 0ac73e6
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { useId, useMemo } from 'react';
const sumArray = (array: number[]) => array.reduce((a, b) => a + b, 0);

/**
* Pseudo random number generator ([linear congruential
* Pseudo random number generator generator ([linear congruential
* generator](https://en.wikipedia.org/wiki/Linear_congruential_generator)).
*
* I'll be honest, I don't fully understand this, but it generates a random
* number based on a seed, in this case an array of numbers.
* I'll be honest, I don't fully understand it, but it creates a pseudo random
* number generator based on a seed, in this case an array of numbers.
*
* It's deterministic, so the same seed will always generate the same results.
* It's deterministic, so calls to the function it returns will always return
* the same results.
*
* Copilot helped me with it...
*/
Expand All @@ -36,11 +37,13 @@ function shuffle(array: number[]) {
return array.sort(() => getSeededRandomNumber() - getSeededRandomNumber());
}

// normalize the amplitude of the fake audio data
const normalizeAmplitude = (data: number[]) => {
const multiplier = Math.pow(Math.max(...data), -1);
return data.map((n) => n * multiplier * 100);
};

/** Returns a string of the specified length, repeating the input string as necessary. */
function padString(str: string, length: number) {
// Repeat the string until it is longer than the desired length
const result = str.repeat(Math.ceil(length / str.length));
Expand Down

0 comments on commit 0ac73e6

Please sign in to comment.