General Utilities¶
-
asmd.utils.f0_to_midi_pitch(f0)[source]¶ Return a midi pitch (in 0-127) given a frequency value in Hz
-
asmd.utils.frame2time(frame: int, hop_size=3072, win_len=4096) → float[source]¶ Takes frame index (int) and returns the corresponding central sample The output will use the same unity of measure as
hop_sizeandwin_len(e.g. samples or seconds). Indices start from 0.Returns a float!
-
asmd.utils.mat2midipath(mat, path)[source]¶ Writes a midi file from a mat like asmd:
pitch, start (sec), end (sec), velocity
If mat is empty, just do nothing.
-
asmd.utils.mat_stretch(mat, target)[source]¶ Changes times of mat in-place so that it has the same average BPM and initial time as target.
Returns mat changed in-place.
-
asmd.utils.midipath2mat(path)[source]¶ Open a midi file with one instrument track and construct a mat like asmd:
pitch, start (sec), end (sec), velocity
Rows are sorted by onset, pitch and offset (in this order)
-
asmd.utils.nframes(dur, hop_size=3072, win_len=4096) → float[source]¶ Compute the numbero of frames given a total duration, the hop size and window length. Output unitiy of measure will be the same as the inputs unity of measure (e.g. samples or seconds).
N.B. This returns a float!
-
asmd.utils.open_audio(audio_fn: Union[str, pathlib.Path]) → Tuple[numpy.ndarray, int][source]¶ Open the audio file in audio_fn and returns a numpy array containing it, one row for each channel (only Mono supported for now) and the orginal sample_rate
-
asmd.utils.time2frame(time, hop_size=3072, win_len=4096) → int[source]¶ Takes a time position and outputs the best frame representing it. The input must use the same unity of measure for
time,hop_size, andwin_len(e.g. samples or seconds). Indices start from 0.Returns and int!