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

computePitch More...

Functions

 computePitch (cPitchTrackName, x, f_s, afWindow=None, iBlockLength=4096, iHopLength=2048)
 computes the fundamental frequency of (monophonic) audio supported pitch trackers are: 'SpectralAcf', 'SpectralHps', 'TimeAcf', 'TimeAmdf', 'TimeAuditory', 'TimeZeroCrossings',
 
 isSpectral (cName)
 helper functions
 
 isTemporal (cName)
 
 computePitchCl (cPath, cPitchTrackName, bPlotOutput=False)
 main
 

Variables

 parser = argparse.ArgumentParser(description='Compute key of wav file')
 
 metavar
 
 required
 
 help
 
 args = parser.parse_args()
 
 cPath = args.infile
 
 cPitchTrackName = args.featurename
 
 bPlotOutput = args.plotoutput
 

Detailed Description

computePitch

computes the fundamental frequency of the (monophonic) audio supported pitch trackers are: 'SpectralAcf', 'SpectralHps', 'TimeAcf', 'TimeAmdf', 'TimeAuditory', 'TimeZeroCrossings', Args:

x: array with floating point audio data
f_s: sample rate
afWindow: FFT window of length iBlockLength (default: hann)
iBlockLength: internal block length (default: 4096 samples)
iHopLength: internal hop length (default: 2048 samples)

Returns: f frequency t time stamp for the frequency value

Function Documentation

◆ computePitch()

computePitch ( cPitchTrackName,
x,
f_s,
afWindow = None,
iBlockLength = 4096,
iHopLength = 2048 )

computes the fundamental frequency of (monophonic) audio supported pitch trackers are: 'SpectralAcf', 'SpectralHps', 'TimeAcf', 'TimeAmdf', 'TimeAuditory', 'TimeZeroCrossings',

Parameters
cPitchTrackNamefeature to compute, e.g. 'SpectralHps'
xarray with floating point audio data (dimension samples x channels)
f_ssample rate of audio data
afWindowFFT window of length iBlockLength (default: hann), can be [] empty
iBlockLengthinternal block length (default: 4096 samples)
iHopLengthinternal hop length (default: 2048 samples)
Returns
f_0: frequency
t: time stamps

Definition at line 53 of file computePitch.py.

53def computePitch(cPitchTrackName, x, f_s, afWindow=None, iBlockLength=4096, iHopLength=2048):
54
55 # mypackage = __import__(".Pitch" + cPitchTrackName, package="pyACA")
56 hPitchFunc = getattr(pyACA, "Pitch" + cPitchTrackName)
57
58 # pre-processing
59 x = ToolPreprocAudio(x)
60
61 if isSpectral(cPitchTrackName):
62 # compute window function for FFT
63 if afWindow is None:
64 afWindow = ToolComputeHann(iBlockLength)
65
66 assert(afWindow.shape[0] == iBlockLength), "parameter error: invalid window dimension"
67
68 # in the real world, we would do this block by block...
69 [X, f, t] = computeSpectrogram(x, f_s, None, iBlockLength, iHopLength)
70
71 # compute instantaneous pitch chroma
72 f_0 = hPitchFunc(X, f_s)
73
74 if isTemporal(cPitchTrackName):
75 [f_0, t] = hPitchFunc(x, iBlockLength, iHopLength, f_s)
76
77 return f_0, t
78
79
Here is the call graph for this function:

◆ computePitchCl()

computePitchCl ( cPath,
cPitchTrackName,
bPlotOutput = False )

main

Definition at line 100 of file computePitch.py.

100def computePitchCl(cPath, cPitchTrackName, bPlotOutput=False):
101
102 # read audio file
103 [f_s, afAudioData] = ToolReadAudio(cPath)
104 # afAudioData = np.sin(2*np.pi * np.arange(f_s*1)*440./f_s)
105
106 # compute feature
107 [v, t] = computePitch(cPitchTrackName, afAudioData, f_s)
108
109 # plot feature output
110 if bPlotOutput:
111 plt.plot(t, v)
112
113 return v, t
114
115

◆ isSpectral()

isSpectral ( cName)

helper functions

Definition at line 82 of file computePitch.py.

82def isSpectral(cName):
83 bResult = False
84 if "Spectral" in cName:
85 bResult = True
86
87 return bResult
88
89
Here is the caller graph for this function:

◆ isTemporal()

isTemporal ( cName)

Definition at line 90 of file computePitch.py.

90def isTemporal(cName):
91 bResult = False
92 if "Time" in cName:
93 bResult = True
94
95 return bResult
96
97
Here is the caller graph for this function:

Variable Documentation

◆ args

args = parser.parse_args()

Definition at line 129 of file computePitch.py.

◆ bPlotOutput

bool bPlotOutput = args.plotoutput

Definition at line 132 of file computePitch.py.

◆ cPath

str cPath = args.infile

Definition at line 130 of file computePitch.py.

◆ cPitchTrackName

str cPitchTrackName = args.featurename

Definition at line 131 of file computePitch.py.

◆ help

help

Definition at line 122 of file computePitch.py.

◆ metavar

metavar

Definition at line 121 of file computePitch.py.

◆ parser

parser = argparse.ArgumentParser(description='Compute key of wav file')

Definition at line 120 of file computePitch.py.

◆ required

required

Definition at line 121 of file computePitch.py.