Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def compute_beatsync_features(ticks, audio):
"""Computes the HPCP and MFCC beat-synchronous features given a set
of beats (ticks)."""
MFCC = STFTFeature(FRAME_SIZE, HOP_SIZE, WINDOW_TYPE,
ES.MFCC(numberCoefficients=14), ticks, SAMPLE_RATE)
HPCP = STFTFeature(FRAME_SIZE, HOP_SIZE, WINDOW_TYPE, ES.HPCP(),
ticks, SAMPLE_RATE)
logging.info("Computing Beat-synchronous MFCCs...")
mfcc = MFCC.compute_features(audio)
logging.info("Computing Beat-synchronous HPCPs...")
hpcp = HPCP.compute_features(audio)
logging.info("Computing Beat-synchronous Tonnetz...")
tonnetz = utils.chroma_to_tonnetz(hpcp)
return mfcc.tolist(), hpcp.tolist(), tonnetz.tolist()
def compute_features(audio, beats=None):
"""Computes the HPCP and MFCC beat-synchronous features given a set
of beats (beats)."""
beatsync_str = ""
if beats is not None:
beatsync_str = "Beat-synchronous "
MFCC = STFTFeature(msaf.Anal.frame_size, msaf.Anal.hop_size,
msaf.Anal.window_type,
ES.MFCC(numberCoefficients=msaf.Anal.mfcc_coeff),
msaf.Anal.sample_rate, beats)
HPCP = STFTFeature(msaf.Anal.frame_size, msaf.Anal.hop_size,
msaf.Anal.window_type, ES.HPCP(), msaf.Anal.sample_rate,
beats)
logging.info("Computing %sMFCCs..." % beatsync_str)
mfcc = MFCC.compute_features(audio)
logging.info("Computing %sHPCPs..." % beatsync_str)
hpcp = HPCP.compute_features(audio)
#plt.imshow(hpcp.T, interpolation="nearest", aspect="auto"); plt.show()
logging.info("Computing %sTonnetz..." % beatsync_str)
tonnetz = utils.chroma_to_tonnetz(hpcp)
return mfcc, hpcp, tonnetz