Skip to content

Commit

Permalink
Merge 0cfe11d into 699f6a2
Browse files Browse the repository at this point in the history
  • Loading branch information
rabitt committed May 30, 2017
2 parents 699f6a2 + 0cfe11d commit 77728f8
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ stems:
S02:
component: ''
filename: CountingCrows_AccidentallyInLove_STEM_02.wav
instrument: distorted electric guitar
instrument:
- distorted electric guitar
- acoustic guitar
- mandolin
raw:
R01:
filename: CountingCrows_AccidentallyInLove_RAW_02_01.wav
instrument: distorted electric guitar
instrument:
- distorted electric guitar
- acoustic guitar
- mandolin
R02:
filename: CountingCrows_AccidentallyInLove_RAW_02_02.wav
instrument: distorted electric guitar
instrument:
- distorted electric guitar
- acoustic guitar
- mandolin
S03:
component: bass
filename: CountingCrows_AccidentallyInLove_STEM_03.wav
Expand Down
20 changes: 15 additions & 5 deletions medleydb/data/Metadata/Inxs_NeedYouTonight_METADATA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,30 @@ stems:
S03:
component: ''
filename: Inxs_NeedYouTonight_STEM_03.wav
instrument: auxiliary percussion
instrument:
- auxiliary percussion
- Unlabeled
raw:
R01:
filename: Inxs_NeedYouTonight_RAW_03_01.wav
instrument: auxiliary percussion
instrument:
- auxiliary percussion
- Unlabeled
R02:
filename: Inxs_NeedYouTonight_RAW_03_02.wav
instrument: auxiliary percussion
instrument:
- auxiliary percussion
- Unlabeled
R03:
filename: Inxs_NeedYouTonight_RAW_03_03.wav
instrument: auxiliary percussion
instrument:
- auxiliary percussion
- Unlabeled
R04:
filename: Inxs_NeedYouTonight_RAW_03_04.wav
instrument: auxiliary percussion
instrument:
- auxiliary percussion
- Unlabeled
S04:
component: ''
filename: Inxs_NeedYouTonight_STEM_04.wav
Expand Down
2 changes: 1 addition & 1 deletion medleydb/data/Metadata/MileyCyrus_7Things_METADATA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ stems:
S03:
component: bass
filename: MileyCyrus_7Things_STEM_03.wav
instrument: Unlabeled
instrument: electric bass
raw:
R01:
filename: MileyCyrus_7Things_RAW_03_01.wav
Expand Down
12 changes: 9 additions & 3 deletions medleydb/data/Metadata/Misfits_AstroZombies_METADATA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,20 @@ stems:
S04:
component: melody
filename: Misfits_AstroZombies_STEM_04.wav
instrument: male singer
instrument:
- male singer
- vocalists
raw:
R01:
filename: Misfits_AstroZombies_RAW_04_01.wav
instrument: male singer
instrument:
- male singer
- vocalists
R02:
filename: Misfits_AstroZombies_RAW_04_02.wav
instrument: male singer
instrument:
- male singer
- vocalists
title: Astro Zombies
version: 1.2
website: ''
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,26 @@ stems:
S04:
component: ''
filename: TheAllAmericanRejects_DirtyLittleSecret_STEM_04.wav
instrument: distorted electric guitar
instrument:
- distorted electric guitar
- piano
- synthesizer
- tambourine
raw:
R01:
filename: TheAllAmericanRejects_DirtyLittleSecret_RAW_04_01.wav
instrument: distorted electric guitar
instrument:
- distorted electric guitar
- piano
- synthesizer
- tambourine
R02:
filename: TheAllAmericanRejects_DirtyLittleSecret_RAW_04_02.wav
instrument: distorted electric guitar
instrument:
- distorted electric guitar
- piano
- synthesizer
- tambourine
S05:
component: melody
filename: TheAllAmericanRejects_DirtyLittleSecret_STEM_05.wav
Expand Down
57 changes: 44 additions & 13 deletions medleydb/multitrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def stem_activations_v2(self):
if self._stem_activations_v2 is None:
(self._stem_activations_v2,
self._stem_activations_idx_v2
) = self._get_activation_annotations(version='v2')
) = self._get_activation_annotations(version='v2')
return self._stem_activations_v2

@property
Expand All @@ -351,7 +351,7 @@ def stem_activations_idx_v2(self):
if self._stem_activations_idx_v2 is None:
(self._stem_activations_v2,
self._stem_activations_idx_v2
) = self._get_activation_annotations(version='v2')
) = self._get_activation_annotations(version='v2')
return self._stem_activations_idx_v2

def _load_metadata(self):
Expand Down Expand Up @@ -402,19 +402,13 @@ def _parse_metadata(self):

file_id = "%s_STEM_%s" % (self.track_id, k[1:])

if self.mixing_coefficients is not None:
mix_coeff = (
self.mixing_coefficients['audio'][stem_idx] +
self.mixing_coefficients['stft'][stem_idx]
) * 0.5
else:
mix_coeff = None
mixing_coefficient = self._get_mixing_coefficient(stem_idx)

track = Track(instrument=instrument, audio_path=audio_path,
component=component, stem_idx=stem_idx,
ranking=ranking, mix_path=self.mix_path,
file_id=file_id,
mix_coeff=mix_coeff)
mixing_coefficient=mixing_coefficient)

stems[stem_idx] = track
raw_dict = stem_dict[k]['raw']
Expand All @@ -439,6 +433,43 @@ def _parse_metadata(self):

return stems, raw_audio

def _get_mixing_coefficient(self, stem_idx):
"""Get best availalbe mixing coefficient for a stem.
Parameters
----------
stem_idx : int
Stem index
Returns
-------
mixing_coefficient : float
Stem's mixing coefficient
"""
if self.mixing_coefficients is not None:
print(self.track_id)
print(self.mixing_coefficients.keys())
use_manual = (
'manual' in self.mixing_coefficients.keys() and
self.mixing_coefficients['manual'] != {}
)

if use_manual:
mixing_coefficient = (
self.mixing_coefficients['manual'][stem_idx]
)
else:
mixing_coefficient = (
self.mixing_coefficients['audio'][stem_idx] +
self.mixing_coefficients['stft'][stem_idx]
) * 0.5

else:
mixing_coefficient = None

return mixing_coefficient

def _get_melody_rankings(self):
"""Get rankings from the melody rankings annotation file.
Expand Down Expand Up @@ -645,7 +676,7 @@ class Track(object):
stem's component label, if exists.
ranking : int or None, default=None
The Track's melodic ranking
mix_coeff : float or None, default=None
mixing_coefficient : float or None, default=None
The Tracks's mixing coefficient
Attributes
Expand Down Expand Up @@ -684,7 +715,7 @@ class Track(object):
"""
def __init__(self, instrument, audio_path, stem_idx, mix_path,
file_id=None, raw_idx=None, component='', ranking=None,
mix_coeff=None):
mixing_coefficient=None):
"""Track object __init__ method.
"""
if isinstance(instrument, list):
Expand All @@ -710,7 +741,7 @@ def __init__(self, instrument, audio_path, stem_idx, mix_path,
self.pitch_pyin_path = None

self._duration = None
self.mixing_coefficient = mix_coeff
self.mixing_coefficient = mixing_coefficient

self.mix_path = mix_path
self._pitch_annotation = None
Expand Down
4 changes: 2 additions & 2 deletions medleydb/resources/instrument_f0_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@
"electronic organ": "p",
"synthesizer": "p",
"theremin": "m",
"fx/processed sound": "u",
"fx/processed sound": "p",
"scratches": "u",
"sampler": "p",
"snaps": "u",
"crowd": "m",
"crowd": "p",
"choir": "p",
"male screamer": "m",
"female screamer": "m",
Expand Down

0 comments on commit 77728f8

Please sign in to comment.