Welcome to musdb documentation!¶
API documentation¶
- class musdb.DB(root=None, setup_file=None, is_wav=False, download=False, subsets=['train', 'test'], split=None, sample_rate=None)[source]¶
- The musdb DB Object - Parameters:
- root (str, optional) – musdb Root path. If set to None it will be read from the MUSDB_PATH environment variable 
- subsets (list[str], optional) – select a _musdb_ subset train or test (defaults to both) 
- is_wav (boolean, optional) – expect subfolder with wav files for each source instead stems, defaults to False 
- download (boolean, optional) – download sample version of MUSDB18 which includes 7s excerpts, defaults to False 
- subsets – select a _musdb_ subset train or test. Default None loads [‘train’, ‘test’] 
- split (str, optional) – when subsets=train, split selects the train/validation split. split=’train’ loads the training split, `split=’valid’ loads the validation split. split=None applies no splitting. 
 
 - setup_file¶
- path to yaml file. default: setup.yaml - Type:
- str 
 
 - root¶
- musdb Root path. Default is MUSDB_PATH. In combination with download, this path will set the download destination and set to ‘~/musdb/’ by default. - Type:
- str 
 
 - sources_dir¶
- path to Sources directory - Type:
- str 
 
 - sources_names¶
- list of names of available sources - Type:
- list[str] 
 
 - targets_names¶
- list of names of available targets - Type:
- list[str] 
 
 - setup¶
- loaded yaml configuration - Type:
- Dict 
 
 - sample_rate¶
- sets sample rate for optional resampling. Defaults to none which results in 44100.0 - Type:
- Optional(Float) 
 
 - get_track_indices_by_names(names)[source]¶
- Returns musdb track indices by track name - Can be used to filter the musdb tracks for a validation subset by trackname - Parameters == == == == == names : list[str], optional - select tracks by a given str or list of tracknames - Returns:
- return a list of - TrackObjects
- Return type:
- list[int] 
 
 - get_validation_track_indices(validation_track_names=None)[source]¶
- Returns validation track indices by a given list of track names - Defaults to the builtin selection 8 validation tracks, defined in mus.yaml. - Parameters == == == == == validation_track_names : list[str], optional - validation track names by a given str or list of tracknames - Returns:
- return a list of validation track indices 
- Return type:
- list[int] 
 
 - load_mus_tracks(subsets=None, split=None)[source]¶
- Parses the musdb folder structure, returns list of Track objects - Parameters:
- subsets (list[str], optional) – select a _musdb_ subset train or test. Default None loads [train, test]. 
- split (str) – for subsets=’train’, split=’train applies a train/validation split. if split=’valid’ the validation split of the training subset will be used 
 
- Returns:
- return a list of - TrackObjects
- Return type:
- list[Track] 
 
 - save_estimates(user_estimates, track, estimates_dir, write_stems=False)[source]¶
- Writes user_estimates to disk while recreating the musdb file structure in that folder. - Parameters:
- user_estimates (Dict[np.array]) – the target estimates. 
- track (Track,) – musdb track object 
- estimates_dir (str,) – output folder name where to save the estimates. 
 
 
 
- class musdb.audio_classes.MultiTrack(path=None, name=None, artist=None, title=None, sources=None, targets=None, sample_rate=None, *args, **kwargs)[source]¶
- property stems¶
- [shape=(stems, num_samples, num_channels)] - Type:
- array_like 
 
 
- class musdb.audio_classes.Source(multitrack, name=None, path=None, stem_id=None, gain=1.0, *args, **kwargs)[source]¶
- An audio Target which is a linear mixture of several sources - name¶
- Name of this source - Type:
- str 
 
 - stem_id¶
- stem/substream ID is set here. - Type:
- int 
 
 - is_wav¶
- If stem is read from wav or mp4 stem - Type:
- boolean 
 
 - path¶
- Absolute path to audio file - Type:
- str 
 
 - gain¶
- Mixing weight for this source - Type:
- float 
 
 
- class musdb.audio_classes.Target(multitrack, sources, name=None)[source]¶
- An audio Target which is a linear mixture of several sources - property audio¶
- [shape=(num_samples, num_channels)] - mixes audio for targets on the fly - Type:
- array_like 
 
 
- class musdb.audio_classes.Track(path='None', is_wav=False, stem_id=None, subset=None, chunk_start=0, chunk_duration=None, sample_rate=None)[source]¶
- Generic audio Track that can be wav or stem file - name¶
- Track name - Type:
- str 
 
 - path¶
- Absolute path of mixture audio file - Type:
- str 
 
 - stem_id¶
- stem/substream ID - Type:
- int 
 
 - is_wav¶
- If stem is read from wav or mp4 stem - Type:
- boolean 
 
 - subset¶
- Track belongs to which subset. - Type:
- {‘train’, ‘test’} 
 
 - targets¶
- OrderedDict of mixted Targets for this - track.- Type:
- OrderedDict 
 
 - sources¶
- Dict of - Sourceobjects for this- track.- Type:
- Dict 
 
 - chunk_start¶
- sets offset when loading the audio, defaults to 0 (beginning). - Type:
- float 
 
 - chunk_duration¶
- sets duration for the audio, defaults to - None(end).- Type:
- float