Function calculate_frequencies

Source
pub fn calculate_frequencies(n: usize, sample_rate: f32) -> Vec<f32>
Expand description

Calculates the frequency values corresponding to the given number of samples and sample rate.

This function generates a vector of frequency values based on the number of samples and the sample rate. The frequencies are calculated as k * sample_rate / n, where k is the index of the frequency bin.

§Parameters

  • n: The number of frequency bins (samples).
  • sample_rate: The sample rate in Hertz (Hz).

§Returns

A vector of f32 values representing the frequency values for each bin. The length of the output vector will be equal to n.

§Example

let n = 1024; // Number of frequency bins
let sample_rate = 44100.0; // Sample rate in Hz
let frequencies = calculate_frequencies(n, sample_rate);