Letztes Quartal 2019 M3T-Klimper

Besser, wenn ich's nicht nicht gemacht hätte.


Letztes Geklimper im letzten Quartal (erste Teile davon)


hoinkytoinkyboijy-1
hoinkytoinkyboijy-2
hoinkytoinkyboijy-3


Das Jahr neigt sich gegen sein Ende, sein letztes Quartal verinnt. Viel mehr als das oben zu Hörende wird wohl nicht mehr draus werden, bevor's um ist. Damit kann ich mich aber zufrieden geben.


Ein paar mysukalische Überraschungen - außer die nicht mehr kommenden Fingerfertigkeitsfortschritte - könnte es aber vor 2020 noch geben. Warten wir's mal ab, bleiben wir mal gespannt, freuen wir uns aufs Christkind, essen wir nen Keks, fressen wir uns Plätzchen ... äh, ja.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3 Arten von Beattracking


Mal so hier reingeschmissen. Erst wenn ich mehr Erfahrung mit den Tools gesammelt habe, werde ich mich näher dazu äußern (können).


#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys


# In[ ]:


get_ipython().system('{sys.executable} -m pip install git+https://github.com/aubio/aubio.git/ -v --user')


# In[16]:


get_ipython().system('{sys.executable} -m pip install pydub')


# In[14]:


import aubio
import numpy as np


# In[19]:


import pydub


# In[48]:


sound = pydub.AudioSegment.from_mp3("/home/heide/Musikpool/Joris - Herz über Kopf.mp3")


# In[49]:


sound.export("/tmp/sound.wav", format="wav")


# In[50]:


from aubio import tempo, source

win_s = 512                 # fft size
hop_s = win_s // 2          # hop size


samplerate = 0


s = source('/tmp/sound.wav', samplerate, hop_s)
samplerate = s.samplerate
o = tempo("default", win_s, hop_s, samplerate)

# tempo detection delay, in samples
# default to 4 blocks delay to catch up with
delay = 4. * hop_s

# list of beats, in samples
beats = []

# total number of frames read
total_frames = 0
while True:
    samples, read = s()
    is_beat = o(samples)
    if is_beat:
        this_beat = o.get_last_s()
        beats.append(this_beat)
    total_frames += read
    if read < hop_s: break

if len(beats) > 1:
    # do plotting
    from numpy import mean, median, diff
    import matplotlib.pyplot as plt
    bpms = 60./ diff(beats)
    print('mean period: %.2fbpm, median: %.2fbpm' % (mean(bpms), median(bpms)))
    print('plotting %s' % filename)
    plt1 = plt.axes([0.1, 0.75, 0.8, 0.19])
    plt2 = plt.axes([0.1, 0.1, 0.8, 0.65], sharex = plt1)
    plt.rc('lines',linewidth='.8')
    for stamp in beats: plt1.plot([stamp, stamp], [-1., 1.], '-r')
    plt1.axis(xmin = 0., xmax = total_frames / float(samplerate) )
    plt1.xaxis.set_visible(False)
    plt1.yaxis.set_visible(False)

    # plot actual periods
    plt2.plot(beats[1:], bpms, '-', label = 'raw')

    # plot moving median of 5 last periods
    median_win_s = 5
    bpms_median = [ median(bpms[i:i + median_win_s:1]) for i in range(len(bpms) - median_win_s ) ]
    plt2.plot(beats[median_win_s+1:], bpms_median, '-', label = 'median of %d' % median_win_s)
    # plot moving median of 10 last periods
    median_win_s = 20
    bpms_median = [ median(bpms[i:i + median_win_s:1]) for i in range(len(bpms) - median_win_s ) ]
    plt2.plot(beats[median_win_s+1:], bpms_median, '-', label = 'median of %d' % median_win_s)

    plt2.axis(ymin = min(bpms), ymax = max(bpms))
    #plt2.axis(ymin = 40, ymax = 240)
    plt.xlabel('time (mm:ss)')
    plt.ylabel('beats per minute (bpm)')
    plt2.set_xticklabels([ "%02d:%02d" % (t/60, t%60) for t in plt2.get_xticks()[:-1]], rotation = 50)

    #plt.savefig('/tmp/t.png', dpi=200)
    plt2.legend()
    plt.show()

else:
    print('mean period: %.2fbpm, median: %.2fbpm' % (0, 0))
    print('plotting %s' % filename)




#!/usr/bin/env python
# coding: utf-8

# In[ ]:


# Tutorial
# https://www.analyticsvidhya.com/blog/2018/02/audio-beat-tracking-for-music-information-retrieval/


# In[ ]:


# Don't forget!
# https://louridas.github.io/rwa/assignments/musical-rhythms/


# In[10]:


import sys


# In[11]:


get_ipython().system('{sys.executable} -m pip install cython')


# In[12]:


get_ipython().system('{sys.executable} -m pip install madmom')


# In[1]:


# import modules

import librosa
import IPython.display as ipd


# In[2]:


# read audio file

x, sr = librosa.load('/home/heide/Musikpool/Joris - Herz über Kopf.mp3')


# In[3]:


ipd.Audio(x, rate=sr)


# In[6]:


# approach 1 - onset detection and dynamic programming

tempo, beat_times = librosa.beat.beat_track(x, sr=sr, units='time')


# In[7]:


tempo


# In[5]:


beat_times


# In[8]:


clicks = librosa.clicks(beat_times, sr=sr, length=len(x))
ipd.Audio(x + clicks, rate=sr)


# In[13]:


# import modules

import madmom

# approach 2 - dbn tracker

proc = madmom.features.beats.DBNBeatTrackingProcessor(fps=100)
act = madmom.features.beats.RNNBeatProcessor()('/home/heide/Musikpool/Joris - Herz über Kopf.mp3')

beat_times = proc(act)


# In[14]:


beat_times


# In[ ]:


Links:



How to get BPM and tempo audio features in Python - Stack Overflow Which Python libraries can I use to get the BPM (beats per minute) of a MP3 file? - Quora Detecting Music BPM using Neural Networks - nlml aubio/demo_tempo_plot.py at master · aubio/aubio · GitHub GitHub - jiaaro/pydub: Manipulate audio with a simple and easy high level interface Convert MP3 to WAV | Python Tutorial Command line tools — aubio 0.4.9 documentation Welcome — aubio 0.4.9 documentation librosa/beat.py at master · librosa/librosa · GitHub GitHub - aubio/aubio: a library for audio and music analysis beat_tracking madmom/tests at master · CPJKU/madmom · GitHub Learn Audio Beat Tracking for Music Information Retrieval (with Python codes) rp_extract/RP_extract_Tutorial.v4.ipynb at master · tuwien-musicir/rp_extract · GitHub GitHub - tuwien-musicir/rp_extract: Rhythm Pattern music feature extractor by IFS @ TU-Vienna





Kommentare

Beliebte Posts aus diesem Blog

·

Es brennt.

Bye, bye Nord Stream 2!