Function magphase

Source
pub fn magphase(
    d: &Array2<Complex<f32>>,
    power: Option<f32>,
) -> (Array2<f32>, Array2<Complex<f32>>)
Expand description

Separates magnitude and phase from a complex spectrogram.

§Arguments

  • D - Input spectrogram as an Array2<Complex<f32>>
  • power - Optional power to raise the magnitude (defaults to 1.0)

§Returns

Returns a tuple (magnitude, phase) where:

  • magnitude is an Array2<f32> of magnitude values
  • phase is an Array2<Complex<f32>> of unit-magnitude phase values

§Examples

use ndarray::arr2;
let spectrogram = arr2(&[[Complex::new(3.0, 4.0)]]);
let (mag, phase) = magphase(&spectrogram, None);
assert_eq!(mag[[0, 0]], 5.0); // sqrt(3^2 + 4^2)