【鼎革‧革鼎】︰ Raspbian Stretch 《六之 J.3‧MIR-13.2 》

音樂 = □ + □

白居易琵琶行

……

千呼萬喚始出來,猶抱琵琶半遮面。
轉軸撥絃三兩聲,未成曲調先有情。
絃絃掩抑聲聲思,似訴平生不得志。
低眉信手續續彈,說盡心中無限事。
輕攏慢撚抹復挑,初為《霓裳》後《六么》。
大絃嘈嘈如急雨,小絃切切如私語。
嘈嘈切切錯雜彈,大珠小珠落玉盤。
間關鶯語花底滑,幽咽泉流水下灘。
水泉冷澀絃凝絕,凝絕不通聲暫歇。
別有幽愁暗恨生,此時無聲勝有聲。
銀瓶乍破水漿迸,鐵騎突出刀槍鳴。
曲終收撥當心畫,四絃一聲如裂帛。
東舟西舫悄無言,唯見江心秋月白。
……

過去唐朝的大詩人白樂天,文章功深力厚又精音通律,於琵琶行一文中描寫著一位『彈著琵琶的女子』,文本直叫能『音聲』透出筆端奪字而來。

………《走進音樂世界!!

 

若說『嘈嘈切切錯雜彈,大珠小珠落玉盤。』,都給白居易聽的那麼清楚,想必早已精通 Onset 『有無個中』三昧矣!

Onset (audio)

Onset refers to the beginning of a musical note or other sound. It is related to (but different from) the concept of a transient: all musical notes have an onset, but do not necessarily include an initial transient.

In phonetics the term is used differently – see syllable onset.

Onset detection

In signal processing, onset detection is an active research area. For example, the MIREX annual competition features an Audio Onset Detection contest.

Approaches to onset detection can operate in the time domain, frequency domain, phase domain, or complex domain, and include looking for:

Simpler techniques such as detecting increases in time-domain amplitude can typically lead to an unsatisfactorily high amount of false positives or false negatives.

The aim is often to judge onsets similarly to how a human would: so psychoacoustically-motivated strategies may be employed. Sometimes the onset detector can be restricted to a particular domain (depending on intended application), for example being targeted at detecting percussive onsets. With a narrower focus, it can be more straightforward to obtain reliable detection.

※ 註

Spectral flux

Spectral flux is a measure of how quickly the power spectrum of a signal is changing, calculated by comparing the power spectrum for one frame against the power spectrum from the previous frame.[1] More precisely, it is usually calculated as the 2-norm (also known as the Euclidean distance) between the two normalised spectra.

Calculated this way, the spectral flux is not dependent upon overall power (since the spectra are normalised), nor on phase considerations (since only the magnitudes are compared).

The spectral flux can be used to determine the timbre of an audio signal, or in onset detection,[2] among other things.

 

據聞 Onset 的偵測方法尚未完善,不要只顧使用現成程式庫也?

librosa.onset.onset_detect

librosa.onset.onset_detect(y=None, sr=22050, onset_envelope=None, hop_length=512, backtrack=False, energy=None, units=’frames’, **kwargs)
 

Basic onset detector. Locate note onset events by picking peaks in an onset strength envelope.

The peak_pick parameters were chosen by large-scale hyper-parameter optimization over the dataset provided by [R42].

Parameters:

y : np.ndarray [shape=(n,)]

audio time series

sr : number > 0 [scalar]

sampling rate of y

onset_envelope : np.ndarray [shape=(m,)]

(optional) pre-computed onset strength envelope

hop_length : int > 0 [scalar]

hop length (in samples)

units : {‘frames’, ‘samples’, ‘time’}

The units to encode detected onset events in. By default, ‘frames’ are used.

backtrack : bool

If True, detected onset events are backtracked to the nearest preceding minimum of energy.

This is primarily useful when using onsets as slice points for segmentation.

energy : np.ndarray [shape=(m,)] (optional)

An energy function to use for backtracking detected onset events. If none is provided, then onset_envelope is used.

kwargs : additional keyword arguments

Additional parameters for peak picking.

See librosa.util.peak_pick for details.

Returns:

onsets : np.ndarray [shape=(n_onsets,)]

estimated positions of detected onsets, in whichever units are specified. By default, frame indices.

Note

If no onset strength could be detected, onset_detect returns an empty list.

Raises:

ParameterError

if neither y nor onsets are provided

or if units is not one of ‘frames’, ‘samples’, or ‘time’

 

※ 範例

 

 

最好能追本溯源,了解演算法核心哩◎

librosa.onset.onset_strength

librosa.onset.onset_strength(y=None, sr=22050, S=None, lag=1, max_size=1, detrend=False, center=True, feature=None, aggregate=None, centering=None, **kwargs)
 

Compute a spectral flux onset strength envelope.

Onset strength at time t is determined by:

mean_f max(0, S[f, t] – ref_S[f, t – lag])

where ref_S is S after local max filtering along the frequency axis [R43].

By default, if a time series y is provided, S will be the log-power Mel spectrogram.