ewan-xu / LibrosaCpp

LibrosaCpp is a c++ implemention of librosa to compute short-time fourier transform coefficients,mel spectrogram or mfcc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can we pass an argument like `transpose`?

yuikns opened this issue · comments

commented

The origin API was

  static std::vector<std::vector<float>> melspectrogram(
      std::vector<float> &x, int sr, int n_fft, int n_hop,
      const std::string &win, bool center, const std::string &mode, float power,
      int n_mels, int fmin, int fmax) {
    Matrixf mel = internal::melspectrogram(); // do some stuff here
    std::vector<std::vector<float>> mel_vector();
    // 'cast' to vector of vector
    return mel_vector;
}

However, it is not easy to transpose a vector of vector in C++.

Is it possible to add a special args like transpose:

  static std::vector<std::vector<float>> melspectrogram(
      std::vector<float> &x, int sr, int n_fft, int n_hop,
      const std::string &win, bool center, const std::string &mode, float power,
      int n_mels, int fmin, int fmax, bool transpose = false) {
    Matrixf mel = internal::melspectrogram(); // do some stuff here
    if (transpose) {
      mel.transposeInPlace();
    }
    std::vector<std::vector<float>> mel_vector();
    // 'cast' to vector of vector
    return mel_vector; // return origin_mel_vector.T
}

It may make the result easier for me.

Have a nice day!

good idea, I will add this feature when I have time recently