Code Monkey home page Code Monkey logo

complexnmf's Introduction

Complex_NMF


This repository is for using NMF and complex NMF. Comments in the codes are written in Japanese.


Description

The main contents are divided into two types.

  1. NMF: just decomposing non-negative spectrogram into basis and activation.
  2. CNMF: decomposing complex spectrogram with using phase values.

In this context, the basis matrix is considered to be fixed. Therefore, please give them an initial basis matrix as a fixed matrix. Note that the activation is initialized by Gaussian distribution.


Usage

Making initialized basis spectrogram

In order to conduct source separation, a basis supectrogram should be prepared. You have to prepare wav files in advance which are used for making a basis spectrogram. In this repository, we prepare some samples of the wav files. These templates are sampled from Musescore, one of the most popular notation software. In this repository named "basis_wav_piano" includes 3 octaves of single piano sound. Then using the code below, you can make fixed basis spectrograms which are made through NMF (They include noise, and we strongly recommend that you should prepare them by yourself).


$ python make_init.py [path_to_template_directory]

Arguments:

  1. Path to the directory which includes template wav files.

Return:

  • Basis matrix (fixed_basis.npy)

In this algorithm, I adopt the parameters based on the harmonic feature of the piano as follows. 130.81 is the frequency of C3. Also, the damping coefficient is set as 0.9, variance as 1.0 and the number of the Gaussian peak as 50.





Those parameters determine the initial values of NMF to make basis spectrograms. Furthermore, you can prepare another template. Note that default settings basically rely on the librosa's ones.


NMF

First, please prepare the spectrogram whose type is ndarray. Also, prepare the initial values of the basis matrix, which is fixed through the overall iterations. Note that the number of frequency bins must be the same number between the spectrogram and the initial values.



$ python NMF.py [path_to_spectrogram.npy] [iterations] [path_to_initial_values]

Arguments:

  1. Path to the spectrogram file made by ndarray.
  2. The number of overall iterations.
  3. Path to the initial values of basis matrix

Return:

  • Basis matrix (basis_calc.npy)
  • Activation matrix (activation_calc.npy)
  • Errors based on the euclid_divergence (cost.npy)
    ※Automatically saved ndarray as ".npy". In addition, automatically draw the learning curve.

Complex NMF

As the case of NMF, please prepare the spectrogram with ndarray. At the same time, make the initial values as a fixed matrix. Then the activation matrix is initialized using the same way as NMF while the phase matrix is initialized as follows. It is based on the original paper of complex NMF[2].



$ python CNMF.py [path_to_spectrogram.npy] [iterations] [path_to_initial_values] -thr [threshold]

Arguments:

  1. Path to the spectrogram file made by ndarray.
  2. The number of overall iterations.
  3. Path to the initial values of the basis matrix
  4. A threshold of the error (optional)

Return:

  • Basis matrix (basis_calc.npy)
  • Activation matrix (activation_calc.npy)
  • Exponential-phase matrix (phase_calc.npy)
  • Reconstructed spectrigram (reconst.npy)
  • Errors based on the euclid_divergence (cost.npy)

※Automatically saved ndarray as ".npy". In addition, automatically draw the learning curve.


References

[1] Kameoka, Hirokazu, et al. "Complex NMF: A new sparse representation for acoustic signals." 2009 IEEE International Conference on Acoustics, Speech and Signal Processing. IEEE, 2009.

complexnmf's People

Contributors

beginaid avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.