Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fca48a2

Browse filesBrowse files
authored
Merge pull request #5 from libAudioFlux/dev1
Dev1
2 parents 78f881e + 40157db commit fca48a2
Copy full SHA for fca48a2
Expand file treeCollapse file tree

25 files changed

+287
-217
lines changed
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build/
33
scripts/android
44
scripts/windows
5-
audioflux/lib/*
5+
audioflux/lib
66

77
# Byte-compiled / optimized / DLL files
88
__pycache__/
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+24-28Lines changed: 24 additions & 28 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,11 @@ To install the **`audioFlux`** package, Python >=3.6, using the released python
149149
Mel spectrogram and Mel-frequency cepstral coefficients
150150

151151
```python
152-
# Feature extraction example
153152
import numpy as np
154-
import matplotlib.pyplot as plt
155-
156153
import audioflux as af
154+
155+
import matplotlib.pyplot as plt
157156
from audioflux.display import fill_spec
158-
from audioflux.type import SpectralFilterBankScaleType
159157

160158
# Get a 220Hz's audio file path
161159
sample_path = af.utils.sample_path('220')
@@ -164,29 +162,28 @@ sample_path = af.utils.sample_path('220')
164162
audio_arr, sr = af.read(sample_path)
165163

166164
# Extract mel spectrogram
167-
bft_obj = af.BFT(num=128, radix2_exp=12, samplate=sr,
168-
scale_type=SpectralFilterBankScaleType.MEL)
169-
spec_arr = bft_obj.bft(audio_arr)
165+
spec_arr, mel_fre_band_arr = af.mel_spectrogram(audio_arr, num=128, radix2_exp=12, samplate=sr)
170166
spec_arr = np.abs(spec_arr)
171167

172-
# Create XXCC object and extract mfcc
173-
xxcc_obj = af.XXCC(bft_obj.num)
174-
xxcc_obj.set_time_length(time_length=spec_arr.shape[1])
175-
mfcc_arr = xxcc_obj.xxcc(spec_arr)
168+
# Extract mfcc
169+
mfcc_arr, _ = af.mfcc(audio_arr, cc_num=13, mel_num=128, radix2_exp=12, samplate=sr)
176170

171+
# Display
177172
audio_len = audio_arr.shape[0]
173+
# calculate x/y-coords
174+
x_coords = np.linspace(0, audio_len / sr, spec_arr.shape[1] + 1)
175+
y_coords = np.insert(mel_fre_band_arr, 0, 0)
178176
fig, ax = plt.subplots()
179177
img = fill_spec(spec_arr, axes=ax,
180-
x_coords=bft_obj.x_coords(audio_len),
181-
y_coords=bft_obj.y_coords(),
182-
x_axis='time', y_axis='log',
183-
title='Mel Spectrogram')
178+
x_coords=x_coords, y_coords=y_coords,
179+
x_axis='time', y_axis='log',
180+
title='Mel Spectrogram')
184181
fig.colorbar(img, ax=ax)
185182

186183
fig, ax = plt.subplots()
187184
img = fill_spec(mfcc_arr, axes=ax,
188-
x_coords=bft_obj.x_coords(audio_len), x_axis='time',
189-
title='MFCC')
185+
x_coords=x_coords, x_axis='time',
186+
title='MFCC')
190187
fig.colorbar(img, ax=ax)
191188

192189
plt.show()
@@ -199,15 +196,14 @@ plt.show()
199196
Continuous Wavelet Transform spectrogram and its corresponding synchrosqueezing reassignment spectrogram
200197

201198
```python
202-
# Feature extraction example
203199
import numpy as np
204-
import matplotlib.pyplot as plt
205-
206200
import audioflux as af
207-
from audioflux.display import fill_spec
208201
from audioflux.type import SpectralFilterBankScaleType, WaveletContinueType
209202
from audioflux.utils import note_to_hz
210203

204+
import matplotlib.pyplot as plt
205+
from audioflux.display import fill_spec
206+
211207
# Get a 220Hz's audio file path
212208
sample_path = af.utils.sample_path('220')
213209

@@ -230,15 +226,15 @@ synsq_arr = synsq_obj.synsq(cwt_spec_arr,
230226
fre_arr=cwt_obj.get_fre_band_arr())
231227

232228
# Show CWT
233-
fig, ax = plt.subplots(figsize=(7,4))
229+
fig, ax = plt.subplots(figsize=(7, 4))
234230
img = fill_spec(np.abs(cwt_spec_arr), axes=ax,
235231
x_coords=cwt_obj.x_coords(),
236232
y_coords=cwt_obj.y_coords(),
237233
x_axis='time', y_axis='log',
238234
title='CWT')
239235
fig.colorbar(img, ax=ax)
240236
# Show Synsq
241-
fig, ax = plt.subplots(figsize=(7,4))
237+
fig, ax = plt.subplots(figsize=(7, 4))
242238
img = fill_spec(np.abs(synsq_arr), axes=ax,
243239
x_coords=cwt_obj.x_coords(),
244240
y_coords=cwt_obj.y_coords(),
@@ -276,11 +272,11 @@ Using PyPI:
276272
$ pip install audioflux
277273
```
278274

279-
<!--Using Anaconda:
275+
Using Anaconda:
280276

281277
```
282-
$ conda install -c conda-forge audioflux
283-
```-->
278+
$ conda install -c tanky25 -c conda-forge audioflux
279+
```
284280

285281

286282
<!--Read installation instructions:
@@ -303,7 +299,7 @@ Enter the **`audioFlux`** project **`scripts`** directory and switch to the curr
303299
$ ./build_iOS.sh
304300
```
305301

306-
Build and compile successfully, the project build compilation results are in the **`build`** folder
302+
Build and compile successfully, the project build compilation results are in the **`build`** folder
307303

308304
### Android build
309305

@@ -324,7 +320,7 @@ Enter the **`audioFlux`** project **`scripts`** directory and switch to the curr
324320
$ ./build_android.sh
325321
```
326322

327-
Build and compile successfully, the project build compilation results are in the **`build`** folder
323+
Build and compile successfully, the project build compilation results are in the **`build`** folder
328324

329325

330326
### Building from source
Collapse file

‎audioflux/__version__.py‎

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__title__ = 'audioflux'
22
__description__ = 'A library for audio and music analysis, feature extraction.'
3-
__version__ = '0.1.1'
3+
__version__ = '0.1.2'
Collapse file

‎audioflux/core.py‎

Copy file name to clipboardExpand all lines: audioflux/core.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ def vqt(X, num=84, samplate=32000, low_fre=note_to_hz('C1'), bin_per_octave=12,
11361136
>>> audio_arr, sr = af.read(audio_path)
11371137
11381138
Extract spectrogram of dB
1139+
11391140
>>> low_fre = af.utils.note_to_hz('C1')
11401141
>>> spec_arr, fre_band_arr = af.vqt(audio_arr, samplate=sr, low_fre=low_fre)
11411142
>>> spec_dB_arr = af.utils.power_to_db(spec_arr ** 2)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.