元編程參考文件

頻譜

8 個節點

本頁內容 8

繪製短時頻譜

函數

Draws a spectrogram: time across, frequency up, and how strong each frequency is at each moment as brightness.

簽名
繪製短時頻譜 -> Pixel Image
    頻譜: Audio Spectrogram
    寬度: 整數
    高度: 整數
PixelImage DrawTransform(
    AudioSpectrogram spectrogram,
    int width = 800,
    int height = 300)

參數

名稱型別預設值說明
頻譜Audio Spectrogram—The transform.
寬度整數800Pixels across.
高度整數300Pixels up.

返回

影像Pixel Image

備註

Several channels are drawn as their average. Levels run from -100 dB, black, to 0 dB, white, through the same colours as Draw Spectrogram, so a band taken out shows as a dark stripe.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理

逆變換

函數

Puts a clip back together from its frequencies: the inverse short-time Fourier transform.

簽名
逆變換(頻譜: Audio Spectrogram) -> AudioBuffer
AudioBuffer Inverse(AudioSpectrogram spectrogram)

參數

名稱型別預設值說明
頻譜Audio Spectrogram—The transform, changed or not.

返回

音訊AudioBuffer

備註

Each frame is turned back into samples, windowed again and overlap-added, and the sum divided by how much window covers each sample. A spectrogram nothing has changed comes back as the clip it was taken from, to within float rounding.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理

保留頻段

函數

Keeps only the frequencies from Low up to High.

簽名
保留頻段 -> Audio Spectrogram
    頻譜: Audio Spectrogram
    下限: 數字
    上限: 數字
AudioSpectrogram KeepBand(
    AudioSpectrogram spectrogram,
    double low = 300,
    double high = 3000)

參數

名稱型別預設值說明
頻譜Audio Spectrogram—The transform.
下限數字300The band's lower edge, in hertz.
上限數字3000The band's upper edge, in hertz; above half the sample rate means everything from the lower edge up.

返回

頻譜Audio Spectrogram

備註

A frequency is kept when its bin's centre lies in the band, low end included and high end not, and the rest are set to nothing. Keep Band and Remove Band with the same edges are exact complements: the two inverses add up to the clip.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理

去除頻段

函數

Takes out the frequencies from Low up to High and keeps the rest.

簽名
去除頻段 -> Audio Spectrogram
    頻譜: Audio Spectrogram
    下限: 數字
    上限: 數字
AudioSpectrogram RemoveBand(
    AudioSpectrogram spectrogram,
    double low = 300,
    double high = 3000)

參數

名稱型別預設值說明
頻譜Audio Spectrogram—The transform.
下限數字300The band's lower edge, in hertz.
上限數字3000The band's upper edge, in hertz.

返回

頻譜Audio Spectrogram
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理

分離諧波與打擊

函數

Divides a clip into what holds steady - notes, chords, sustained voices - and what is brief and broad - drums, clicks, consonants.

簽名
分離諧波與打擊 -> (諧波: AudioBuffer, 打擊: AudioBuffer)
    音訊: AudioBuffer
    中值窗: 整數
    冪次: 數字
    幀長: 整數
    幀移: 整數
void SeparateHarmonicPercussive(
    AudioBuffer audio,
    out AudioBuffer harmonic,
    out AudioBuffer percussive,
    int kernel = 31,
    double power = 2,
    int frameSize = 2048,
    int hop = 512)

參數

名稱型別預設值說明
音訊AudioBuffer—The clip.
中值窗整數31How many frames, and frequencies, each median spans; odd. Wider separates more firmly and smears more.
冪次數字2How firmly each frequency is given to one side: 1 shares in proportion, 2 is librosa's default, higher approaches all or nothing.
幀長整數2048Samples per frame, as Short-Time Transform takes it.
幀移整數512Samples between frames, as Short-Time Transform takes it.

返回

諧波AudioBuffer
打擊AudioBuffer

備註

Fitzgerald's median-filtering method, as librosa's decompose.hpss computes it: across time the steady parts stand out, across frequency the sharp ones do, and each frequency at each moment is shared between the two in proportion. The shares add to one everywhere, so the two parts mixed together are the clip.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理

拆分頻段

函數

Divides a clip into frequency bands - lows, mids, highs, or as many as the edges make - which add back up to the clip.

簽名
拆分頻段 -> AudioBuffer 陣列
    音訊: AudioBuffer
    分界: 數字陣列
    幀長: 整數
    幀移: 整數
AudioBuffer[] SplitIntoBands(
    AudioBuffer audio,
    double[] edges,
    int frameSize = 2048,
    int hop = 512)

參數

名稱型別預設值說明
音訊AudioBuffer—The clip.
分界數字陣列—Where one band ends and the next begins, in hertz, rising.
幀長整數2048Samples per frame, as Short-Time Transform takes it.
幀移整數512Samples between frames, as Short-Time Transform takes it.

返回

頻段AudioBuffer 陣列

備註

Edges at 250 and 4000 Hz give three clips: everything below 250 Hz, 250 to 4000 Hz, and everything above. Every frequency lands in exactly one band, so Mix All of the bands is the clip again.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理

最強頻率

函數

The frequencies a clip holds most of - its constituents, strongest first, each with its level and the note nearest it.

簽名
最強頻率(音訊: AudioBuffer, 數量: 整數) -> Table
Table StrongestFrequencies(AudioBuffer audio, int count = 10)

參數

名稱型別預設值說明
音訊AudioBuffer—The clip.
數量整數10How many to list.

返回

頻率Table

備註

Peaks of the clip's averaged spectrum, each placed between bins by fitting a parabola to it and its neighbours. A peak within a semitone of a stronger one is the same constituent's skirt and is left out.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理

短時傅立葉變換

函數

Takes a clip apart into its frequencies over time: the short-time Fourier transform.

簽名
短時傅立葉變換 -> Audio Spectrogram
    音訊: AudioBuffer
    幀長: 整數
    幀移: 整數
AudioSpectrogram Transform(
    AudioBuffer audio,
    int frameSize = 2048,
    int hop = 512)

參數

名稱型別預設值說明
音訊AudioBuffer—The clip.
幀長整數2048Samples per frame, a power of two from 64 to 32768: larger tells close frequencies apart, smaller places changes more exactly in time.
幀移整數512Samples from one frame to the next, at most a quarter of the frame so the frames overlap enough to rebuild the clip.

返回

頻譜Audio Spectrogram

備註

Each channel is cut into Hann-windowed frames of Frame Size samples, one every Hop, and each frame becomes the amplitude and phase of every frequency in it. The clip is padded with half a frame of silence at each end, as librosa and SciPy do, so its first and last moments come back too.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
頻譜
所屬包
音訊處理