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

computes the RMS of a time domain signal More...

Functions

 FeatureTimeRms (x, iBlockLength, iHopLength, f_s)
 computes the RMS of a time domain signal
 
 filterSP (x, alpha)
 

Detailed Description

computes the RMS of a time domain signal

Args: x: audio signal iBlockLength: block length in samples iHopLength: hop length in samples f_s: sample rate of audio data (unused)

Returns: vrms rms value (row 1: block-based rms, row 2: single pole approx) t time stamp

Function Documentation

◆ FeatureTimeRms()

FeatureTimeRms ( x,
iBlockLength,
iHopLength,
f_s )

computes the RMS of a time domain signal

Parameters
xarray with floating point audio data (dimension samples x channels)
iBlockLengthblock length in samples
iHopLengthhop length in samples
f_ssample rate of audio data
Returns
vrms:rms value (row 1: block-based rms, row 2: single pole approx)
t: time stamp

Definition at line 30 of file FeatureTimeRms.py.

30def FeatureTimeRms(x, iBlockLength, iHopLength, f_s):
31
32 T_i = .3
33 alpha = 1 - np.exp(-2.2/f_s/T_i)
34
35 # create blocks
36 x_b, t = pyACA.ToolBlockAudio(x, iBlockLength, iHopLength, f_s)
37
38 # number of results
39 iNumOfBlocks = x_b.shape[0]
40
41 # single pole implementation
42 v_sp = filterSP(x**2, alpha)
43
44 # allocate memory
45 vrms = np.zeros([2, iNumOfBlocks])
46
47 for n, block in enumerate(x_b):
48 i_start = n * iHopLength
49 i_stop = np.min([len(x), i_start + iBlockLength])
50
51 # calculate the rms
52 vrms[0, n] = np.sqrt(np.dot(block, block) / block.size)
53 vrms[1, n] = np.max(np.sqrt(v_sp[i_start:i_stop]))
54
55 # convert to dB
56 epsilon = 1e-5 # -100dB
57
58 vrms[vrms < epsilon] = epsilon
59 vrms = 20 * np.log10(vrms)
60
61 return vrms, t
62
63
Here is the call graph for this function:

◆ filterSP()

filterSP ( x,
alpha )

Definition at line 64 of file FeatureTimeRms.py.

64def filterSP(x, alpha):
65
66 xf = np.zeros(x.shape)
67 xf[0] = alpha * x[0]
68
69 for i in range(1, len(x)):
70 xf[i] = alpha * x[i] + (1 - alpha) * xf[i-1]
71
72 return xf
Here is the caller graph for this function: