# Path: msaf/features.py
# class CQT(Features):
# class MFCC(Features):
# class PCP(Features):
# class Tonnetz(Features):
# class Tempogram(Features):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_bins=config.cqt.bins,
#                  norm=config.cqt.norm, filter_scale=config.cqt.filter_scale,
#                  ref_power=config.cqt.ref_power):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_fft=config.n_fft,
#                  n_mels=config.mfcc.n_mels, n_mfcc=config.mfcc.n_mfcc,
#                  ref_power=config.mfcc.ref_power):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_bins=config.pcp.bins,
#                  norm=config.pcp.norm, f_min=config.pcp.f_min,
#                  n_octaves=config.pcp.n_octaves):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_bins=config.tonnetz.bins,
#                  norm=config.tonnetz.norm, f_min=config.tonnetz.f_min,
#                  n_octaves=config.tonnetz.n_octaves):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size,
#                  win_length=config.tempogram.win_length):
#     def get_id(self):
#     def compute_features(self):
#         S = librosa.feature.melspectrogram(self._audio,
#                                            sr=self.sr,
#                                            n_fft=self.n_fft,
#                                            hop_length=self.hop_length,
#                                            n_mels=self.n_mels)


import argparse
import logging
import os
import time
import msaf
from joblib import Parallel, delayed
from msaf.features import Features
#!/usr/bin/env python
"""
This script computes the features for a single or multiple audio files.
It uses the default parameters. These parameters can be changed the
`.msafrc` config file.

Examples:

    Single file mode:
        >> ./compute_features.py path_to_audio.mp3 -o my_features.json

    Collection mode:
        Run on 12 cores on the specified dataset:
            >> ./compute_features.py path_to_dataset/ -j 12
"""


# Local stuff


def compute_all_features(file_struct, framesync):
    """Computes all features for the given file."""
    for feature_id in msaf.features_registry:
        logging.info("Computing %s for file %s" % (feature_id,
                                                   file_struct.audio_file))

# Path: msaf/features.py
# class CQT(Features):
# class MFCC(Features):
# class PCP(Features):
# class Tonnetz(Features):
# class Tempogram(Features):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_bins=config.cqt.bins,
#                  norm=config.cqt.norm, filter_scale=config.cqt.filter_scale,
#                  ref_power=config.cqt.ref_power):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_fft=config.n_fft,
#                  n_mels=config.mfcc.n_mels, n_mfcc=config.mfcc.n_mfcc,
#                  ref_power=config.mfcc.ref_power):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_bins=config.pcp.bins,
#                  norm=config.pcp.norm, f_min=config.pcp.f_min,
#                  n_octaves=config.pcp.n_octaves):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size, n_bins=config.tonnetz.bins,
#                  norm=config.tonnetz.norm, f_min=config.tonnetz.f_min,
#                  n_octaves=config.tonnetz.n_octaves):
#     def get_id(self):
#     def compute_features(self):
#     def __init__(self, file_struct, feat_type, sr=config.sample_rate,
#                  hop_length=config.hop_size,
#                  win_length=config.tempogram.win_length):
#     def get_id(self):
#     def compute_features(self):
#         S = librosa.feature.melspectrogram(self._audio,
#                                            sr=self.sr,
#                                            n_fft=self.n_fft,
#                                            hop_length=self.hop_length,
#                                            n_mels=self.n_mels)


# Path: examples/compute_features.py
import argparse
import logging
import os
import time
import msaf
from joblib import Parallel, delayed
from msaf.features import Features

#!/usr/bin/env python
"""
This script computes the features for a single or multiple audio files.
It uses the default parameters. These parameters can be changed the
`.msafrc` config file.

Examples:

    Single file mode:
        >> ./compute_features.py path_to_audio.mp3 -o my_features.json

    Collection mode:
        Run on 12 cores on the specified dataset:
            >> ./compute_features.py path_to_dataset/ -j 12
"""


# Local stuff


def compute_all_features(file_struct, framesync):
    """Computes all features for the given file."""
    for feature_id in msaf.features_registry:
        logging.info("Computing %s for file %s" % (feature_id,
                                                   file_struct.audio_file))

        feats = Features.select_features(feature_id, file_struct, False, framesync)