Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.10.2.

librosa.frames_to_samples

librosa.frames_to_samples(frames, *, hop_length=512, n_fft=None)[source]

Convert frame indices to audio sample indices.

Parameters:
framesnumber or np.ndarray [shape=(n,)]

frame index or vector of frame indices

hop_lengthint > 0 [scalar]

number of samples between successive frames

n_fftNone or int > 0 [scalar]

Optional: length of the FFT window. If given, time conversion will include an offset of n_fft // 2 to counteract windowing effects when using a non-centered STFT.

Returns:
timesnumber or np.ndarray

time (in samples) of each given frame number:

times[i] = frames[i] * hop_length

See also

frames_to_time

convert frame indices to time values

samples_to_frames

convert sample indices to frame indices

Examples

>>> y, sr = librosa.load(librosa.ex('choice'))
>>> tempo, beats = librosa.beat.beat_track(y=y, sr=sr)
>>> beat_samples = librosa.frames_to_samples(beats)