pyACA: Documentation 0.3.1
Source Code for Audio Content Analysis
Loading...
Searching...
No Matches
Functions
pyACA.ToolBlockAudio Namespace Reference

Functions

 ToolBlockAudio (x, iBlockLength, iHopLength, f_s)
 helper function: blocks an audio signal into overlapping blocks
 

Function Documentation

◆ ToolBlockAudio()

ToolBlockAudio ( x,
iBlockLength,
iHopLength,
f_s )

helper function: blocks an audio signal into overlapping blocks

Parameters
xarray with floating point audio data (dimension samples x channels)
iBlockLengthinternal block length
iHopLengthinternal hop length
f_ssample rate of audio data
Returns
x_b: 2D np.array containing the blocked data of shape (iNumOfBlocks x iBlockLength)
t: time stamp

Definition at line 15 of file ToolBlockAudio.py.

15def ToolBlockAudio(x, iBlockLength, iHopLength, f_s):
16
17 iNumBlocks = np.ceil(x.shape[0] / iHopLength).astype(int)
18
19 # time stamp vector
20 t = np.arange(0, iNumBlocks) * iHopLength / f_s + iBlockLength / (2*f_s)
21
22 # pad with block length zeros just to make sure it runs for weird inputs, too
23 afAudioPadded = np.concatenate((x, np.zeros([iBlockLength+iHopLength, ])), axis=0)
24
25 return np.vstack([np.array(afAudioPadded[n*iHopLength:n*iHopLength+iBlockLength]) for n in range(iNumBlocks)]), t