ailiaAudioMagPhase method

int ailiaAudioMagPhase(
  1. Pointer<Void> dst_mag,
  2. Pointer<Void> dst_phase,
  3. Pointer<Void> src,
  4. int freq_n,
  5. int frame_n,
  6. double power,
  7. int phase_form
)

~japanese @brief スペクトログラムから振幅と位相を計算します。 @param dst_mag 振幅の出力先ポインタ、外側から freq_n, frame_n 順のメモリレイアウト @param dst_phase 位相の出力先ポインタ、外側から freq_n, frame_n, 2(実部、虚部) 順のメモリレイアウト @param src 入力データのポインタ、frame_n, freq_n, 2(実部、虚部) 順のメモリレイアウト @param freq_n 周波数のインデックス数 @param frame_n 時間フレームの数 @param power 振幅スペクトルの乗数 ( > 0.0)、1.0: 振幅スペクトログラム、2.0: パワースペクトログラムに相当 @param phase_form 位相の出力形式、AILIA_AUDIO_PHASE_FORM_* のいずれか @return 成功した場合は \ref AILIA_STATUS_SUCCESS 、そうでなければエラーコードを返す。 @details librosaのデフォルト値と互換の条件: phase_form = \ref AILIA_AUDIO_PHASE_FORM_COMPLEX , power = 1.0 PyTorchのデフォルト値と互換の条件: phase_form = \ref AILIA_AUDIO_PHASE_FORM_REAL , power = 1.0 phase_formによってdst_phaseの出力が変わります。

  • \ref AILIA_AUDIO_PHASE_FORM_COMPLEX : 実部と虚部の交互信号、サイズは freq_n * frame_n * 2
  • \ref AILIA_AUDIO_PHASE_FORM_REAL : 実部のみの信号、サイズは freq_n * frame_n

~english @brief Get the amplitude and the phase from the spectrogram. @param dst_mag pointer to the outputted amplitudes, an array of length (freq_n * frame_n). (memory layout, using the row-major convention: (freq_n, frame_n)) @param dst_phase pointer to the outputted phases, an array of length (2 * freq_n * frame_n) (sequence of complex pairs real part, imaginary part). (memory layout, using the row-major convention: (freq_n, frame_n, 2)) @param src pointer to the input data, of length (2 * frame_n * freq_n) (a sequence of complex pairs real, imaginary). (memory layout, using the row-major convention: (frame_n, freq_n, 2)) @param freq_n number of frequency indices @param frame_n number of time frames @param power exponent to apply to the spectrogram (> 0.0). 1.0: amplitude spectrogram, 2.0: power spectrogram, etc, any other positive exponent value is allowed. @param phase_form format of the outputted phase: any of the AILIA_AUDIO_PHASE_FORM_* constants @return In case of success, \ref AILIA_STATUS_SUCCESS , and else an error code is returned. @details To be compatible with librosa, use: phase_form = \ref AILIA_AUDIO_PHASE_FORM_COMPLEX , power = 1.0 To be compatible with PyTorch, use: phase_form = \ref AILIA_AUDIO_PHASE_FORM_REAL , power = 1.0 The dst_phase output depends on phase_form:

  • \ref AILIA_AUDIO_PHASE_FORM_COMPLEX : signal with real and imaginary parts, of size (freq_n * frame_n * 2)
  • \ref AILIA_AUDIO_PHASE_FORM_REAL : real signal, of size (freq_n * frame_n)

Implementation

int ailiaAudioMagPhase(
  ffi.Pointer<ffi.Void> dst_mag,
  ffi.Pointer<ffi.Void> dst_phase,
  ffi.Pointer<ffi.Void> src,
  int freq_n,
  int frame_n,
  double power,
  int phase_form,
) {
  return _ailiaAudioMagPhase(
    dst_mag,
    dst_phase,
    src,
    freq_n,
    frame_n,
    power,
    phase_form,
  );
}