Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
musicinformationretrieval-com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
A.S.
musicinformationretrieval-com
Commits
dc9b8060
Commit
dc9b8060
authored
Jun 13, 2016
by
Steve Tjoa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
download=True option
parent
80f5cb83
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
13 deletions
+26
-13
core.py
stanford_mir/core.py
+26
-13
No files found.
stanford_mir/core.py
View file @
dc9b8060
...
@@ -64,7 +64,7 @@ def get_features(collection='drum_samples_train',
...
@@ -64,7 +64,7 @@ def get_features(collection='drum_samples_train',
return
test_features
,
labels
,
scaler
return
test_features
,
labels
,
scaler
def
download_samples
(
collection
=
'drum_samples_train'
):
def
download_samples
(
collection
=
'drum_samples_train'
,
download
=
True
):
"""Download ten kick drum samples and ten snare drum samples.
"""Download ten kick drum samples and ten snare drum samples.
`collection`: output directory containing the twenty drum samples
`collection`: output directory containing the twenty drum samples
...
@@ -80,23 +80,36 @@ def download_samples(collection='drum_samples_train'):
...
@@ -80,23 +80,36 @@ def download_samples(collection='drum_samples_train'):
except
OSError
as
exception
:
except
OSError
as
exception
:
if
exception
.
errno
!=
errno
.
EEXIST
:
if
exception
.
errno
!=
errno
.
EEXIST
:
raise
raise
else
:
print
"Directory
%
s already exists."
%
collection
if
collection
==
'drum_samples_train'
:
if
collection
==
'drum_samples_train'
:
for
drum_type
in
[
'kick'
,
'snare'
]:
if
download
:
for
i
in
range
(
1
,
11
):
for
drum_type
in
[
'kick'
,
'snare'
]:
filename
=
'
%
s_
%02
d.wav'
%
(
drum_type
,
i
)
for
i
in
range
(
1
,
11
):
urllib
.
urlretrieve
(
'http://audio.musicinformationretrieval.com/drum_samples/
%
s'
%
filename
,
filename
=
'
%
s_
%02
d.wav'
%
(
drum_type
,
i
)
filename
=
os
.
path
.
join
(
collection
,
filename
))
urllib
.
urlretrieve
(
'http://audio.musicinformationretrieval.com/drum_samples/
%
s'
%
filename
,
filename
=
os
.
path
.
join
(
collection
,
filename
))
kick_filepaths
=
[
os
.
path
.
join
(
collection
,
'kick_
%02
d.wav'
%
i
)
for
i
in
range
(
1
,
11
)]
kick_filepaths
=
[
os
.
path
.
join
(
collection
,
'kick_
%02
d.wav'
%
i
)
for
i
in
range
(
1
,
11
)]
snare_filepaths
=
[
os
.
path
.
join
(
collection
,
'snare_
%02
d.wav'
%
i
)
for
i
in
range
(
1
,
11
)]
snare_filepaths
=
[
os
.
path
.
join
(
collection
,
'snare_
%02
d.wav'
%
i
)
for
i
in
range
(
1
,
11
)]
return
kick_filepaths
,
snare_filepaths
return
kick_filepaths
,
snare_filepaths
elif
collection
==
'drum_samples_test'
:
elif
collection
==
'drum_samples_test'
:
for
drum_type
in
[
'kick'
,
'snare'
]:
if
download
:
for
i
in
range
(
30
):
for
drum_type
in
[
'kick'
,
'snare'
]:
filename
=
'
%
s_
%02
d.wav'
%
(
drum_type
,
i
)
for
i
in
range
(
30
):
urllib
.
urlretrieve
(
'http://audio.musicinformationretrieval.com/drum_samples/test/
%
s'
%
filename
,
filename
=
'
%
s_
%02
d.wav'
%
(
drum_type
,
i
)
filename
=
os
.
path
.
join
(
collection
,
filename
))
urllib
.
urlretrieve
(
'http://audio.musicinformationretrieval.com/drum_samples/test/
%
s'
%
filename
,
filename
=
os
.
path
.
join
(
collection
,
filename
))
kick_filepaths
=
[
os
.
path
.
join
(
collection
,
'kick_
%02
d.wav'
%
i
)
for
i
in
range
(
30
)]
kick_filepaths
=
[
os
.
path
.
join
(
collection
,
'kick_
%02
d.wav'
%
i
)
for
i
in
range
(
30
)]
snare_filepaths
=
[
os
.
path
.
join
(
collection
,
'snare_
%02
d.wav'
%
i
)
for
i
in
range
(
30
)]
snare_filepaths
=
[
os
.
path
.
join
(
collection
,
'snare_
%02
d.wav'
%
i
)
for
i
in
range
(
30
)]
return
kick_filepaths
,
snare_filepaths
return
kick_filepaths
,
snare_filepaths
elif
collection
==
'violin_samples_train'
:
urllib
.
urlretrieve
(
'http://audio.musicinformationretrieval.com/violin_samples_train/list.txt'
,
filename
=
os
.
path
.
join
(
collection
,
'list.txt'
))
for
line
in
open
(
os
.
path
.
join
(
collection
,
'list.txt'
),
'r'
):
filename
=
line
.
strip
()
print
filename
if
filename
.
endswith
(
'.wav'
):
urllib
.
urlretrieve
(
'http://audio.musicinformationretrieval.com/'
+
filename
,
filename
=
filename
)
return
[
os
.
path
.
join
(
collection
,
f
)
for
f
in
os
.
listdir
(
collection
)]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment