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

Functions

 ToolReadAudio (cAudioFilePath)
 helper function: read audio from wav
 

Function Documentation

◆ ToolReadAudio()

ToolReadAudio ( cAudioFilePath)

helper function: read audio from wav

Parameters
cAudioFilePathpath to audio file
Returns
f_s: sample rate
x: array with floating point audio data (dimension samples x channels)

Definition at line 12 of file ToolReadAudio.py.

12def ToolReadAudio(cAudioFilePath):
13 [f_s, x] = wavread(cAudioFilePath)
14
15 if x.dtype == 'float32':
16 x = x
17 else:
18 # change range to [-1,1)
19 if x.dtype == 'uint8':
20 nbits = 8
21 elif x.dtype == 'int16':
22 nbits = 16
23 elif x.dtype == 'int32':
24 nbits = 32
25
26 x = x / float(2**(nbits - 1))
27
28 # special case of unsigned format
29 if x.dtype == 'uint8':
30 x = x - 1.
31
32 return f_s, x