partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | time_to_frames | Converts time stamps into STFT frames.
Parameters
----------
times : np.ndarray [shape=(n,)]
time (in seconds) or vector of time values
sr : number > 0 [scalar]
audio sampling rate
hop_length : int > 0 [scalar]
number of samples between successive frames
n_fft : None ... | librosa/core/time_frequency.py | def time_to_frames(times, sr=22050, hop_length=512, n_fft=None):
"""Converts time stamps into STFT frames.
Parameters
----------
times : np.ndarray [shape=(n,)]
time (in seconds) or vector of time values
sr : number > 0 [scalar]
audio sampling rate
hop_length : int > 0 [scalar... | def time_to_frames(times, sr=22050, hop_length=512, n_fft=None):
"""Converts time stamps into STFT frames.
Parameters
----------
times : np.ndarray [shape=(n,)]
time (in seconds) or vector of time values
sr : number > 0 [scalar]
audio sampling rate
hop_length : int > 0 [scalar... | [
"Converts",
"time",
"stamps",
"into",
"STFT",
"frames",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L165-L209 | [
"def",
"time_to_frames",
"(",
"times",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"n_fft",
"=",
"None",
")",
":",
"samples",
"=",
"time_to_samples",
"(",
"times",
",",
"sr",
"=",
"sr",
")",
"return",
"samples_to_frames",
"(",
"samples",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | note_to_midi | Convert one or more spelled notes to MIDI number(s).
Notes may be spelled out with optional accidentals or octave numbers.
The leading note name is case-insensitive.
Sharps are indicated with ``#``, flats may be indicated with ``!`` or ``b``.
Parameters
----------
note : str or iterable of s... | librosa/core/time_frequency.py | def note_to_midi(note, round_midi=True):
'''Convert one or more spelled notes to MIDI number(s).
Notes may be spelled out with optional accidentals or octave numbers.
The leading note name is case-insensitive.
Sharps are indicated with ``#``, flats may be indicated with ``!`` or ``b``.
Parameter... | def note_to_midi(note, round_midi=True):
'''Convert one or more spelled notes to MIDI number(s).
Notes may be spelled out with optional accidentals or octave numbers.
The leading note name is case-insensitive.
Sharps are indicated with ``#``, flats may be indicated with ``!`` or ``b``.
Parameter... | [
"Convert",
"one",
"or",
"more",
"spelled",
"notes",
"to",
"MIDI",
"number",
"(",
"s",
")",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L319-L404 | [
"def",
"note_to_midi",
"(",
"note",
",",
"round_midi",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"note",
",",
"six",
".",
"string_types",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"note_to_midi",
"(",
"n",
",",
"round_midi",
"=",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | midi_to_note | Convert one or more MIDI numbers to note strings.
MIDI numbers will be rounded to the nearest integer.
Notes will be of the format 'C0', 'C#0', 'D0', ...
Examples
--------
>>> librosa.midi_to_note(0)
'C-1'
>>> librosa.midi_to_note(37)
'C#2'
>>> librosa.midi_to_note(-2)
'A#-2'
... | librosa/core/time_frequency.py | def midi_to_note(midi, octave=True, cents=False):
'''Convert one or more MIDI numbers to note strings.
MIDI numbers will be rounded to the nearest integer.
Notes will be of the format 'C0', 'C#0', 'D0', ...
Examples
--------
>>> librosa.midi_to_note(0)
'C-1'
>>> librosa.midi_to_note(3... | def midi_to_note(midi, octave=True, cents=False):
'''Convert one or more MIDI numbers to note strings.
MIDI numbers will be rounded to the nearest integer.
Notes will be of the format 'C0', 'C#0', 'D0', ...
Examples
--------
>>> librosa.midi_to_note(0)
'C-1'
>>> librosa.midi_to_note(3... | [
"Convert",
"one",
"or",
"more",
"MIDI",
"numbers",
"to",
"note",
"strings",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L407-L478 | [
"def",
"midi_to_note",
"(",
"midi",
",",
"octave",
"=",
"True",
",",
"cents",
"=",
"False",
")",
":",
"if",
"cents",
"and",
"not",
"octave",
":",
"raise",
"ParameterError",
"(",
"'Cannot encode cents without octave information.'",
")",
"if",
"not",
"np",
".",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | hz_to_mel | Convert Hz to Mels
Examples
--------
>>> librosa.hz_to_mel(60)
0.9
>>> librosa.hz_to_mel([110, 220, 440])
array([ 1.65, 3.3 , 6.6 ])
Parameters
----------
frequencies : number or np.ndarray [shape=(n,)] , float
scalar or array of frequencies
htk : bool
... | librosa/core/time_frequency.py | def hz_to_mel(frequencies, htk=False):
"""Convert Hz to Mels
Examples
--------
>>> librosa.hz_to_mel(60)
0.9
>>> librosa.hz_to_mel([110, 220, 440])
array([ 1.65, 3.3 , 6.6 ])
Parameters
----------
frequencies : number or np.ndarray [shape=(n,)] , float
scalar or arr... | def hz_to_mel(frequencies, htk=False):
"""Convert Hz to Mels
Examples
--------
>>> librosa.hz_to_mel(60)
0.9
>>> librosa.hz_to_mel([110, 220, 440])
array([ 1.65, 3.3 , 6.6 ])
Parameters
----------
frequencies : number or np.ndarray [shape=(n,)] , float
scalar or arr... | [
"Convert",
"Hz",
"to",
"Mels"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L591-L643 | [
"def",
"hz_to_mel",
"(",
"frequencies",
",",
"htk",
"=",
"False",
")",
":",
"frequencies",
"=",
"np",
".",
"asanyarray",
"(",
"frequencies",
")",
"if",
"htk",
":",
"return",
"2595.0",
"*",
"np",
".",
"log10",
"(",
"1.0",
"+",
"frequencies",
"/",
"700.0... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | mel_to_hz | Convert mel bin numbers to frequencies
Examples
--------
>>> librosa.mel_to_hz(3)
200.
>>> librosa.mel_to_hz([1,2,3,4,5])
array([ 66.667, 133.333, 200. , 266.667, 333.333])
Parameters
----------
mels : np.ndarray [shape=(n,)], float
mel bins to convert
... | librosa/core/time_frequency.py | def mel_to_hz(mels, htk=False):
"""Convert mel bin numbers to frequencies
Examples
--------
>>> librosa.mel_to_hz(3)
200.
>>> librosa.mel_to_hz([1,2,3,4,5])
array([ 66.667, 133.333, 200. , 266.667, 333.333])
Parameters
----------
mels : np.ndarray [shape=(n,)],... | def mel_to_hz(mels, htk=False):
"""Convert mel bin numbers to frequencies
Examples
--------
>>> librosa.mel_to_hz(3)
200.
>>> librosa.mel_to_hz([1,2,3,4,5])
array([ 66.667, 133.333, 200. , 266.667, 333.333])
Parameters
----------
mels : np.ndarray [shape=(n,)],... | [
"Convert",
"mel",
"bin",
"numbers",
"to",
"frequencies"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L646-L697 | [
"def",
"mel_to_hz",
"(",
"mels",
",",
"htk",
"=",
"False",
")",
":",
"mels",
"=",
"np",
".",
"asanyarray",
"(",
"mels",
")",
"if",
"htk",
":",
"return",
"700.0",
"*",
"(",
"10.0",
"**",
"(",
"mels",
"/",
"2595.0",
")",
"-",
"1.0",
")",
"# Fill in... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | hz_to_octs | Convert frequencies (Hz) to (fractional) octave numbers.
Examples
--------
>>> librosa.hz_to_octs(440.0)
4.
>>> librosa.hz_to_octs([32, 64, 128, 256])
array([ 0.219, 1.219, 2.219, 3.219])
Parameters
----------
frequencies : number >0 or np.ndarray [shape=(n,)] or float
... | librosa/core/time_frequency.py | def hz_to_octs(frequencies, A440=440.0):
"""Convert frequencies (Hz) to (fractional) octave numbers.
Examples
--------
>>> librosa.hz_to_octs(440.0)
4.
>>> librosa.hz_to_octs([32, 64, 128, 256])
array([ 0.219, 1.219, 2.219, 3.219])
Parameters
----------
frequencies : numbe... | def hz_to_octs(frequencies, A440=440.0):
"""Convert frequencies (Hz) to (fractional) octave numbers.
Examples
--------
>>> librosa.hz_to_octs(440.0)
4.
>>> librosa.hz_to_octs([32, 64, 128, 256])
array([ 0.219, 1.219, 2.219, 3.219])
Parameters
----------
frequencies : numbe... | [
"Convert",
"frequencies",
"(",
"Hz",
")",
"to",
"(",
"fractional",
")",
"octave",
"numbers",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L700-L726 | [
"def",
"hz_to_octs",
"(",
"frequencies",
",",
"A440",
"=",
"440.0",
")",
":",
"return",
"np",
".",
"log2",
"(",
"np",
".",
"asanyarray",
"(",
"frequencies",
")",
"/",
"(",
"float",
"(",
"A440",
")",
"/",
"16",
")",
")"
] | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | fft_frequencies | Alternative implementation of `np.fft.fftfreq`
Parameters
----------
sr : number > 0 [scalar]
Audio sampling rate
n_fft : int > 0 [scalar]
FFT window size
Returns
-------
freqs : np.ndarray [shape=(1 + n_fft/2,)]
Frequencies `(0, sr/n_fft, 2*sr/n_fft, ..., sr/2)`
... | librosa/core/time_frequency.py | def fft_frequencies(sr=22050, n_fft=2048):
'''Alternative implementation of `np.fft.fftfreq`
Parameters
----------
sr : number > 0 [scalar]
Audio sampling rate
n_fft : int > 0 [scalar]
FFT window size
Returns
-------
freqs : np.ndarray [shape=(1 + n_fft/2,)]
F... | def fft_frequencies(sr=22050, n_fft=2048):
'''Alternative implementation of `np.fft.fftfreq`
Parameters
----------
sr : number > 0 [scalar]
Audio sampling rate
n_fft : int > 0 [scalar]
FFT window size
Returns
-------
freqs : np.ndarray [shape=(1 + n_fft/2,)]
F... | [
"Alternative",
"implementation",
"of",
"np",
".",
"fft",
".",
"fftfreq"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L760-L789 | [
"def",
"fft_frequencies",
"(",
"sr",
"=",
"22050",
",",
"n_fft",
"=",
"2048",
")",
":",
"return",
"np",
".",
"linspace",
"(",
"0",
",",
"float",
"(",
"sr",
")",
"/",
"2",
",",
"int",
"(",
"1",
"+",
"n_fft",
"//",
"2",
")",
",",
"endpoint",
"=",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | cqt_frequencies | Compute the center frequencies of Constant-Q bins.
Examples
--------
>>> # Get the CQT frequencies for 24 notes, starting at C2
>>> librosa.cqt_frequencies(24, fmin=librosa.note_to_hz('C2'))
array([ 65.406, 69.296, 73.416, 77.782, 82.407, 87.307,
92.499, 97.999, 103.826, ... | librosa/core/time_frequency.py | def cqt_frequencies(n_bins, fmin, bins_per_octave=12, tuning=0.0):
"""Compute the center frequencies of Constant-Q bins.
Examples
--------
>>> # Get the CQT frequencies for 24 notes, starting at C2
>>> librosa.cqt_frequencies(24, fmin=librosa.note_to_hz('C2'))
array([ 65.406, 69.296, 73.41... | def cqt_frequencies(n_bins, fmin, bins_per_octave=12, tuning=0.0):
"""Compute the center frequencies of Constant-Q bins.
Examples
--------
>>> # Get the CQT frequencies for 24 notes, starting at C2
>>> librosa.cqt_frequencies(24, fmin=librosa.note_to_hz('C2'))
array([ 65.406, 69.296, 73.41... | [
"Compute",
"the",
"center",
"frequencies",
"of",
"Constant",
"-",
"Q",
"bins",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L792-L827 | [
"def",
"cqt_frequencies",
"(",
"n_bins",
",",
"fmin",
",",
"bins_per_octave",
"=",
"12",
",",
"tuning",
"=",
"0.0",
")",
":",
"correction",
"=",
"2.0",
"**",
"(",
"float",
"(",
"tuning",
")",
"/",
"bins_per_octave",
")",
"frequencies",
"=",
"2.0",
"**",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | mel_frequencies | Compute an array of acoustic frequencies tuned to the mel scale.
The mel scale is a quasi-logarithmic function of acoustic frequency
designed such that perceptually similar pitch intervals (e.g. octaves)
appear equal in width over the full hearing range.
Because the definition of the mel scale is cond... | librosa/core/time_frequency.py | def mel_frequencies(n_mels=128, fmin=0.0, fmax=11025.0, htk=False):
"""Compute an array of acoustic frequencies tuned to the mel scale.
The mel scale is a quasi-logarithmic function of acoustic frequency
designed such that perceptually similar pitch intervals (e.g. octaves)
appear equal in width over t... | def mel_frequencies(n_mels=128, fmin=0.0, fmax=11025.0, htk=False):
"""Compute an array of acoustic frequencies tuned to the mel scale.
The mel scale is a quasi-logarithmic function of acoustic frequency
designed such that perceptually similar pitch intervals (e.g. octaves)
appear equal in width over t... | [
"Compute",
"an",
"array",
"of",
"acoustic",
"frequencies",
"tuned",
"to",
"the",
"mel",
"scale",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L830-L914 | [
"def",
"mel_frequencies",
"(",
"n_mels",
"=",
"128",
",",
"fmin",
"=",
"0.0",
",",
"fmax",
"=",
"11025.0",
",",
"htk",
"=",
"False",
")",
":",
"# 'Center freqs' of mel bands - uniformly spaced between limits",
"min_mel",
"=",
"hz_to_mel",
"(",
"fmin",
",",
"htk"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | tempo_frequencies | Compute the frequencies (in beats-per-minute) corresponding
to an onset auto-correlation or tempogram matrix.
Parameters
----------
n_bins : int > 0
The number of lag bins
hop_length : int > 0
The number of samples between each bin
sr : number > 0
The audio sampling ra... | librosa/core/time_frequency.py | def tempo_frequencies(n_bins, hop_length=512, sr=22050):
'''Compute the frequencies (in beats-per-minute) corresponding
to an onset auto-correlation or tempogram matrix.
Parameters
----------
n_bins : int > 0
The number of lag bins
hop_length : int > 0
The number of samples bet... | def tempo_frequencies(n_bins, hop_length=512, sr=22050):
'''Compute the frequencies (in beats-per-minute) corresponding
to an onset auto-correlation or tempogram matrix.
Parameters
----------
n_bins : int > 0
The number of lag bins
hop_length : int > 0
The number of samples bet... | [
"Compute",
"the",
"frequencies",
"(",
"in",
"beats",
"-",
"per",
"-",
"minute",
")",
"corresponding",
"to",
"an",
"onset",
"auto",
"-",
"correlation",
"or",
"tempogram",
"matrix",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L917-L953 | [
"def",
"tempo_frequencies",
"(",
"n_bins",
",",
"hop_length",
"=",
"512",
",",
"sr",
"=",
"22050",
")",
":",
"bin_frequencies",
"=",
"np",
".",
"zeros",
"(",
"int",
"(",
"n_bins",
")",
",",
"dtype",
"=",
"np",
".",
"float",
")",
"bin_frequencies",
"[",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | A_weighting | Compute the A-weighting of a set of frequencies.
Parameters
----------
frequencies : scalar or np.ndarray [shape=(n,)]
One or more frequencies (in Hz)
min_db : float [scalar] or None
Clip weights below this threshold.
If `None`, no clipping is performed.
Returns
------... | librosa/core/time_frequency.py | def A_weighting(frequencies, min_db=-80.0): # pylint: disable=invalid-name
'''Compute the A-weighting of a set of frequencies.
Parameters
----------
frequencies : scalar or np.ndarray [shape=(n,)]
One or more frequencies (in Hz)
min_db : float [scalar] or None
Clip weights belo... | def A_weighting(frequencies, min_db=-80.0): # pylint: disable=invalid-name
'''Compute the A-weighting of a set of frequencies.
Parameters
----------
frequencies : scalar or np.ndarray [shape=(n,)]
One or more frequencies (in Hz)
min_db : float [scalar] or None
Clip weights belo... | [
"Compute",
"the",
"A",
"-",
"weighting",
"of",
"a",
"set",
"of",
"frequencies",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L957-L1011 | [
"def",
"A_weighting",
"(",
"frequencies",
",",
"min_db",
"=",
"-",
"80.0",
")",
":",
"# pylint: disable=invalid-name",
"# Vectorize to make our lives easier",
"frequencies",
"=",
"np",
".",
"asanyarray",
"(",
"frequencies",
")",
"# Pre-compute squared frequency",
"f_sq",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | times_like | Return an array of time values to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X represents the number of frames.
sr : number > 0 [scalar]
a... | librosa/core/time_frequency.py | def times_like(X, sr=22050, hop_length=512, n_fft=None, axis=-1):
"""Return an array of time values to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X... | def times_like(X, sr=22050, hop_length=512, n_fft=None, axis=-1):
"""Return an array of time values to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X... | [
"Return",
"an",
"array",
"of",
"time",
"values",
"to",
"match",
"the",
"time",
"axis",
"from",
"a",
"feature",
"matrix",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L1014-L1067 | [
"def",
"times_like",
"(",
"X",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"n_fft",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
")",
":",
"samples",
"=",
"samples_like",
"(",
"X",
",",
"hop_length",
"=",
"hop_length",
",",
"n_fft",
"=... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | samples_like | Return an array of sample indices to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X represents the number of frames.
hop_length : int > 0 [scalar]
... | librosa/core/time_frequency.py | def samples_like(X, hop_length=512, n_fft=None, axis=-1):
"""Return an array of sample indices to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X repr... | def samples_like(X, hop_length=512, n_fft=None, axis=-1):
"""Return an array of sample indices to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X repr... | [
"Return",
"an",
"array",
"of",
"sample",
"indices",
"to",
"match",
"the",
"time",
"axis",
"from",
"a",
"feature",
"matrix",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L1070-L1121 | [
"def",
"samples_like",
"(",
"X",
",",
"hop_length",
"=",
"512",
",",
"n_fft",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"X",
")",
":",
"frames",
"=",
"np",
".",
"arange",
"(",
"X",
")",
"else",
":",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | cqt | Compute the constant-Q transform of an audio signal.
This implementation is based on the recursive sub-sampling method
described by [1]_.
.. [1] Schoerkhuber, Christian, and Anssi Klapuri.
"Constant-Q transform toolbox for music processing."
7th Sound and Music Computing Conference, Barcel... | librosa/core/constantq.py | def cqt(y, sr=22050, hop_length=512, fmin=None, n_bins=84,
bins_per_octave=12, tuning=0.0, filter_scale=1,
norm=1, sparsity=0.01, window='hann',
scale=True, pad_mode='reflect', res_type=None):
'''Compute the constant-Q transform of an audio signal.
This implementation is based on the re... | def cqt(y, sr=22050, hop_length=512, fmin=None, n_bins=84,
bins_per_octave=12, tuning=0.0, filter_scale=1,
norm=1, sparsity=0.01, window='hann',
scale=True, pad_mode='reflect', res_type=None):
'''Compute the constant-Q transform of an audio signal.
This implementation is based on the re... | [
"Compute",
"the",
"constant",
"-",
"Q",
"transform",
"of",
"an",
"audio",
"signal",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L24-L278 | [
"def",
"cqt",
"(",
"y",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"fmin",
"=",
"None",
",",
"n_bins",
"=",
"84",
",",
"bins_per_octave",
"=",
"12",
",",
"tuning",
"=",
"0.0",
",",
"filter_scale",
"=",
"1",
",",
"norm",
"=",
"1"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | hybrid_cqt | Compute the hybrid constant-Q transform of an audio signal.
Here, the hybrid CQT uses the pseudo CQT for higher frequencies where
the hop_length is longer than half the filter length and the full CQT
for lower frequencies.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time se... | librosa/core/constantq.py | def hybrid_cqt(y, sr=22050, hop_length=512, fmin=None, n_bins=84,
bins_per_octave=12, tuning=0.0, filter_scale=1,
norm=1, sparsity=0.01, window='hann', scale=True,
pad_mode='reflect', res_type=None):
'''Compute the hybrid constant-Q transform of an audio signal.
Her... | def hybrid_cqt(y, sr=22050, hop_length=512, fmin=None, n_bins=84,
bins_per_octave=12, tuning=0.0, filter_scale=1,
norm=1, sparsity=0.01, window='hann', scale=True,
pad_mode='reflect', res_type=None):
'''Compute the hybrid constant-Q transform of an audio signal.
Her... | [
"Compute",
"the",
"hybrid",
"constant",
"-",
"Q",
"transform",
"of",
"an",
"audio",
"signal",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L282-L422 | [
"def",
"hybrid_cqt",
"(",
"y",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"fmin",
"=",
"None",
",",
"n_bins",
"=",
"84",
",",
"bins_per_octave",
"=",
"12",
",",
"tuning",
"=",
"0.0",
",",
"filter_scale",
"=",
"1",
",",
"norm",
"="... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | pseudo_cqt | Compute the pseudo constant-Q transform of an audio signal.
This uses a single fft size that is the smallest power of 2 that is greater
than or equal to the max of:
1. The longest CQT filter
2. 2x the hop_length
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time ... | librosa/core/constantq.py | def pseudo_cqt(y, sr=22050, hop_length=512, fmin=None, n_bins=84,
bins_per_octave=12, tuning=0.0, filter_scale=1,
norm=1, sparsity=0.01, window='hann', scale=True,
pad_mode='reflect'):
'''Compute the pseudo constant-Q transform of an audio signal.
This uses a single... | def pseudo_cqt(y, sr=22050, hop_length=512, fmin=None, n_bins=84,
bins_per_octave=12, tuning=0.0, filter_scale=1,
norm=1, sparsity=0.01, window='hann', scale=True,
pad_mode='reflect'):
'''Compute the pseudo constant-Q transform of an audio signal.
This uses a single... | [
"Compute",
"the",
"pseudo",
"constant",
"-",
"Q",
"transform",
"of",
"an",
"audio",
"signal",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L426-L534 | [
"def",
"pseudo_cqt",
"(",
"y",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"fmin",
"=",
"None",
",",
"n_bins",
"=",
"84",
",",
"bins_per_octave",
"=",
"12",
",",
"tuning",
"=",
"0.0",
",",
"filter_scale",
"=",
"1",
",",
"norm",
"="... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | icqt | Compute the inverse constant-Q transform.
Given a constant-Q transform representation `C` of an audio signal `y`,
this function produces an approximation `y_hat`.
Parameters
----------
C : np.ndarray, [shape=(n_bins, n_frames)]
Constant-Q representation as produced by `core.cqt`
hop_... | librosa/core/constantq.py | def icqt(C, sr=22050, hop_length=512, fmin=None, bins_per_octave=12,
tuning=0.0, filter_scale=1, norm=1, sparsity=0.01, window='hann',
scale=True, length=None, amin=util.Deprecated(), res_type='fft'):
'''Compute the inverse constant-Q transform.
Given a constant-Q transform representation `C`... | def icqt(C, sr=22050, hop_length=512, fmin=None, bins_per_octave=12,
tuning=0.0, filter_scale=1, norm=1, sparsity=0.01, window='hann',
scale=True, length=None, amin=util.Deprecated(), res_type='fft'):
'''Compute the inverse constant-Q transform.
Given a constant-Q transform representation `C`... | [
"Compute",
"the",
"inverse",
"constant",
"-",
"Q",
"transform",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L538-L703 | [
"def",
"icqt",
"(",
"C",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"fmin",
"=",
"None",
",",
"bins_per_octave",
"=",
"12",
",",
"tuning",
"=",
"0.0",
",",
"filter_scale",
"=",
"1",
",",
"norm",
"=",
"1",
",",
"sparsity",
"=",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __cqt_filter_fft | Generate the frequency domain constant-Q filter basis. | librosa/core/constantq.py | def __cqt_filter_fft(sr, fmin, n_bins, bins_per_octave, tuning,
filter_scale, norm, sparsity, hop_length=None,
window='hann'):
'''Generate the frequency domain constant-Q filter basis.'''
basis, lengths = filters.constant_q(sr,
f... | def __cqt_filter_fft(sr, fmin, n_bins, bins_per_octave, tuning,
filter_scale, norm, sparsity, hop_length=None,
window='hann'):
'''Generate the frequency domain constant-Q filter basis.'''
basis, lengths = filters.constant_q(sr,
f... | [
"Generate",
"the",
"frequency",
"domain",
"constant",
"-",
"Q",
"filter",
"basis",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L707-L740 | [
"def",
"__cqt_filter_fft",
"(",
"sr",
",",
"fmin",
",",
"n_bins",
",",
"bins_per_octave",
",",
"tuning",
",",
"filter_scale",
",",
"norm",
",",
"sparsity",
",",
"hop_length",
"=",
"None",
",",
"window",
"=",
"'hann'",
")",
":",
"basis",
",",
"lengths",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __trim_stack | Helper function to trim and stack a collection of CQT responses | librosa/core/constantq.py | def __trim_stack(cqt_resp, n_bins):
'''Helper function to trim and stack a collection of CQT responses'''
# cleanup any framing errors at the boundaries
max_col = min(x.shape[1] for x in cqt_resp)
cqt_resp = np.vstack([x[:, :max_col] for x in cqt_resp][::-1])
# Finally, clip out any bottom freque... | def __trim_stack(cqt_resp, n_bins):
'''Helper function to trim and stack a collection of CQT responses'''
# cleanup any framing errors at the boundaries
max_col = min(x.shape[1] for x in cqt_resp)
cqt_resp = np.vstack([x[:, :max_col] for x in cqt_resp][::-1])
# Finally, clip out any bottom freque... | [
"Helper",
"function",
"to",
"trim",
"and",
"stack",
"a",
"collection",
"of",
"CQT",
"responses"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L743-L753 | [
"def",
"__trim_stack",
"(",
"cqt_resp",
",",
"n_bins",
")",
":",
"# cleanup any framing errors at the boundaries",
"max_col",
"=",
"min",
"(",
"x",
".",
"shape",
"[",
"1",
"]",
"for",
"x",
"in",
"cqt_resp",
")",
"cqt_resp",
"=",
"np",
".",
"vstack",
"(",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __cqt_response | Compute the filter response with a target STFT hop. | librosa/core/constantq.py | def __cqt_response(y, n_fft, hop_length, fft_basis, mode):
'''Compute the filter response with a target STFT hop.'''
# Compute the STFT matrix
D = stft(y, n_fft=n_fft, hop_length=hop_length,
window='ones',
pad_mode=mode)
# And filter response energy
return fft_basis.dot(D... | def __cqt_response(y, n_fft, hop_length, fft_basis, mode):
'''Compute the filter response with a target STFT hop.'''
# Compute the STFT matrix
D = stft(y, n_fft=n_fft, hop_length=hop_length,
window='ones',
pad_mode=mode)
# And filter response energy
return fft_basis.dot(D... | [
"Compute",
"the",
"filter",
"response",
"with",
"a",
"target",
"STFT",
"hop",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L756-L765 | [
"def",
"__cqt_response",
"(",
"y",
",",
"n_fft",
",",
"hop_length",
",",
"fft_basis",
",",
"mode",
")",
":",
"# Compute the STFT matrix",
"D",
"=",
"stft",
"(",
"y",
",",
"n_fft",
"=",
"n_fft",
",",
"hop_length",
"=",
"hop_length",
",",
"window",
"=",
"'... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __early_downsample_count | Compute the number of early downsampling operations | librosa/core/constantq.py | def __early_downsample_count(nyquist, filter_cutoff, hop_length, n_octaves):
'''Compute the number of early downsampling operations'''
downsample_count1 = max(0, int(np.ceil(np.log2(audio.BW_FASTEST * nyquist /
filter_cutoff)) - 1) - 1)
num_twos = __num_t... | def __early_downsample_count(nyquist, filter_cutoff, hop_length, n_octaves):
'''Compute the number of early downsampling operations'''
downsample_count1 = max(0, int(np.ceil(np.log2(audio.BW_FASTEST * nyquist /
filter_cutoff)) - 1) - 1)
num_twos = __num_t... | [
"Compute",
"the",
"number",
"of",
"early",
"downsampling",
"operations"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L768-L777 | [
"def",
"__early_downsample_count",
"(",
"nyquist",
",",
"filter_cutoff",
",",
"hop_length",
",",
"n_octaves",
")",
":",
"downsample_count1",
"=",
"max",
"(",
"0",
",",
"int",
"(",
"np",
".",
"ceil",
"(",
"np",
".",
"log2",
"(",
"audio",
".",
"BW_FASTEST",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __early_downsample | Perform early downsampling on an audio signal, if it applies. | librosa/core/constantq.py | def __early_downsample(y, sr, hop_length, res_type, n_octaves,
nyquist, filter_cutoff, scale):
'''Perform early downsampling on an audio signal, if it applies.'''
downsample_count = __early_downsample_count(nyquist, filter_cutoff,
hop_lengt... | def __early_downsample(y, sr, hop_length, res_type, n_octaves,
nyquist, filter_cutoff, scale):
'''Perform early downsampling on an audio signal, if it applies.'''
downsample_count = __early_downsample_count(nyquist, filter_cutoff,
hop_lengt... | [
"Perform",
"early",
"downsampling",
"on",
"an",
"audio",
"signal",
"if",
"it",
"applies",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/constantq.py#L780-L808 | [
"def",
"__early_downsample",
"(",
"y",
",",
"sr",
",",
"hop_length",
",",
"res_type",
",",
"n_octaves",
",",
"nyquist",
",",
"filter_cutoff",
",",
"scale",
")",
":",
"downsample_count",
"=",
"__early_downsample_count",
"(",
"nyquist",
",",
"filter_cutoff",
",",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | delta | r'''Compute delta features: local estimate of the derivative
of the input data along the selected axis.
Delta features are computed Savitsky-Golay filtering.
Parameters
----------
data : np.ndarray
the input data matrix (eg, spectrogram)
width : int, positive, odd [scalar]
... | librosa/feature/utils.py | def delta(data, width=9, order=1, axis=-1, mode='interp', **kwargs):
r'''Compute delta features: local estimate of the derivative
of the input data along the selected axis.
Delta features are computed Savitsky-Golay filtering.
Parameters
----------
data : np.ndarray
the input data... | def delta(data, width=9, order=1, axis=-1, mode='interp', **kwargs):
r'''Compute delta features: local estimate of the derivative
of the input data along the selected axis.
Delta features are computed Savitsky-Golay filtering.
Parameters
----------
data : np.ndarray
the input data... | [
"r",
"Compute",
"delta",
"features",
":",
"local",
"estimate",
"of",
"the",
"derivative",
"of",
"the",
"input",
"data",
"along",
"the",
"selected",
"axis",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/feature/utils.py#L15-L115 | [
"def",
"delta",
"(",
"data",
",",
"width",
"=",
"9",
",",
"order",
"=",
"1",
",",
"axis",
"=",
"-",
"1",
",",
"mode",
"=",
"'interp'",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"np",
".",
"atleast_1d",
"(",
"data",
")",
"if",
"mode",
"=... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | stack_memory | Short-term history embedding: vertically concatenate a data
vector or matrix with delayed copies of itself.
Each column `data[:, i]` is mapped to::
data[:, i] -> [data[:, i],
data[:, i - delay],
...
data[:, i - (n_steps-1)*delay]... | librosa/feature/utils.py | def stack_memory(data, n_steps=2, delay=1, **kwargs):
"""Short-term history embedding: vertically concatenate a data
vector or matrix with delayed copies of itself.
Each column `data[:, i]` is mapped to::
data[:, i] -> [data[:, i],
data[:, i - delay],
... | def stack_memory(data, n_steps=2, delay=1, **kwargs):
"""Short-term history embedding: vertically concatenate a data
vector or matrix with delayed copies of itself.
Each column `data[:, i]` is mapped to::
data[:, i] -> [data[:, i],
data[:, i - delay],
... | [
"Short",
"-",
"term",
"history",
"embedding",
":",
"vertically",
"concatenate",
"a",
"data",
"vector",
"or",
"matrix",
"with",
"delayed",
"copies",
"of",
"itself",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/feature/utils.py#L119-L252 | [
"def",
"stack_memory",
"(",
"data",
",",
"n_steps",
"=",
"2",
",",
"delay",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"n_steps",
"<",
"1",
":",
"raise",
"ParameterError",
"(",
"'n_steps must be a positive integer'",
")",
"if",
"delay",
"==",
"0"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | dtw | Dynamic time warping (DTW).
This function performs a DTW and path backtracking on two sequences.
We follow the nomenclature and algorithmic approach as described in [1]_.
.. [1] Meinard Mueller
Fundamentals of Music Processing — Audio, Analysis, Algorithms, Applications
Springer Verl... | librosa/sequence.py | def dtw(X=None, Y=None, C=None, metric='euclidean', step_sizes_sigma=None,
weights_add=None, weights_mul=None, subseq=False, backtrack=True,
global_constraints=False, band_rad=0.25):
'''Dynamic time warping (DTW).
This function performs a DTW and path backtracking on two sequences.
We follo... | def dtw(X=None, Y=None, C=None, metric='euclidean', step_sizes_sigma=None,
weights_add=None, weights_mul=None, subseq=False, backtrack=True,
global_constraints=False, band_rad=0.25):
'''Dynamic time warping (DTW).
This function performs a DTW and path backtracking on two sequences.
We follo... | [
"Dynamic",
"time",
"warping",
"(",
"DTW",
")",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L52-L234 | [
"def",
"dtw",
"(",
"X",
"=",
"None",
",",
"Y",
"=",
"None",
",",
"C",
"=",
"None",
",",
"metric",
"=",
"'euclidean'",
",",
"step_sizes_sigma",
"=",
"None",
",",
"weights_add",
"=",
"None",
",",
"weights_mul",
"=",
"None",
",",
"subseq",
"=",
"False",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __dtw_calc_accu_cost | Calculate the accumulated cost matrix D.
Use dynamic programming to calculate the accumulated costs.
Parameters
----------
C : np.ndarray [shape=(N, M)]
pre-computed cost matrix
D : np.ndarray [shape=(N, M)]
accumulated cost matrix
D_steps : np.ndarray [shape=(N, M)]
... | librosa/sequence.py | def __dtw_calc_accu_cost(C, D, D_steps, step_sizes_sigma,
weights_mul, weights_add, max_0, max_1): # pragma: no cover
'''Calculate the accumulated cost matrix D.
Use dynamic programming to calculate the accumulated costs.
Parameters
----------
C : np.ndarray [shape=(N, M)... | def __dtw_calc_accu_cost(C, D, D_steps, step_sizes_sigma,
weights_mul, weights_add, max_0, max_1): # pragma: no cover
'''Calculate the accumulated cost matrix D.
Use dynamic programming to calculate the accumulated costs.
Parameters
----------
C : np.ndarray [shape=(N, M)... | [
"Calculate",
"the",
"accumulated",
"cost",
"matrix",
"D",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L238-L302 | [
"def",
"__dtw_calc_accu_cost",
"(",
"C",
",",
"D",
",",
"D_steps",
",",
"step_sizes_sigma",
",",
"weights_mul",
",",
"weights_add",
",",
"max_0",
",",
"max_1",
")",
":",
"# pragma: no cover",
"for",
"cur_n",
"in",
"range",
"(",
"max_0",
",",
"D",
".",
"sha... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __dtw_backtracking | Backtrack optimal warping path.
Uses the saved step sizes from the cost accumulation
step to backtrack the index pairs for an optimal
warping path.
Parameters
----------
D_steps : np.ndarray [shape=(N, M)]
Saved indices of the used steps used in the calculation of D.
step_sizes_s... | librosa/sequence.py | def __dtw_backtracking(D_steps, step_sizes_sigma): # pragma: no cover
'''Backtrack optimal warping path.
Uses the saved step sizes from the cost accumulation
step to backtrack the index pairs for an optimal
warping path.
Parameters
----------
D_steps : np.ndarray [shape=(N, M)]
S... | def __dtw_backtracking(D_steps, step_sizes_sigma): # pragma: no cover
'''Backtrack optimal warping path.
Uses the saved step sizes from the cost accumulation
step to backtrack the index pairs for an optimal
warping path.
Parameters
----------
D_steps : np.ndarray [shape=(N, M)]
S... | [
"Backtrack",
"optimal",
"warping",
"path",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L306-L352 | [
"def",
"__dtw_backtracking",
"(",
"D_steps",
",",
"step_sizes_sigma",
")",
":",
"# pragma: no cover",
"wp",
"=",
"[",
"]",
"# Set starting point D(N,M) and append it to the path",
"cur_idx",
"=",
"(",
"D_steps",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
",",
"D_steps... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | _viterbi | Core Viterbi algorithm.
This is intended for internal use only.
Parameters
----------
log_prob : np.ndarray [shape=(T, m)]
`log_prob[t, s]` is the conditional log-likelihood
log P[X = X(t) | State(t) = s]
log_trans : np.ndarray [shape=(m, m)]
The log transition matrix
... | librosa/sequence.py | def _viterbi(log_prob, log_trans, log_p_init, state, value, ptr): # pragma: no cover
'''Core Viterbi algorithm.
This is intended for internal use only.
Parameters
----------
log_prob : np.ndarray [shape=(T, m)]
`log_prob[t, s]` is the conditional log-likelihood
log P[X = X(t) | St... | def _viterbi(log_prob, log_trans, log_p_init, state, value, ptr): # pragma: no cover
'''Core Viterbi algorithm.
This is intended for internal use only.
Parameters
----------
log_prob : np.ndarray [shape=(T, m)]
`log_prob[t, s]` is the conditional log-likelihood
log P[X = X(t) | St... | [
"Core",
"Viterbi",
"algorithm",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L356-L417 | [
"def",
"_viterbi",
"(",
"log_prob",
",",
"log_trans",
",",
"log_p_init",
",",
"state",
",",
"value",
",",
"ptr",
")",
":",
"# pragma: no cover",
"n_steps",
",",
"n_states",
"=",
"log_prob",
".",
"shape",
"# factor in initial state distribution",
"value",
"[",
"0... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | viterbi_discriminative | Viterbi decoding from discriminative state predictions.
Given a sequence of conditional state predictions `prob[s, t]`,
indicating the conditional likelihood of state `s` given the
observation at time `t`, and a transition matrix `transition[i, j]`
which encodes the conditional probability of moving fr... | librosa/sequence.py | def viterbi_discriminative(prob, transition, p_state=None, p_init=None, return_logp=False):
'''Viterbi decoding from discriminative state predictions.
Given a sequence of conditional state predictions `prob[s, t]`,
indicating the conditional likelihood of state `s` given the
observation at time `t`, an... | def viterbi_discriminative(prob, transition, p_state=None, p_init=None, return_logp=False):
'''Viterbi decoding from discriminative state predictions.
Given a sequence of conditional state predictions `prob[s, t]`,
indicating the conditional likelihood of state `s` given the
observation at time `t`, an... | [
"Viterbi",
"decoding",
"from",
"discriminative",
"state",
"predictions",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L540-L717 | [
"def",
"viterbi_discriminative",
"(",
"prob",
",",
"transition",
",",
"p_state",
"=",
"None",
",",
"p_init",
"=",
"None",
",",
"return_logp",
"=",
"False",
")",
":",
"n_states",
",",
"n_steps",
"=",
"prob",
".",
"shape",
"if",
"transition",
".",
"shape",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | viterbi_binary | Viterbi decoding from binary (multi-label), discriminative state predictions.
Given a sequence of conditional state predictions `prob[s, t]`,
indicating the conditional likelihood of state `s` being active
conditional on observation at time `t`, and a 2*2 transition matrix
`transition` which encodes th... | librosa/sequence.py | def viterbi_binary(prob, transition, p_state=None, p_init=None, return_logp=False):
'''Viterbi decoding from binary (multi-label), discriminative state predictions.
Given a sequence of conditional state predictions `prob[s, t]`,
indicating the conditional likelihood of state `s` being active
conditiona... | def viterbi_binary(prob, transition, p_state=None, p_init=None, return_logp=False):
'''Viterbi decoding from binary (multi-label), discriminative state predictions.
Given a sequence of conditional state predictions `prob[s, t]`,
indicating the conditional likelihood of state `s` being active
conditiona... | [
"Viterbi",
"decoding",
"from",
"binary",
"(",
"multi",
"-",
"label",
")",
"discriminative",
"state",
"predictions",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L720-L864 | [
"def",
"viterbi_binary",
"(",
"prob",
",",
"transition",
",",
"p_state",
"=",
"None",
",",
"p_init",
"=",
"None",
",",
"return_logp",
"=",
"False",
")",
":",
"prob",
"=",
"np",
".",
"atleast_2d",
"(",
"prob",
")",
"n_states",
",",
"n_steps",
"=",
"prob... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | transition_uniform | Construct a uniform transition matrix over `n_states`.
Parameters
----------
n_states : int > 0
The number of states
Returns
-------
transition : np.ndarray [shape=(n_states, n_states)]
`transition[i, j] = 1./n_states`
Examples
--------
>>> librosa.sequence.transi... | librosa/sequence.py | def transition_uniform(n_states):
'''Construct a uniform transition matrix over `n_states`.
Parameters
----------
n_states : int > 0
The number of states
Returns
-------
transition : np.ndarray [shape=(n_states, n_states)]
`transition[i, j] = 1./n_states`
Examples
... | def transition_uniform(n_states):
'''Construct a uniform transition matrix over `n_states`.
Parameters
----------
n_states : int > 0
The number of states
Returns
-------
transition : np.ndarray [shape=(n_states, n_states)]
`transition[i, j] = 1./n_states`
Examples
... | [
"Construct",
"a",
"uniform",
"transition",
"matrix",
"over",
"n_states",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L867-L894 | [
"def",
"transition_uniform",
"(",
"n_states",
")",
":",
"if",
"not",
"isinstance",
"(",
"n_states",
",",
"int",
")",
"or",
"n_states",
"<=",
"0",
":",
"raise",
"ParameterError",
"(",
"'n_states={} must be a positive integer'",
")",
"transition",
"=",
"np",
".",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | transition_loop | Construct a self-loop transition matrix over `n_states`.
The transition matrix will have the following properties:
- `transition[i, i] = p` for all i
- `transition[i, j] = (1 - p) / (n_states - 1)` for all `j != i`
This type of transition matrix is appropriate when states tend to be
local... | librosa/sequence.py | def transition_loop(n_states, prob):
'''Construct a self-loop transition matrix over `n_states`.
The transition matrix will have the following properties:
- `transition[i, i] = p` for all i
- `transition[i, j] = (1 - p) / (n_states - 1)` for all `j != i`
This type of transition matrix is ... | def transition_loop(n_states, prob):
'''Construct a self-loop transition matrix over `n_states`.
The transition matrix will have the following properties:
- `transition[i, i] = p` for all i
- `transition[i, j] = (1 - p) / (n_states - 1)` for all `j != i`
This type of transition matrix is ... | [
"Construct",
"a",
"self",
"-",
"loop",
"transition",
"matrix",
"over",
"n_states",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L897-L958 | [
"def",
"transition_loop",
"(",
"n_states",
",",
"prob",
")",
":",
"if",
"not",
"isinstance",
"(",
"n_states",
",",
"int",
")",
"or",
"n_states",
"<=",
"1",
":",
"raise",
"ParameterError",
"(",
"'n_states={} must be a positive integer > 1'",
")",
"transition",
"=... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | transition_cycle | Construct a cyclic transition matrix over `n_states`.
The transition matrix will have the following properties:
- `transition[i, i] = p`
- `transition[i, i + 1] = (1 - p)`
This type of transition matrix is appropriate for state spaces
with cyclical structure, such as metrical position wit... | librosa/sequence.py | def transition_cycle(n_states, prob):
'''Construct a cyclic transition matrix over `n_states`.
The transition matrix will have the following properties:
- `transition[i, i] = p`
- `transition[i, i + 1] = (1 - p)`
This type of transition matrix is appropriate for state spaces
with cycl... | def transition_cycle(n_states, prob):
'''Construct a cyclic transition matrix over `n_states`.
The transition matrix will have the following properties:
- `transition[i, i] = p`
- `transition[i, i + 1] = (1 - p)`
This type of transition matrix is appropriate for state spaces
with cycl... | [
"Construct",
"a",
"cyclic",
"transition",
"matrix",
"over",
"n_states",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L961-L1021 | [
"def",
"transition_cycle",
"(",
"n_states",
",",
"prob",
")",
":",
"if",
"not",
"isinstance",
"(",
"n_states",
",",
"int",
")",
"or",
"n_states",
"<=",
"1",
":",
"raise",
"ParameterError",
"(",
"'n_states={} must be a positive integer > 1'",
")",
"transition",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | transition_local | Construct a localized transition matrix.
The transition matrix will have the following properties:
- `transition[i, j] = 0` if `|i - j| > width`
- `transition[i, i]` is maximal
- `transition[i, i - width//2 : i + width//2]` has shape `window`
This type of transition matrix is appropri... | librosa/sequence.py | def transition_local(n_states, width, window='triangle', wrap=False):
'''Construct a localized transition matrix.
The transition matrix will have the following properties:
- `transition[i, j] = 0` if `|i - j| > width`
- `transition[i, i]` is maximal
- `transition[i, i - width//2 : i + ... | def transition_local(n_states, width, window='triangle', wrap=False):
'''Construct a localized transition matrix.
The transition matrix will have the following properties:
- `transition[i, j] = 0` if `|i - j| > width`
- `transition[i, i]` is maximal
- `transition[i, i - width//2 : i + ... | [
"Construct",
"a",
"localized",
"transition",
"matrix",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L1024-L1129 | [
"def",
"transition_local",
"(",
"n_states",
",",
"width",
",",
"window",
"=",
"'triangle'",
",",
"wrap",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"n_states",
",",
"int",
")",
"or",
"n_states",
"<=",
"1",
":",
"raise",
"ParameterError",
"("... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | onset_detect | Basic onset detector. Locate note onset events by picking peaks in an
onset strength envelope.
The `peak_pick` parameters were chosen by large-scale hyper-parameter
optimization over the dataset provided by [1]_.
.. [1] https://github.com/CPJKU/onset_db
Parameters
----------
y ... | librosa/onset.py | def onset_detect(y=None, sr=22050, onset_envelope=None, hop_length=512,
backtrack=False, energy=None,
units='frames', **kwargs):
"""Basic onset detector. Locate note onset events by picking peaks in an
onset strength envelope.
The `peak_pick` parameters were chosen by lar... | def onset_detect(y=None, sr=22050, onset_envelope=None, hop_length=512,
backtrack=False, energy=None,
units='frames', **kwargs):
"""Basic onset detector. Locate note onset events by picking peaks in an
onset strength envelope.
The `peak_pick` parameters were chosen by lar... | [
"Basic",
"onset",
"detector",
".",
"Locate",
"note",
"onset",
"events",
"by",
"picking",
"peaks",
"in",
"an",
"onset",
"strength",
"envelope",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/onset.py#L31-L182 | [
"def",
"onset_detect",
"(",
"y",
"=",
"None",
",",
"sr",
"=",
"22050",
",",
"onset_envelope",
"=",
"None",
",",
"hop_length",
"=",
"512",
",",
"backtrack",
"=",
"False",
",",
"energy",
"=",
"None",
",",
"units",
"=",
"'frames'",
",",
"*",
"*",
"kwarg... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | onset_strength | Compute a spectral flux onset strength envelope.
Onset strength at time `t` is determined by:
`mean_f max(0, S[f, t] - ref[f, t - lag])`
where `ref` is `S` after local max filtering along the frequency
axis [1]_.
By default, if a time series `y` is provided, S will be the
log-power Mel spect... | librosa/onset.py | def onset_strength(y=None, sr=22050, S=None, lag=1, max_size=1,
ref=None,
detrend=False, center=True,
feature=None, aggregate=None,
centering=None,
**kwargs):
"""Compute a spectral flux onset strength envelope.
Onset... | def onset_strength(y=None, sr=22050, S=None, lag=1, max_size=1,
ref=None,
detrend=False, center=True,
feature=None, aggregate=None,
centering=None,
**kwargs):
"""Compute a spectral flux onset strength envelope.
Onset... | [
"Compute",
"a",
"spectral",
"flux",
"onset",
"strength",
"envelope",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/onset.py#L185-L333 | [
"def",
"onset_strength",
"(",
"y",
"=",
"None",
",",
"sr",
"=",
"22050",
",",
"S",
"=",
"None",
",",
"lag",
"=",
"1",
",",
"max_size",
"=",
"1",
",",
"ref",
"=",
"None",
",",
"detrend",
"=",
"False",
",",
"center",
"=",
"True",
",",
"feature",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | onset_backtrack | Backtrack detected onset events to the nearest preceding local
minimum of an energy function.
This function can be used to roll back the timing of detected onsets
from a detected peak amplitude to the preceding minimum.
This is most useful when using onsets to determine slice points for
segmentati... | librosa/onset.py | def onset_backtrack(events, energy):
'''Backtrack detected onset events to the nearest preceding local
minimum of an energy function.
This function can be used to roll back the timing of detected onsets
from a detected peak amplitude to the preceding minimum.
This is most useful when using onsets ... | def onset_backtrack(events, energy):
'''Backtrack detected onset events to the nearest preceding local
minimum of an energy function.
This function can be used to roll back the timing of detected onsets
from a detected peak amplitude to the preceding minimum.
This is most useful when using onsets ... | [
"Backtrack",
"detected",
"onset",
"events",
"to",
"the",
"nearest",
"preceding",
"local",
"minimum",
"of",
"an",
"energy",
"function",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/onset.py#L336-L403 | [
"def",
"onset_backtrack",
"(",
"events",
",",
"energy",
")",
":",
"# Find points where energy is non-increasing",
"# all points: energy[i] <= energy[i-1]",
"# tail points: energy[i] < energy[i+1]",
"minima",
"=",
"np",
".",
"flatnonzero",
"(",
"(",
"energy",
"[",
"1",
":",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | onset_strength_multi | Compute a spectral flux onset strength envelope across multiple channels.
Onset strength for channel `i` at time `t` is determined by:
`mean_{f in channels[i]} max(0, S[f, t+1] - S[f, t])`
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time-series
sr : number >... | librosa/onset.py | def onset_strength_multi(y=None, sr=22050, S=None, lag=1, max_size=1,
ref=None, detrend=False, center=True, feature=None,
aggregate=None, channels=None, **kwargs):
"""Compute a spectral flux onset strength envelope across multiple channels.
Onset strength for c... | def onset_strength_multi(y=None, sr=22050, S=None, lag=1, max_size=1,
ref=None, detrend=False, center=True, feature=None,
aggregate=None, channels=None, **kwargs):
"""Compute a spectral flux onset strength envelope across multiple channels.
Onset strength for c... | [
"Compute",
"a",
"spectral",
"flux",
"onset",
"strength",
"envelope",
"across",
"multiple",
"channels",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/onset.py#L407-L586 | [
"def",
"onset_strength_multi",
"(",
"y",
"=",
"None",
",",
"sr",
"=",
"22050",
",",
"S",
"=",
"None",
",",
"lag",
"=",
"1",
",",
"max_size",
"=",
"1",
",",
"ref",
"=",
"None",
",",
"detrend",
"=",
"False",
",",
"center",
"=",
"True",
",",
"featur... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | annotation | r'''Save annotations in a 3-column format::
intervals[0, 0],intervals[0, 1],annotations[0]\n
intervals[1, 0],intervals[1, 1],annotations[1]\n
intervals[2, 0],intervals[2, 1],annotations[2]\n
...
This can be used for segment or chord annotations.
Parameters
----------
p... | librosa/output.py | def annotation(path, intervals, annotations=None, delimiter=',', fmt='%0.3f'):
r'''Save annotations in a 3-column format::
intervals[0, 0],intervals[0, 1],annotations[0]\n
intervals[1, 0],intervals[1, 1],annotations[1]\n
intervals[2, 0],intervals[2, 1],annotations[2]\n
...
This... | def annotation(path, intervals, annotations=None, delimiter=',', fmt='%0.3f'):
r'''Save annotations in a 3-column format::
intervals[0, 0],intervals[0, 1],annotations[0]\n
intervals[1, 0],intervals[1, 1],annotations[1]\n
intervals[2, 0],intervals[2, 1],annotations[2]\n
...
This... | [
"r",
"Save",
"annotations",
"in",
"a",
"3",
"-",
"column",
"format",
"::"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/output.py#L36-L117 | [
"def",
"annotation",
"(",
"path",
",",
"intervals",
",",
"annotations",
"=",
"None",
",",
"delimiter",
"=",
"','",
",",
"fmt",
"=",
"'%0.3f'",
")",
":",
"util",
".",
"valid_intervals",
"(",
"intervals",
")",
"if",
"annotations",
"is",
"not",
"None",
"and... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | times_csv | r"""Save time steps as in CSV format. This can be used to store the output
of a beat-tracker or segmentation algorithm.
If only `times` are provided, the file will contain each value
of `times` on a row::
times[0]\n
times[1]\n
times[2]\n
...
If `annotations` are also ... | librosa/output.py | def times_csv(path, times, annotations=None, delimiter=',', fmt='%0.3f'):
r"""Save time steps as in CSV format. This can be used to store the output
of a beat-tracker or segmentation algorithm.
If only `times` are provided, the file will contain each value
of `times` on a row::
times[0]\n
... | def times_csv(path, times, annotations=None, delimiter=',', fmt='%0.3f'):
r"""Save time steps as in CSV format. This can be used to store the output
of a beat-tracker or segmentation algorithm.
If only `times` are provided, the file will contain each value
of `times` on a row::
times[0]\n
... | [
"r",
"Save",
"time",
"steps",
"as",
"in",
"CSV",
"format",
".",
"This",
"can",
"be",
"used",
"to",
"store",
"the",
"output",
"of",
"a",
"beat",
"-",
"tracker",
"or",
"segmentation",
"algorithm",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/output.py#L120-L184 | [
"def",
"times_csv",
"(",
"path",
",",
"times",
",",
"annotations",
"=",
"None",
",",
"delimiter",
"=",
"','",
",",
"fmt",
"=",
"'%0.3f'",
")",
":",
"if",
"annotations",
"is",
"not",
"None",
"and",
"len",
"(",
"annotations",
")",
"!=",
"len",
"(",
"ti... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | write_wav | Output a time series as a .wav file
Note: only mono or stereo, floating-point data is supported.
For more advanced and flexible output options, refer to
`soundfile`.
Parameters
----------
path : str
path to save the output wav file
y : np.ndarray [shape=(n,) or (2,n), dtyp... | librosa/output.py | def write_wav(path, y, sr, norm=False):
"""Output a time series as a .wav file
Note: only mono or stereo, floating-point data is supported.
For more advanced and flexible output options, refer to
`soundfile`.
Parameters
----------
path : str
path to save the output wav file... | def write_wav(path, y, sr, norm=False):
"""Output a time series as a .wav file
Note: only mono or stereo, floating-point data is supported.
For more advanced and flexible output options, refer to
`soundfile`.
Parameters
----------
path : str
path to save the output wav file... | [
"Output",
"a",
"time",
"series",
"as",
"a",
".",
"wav",
"file"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/output.py#L187-L238 | [
"def",
"write_wav",
"(",
"path",
",",
"y",
",",
"sr",
",",
"norm",
"=",
"False",
")",
":",
"# Validate the buffer. Stereo is okay here.",
"util",
".",
"valid_audio",
"(",
"y",
",",
"mono",
"=",
"False",
")",
"# normalize",
"if",
"norm",
"and",
"np",
".",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | cmap | Get a default colormap from the given data.
If the data is boolean, use a black and white colormap.
If the data has both positive and negative values,
use a diverging colormap.
Otherwise, use a sequential colormap.
Parameters
----------
data : np.ndarray
Input data
robust : ... | librosa/display.py | def cmap(data, robust=True, cmap_seq='magma', cmap_bool='gray_r', cmap_div='coolwarm'):
'''Get a default colormap from the given data.
If the data is boolean, use a black and white colormap.
If the data has both positive and negative values,
use a diverging colormap.
Otherwise, use a sequential c... | def cmap(data, robust=True, cmap_seq='magma', cmap_bool='gray_r', cmap_div='coolwarm'):
'''Get a default colormap from the given data.
If the data is boolean, use a black and white colormap.
If the data has both positive and negative values,
use a diverging colormap.
Otherwise, use a sequential c... | [
"Get",
"a",
"default",
"colormap",
"from",
"the",
"given",
"data",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L293-L349 | [
"def",
"cmap",
"(",
"data",
",",
"robust",
"=",
"True",
",",
"cmap_seq",
"=",
"'magma'",
",",
"cmap_bool",
"=",
"'gray_r'",
",",
"cmap_div",
"=",
"'coolwarm'",
")",
":",
"data",
"=",
"np",
".",
"atleast_1d",
"(",
"data",
")",
"if",
"data",
".",
"dtyp... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __envelope | Compute the max-envelope of x at a stride/frame length of h | librosa/display.py | def __envelope(x, hop):
'''Compute the max-envelope of x at a stride/frame length of h'''
return util.frame(x, hop_length=hop, frame_length=hop).max(axis=0) | def __envelope(x, hop):
'''Compute the max-envelope of x at a stride/frame length of h'''
return util.frame(x, hop_length=hop, frame_length=hop).max(axis=0) | [
"Compute",
"the",
"max",
"-",
"envelope",
"of",
"x",
"at",
"a",
"stride",
"/",
"frame",
"length",
"of",
"h"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L352-L354 | [
"def",
"__envelope",
"(",
"x",
",",
"hop",
")",
":",
"return",
"util",
".",
"frame",
"(",
"x",
",",
"hop_length",
"=",
"hop",
",",
"frame_length",
"=",
"hop",
")",
".",
"max",
"(",
"axis",
"=",
"0",
")"
] | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | waveplot | Plot the amplitude envelope of a waveform.
If `y` is monophonic, a filled curve is drawn between `[-abs(y), abs(y)]`.
If `y` is stereo, the curve is drawn between `[-abs(y[1]), abs(y[0])]`,
so that the left and right channels are drawn above and below the axis,
respectively.
Long signals (`durati... | librosa/display.py | def waveplot(y, sr=22050, max_points=5e4, x_axis='time', offset=0.0,
max_sr=1000, ax=None, **kwargs):
'''Plot the amplitude envelope of a waveform.
If `y` is monophonic, a filled curve is drawn between `[-abs(y), abs(y)]`.
If `y` is stereo, the curve is drawn between `[-abs(y[1]), abs(y[0])]`... | def waveplot(y, sr=22050, max_points=5e4, x_axis='time', offset=0.0,
max_sr=1000, ax=None, **kwargs):
'''Plot the amplitude envelope of a waveform.
If `y` is monophonic, a filled curve is drawn between `[-abs(y), abs(y)]`.
If `y` is stereo, the curve is drawn between `[-abs(y[1]), abs(y[0])]`... | [
"Plot",
"the",
"amplitude",
"envelope",
"of",
"a",
"waveform",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L357-L488 | [
"def",
"waveplot",
"(",
"y",
",",
"sr",
"=",
"22050",
",",
"max_points",
"=",
"5e4",
",",
"x_axis",
"=",
"'time'",
",",
"offset",
"=",
"0.0",
",",
"max_sr",
"=",
"1000",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"util",
".",
"v... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | specshow | Display a spectrogram/chromagram/cqt/etc.
Parameters
----------
data : np.ndarray [shape=(d, n)]
Matrix to display (e.g., spectrogram)
sr : number > 0 [scalar]
Sample rate used to determine time scale in x-axis.
hop_length : int > 0 [scalar]
Hop length, also used to deter... | librosa/display.py | def specshow(data, x_coords=None, y_coords=None,
x_axis=None, y_axis=None,
sr=22050, hop_length=512,
fmin=None, fmax=None,
bins_per_octave=12,
ax=None,
**kwargs):
'''Display a spectrogram/chromagram/cqt/etc.
Parameters
---------... | def specshow(data, x_coords=None, y_coords=None,
x_axis=None, y_axis=None,
sr=22050, hop_length=512,
fmin=None, fmax=None,
bins_per_octave=12,
ax=None,
**kwargs):
'''Display a spectrogram/chromagram/cqt/etc.
Parameters
---------... | [
"Display",
"a",
"spectrogram",
"/",
"chromagram",
"/",
"cqt",
"/",
"etc",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L491-L731 | [
"def",
"specshow",
"(",
"data",
",",
"x_coords",
"=",
"None",
",",
"y_coords",
"=",
"None",
",",
"x_axis",
"=",
"None",
",",
"y_axis",
"=",
"None",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"fmin",
"=",
"None",
",",
"fmax",
"=",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __set_current_image | Helper to set the current image in pyplot mode.
If the provided `ax` is not `None`, then we assume that the user is using the object API.
In this case, the pyplot current image is not set. | librosa/display.py | def __set_current_image(ax, img):
'''Helper to set the current image in pyplot mode.
If the provided `ax` is not `None`, then we assume that the user is using the object API.
In this case, the pyplot current image is not set.
'''
if ax is None:
import matplotlib.pyplot as plt
plt.s... | def __set_current_image(ax, img):
'''Helper to set the current image in pyplot mode.
If the provided `ax` is not `None`, then we assume that the user is using the object API.
In this case, the pyplot current image is not set.
'''
if ax is None:
import matplotlib.pyplot as plt
plt.s... | [
"Helper",
"to",
"set",
"the",
"current",
"image",
"in",
"pyplot",
"mode",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L734-L743 | [
"def",
"__set_current_image",
"(",
"ax",
",",
"img",
")",
":",
"if",
"ax",
"is",
"None",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"plt",
".",
"sci",
"(",
"img",
")"
] | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __mesh_coords | Compute axis coordinates | librosa/display.py | def __mesh_coords(ax_type, coords, n, **kwargs):
'''Compute axis coordinates'''
if coords is not None:
if len(coords) < n:
raise ParameterError('Coordinate shape mismatch: '
'{}<{}'.format(len(coords), n))
return coords
coord_map = {'linear': __... | def __mesh_coords(ax_type, coords, n, **kwargs):
'''Compute axis coordinates'''
if coords is not None:
if len(coords) < n:
raise ParameterError('Coordinate shape mismatch: '
'{}<{}'.format(len(coords), n))
return coords
coord_map = {'linear': __... | [
"Compute",
"axis",
"coordinates"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L746-L777 | [
"def",
"__mesh_coords",
"(",
"ax_type",
",",
"coords",
",",
"n",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"coords",
"is",
"not",
"None",
":",
"if",
"len",
"(",
"coords",
")",
"<",
"n",
":",
"raise",
"ParameterError",
"(",
"'Coordinate shape mismatch: '",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __check_axes | Check if "axes" is an instance of an axis object. If not, use `gca`. | librosa/display.py | def __check_axes(axes):
'''Check if "axes" is an instance of an axis object. If not, use `gca`.'''
if axes is None:
import matplotlib.pyplot as plt
axes = plt.gca()
elif not isinstance(axes, Axes):
raise ValueError("`axes` must be an instance of matplotlib.axes.Axes. "
... | def __check_axes(axes):
'''Check if "axes" is an instance of an axis object. If not, use `gca`.'''
if axes is None:
import matplotlib.pyplot as plt
axes = plt.gca()
elif not isinstance(axes, Axes):
raise ValueError("`axes` must be an instance of matplotlib.axes.Axes. "
... | [
"Check",
"if",
"axes",
"is",
"an",
"instance",
"of",
"an",
"axis",
"object",
".",
"If",
"not",
"use",
"gca",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L780-L788 | [
"def",
"__check_axes",
"(",
"axes",
")",
":",
"if",
"axes",
"is",
"None",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"axes",
"=",
"plt",
".",
"gca",
"(",
")",
"elif",
"not",
"isinstance",
"(",
"axes",
",",
"Axes",
")",
":",
"raise",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __scale_axes | Set the axis scaling | librosa/display.py | def __scale_axes(axes, ax_type, which):
'''Set the axis scaling'''
kwargs = dict()
if which == 'x':
thresh = 'linthreshx'
base = 'basex'
scale = 'linscalex'
scaler = axes.set_xscale
limit = axes.set_xlim
else:
thresh = 'linthreshy'
base = 'basey'
... | def __scale_axes(axes, ax_type, which):
'''Set the axis scaling'''
kwargs = dict()
if which == 'x':
thresh = 'linthreshx'
base = 'basex'
scale = 'linscalex'
scaler = axes.set_xscale
limit = axes.set_xlim
else:
thresh = 'linthreshy'
base = 'basey'
... | [
"Set",
"the",
"axis",
"scaling"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L791-L831 | [
"def",
"__scale_axes",
"(",
"axes",
",",
"ax_type",
",",
"which",
")",
":",
"kwargs",
"=",
"dict",
"(",
")",
"if",
"which",
"==",
"'x'",
":",
"thresh",
"=",
"'linthreshx'",
"base",
"=",
"'basex'",
"scale",
"=",
"'linscalex'",
"scaler",
"=",
"axes",
"."... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __decorate_axis | Configure axis tickers, locators, and labels | librosa/display.py | def __decorate_axis(axis, ax_type):
'''Configure axis tickers, locators, and labels'''
if ax_type == 'tonnetz':
axis.set_major_formatter(TonnetzFormatter())
axis.set_major_locator(FixedLocator(0.5 + np.arange(6)))
axis.set_label_text('Tonnetz')
elif ax_type == 'chroma':
axi... | def __decorate_axis(axis, ax_type):
'''Configure axis tickers, locators, and labels'''
if ax_type == 'tonnetz':
axis.set_major_formatter(TonnetzFormatter())
axis.set_major_locator(FixedLocator(0.5 + np.arange(6)))
axis.set_label_text('Tonnetz')
elif ax_type == 'chroma':
axi... | [
"Configure",
"axis",
"tickers",
"locators",
"and",
"labels"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L834-L920 | [
"def",
"__decorate_axis",
"(",
"axis",
",",
"ax_type",
")",
":",
"if",
"ax_type",
"==",
"'tonnetz'",
":",
"axis",
".",
"set_major_formatter",
"(",
"TonnetzFormatter",
"(",
")",
")",
"axis",
".",
"set_major_locator",
"(",
"FixedLocator",
"(",
"0.5",
"+",
"np"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __coord_fft_hz | Get the frequencies for FFT bins | librosa/display.py | def __coord_fft_hz(n, sr=22050, **_kwargs):
'''Get the frequencies for FFT bins'''
n_fft = 2 * (n - 1)
# The following code centers the FFT bins at their frequencies
# and clips to the non-negative frequency range [0, nyquist]
basis = core.fft_frequencies(sr=sr, n_fft=n_fft)
fmax = basis[-1]
... | def __coord_fft_hz(n, sr=22050, **_kwargs):
'''Get the frequencies for FFT bins'''
n_fft = 2 * (n - 1)
# The following code centers the FFT bins at their frequencies
# and clips to the non-negative frequency range [0, nyquist]
basis = core.fft_frequencies(sr=sr, n_fft=n_fft)
fmax = basis[-1]
... | [
"Get",
"the",
"frequencies",
"for",
"FFT",
"bins"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L923-L932 | [
"def",
"__coord_fft_hz",
"(",
"n",
",",
"sr",
"=",
"22050",
",",
"*",
"*",
"_kwargs",
")",
":",
"n_fft",
"=",
"2",
"*",
"(",
"n",
"-",
"1",
")",
"# The following code centers the FFT bins at their frequencies",
"# and clips to the non-negative frequency range [0, nyqu... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __coord_mel_hz | Get the frequencies for Mel bins | librosa/display.py | def __coord_mel_hz(n, fmin=0, fmax=11025.0, **_kwargs):
'''Get the frequencies for Mel bins'''
if fmin is None:
fmin = 0
if fmax is None:
fmax = 11025.0
basis = core.mel_frequencies(n, fmin=fmin, fmax=fmax)
basis[1:] -= 0.5 * np.diff(basis)
basis = np.append(np.maximum(0, basis... | def __coord_mel_hz(n, fmin=0, fmax=11025.0, **_kwargs):
'''Get the frequencies for Mel bins'''
if fmin is None:
fmin = 0
if fmax is None:
fmax = 11025.0
basis = core.mel_frequencies(n, fmin=fmin, fmax=fmax)
basis[1:] -= 0.5 * np.diff(basis)
basis = np.append(np.maximum(0, basis... | [
"Get",
"the",
"frequencies",
"for",
"Mel",
"bins"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L935-L946 | [
"def",
"__coord_mel_hz",
"(",
"n",
",",
"fmin",
"=",
"0",
",",
"fmax",
"=",
"11025.0",
",",
"*",
"*",
"_kwargs",
")",
":",
"if",
"fmin",
"is",
"None",
":",
"fmin",
"=",
"0",
"if",
"fmax",
"is",
"None",
":",
"fmax",
"=",
"11025.0",
"basis",
"=",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __coord_cqt_hz | Get CQT bin frequencies | librosa/display.py | def __coord_cqt_hz(n, fmin=None, bins_per_octave=12, **_kwargs):
'''Get CQT bin frequencies'''
if fmin is None:
fmin = core.note_to_hz('C1')
# we drop by half a bin so that CQT bins are centered vertically
return core.cqt_frequencies(n+1,
fmin=fmin / 2.0**(0.5/bi... | def __coord_cqt_hz(n, fmin=None, bins_per_octave=12, **_kwargs):
'''Get CQT bin frequencies'''
if fmin is None:
fmin = core.note_to_hz('C1')
# we drop by half a bin so that CQT bins are centered vertically
return core.cqt_frequencies(n+1,
fmin=fmin / 2.0**(0.5/bi... | [
"Get",
"CQT",
"bin",
"frequencies"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L949-L957 | [
"def",
"__coord_cqt_hz",
"(",
"n",
",",
"fmin",
"=",
"None",
",",
"bins_per_octave",
"=",
"12",
",",
"*",
"*",
"_kwargs",
")",
":",
"if",
"fmin",
"is",
"None",
":",
"fmin",
"=",
"core",
".",
"note_to_hz",
"(",
"'C1'",
")",
"# we drop by half a bin so tha... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __coord_chroma | Get chroma bin numbers | librosa/display.py | def __coord_chroma(n, bins_per_octave=12, **_kwargs):
'''Get chroma bin numbers'''
return np.linspace(0, (12.0 * n) / bins_per_octave, num=n+1, endpoint=True) | def __coord_chroma(n, bins_per_octave=12, **_kwargs):
'''Get chroma bin numbers'''
return np.linspace(0, (12.0 * n) / bins_per_octave, num=n+1, endpoint=True) | [
"Get",
"chroma",
"bin",
"numbers"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L960-L962 | [
"def",
"__coord_chroma",
"(",
"n",
",",
"bins_per_octave",
"=",
"12",
",",
"*",
"*",
"_kwargs",
")",
":",
"return",
"np",
".",
"linspace",
"(",
"0",
",",
"(",
"12.0",
"*",
"n",
")",
"/",
"bins_per_octave",
",",
"num",
"=",
"n",
"+",
"1",
",",
"en... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __coord_tempo | Tempo coordinates | librosa/display.py | def __coord_tempo(n, sr=22050, hop_length=512, **_kwargs):
'''Tempo coordinates'''
basis = core.tempo_frequencies(n+2, sr=sr, hop_length=hop_length)[1:]
edges = np.arange(1, n+2)
return basis * (edges + 0.5) / edges | def __coord_tempo(n, sr=22050, hop_length=512, **_kwargs):
'''Tempo coordinates'''
basis = core.tempo_frequencies(n+2, sr=sr, hop_length=hop_length)[1:]
edges = np.arange(1, n+2)
return basis * (edges + 0.5) / edges | [
"Tempo",
"coordinates"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L965-L969 | [
"def",
"__coord_tempo",
"(",
"n",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"*",
"*",
"_kwargs",
")",
":",
"basis",
"=",
"core",
".",
"tempo_frequencies",
"(",
"n",
"+",
"2",
",",
"sr",
"=",
"sr",
",",
"hop_length",
"=",
"hop_len... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __coord_time | Get time coordinates from frames | librosa/display.py | def __coord_time(n, sr=22050, hop_length=512, **_kwargs):
'''Get time coordinates from frames'''
return core.frames_to_time(np.arange(n+1), sr=sr, hop_length=hop_length) | def __coord_time(n, sr=22050, hop_length=512, **_kwargs):
'''Get time coordinates from frames'''
return core.frames_to_time(np.arange(n+1), sr=sr, hop_length=hop_length) | [
"Get",
"time",
"coordinates",
"from",
"frames"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L977-L979 | [
"def",
"__coord_time",
"(",
"n",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"*",
"*",
"_kwargs",
")",
":",
"return",
"core",
".",
"frames_to_time",
"(",
"np",
".",
"arange",
"(",
"n",
"+",
"1",
")",
",",
"sr",
"=",
"sr",
",",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | estimate_tuning | Estimate the tuning of an audio time series or spectrogram input.
Parameters
----------
y: np.ndarray [shape=(n,)] or None
audio signal
sr : number > 0 [scalar]
audio sampling rate of `y`
S: np.ndarray [shape=(d, t)] or None
magnitude or power spectrogram
n_fft : int ... | librosa/core/pitch.py | def estimate_tuning(y=None, sr=22050, S=None, n_fft=2048,
resolution=0.01, bins_per_octave=12, **kwargs):
'''Estimate the tuning of an audio time series or spectrogram input.
Parameters
----------
y: np.ndarray [shape=(n,)] or None
audio signal
sr : number > 0 [scalar]
... | def estimate_tuning(y=None, sr=22050, S=None, n_fft=2048,
resolution=0.01, bins_per_octave=12, **kwargs):
'''Estimate the tuning of an audio time series or spectrogram input.
Parameters
----------
y: np.ndarray [shape=(n,)] or None
audio signal
sr : number > 0 [scalar]
... | [
"Estimate",
"the",
"tuning",
"of",
"an",
"audio",
"time",
"series",
"or",
"spectrogram",
"input",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/pitch.py#L17-L93 | [
"def",
"estimate_tuning",
"(",
"y",
"=",
"None",
",",
"sr",
"=",
"22050",
",",
"S",
"=",
"None",
",",
"n_fft",
"=",
"2048",
",",
"resolution",
"=",
"0.01",
",",
"bins_per_octave",
"=",
"12",
",",
"*",
"*",
"kwargs",
")",
":",
"pitch",
",",
"mag",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | pitch_tuning | Given a collection of pitches, estimate its tuning offset
(in fractions of a bin) relative to A440=440.0Hz.
Parameters
----------
frequencies : array-like, float
A collection of frequencies detected in the signal.
See `piptrack`
resolution : float in `(0, 1)`
Resolution of ... | librosa/core/pitch.py | def pitch_tuning(frequencies, resolution=0.01, bins_per_octave=12):
'''Given a collection of pitches, estimate its tuning offset
(in fractions of a bin) relative to A440=440.0Hz.
Parameters
----------
frequencies : array-like, float
A collection of frequencies detected in the signal.
... | def pitch_tuning(frequencies, resolution=0.01, bins_per_octave=12):
'''Given a collection of pitches, estimate its tuning offset
(in fractions of a bin) relative to A440=440.0Hz.
Parameters
----------
frequencies : array-like, float
A collection of frequencies detected in the signal.
... | [
"Given",
"a",
"collection",
"of",
"pitches",
"estimate",
"its",
"tuning",
"offset",
"(",
"in",
"fractions",
"of",
"a",
"bin",
")",
"relative",
"to",
"A440",
"=",
"440",
".",
"0Hz",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/pitch.py#L96-L163 | [
"def",
"pitch_tuning",
"(",
"frequencies",
",",
"resolution",
"=",
"0.01",
",",
"bins_per_octave",
"=",
"12",
")",
":",
"frequencies",
"=",
"np",
".",
"atleast_1d",
"(",
"frequencies",
")",
"# Trim out any DC components",
"frequencies",
"=",
"frequencies",
"[",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | piptrack | Pitch tracking on thresholded parabolically-interpolated STFT.
This implementation uses the parabolic interpolation method described by [1]_.
.. [1] https://ccrma.stanford.edu/~jos/sasp/Sinusoidal_Peak_Interpolation.html
Parameters
----------
y: np.ndarray [shape=(n,)] or None
audio signa... | librosa/core/pitch.py | def piptrack(y=None, sr=22050, S=None, n_fft=2048, hop_length=None,
fmin=150.0, fmax=4000.0, threshold=0.1,
win_length=None, window='hann', center=True, pad_mode='reflect',
ref=None):
'''Pitch tracking on thresholded parabolically-interpolated STFT.
This implementation us... | def piptrack(y=None, sr=22050, S=None, n_fft=2048, hop_length=None,
fmin=150.0, fmax=4000.0, threshold=0.1,
win_length=None, window='hann', center=True, pad_mode='reflect',
ref=None):
'''Pitch tracking on thresholded parabolically-interpolated STFT.
This implementation us... | [
"Pitch",
"tracking",
"on",
"thresholded",
"parabolically",
"-",
"interpolated",
"STFT",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/pitch.py#L167-L338 | [
"def",
"piptrack",
"(",
"y",
"=",
"None",
",",
"sr",
"=",
"22050",
",",
"S",
"=",
"None",
",",
"n_fft",
"=",
"2048",
",",
"hop_length",
"=",
"None",
",",
"fmin",
"=",
"150.0",
",",
"fmax",
"=",
"4000.0",
",",
"threshold",
"=",
"0.1",
",",
"win_le... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | hpss | Decompose an audio time series into harmonic and percussive components.
This function automates the STFT->HPSS->ISTFT pipeline, and ensures that
the output waveforms have equal length to the input waveform `y`.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
kwargs... | librosa/effects.py | def hpss(y, **kwargs):
'''Decompose an audio time series into harmonic and percussive components.
This function automates the STFT->HPSS->ISTFT pipeline, and ensures that
the output waveforms have equal length to the input waveform `y`.
Parameters
----------
y : np.ndarray [shape=(n,)]
... | def hpss(y, **kwargs):
'''Decompose an audio time series into harmonic and percussive components.
This function automates the STFT->HPSS->ISTFT pipeline, and ensures that
the output waveforms have equal length to the input waveform `y`.
Parameters
----------
y : np.ndarray [shape=(n,)]
... | [
"Decompose",
"an",
"audio",
"time",
"series",
"into",
"harmonic",
"and",
"percussive",
"components",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L47-L98 | [
"def",
"hpss",
"(",
"y",
",",
"*",
"*",
"kwargs",
")",
":",
"# Compute the STFT matrix",
"stft",
"=",
"core",
".",
"stft",
"(",
"y",
")",
"# Decompose into harmonic and percussives",
"stft_harm",
",",
"stft_perc",
"=",
"decompose",
".",
"hpss",
"(",
"stft",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | harmonic | Extract harmonic elements from an audio time-series.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
kwargs : additional keyword arguments.
See `librosa.decompose.hpss` for details.
Returns
-------
y_harmonic : np.ndarray [shape=(n,)]
audio time ... | librosa/effects.py | def harmonic(y, **kwargs):
'''Extract harmonic elements from an audio time-series.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
kwargs : additional keyword arguments.
See `librosa.decompose.hpss` for details.
Returns
-------
y_harmonic : np.ndarra... | def harmonic(y, **kwargs):
'''Extract harmonic elements from an audio time-series.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
kwargs : additional keyword arguments.
See `librosa.decompose.hpss` for details.
Returns
-------
y_harmonic : np.ndarra... | [
"Extract",
"harmonic",
"elements",
"from",
"an",
"audio",
"time",
"-",
"series",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L101-L142 | [
"def",
"harmonic",
"(",
"y",
",",
"*",
"*",
"kwargs",
")",
":",
"# Compute the STFT matrix",
"stft",
"=",
"core",
".",
"stft",
"(",
"y",
")",
"# Remove percussives",
"stft_harm",
"=",
"decompose",
".",
"hpss",
"(",
"stft",
",",
"*",
"*",
"kwargs",
")",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | percussive | Extract percussive elements from an audio time-series.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
kwargs : additional keyword arguments.
See `librosa.decompose.hpss` for details.
Returns
-------
y_percussive : np.ndarray [shape=(n,)]
audio t... | librosa/effects.py | def percussive(y, **kwargs):
'''Extract percussive elements from an audio time-series.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
kwargs : additional keyword arguments.
See `librosa.decompose.hpss` for details.
Returns
-------
y_percussive : np.... | def percussive(y, **kwargs):
'''Extract percussive elements from an audio time-series.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
kwargs : additional keyword arguments.
See `librosa.decompose.hpss` for details.
Returns
-------
y_percussive : np.... | [
"Extract",
"percussive",
"elements",
"from",
"an",
"audio",
"time",
"-",
"series",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L145-L186 | [
"def",
"percussive",
"(",
"y",
",",
"*",
"*",
"kwargs",
")",
":",
"# Compute the STFT matrix",
"stft",
"=",
"core",
".",
"stft",
"(",
"y",
")",
"# Remove harmonics",
"stft_perc",
"=",
"decompose",
".",
"hpss",
"(",
"stft",
",",
"*",
"*",
"kwargs",
")",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | time_stretch | Time-stretch an audio series by a fixed rate.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
rate : float > 0 [scalar]
Stretch factor. If `rate > 1`, then the signal is sped up.
If `rate < 1`, then the signal is slowed down.
Returns
-------
... | librosa/effects.py | def time_stretch(y, rate):
'''Time-stretch an audio series by a fixed rate.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
rate : float > 0 [scalar]
Stretch factor. If `rate > 1`, then the signal is sped up.
If `rate < 1`, then the signal is slowed d... | def time_stretch(y, rate):
'''Time-stretch an audio series by a fixed rate.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time series
rate : float > 0 [scalar]
Stretch factor. If `rate > 1`, then the signal is sped up.
If `rate < 1`, then the signal is slowed d... | [
"Time",
"-",
"stretch",
"an",
"audio",
"series",
"by",
"a",
"fixed",
"rate",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L189-L239 | [
"def",
"time_stretch",
"(",
"y",
",",
"rate",
")",
":",
"if",
"rate",
"<=",
"0",
":",
"raise",
"ParameterError",
"(",
"'rate must be a positive number'",
")",
"# Construct the stft",
"stft",
"=",
"core",
".",
"stft",
"(",
"y",
")",
"# Stretch by phase vocoding",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | pitch_shift | Pitch-shift the waveform by `n_steps` half-steps.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time-series
sr : number > 0 [scalar]
audio sampling rate of `y`
n_steps : float [scalar]
how many (fractional) half-steps to shift `y`
bins_per_octave : float > ... | librosa/effects.py | def pitch_shift(y, sr, n_steps, bins_per_octave=12, res_type='kaiser_best'):
'''Pitch-shift the waveform by `n_steps` half-steps.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time-series
sr : number > 0 [scalar]
audio sampling rate of `y`
n_steps : float [scalar]
... | def pitch_shift(y, sr, n_steps, bins_per_octave=12, res_type='kaiser_best'):
'''Pitch-shift the waveform by `n_steps` half-steps.
Parameters
----------
y : np.ndarray [shape=(n,)]
audio time-series
sr : number > 0 [scalar]
audio sampling rate of `y`
n_steps : float [scalar]
... | [
"Pitch",
"-",
"shift",
"the",
"waveform",
"by",
"n_steps",
"half",
"-",
"steps",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L242-L307 | [
"def",
"pitch_shift",
"(",
"y",
",",
"sr",
",",
"n_steps",
",",
"bins_per_octave",
"=",
"12",
",",
"res_type",
"=",
"'kaiser_best'",
")",
":",
"if",
"bins_per_octave",
"<",
"1",
"or",
"not",
"np",
".",
"issubdtype",
"(",
"type",
"(",
"bins_per_octave",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | remix | Remix an audio signal by re-ordering time intervals.
Parameters
----------
y : np.ndarray [shape=(t,) or (2, t)]
Audio time series
intervals : iterable of tuples (start, end)
An iterable (list-like or generator) where the `i`th item
`intervals[i]` indicates the start and end (... | librosa/effects.py | def remix(y, intervals, align_zeros=True):
'''Remix an audio signal by re-ordering time intervals.
Parameters
----------
y : np.ndarray [shape=(t,) or (2, t)]
Audio time series
intervals : iterable of tuples (start, end)
An iterable (list-like or generator) where the `i`th item
... | def remix(y, intervals, align_zeros=True):
'''Remix an audio signal by re-ordering time intervals.
Parameters
----------
y : np.ndarray [shape=(t,) or (2, t)]
Audio time series
intervals : iterable of tuples (start, end)
An iterable (list-like or generator) where the `i`th item
... | [
"Remix",
"an",
"audio",
"signal",
"by",
"re",
"-",
"ordering",
"time",
"intervals",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L310-L387 | [
"def",
"remix",
"(",
"y",
",",
"intervals",
",",
"align_zeros",
"=",
"True",
")",
":",
"# Validate the audio buffer",
"util",
".",
"valid_audio",
"(",
"y",
",",
"mono",
"=",
"False",
")",
"y_out",
"=",
"[",
"]",
"if",
"align_zeros",
":",
"y_mono",
"=",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | _signal_to_frame_nonsilent | Frame-wise non-silent indicator for audio input.
This is a helper function for `trim` and `split`.
Parameters
----------
y : np.ndarray, shape=(n,) or (2,n)
Audio signal, mono or stereo
frame_length : int > 0
The number of samples per frame
hop_length : int > 0
The nu... | librosa/effects.py | def _signal_to_frame_nonsilent(y, frame_length=2048, hop_length=512, top_db=60,
ref=np.max):
'''Frame-wise non-silent indicator for audio input.
This is a helper function for `trim` and `split`.
Parameters
----------
y : np.ndarray, shape=(n,) or (2,n)
Audio ... | def _signal_to_frame_nonsilent(y, frame_length=2048, hop_length=512, top_db=60,
ref=np.max):
'''Frame-wise non-silent indicator for audio input.
This is a helper function for `trim` and `split`.
Parameters
----------
y : np.ndarray, shape=(n,) or (2,n)
Audio ... | [
"Frame",
"-",
"wise",
"non",
"-",
"silent",
"indicator",
"for",
"audio",
"input",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L390-L429 | [
"def",
"_signal_to_frame_nonsilent",
"(",
"y",
",",
"frame_length",
"=",
"2048",
",",
"hop_length",
"=",
"512",
",",
"top_db",
"=",
"60",
",",
"ref",
"=",
"np",
".",
"max",
")",
":",
"# Convert to mono",
"y_mono",
"=",
"core",
".",
"to_mono",
"(",
"y",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | trim | Trim leading and trailing silence from an audio signal.
Parameters
----------
y : np.ndarray, shape=(n,) or (2,n)
Audio signal, can be mono or stereo
top_db : number > 0
The threshold (in decibels) below reference to consider as
silence
ref : number or callable
The... | librosa/effects.py | def trim(y, top_db=60, ref=np.max, frame_length=2048, hop_length=512):
'''Trim leading and trailing silence from an audio signal.
Parameters
----------
y : np.ndarray, shape=(n,) or (2,n)
Audio signal, can be mono or stereo
top_db : number > 0
The threshold (in decibels) below refe... | def trim(y, top_db=60, ref=np.max, frame_length=2048, hop_length=512):
'''Trim leading and trailing silence from an audio signal.
Parameters
----------
y : np.ndarray, shape=(n,) or (2,n)
Audio signal, can be mono or stereo
top_db : number > 0
The threshold (in decibels) below refe... | [
"Trim",
"leading",
"and",
"trailing",
"silence",
"from",
"an",
"audio",
"signal",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L432-L498 | [
"def",
"trim",
"(",
"y",
",",
"top_db",
"=",
"60",
",",
"ref",
"=",
"np",
".",
"max",
",",
"frame_length",
"=",
"2048",
",",
"hop_length",
"=",
"512",
")",
":",
"non_silent",
"=",
"_signal_to_frame_nonsilent",
"(",
"y",
",",
"frame_length",
"=",
"frame... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | split | Split an audio signal into non-silent intervals.
Parameters
----------
y : np.ndarray, shape=(n,) or (2, n)
An audio signal
top_db : number > 0
The threshold (in decibels) below reference to consider as
silence
ref : number or callable
The reference power. By defa... | librosa/effects.py | def split(y, top_db=60, ref=np.max, frame_length=2048, hop_length=512):
'''Split an audio signal into non-silent intervals.
Parameters
----------
y : np.ndarray, shape=(n,) or (2, n)
An audio signal
top_db : number > 0
The threshold (in decibels) below reference to consider as
... | def split(y, top_db=60, ref=np.max, frame_length=2048, hop_length=512):
'''Split an audio signal into non-silent intervals.
Parameters
----------
y : np.ndarray, shape=(n,) or (2, n)
An audio signal
top_db : number > 0
The threshold (in decibels) below reference to consider as
... | [
"Split",
"an",
"audio",
"signal",
"into",
"non",
"-",
"silent",
"intervals",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L501-L561 | [
"def",
"split",
"(",
"y",
",",
"top_db",
"=",
"60",
",",
"ref",
"=",
"np",
".",
"max",
",",
"frame_length",
"=",
"2048",
",",
"hop_length",
"=",
"512",
")",
":",
"non_silent",
"=",
"_signal_to_frame_nonsilent",
"(",
"y",
",",
"frame_length",
"=",
"fram... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | stft | Short-time Fourier transform (STFT)
Returns a complex-valued matrix D such that
`np.abs(D[f, t])` is the magnitude of frequency bin `f`
at frame `t`
`np.angle(D[f, t])` is the phase of frequency bin `f`
at frame `t`
Parameters
----------
y : np.ndarray [shape=(n,)], re... | librosa/core/spectrum.py | def stft(y, n_fft=2048, hop_length=None, win_length=None, window='hann',
center=True, dtype=np.complex64, pad_mode='reflect'):
"""Short-time Fourier transform (STFT)
Returns a complex-valued matrix D such that
`np.abs(D[f, t])` is the magnitude of frequency bin `f`
at frame `t`
... | def stft(y, n_fft=2048, hop_length=None, win_length=None, window='hann',
center=True, dtype=np.complex64, pad_mode='reflect'):
"""Short-time Fourier transform (STFT)
Returns a complex-valued matrix D such that
`np.abs(D[f, t])` is the magnitude of frequency bin `f`
at frame `t`
... | [
"Short",
"-",
"time",
"Fourier",
"transform",
"(",
"STFT",
")"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L33-L189 | [
"def",
"stft",
"(",
"y",
",",
"n_fft",
"=",
"2048",
",",
"hop_length",
"=",
"None",
",",
"win_length",
"=",
"None",
",",
"window",
"=",
"'hann'",
",",
"center",
"=",
"True",
",",
"dtype",
"=",
"np",
".",
"complex64",
",",
"pad_mode",
"=",
"'reflect'"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | istft | Inverse short-time Fourier transform (ISTFT).
Converts a complex-valued spectrogram `stft_matrix` to time-series `y`
by minimizing the mean squared error between `stft_matrix` and STFT of
`y` as described in [1]_ up to Section 2 (reconstruction from MSTFT).
In general, window function, hop length and ... | librosa/core/spectrum.py | def istft(stft_matrix, hop_length=None, win_length=None, window='hann',
center=True, dtype=np.float32, length=None):
"""
Inverse short-time Fourier transform (ISTFT).
Converts a complex-valued spectrogram `stft_matrix` to time-series `y`
by minimizing the mean squared error between `stft_matr... | def istft(stft_matrix, hop_length=None, win_length=None, window='hann',
center=True, dtype=np.float32, length=None):
"""
Inverse short-time Fourier transform (ISTFT).
Converts a complex-valued spectrogram `stft_matrix` to time-series `y`
by minimizing the mean squared error between `stft_matr... | [
"Inverse",
"short",
"-",
"time",
"Fourier",
"transform",
"(",
"ISTFT",
")",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L193-L343 | [
"def",
"istft",
"(",
"stft_matrix",
",",
"hop_length",
"=",
"None",
",",
"win_length",
"=",
"None",
",",
"window",
"=",
"'hann'",
",",
"center",
"=",
"True",
",",
"dtype",
"=",
"np",
".",
"float32",
",",
"length",
"=",
"None",
")",
":",
"n_fft",
"=",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | ifgram | Compute the instantaneous frequency (as a proportion of the sampling rate)
obtained as the time-derivative of the phase of the complex spectrum as
described by [1]_.
Calculates regular STFT as a side effect.
.. [1] Abe, Toshihiko, Takao Kobayashi, and Satoshi Imai.
"Harmonics tracking and pitc... | librosa/core/spectrum.py | def ifgram(y, sr=22050, n_fft=2048, hop_length=None, win_length=None,
window='hann', norm=False, center=True, ref_power=1e-6,
clip=True, dtype=np.complex64, pad_mode='reflect'):
'''Compute the instantaneous frequency (as a proportion of the sampling rate)
obtained as the time-derivative of... | def ifgram(y, sr=22050, n_fft=2048, hop_length=None, win_length=None,
window='hann', norm=False, center=True, ref_power=1e-6,
clip=True, dtype=np.complex64, pad_mode='reflect'):
'''Compute the instantaneous frequency (as a proportion of the sampling rate)
obtained as the time-derivative of... | [
"Compute",
"the",
"instantaneous",
"frequency",
"(",
"as",
"a",
"proportion",
"of",
"the",
"sampling",
"rate",
")",
"obtained",
"as",
"the",
"time",
"-",
"derivative",
"of",
"the",
"phase",
"of",
"the",
"complex",
"spectrum",
"as",
"described",
"by",
"[",
... | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L359-L507 | [
"def",
"ifgram",
"(",
"y",
",",
"sr",
"=",
"22050",
",",
"n_fft",
"=",
"2048",
",",
"hop_length",
"=",
"None",
",",
"win_length",
"=",
"None",
",",
"window",
"=",
"'hann'",
",",
"norm",
"=",
"False",
",",
"center",
"=",
"True",
",",
"ref_power",
"=... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | magphase | Separate a complex-valued spectrogram D into its magnitude (S)
and phase (P) components, so that `D = S * P`.
Parameters
----------
D : np.ndarray [shape=(d, t), dtype=complex]
complex-valued spectrogram
power : float > 0
Exponent for the magnitude spectrogram,
e.g., 1 for ... | librosa/core/spectrum.py | def magphase(D, power=1):
"""Separate a complex-valued spectrogram D into its magnitude (S)
and phase (P) components, so that `D = S * P`.
Parameters
----------
D : np.ndarray [shape=(d, t), dtype=complex]
complex-valued spectrogram
power : float > 0
Exponent for the magnitude ... | def magphase(D, power=1):
"""Separate a complex-valued spectrogram D into its magnitude (S)
and phase (P) components, so that `D = S * P`.
Parameters
----------
D : np.ndarray [shape=(d, t), dtype=complex]
complex-valued spectrogram
power : float > 0
Exponent for the magnitude ... | [
"Separate",
"a",
"complex",
"-",
"valued",
"spectrogram",
"D",
"into",
"its",
"magnitude",
"(",
"S",
")",
"and",
"phase",
"(",
"P",
")",
"components",
"so",
"that",
"D",
"=",
"S",
"*",
"P",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L510-L570 | [
"def",
"magphase",
"(",
"D",
",",
"power",
"=",
"1",
")",
":",
"mag",
"=",
"np",
".",
"abs",
"(",
"D",
")",
"mag",
"**=",
"power",
"phase",
"=",
"np",
".",
"exp",
"(",
"1.j",
"*",
"np",
".",
"angle",
"(",
"D",
")",
")",
"return",
"mag",
","... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | phase_vocoder | Phase vocoder. Given an STFT matrix D, speed up by a factor of `rate`
Based on the implementation provided by [1]_.
.. [1] Ellis, D. P. W. "A phase vocoder in Matlab."
Columbia University, 2002.
http://www.ee.columbia.edu/~dpwe/resources/matlab/pvoc/
Examples
--------
>>> # Play ... | librosa/core/spectrum.py | def phase_vocoder(D, rate, hop_length=None):
"""Phase vocoder. Given an STFT matrix D, speed up by a factor of `rate`
Based on the implementation provided by [1]_.
.. [1] Ellis, D. P. W. "A phase vocoder in Matlab."
Columbia University, 2002.
http://www.ee.columbia.edu/~dpwe/resources/mat... | def phase_vocoder(D, rate, hop_length=None):
"""Phase vocoder. Given an STFT matrix D, speed up by a factor of `rate`
Based on the implementation provided by [1]_.
.. [1] Ellis, D. P. W. "A phase vocoder in Matlab."
Columbia University, 2002.
http://www.ee.columbia.edu/~dpwe/resources/mat... | [
"Phase",
"vocoder",
".",
"Given",
"an",
"STFT",
"matrix",
"D",
"speed",
"up",
"by",
"a",
"factor",
"of",
"rate"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L573-L657 | [
"def",
"phase_vocoder",
"(",
"D",
",",
"rate",
",",
"hop_length",
"=",
"None",
")",
":",
"n_fft",
"=",
"2",
"*",
"(",
"D",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
")",
"if",
"hop_length",
"is",
"None",
":",
"hop_length",
"=",
"int",
"(",
"n_fft",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | iirt | r'''Time-frequency representation using IIR filters [1]_.
This function will return a time-frequency representation
using a multirate filter bank consisting of IIR filters.
First, `y` is resampled as needed according to the provided `sample_rates`.
Then, a filterbank with with `n` band-pass filters is ... | librosa/core/spectrum.py | def iirt(y, sr=22050, win_length=2048, hop_length=None, center=True,
tuning=0.0, pad_mode='reflect', flayout=None, **kwargs):
r'''Time-frequency representation using IIR filters [1]_.
This function will return a time-frequency representation
using a multirate filter bank consisting of IIR filters.... | def iirt(y, sr=22050, win_length=2048, hop_length=None, center=True,
tuning=0.0, pad_mode='reflect', flayout=None, **kwargs):
r'''Time-frequency representation using IIR filters [1]_.
This function will return a time-frequency representation
using a multirate filter bank consisting of IIR filters.... | [
"r",
"Time",
"-",
"frequency",
"representation",
"using",
"IIR",
"filters",
"[",
"1",
"]",
"_",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L661-L811 | [
"def",
"iirt",
"(",
"y",
",",
"sr",
"=",
"22050",
",",
"win_length",
"=",
"2048",
",",
"hop_length",
"=",
"None",
",",
"center",
"=",
"True",
",",
"tuning",
"=",
"0.0",
",",
"pad_mode",
"=",
"'reflect'",
",",
"flayout",
"=",
"None",
",",
"*",
"*",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | power_to_db | Convert a power spectrogram (amplitude squared) to decibel (dB) units
This computes the scaling ``10 * log10(S / ref)`` in a numerically
stable way.
Parameters
----------
S : np.ndarray
input power
ref : scalar or callable
If scalar, the amplitude `abs(S)` is scaled relative t... | librosa/core/spectrum.py | def power_to_db(S, ref=1.0, amin=1e-10, top_db=80.0):
"""Convert a power spectrogram (amplitude squared) to decibel (dB) units
This computes the scaling ``10 * log10(S / ref)`` in a numerically
stable way.
Parameters
----------
S : np.ndarray
input power
ref : scalar or callable
... | def power_to_db(S, ref=1.0, amin=1e-10, top_db=80.0):
"""Convert a power spectrogram (amplitude squared) to decibel (dB) units
This computes the scaling ``10 * log10(S / ref)`` in a numerically
stable way.
Parameters
----------
S : np.ndarray
input power
ref : scalar or callable
... | [
"Convert",
"a",
"power",
"spectrogram",
"(",
"amplitude",
"squared",
")",
"to",
"decibel",
"(",
"dB",
")",
"units"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L815-L934 | [
"def",
"power_to_db",
"(",
"S",
",",
"ref",
"=",
"1.0",
",",
"amin",
"=",
"1e-10",
",",
"top_db",
"=",
"80.0",
")",
":",
"S",
"=",
"np",
".",
"asarray",
"(",
"S",
")",
"if",
"amin",
"<=",
"0",
":",
"raise",
"ParameterError",
"(",
"'amin must be str... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | amplitude_to_db | Convert an amplitude spectrogram to dB-scaled spectrogram.
This is equivalent to ``power_to_db(S**2)``, but is provided for convenience.
Parameters
----------
S : np.ndarray
input amplitude
ref : scalar or callable
If scalar, the amplitude `abs(S)` is scaled relative to `ref`:
... | librosa/core/spectrum.py | def amplitude_to_db(S, ref=1.0, amin=1e-5, top_db=80.0):
'''Convert an amplitude spectrogram to dB-scaled spectrogram.
This is equivalent to ``power_to_db(S**2)``, but is provided for convenience.
Parameters
----------
S : np.ndarray
input amplitude
ref : scalar or callable
If... | def amplitude_to_db(S, ref=1.0, amin=1e-5, top_db=80.0):
'''Convert an amplitude spectrogram to dB-scaled spectrogram.
This is equivalent to ``power_to_db(S**2)``, but is provided for convenience.
Parameters
----------
S : np.ndarray
input amplitude
ref : scalar or callable
If... | [
"Convert",
"an",
"amplitude",
"spectrogram",
"to",
"dB",
"-",
"scaled",
"spectrogram",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L966-L1023 | [
"def",
"amplitude_to_db",
"(",
"S",
",",
"ref",
"=",
"1.0",
",",
"amin",
"=",
"1e-5",
",",
"top_db",
"=",
"80.0",
")",
":",
"S",
"=",
"np",
".",
"asarray",
"(",
"S",
")",
"if",
"np",
".",
"issubdtype",
"(",
"S",
".",
"dtype",
",",
"np",
".",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | perceptual_weighting | Perceptual weighting of a power spectrogram:
`S_p[f] = A_weighting(f) + 10*log(S[f] / ref)`
Parameters
----------
S : np.ndarray [shape=(d, t)]
Power spectrogram
frequencies : np.ndarray [shape=(d,)]
Center frequency for each row of `S`
kwargs : additional keyword arguments
... | librosa/core/spectrum.py | def perceptual_weighting(S, frequencies, **kwargs):
'''Perceptual weighting of a power spectrogram:
`S_p[f] = A_weighting(f) + 10*log(S[f] / ref)`
Parameters
----------
S : np.ndarray [shape=(d, t)]
Power spectrogram
frequencies : np.ndarray [shape=(d,)]
Center frequency for e... | def perceptual_weighting(S, frequencies, **kwargs):
'''Perceptual weighting of a power spectrogram:
`S_p[f] = A_weighting(f) + 10*log(S[f] / ref)`
Parameters
----------
S : np.ndarray [shape=(d, t)]
Power spectrogram
frequencies : np.ndarray [shape=(d,)]
Center frequency for e... | [
"Perceptual",
"weighting",
"of",
"a",
"power",
"spectrogram",
":"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L1055-L1123 | [
"def",
"perceptual_weighting",
"(",
"S",
",",
"frequencies",
",",
"*",
"*",
"kwargs",
")",
":",
"offset",
"=",
"time_frequency",
".",
"A_weighting",
"(",
"frequencies",
")",
".",
"reshape",
"(",
"(",
"-",
"1",
",",
"1",
")",
")",
"return",
"offset",
"+... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | fmt | The fast Mellin transform (FMT) [1]_ of a uniformly sampled signal y.
When the Mellin parameter (beta) is 1/2, it is also known as the scale transform [2]_.
The scale transform can be useful for audio analysis because its magnitude is invariant
to scaling of the domain (e.g., time stretching or compression... | librosa/core/spectrum.py | def fmt(y, t_min=0.5, n_fmt=None, kind='cubic', beta=0.5, over_sample=1, axis=-1):
"""The fast Mellin transform (FMT) [1]_ of a uniformly sampled signal y.
When the Mellin parameter (beta) is 1/2, it is also known as the scale transform [2]_.
The scale transform can be useful for audio analysis because its... | def fmt(y, t_min=0.5, n_fmt=None, kind='cubic', beta=0.5, over_sample=1, axis=-1):
"""The fast Mellin transform (FMT) [1]_ of a uniformly sampled signal y.
When the Mellin parameter (beta) is 1/2, it is also known as the scale transform [2]_.
The scale transform can be useful for audio analysis because its... | [
"The",
"fast",
"Mellin",
"transform",
"(",
"FMT",
")",
"[",
"1",
"]",
"_",
"of",
"a",
"uniformly",
"sampled",
"signal",
"y",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L1127-L1328 | [
"def",
"fmt",
"(",
"y",
",",
"t_min",
"=",
"0.5",
",",
"n_fmt",
"=",
"None",
",",
"kind",
"=",
"'cubic'",
",",
"beta",
"=",
"0.5",
",",
"over_sample",
"=",
"1",
",",
"axis",
"=",
"-",
"1",
")",
":",
"n",
"=",
"y",
".",
"shape",
"[",
"axis",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | pcen | Per-channel energy normalization (PCEN) [1]_
This function normalizes a time-frequency representation `S` by
performing automatic gain control, followed by nonlinear compression:
P[f, t] = (S / (eps + M[f, t])**gain + bias)**power - bias**power
where `M` is the result of applying a low-pass, temp... | librosa/core/spectrum.py | def pcen(S, sr=22050, hop_length=512, gain=0.98, bias=2, power=0.5,
time_constant=0.400, eps=1e-6, b=None, max_size=1, ref=None,
axis=-1, max_axis=None, zi=None, return_zf=False):
'''Per-channel energy normalization (PCEN) [1]_
This function normalizes a time-frequency representation `S` by
... | def pcen(S, sr=22050, hop_length=512, gain=0.98, bias=2, power=0.5,
time_constant=0.400, eps=1e-6, b=None, max_size=1, ref=None,
axis=-1, max_axis=None, zi=None, return_zf=False):
'''Per-channel energy normalization (PCEN) [1]_
This function normalizes a time-frequency representation `S` by
... | [
"Per",
"-",
"channel",
"energy",
"normalization",
"(",
"PCEN",
")",
"[",
"1",
"]",
"_"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L1332-L1562 | [
"def",
"pcen",
"(",
"S",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"gain",
"=",
"0.98",
",",
"bias",
"=",
"2",
",",
"power",
"=",
"0.5",
",",
"time_constant",
"=",
"0.400",
",",
"eps",
"=",
"1e-6",
",",
"b",
"=",
"None",
",",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | _spectrogram | Helper function to retrieve a magnitude spectrogram.
This is primarily used in feature extraction functions that can operate on
either audio time-series or spectrogram input.
Parameters
----------
y : None or np.ndarray [ndim=1]
If provided, an audio time series
S : None or np.ndarra... | librosa/core/spectrum.py | def _spectrogram(y=None, S=None, n_fft=2048, hop_length=512, power=1,
win_length=None, window='hann', center=True, pad_mode='reflect'):
'''Helper function to retrieve a magnitude spectrogram.
This is primarily used in feature extraction functions that can operate on
either audio time-serie... | def _spectrogram(y=None, S=None, n_fft=2048, hop_length=512, power=1,
win_length=None, window='hann', center=True, pad_mode='reflect'):
'''Helper function to retrieve a magnitude spectrogram.
This is primarily used in feature extraction functions that can operate on
either audio time-serie... | [
"Helper",
"function",
"to",
"retrieve",
"a",
"magnitude",
"spectrogram",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/spectrum.py#L1565-L1636 | [
"def",
"_spectrogram",
"(",
"y",
"=",
"None",
",",
"S",
"=",
"None",
",",
"n_fft",
"=",
"2048",
",",
"hop_length",
"=",
"512",
",",
"power",
"=",
"1",
",",
"win_length",
"=",
"None",
",",
"window",
"=",
"'hann'",
",",
"center",
"=",
"True",
",",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | hpss_beats | HPSS beat tracking
:parameters:
- input_file : str
Path to input audio file (wav, mp3, m4a, flac, etc.)
- output_file : str
Path to save beat event timestamps as a CSV file | examples/hpss_beats.py | def hpss_beats(input_file, output_csv):
'''HPSS beat tracking
:parameters:
- input_file : str
Path to input audio file (wav, mp3, m4a, flac, etc.)
- output_file : str
Path to save beat event timestamps as a CSV file
'''
# Load the file
print('Loading ', input_file... | def hpss_beats(input_file, output_csv):
'''HPSS beat tracking
:parameters:
- input_file : str
Path to input audio file (wav, mp3, m4a, flac, etc.)
- output_file : str
Path to save beat event timestamps as a CSV file
'''
# Load the file
print('Loading ', input_file... | [
"HPSS",
"beat",
"tracking"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/examples/hpss_beats.py#L24-L62 | [
"def",
"hpss_beats",
"(",
"input_file",
",",
"output_csv",
")",
":",
"# Load the file",
"print",
"(",
"'Loading '",
",",
"input_file",
")",
"y",
",",
"sr",
"=",
"librosa",
".",
"load",
"(",
"input_file",
")",
"# Do HPSS",
"print",
"(",
"'Harmonic-percussive s... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | decompose | Decompose a feature matrix.
Given a spectrogram `S`, produce a decomposition into `components`
and `activations` such that `S ~= components.dot(activations)`.
By default, this is done with with non-negative matrix factorization (NMF),
but any `sklearn.decomposition`-type object will work.
Parame... | librosa/decompose.py | def decompose(S, n_components=None, transformer=None, sort=False, fit=True, **kwargs):
"""Decompose a feature matrix.
Given a spectrogram `S`, produce a decomposition into `components`
and `activations` such that `S ~= components.dot(activations)`.
By default, this is done with with non-negative matri... | def decompose(S, n_components=None, transformer=None, sort=False, fit=True, **kwargs):
"""Decompose a feature matrix.
Given a spectrogram `S`, produce a decomposition into `components`
and `activations` such that `S ~= components.dot(activations)`.
By default, this is done with with non-negative matri... | [
"Decompose",
"a",
"feature",
"matrix",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/decompose.py#L30-L187 | [
"def",
"decompose",
"(",
"S",
",",
"n_components",
"=",
"None",
",",
"transformer",
"=",
"None",
",",
"sort",
"=",
"False",
",",
"fit",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"transformer",
"is",
"None",
":",
"if",
"fit",
"is",
"Fals... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | hpss | Median-filtering harmonic percussive source separation (HPSS).
If `margin = 1.0`, decomposes an input spectrogram `S = H + P`
where `H` contains the harmonic components,
and `P` contains the percussive components.
If `margin > 1.0`, decomposes an input spectrogram `S = H + P + R`
where `R` contain... | librosa/decompose.py | def hpss(S, kernel_size=31, power=2.0, mask=False, margin=1.0):
"""Median-filtering harmonic percussive source separation (HPSS).
If `margin = 1.0`, decomposes an input spectrogram `S = H + P`
where `H` contains the harmonic components,
and `P` contains the percussive components.
If `margin > 1.0`... | def hpss(S, kernel_size=31, power=2.0, mask=False, margin=1.0):
"""Median-filtering harmonic percussive source separation (HPSS).
If `margin = 1.0`, decomposes an input spectrogram `S = H + P`
where `H` contains the harmonic components,
and `P` contains the percussive components.
If `margin > 1.0`... | [
"Median",
"-",
"filtering",
"harmonic",
"percussive",
"source",
"separation",
"(",
"HPSS",
")",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/decompose.py#L191-L375 | [
"def",
"hpss",
"(",
"S",
",",
"kernel_size",
"=",
"31",
",",
"power",
"=",
"2.0",
",",
"mask",
"=",
"False",
",",
"margin",
"=",
"1.0",
")",
":",
"if",
"np",
".",
"iscomplexobj",
"(",
"S",
")",
":",
"S",
",",
"phase",
"=",
"core",
".",
"magphas... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | nn_filter | Filtering by nearest-neighbors.
Each data point (e.g, spectrogram column) is replaced
by aggregating its nearest neighbors in feature space.
This can be useful for de-noising a spectrogram or feature matrix.
The non-local means method [1]_ can be recovered by providing a
weighted recurrence matri... | librosa/decompose.py | def nn_filter(S, rec=None, aggregate=None, axis=-1, **kwargs):
'''Filtering by nearest-neighbors.
Each data point (e.g, spectrogram column) is replaced
by aggregating its nearest neighbors in feature space.
This can be useful for de-noising a spectrogram or feature matrix.
The non-local means met... | def nn_filter(S, rec=None, aggregate=None, axis=-1, **kwargs):
'''Filtering by nearest-neighbors.
Each data point (e.g, spectrogram column) is replaced
by aggregating its nearest neighbors in feature space.
This can be useful for de-noising a spectrogram or feature matrix.
The non-local means met... | [
"Filtering",
"by",
"nearest",
"-",
"neighbors",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/decompose.py#L379-L513 | [
"def",
"nn_filter",
"(",
"S",
",",
"rec",
"=",
"None",
",",
"aggregate",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"aggregate",
"is",
"None",
":",
"aggregate",
"=",
"np",
".",
"mean",
"if",
"rec",
"is",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __nn_filter_helper | Nearest-neighbor filter helper function.
This is an internal function, not for use outside of the decompose module.
It applies the nearest-neighbor filter to S, assuming that the first index
corresponds to observations.
Parameters
----------
R_data, R_indices, R_ptr : np.ndarrays
The ... | librosa/decompose.py | def __nn_filter_helper(R_data, R_indices, R_ptr, S, aggregate):
'''Nearest-neighbor filter helper function.
This is an internal function, not for use outside of the decompose module.
It applies the nearest-neighbor filter to S, assuming that the first index
corresponds to observations.
Parameters... | def __nn_filter_helper(R_data, R_indices, R_ptr, S, aggregate):
'''Nearest-neighbor filter helper function.
This is an internal function, not for use outside of the decompose module.
It applies the nearest-neighbor filter to S, assuming that the first index
corresponds to observations.
Parameters... | [
"Nearest",
"-",
"neighbor",
"filter",
"helper",
"function",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/decompose.py#L516-L560 | [
"def",
"__nn_filter_helper",
"(",
"R_data",
",",
"R_indices",
",",
"R_ptr",
",",
"S",
",",
"aggregate",
")",
":",
"s_out",
"=",
"np",
".",
"empty_like",
"(",
"S",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"R_ptr",
")",
"-",
"1",
")",
":",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | mel | Create a Filterbank matrix to combine FFT bins into Mel-frequency bins
Parameters
----------
sr : number > 0 [scalar]
sampling rate of the incoming signal
n_fft : int > 0 [scalar]
number of FFT components
n_mels : int > 0 [scalar]
number of Mel bands to gener... | librosa/filters.py | def mel(sr, n_fft, n_mels=128, fmin=0.0, fmax=None, htk=False,
norm=1, dtype=np.float32):
"""Create a Filterbank matrix to combine FFT bins into Mel-frequency bins
Parameters
----------
sr : number > 0 [scalar]
sampling rate of the incoming signal
n_fft : int > 0 [scalar... | def mel(sr, n_fft, n_mels=128, fmin=0.0, fmax=None, htk=False,
norm=1, dtype=np.float32):
"""Create a Filterbank matrix to combine FFT bins into Mel-frequency bins
Parameters
----------
sr : number > 0 [scalar]
sampling rate of the incoming signal
n_fft : int > 0 [scalar... | [
"Create",
"a",
"Filterbank",
"matrix",
"to",
"combine",
"FFT",
"bins",
"into",
"Mel",
"-",
"frequency",
"bins"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L112-L225 | [
"def",
"mel",
"(",
"sr",
",",
"n_fft",
",",
"n_mels",
"=",
"128",
",",
"fmin",
"=",
"0.0",
",",
"fmax",
"=",
"None",
",",
"htk",
"=",
"False",
",",
"norm",
"=",
"1",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
":",
"if",
"fmax",
"is",
"None... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | chroma | Create a Filterbank matrix to convert STFT to chroma
Parameters
----------
sr : number > 0 [scalar]
audio sampling rate
n_fft : int > 0 [scalar]
number of FFT bins
n_chroma : int > 0 [scalar]
number of chroma bins
A440 : float > 0 [scalar]
Re... | librosa/filters.py | def chroma(sr, n_fft, n_chroma=12, A440=440.0, ctroct=5.0,
octwidth=2, norm=2, base_c=True, dtype=np.float32):
"""Create a Filterbank matrix to convert STFT to chroma
Parameters
----------
sr : number > 0 [scalar]
audio sampling rate
n_fft : int > 0 [scalar]
... | def chroma(sr, n_fft, n_chroma=12, A440=440.0, ctroct=5.0,
octwidth=2, norm=2, base_c=True, dtype=np.float32):
"""Create a Filterbank matrix to convert STFT to chroma
Parameters
----------
sr : number > 0 [scalar]
audio sampling rate
n_fft : int > 0 [scalar]
... | [
"Create",
"a",
"Filterbank",
"matrix",
"to",
"convert",
"STFT",
"to",
"chroma"
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L229-L359 | [
"def",
"chroma",
"(",
"sr",
",",
"n_fft",
",",
"n_chroma",
"=",
"12",
",",
"A440",
"=",
"440.0",
",",
"ctroct",
"=",
"5.0",
",",
"octwidth",
"=",
"2",
",",
"norm",
"=",
"2",
",",
"base_c",
"=",
"True",
",",
"dtype",
"=",
"np",
".",
"float32",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __float_window | Decorator function for windows with fractional input.
This function guarantees that for fractional `x`, the following hold:
1. `__float_window(window_function)(x)` has length `np.ceil(x)`
2. all values from `np.floor(x)` are set to 0.
For integer-valued `x`, there should be no change in behavior. | librosa/filters.py | def __float_window(window_spec):
'''Decorator function for windows with fractional input.
This function guarantees that for fractional `x`, the following hold:
1. `__float_window(window_function)(x)` has length `np.ceil(x)`
2. all values from `np.floor(x)` are set to 0.
For integer-valued `x`, th... | def __float_window(window_spec):
'''Decorator function for windows with fractional input.
This function guarantees that for fractional `x`, the following hold:
1. `__float_window(window_function)(x)` has length `np.ceil(x)`
2. all values from `np.floor(x)` are set to 0.
For integer-valued `x`, th... | [
"Decorator",
"function",
"for",
"windows",
"with",
"fractional",
"input",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L362-L387 | [
"def",
"__float_window",
"(",
"window_spec",
")",
":",
"def",
"_wrap",
"(",
"n",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"'''The wrapped window'''",
"n_min",
",",
"n_max",
"=",
"int",
"(",
"np",
".",
"floor",
"(",
"n",
")",
")",
",",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | constant_q | r'''Construct a constant-Q basis.
This uses the filter bank described by [1]_.
.. [1] McVicar, Matthew.
"A machine learning approach to automatic chord extraction."
Dissertation, University of Bristol. 2013.
Parameters
----------
sr : number > 0 [scalar]
Audio sam... | librosa/filters.py | def constant_q(sr, fmin=None, n_bins=84, bins_per_octave=12, tuning=0.0,
window='hann', filter_scale=1, pad_fft=True, norm=1,
dtype=np.complex64, **kwargs):
r'''Construct a constant-Q basis.
This uses the filter bank described by [1]_.
.. [1] McVicar, Matthew.
"A ... | def constant_q(sr, fmin=None, n_bins=84, bins_per_octave=12, tuning=0.0,
window='hann', filter_scale=1, pad_fft=True, norm=1,
dtype=np.complex64, **kwargs):
r'''Construct a constant-Q basis.
This uses the filter bank described by [1]_.
.. [1] McVicar, Matthew.
"A ... | [
"r",
"Construct",
"a",
"constant",
"-",
"Q",
"basis",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L391-L543 | [
"def",
"constant_q",
"(",
"sr",
",",
"fmin",
"=",
"None",
",",
"n_bins",
"=",
"84",
",",
"bins_per_octave",
"=",
"12",
",",
"tuning",
"=",
"0.0",
",",
"window",
"=",
"'hann'",
",",
"filter_scale",
"=",
"1",
",",
"pad_fft",
"=",
"True",
",",
"norm",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | constant_q_lengths | r'''Return length of each filter in a constant-Q basis.
Parameters
----------
sr : number > 0 [scalar]
Audio sampling rate
fmin : float > 0 [scalar]
Minimum frequency bin.
n_bins : int > 0 [scalar]
Number of frequencies. Defaults to 7 octaves (84 bins).
bins_per_octa... | librosa/filters.py | def constant_q_lengths(sr, fmin, n_bins=84, bins_per_octave=12,
tuning=0.0, window='hann', filter_scale=1):
r'''Return length of each filter in a constant-Q basis.
Parameters
----------
sr : number > 0 [scalar]
Audio sampling rate
fmin : float > 0 [scalar]
Mi... | def constant_q_lengths(sr, fmin, n_bins=84, bins_per_octave=12,
tuning=0.0, window='hann', filter_scale=1):
r'''Return length of each filter in a constant-Q basis.
Parameters
----------
sr : number > 0 [scalar]
Audio sampling rate
fmin : float > 0 [scalar]
Mi... | [
"r",
"Return",
"length",
"of",
"each",
"filter",
"in",
"a",
"constant",
"-",
"Q",
"basis",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L547-L618 | [
"def",
"constant_q_lengths",
"(",
"sr",
",",
"fmin",
",",
"n_bins",
"=",
"84",
",",
"bins_per_octave",
"=",
"12",
",",
"tuning",
"=",
"0.0",
",",
"window",
"=",
"'hann'",
",",
"filter_scale",
"=",
"1",
")",
":",
"if",
"fmin",
"<=",
"0",
":",
"raise",... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | cq_to_chroma | Convert a Constant-Q basis to Chroma.
Parameters
----------
n_input : int > 0 [scalar]
Number of input components (CQT bins)
bins_per_octave : int > 0 [scalar]
How many bins per octave in the CQT
n_chroma : int > 0 [scalar]
Number of output bins (per octave) in the chroma... | librosa/filters.py | def cq_to_chroma(n_input, bins_per_octave=12, n_chroma=12,
fmin=None, window=None, base_c=True, dtype=np.float32):
'''Convert a Constant-Q basis to Chroma.
Parameters
----------
n_input : int > 0 [scalar]
Number of input components (CQT bins)
bins_per_octave : int > 0 [sc... | def cq_to_chroma(n_input, bins_per_octave=12, n_chroma=12,
fmin=None, window=None, base_c=True, dtype=np.float32):
'''Convert a Constant-Q basis to Chroma.
Parameters
----------
n_input : int > 0 [scalar]
Number of input components (CQT bins)
bins_per_octave : int > 0 [sc... | [
"Convert",
"a",
"Constant",
"-",
"Q",
"basis",
"to",
"Chroma",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L622-L746 | [
"def",
"cq_to_chroma",
"(",
"n_input",
",",
"bins_per_octave",
"=",
"12",
",",
"n_chroma",
"=",
"12",
",",
"fmin",
"=",
"None",
",",
"window",
"=",
"None",
",",
"base_c",
"=",
"True",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
":",
"# How many fract... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | window_bandwidth | Get the equivalent noise bandwidth of a window function.
Parameters
----------
window : callable or string
A window function, or the name of a window function.
Examples:
- scipy.signal.hann
- 'boxcar'
n : int > 0
The number of coefficients to use in estimating ... | librosa/filters.py | def window_bandwidth(window, n=1000):
'''Get the equivalent noise bandwidth of a window function.
Parameters
----------
window : callable or string
A window function, or the name of a window function.
Examples:
- scipy.signal.hann
- 'boxcar'
n : int > 0
The... | def window_bandwidth(window, n=1000):
'''Get the equivalent noise bandwidth of a window function.
Parameters
----------
window : callable or string
A window function, or the name of a window function.
Examples:
- scipy.signal.hann
- 'boxcar'
n : int > 0
The... | [
"Get",
"the",
"equivalent",
"noise",
"bandwidth",
"of",
"a",
"window",
"function",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L750-L790 | [
"def",
"window_bandwidth",
"(",
"window",
",",
"n",
"=",
"1000",
")",
":",
"if",
"hasattr",
"(",
"window",
",",
"'__name__'",
")",
":",
"key",
"=",
"window",
".",
"__name__",
"else",
":",
"key",
"=",
"window",
"if",
"key",
"not",
"in",
"WINDOW_BANDWIDT... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | get_window | Compute a window function.
This is a wrapper for `scipy.signal.get_window` that additionally
supports callable or pre-computed windows.
Parameters
----------
window : string, tuple, number, callable, or list-like
The window specification:
- If string, it's the name of the window f... | librosa/filters.py | def get_window(window, Nx, fftbins=True):
'''Compute a window function.
This is a wrapper for `scipy.signal.get_window` that additionally
supports callable or pre-computed windows.
Parameters
----------
window : string, tuple, number, callable, or list-like
The window specification:
... | def get_window(window, Nx, fftbins=True):
'''Compute a window function.
This is a wrapper for `scipy.signal.get_window` that additionally
supports callable or pre-computed windows.
Parameters
----------
window : string, tuple, number, callable, or list-like
The window specification:
... | [
"Compute",
"a",
"window",
"function",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L794-L856 | [
"def",
"get_window",
"(",
"window",
",",
"Nx",
",",
"fftbins",
"=",
"True",
")",
":",
"if",
"six",
".",
"callable",
"(",
"window",
")",
":",
"return",
"window",
"(",
"Nx",
")",
"elif",
"(",
"isinstance",
"(",
"window",
",",
"(",
"six",
".",
"string... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | _multirate_fb | r'''Helper function to construct a multirate filterbank.
A filter bank consists of multiple band-pass filters which divide the input signal
into subbands. In the case of a multirate filter bank, the band-pass filters
operate with resampled versions of the input signal, e.g. to keep the length
of a ... | librosa/filters.py | def _multirate_fb(center_freqs=None, sample_rates=None, Q=25.0,
passband_ripple=1, stopband_attenuation=50, ftype='ellip', flayout='ba'):
r'''Helper function to construct a multirate filterbank.
A filter bank consists of multiple band-pass filters which divide the input signal
into subb... | def _multirate_fb(center_freqs=None, sample_rates=None, Q=25.0,
passband_ripple=1, stopband_attenuation=50, ftype='ellip', flayout='ba'):
r'''Helper function to construct a multirate filterbank.
A filter bank consists of multiple band-pass filters which divide the input signal
into subb... | [
"r",
"Helper",
"function",
"to",
"construct",
"a",
"multirate",
"filterbank",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L860-L954 | [
"def",
"_multirate_fb",
"(",
"center_freqs",
"=",
"None",
",",
"sample_rates",
"=",
"None",
",",
"Q",
"=",
"25.0",
",",
"passband_ripple",
"=",
"1",
",",
"stopband_attenuation",
"=",
"50",
",",
"ftype",
"=",
"'ellip'",
",",
"flayout",
"=",
"'ba'",
")",
"... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | mr_frequencies | r'''Helper function for generating center frequency and sample rate pairs.
This function will return center frequency and corresponding sample rates
to obtain similar pitch filterbank settings as described in [1]_.
Instead of starting with MIDI pitch `A0`, we start with `C0`.
.. [1] Müller, Meinard.
... | librosa/filters.py | def mr_frequencies(tuning):
r'''Helper function for generating center frequency and sample rate pairs.
This function will return center frequency and corresponding sample rates
to obtain similar pitch filterbank settings as described in [1]_.
Instead of starting with MIDI pitch `A0`, we start with `C0`... | def mr_frequencies(tuning):
r'''Helper function for generating center frequency and sample rate pairs.
This function will return center frequency and corresponding sample rates
to obtain similar pitch filterbank settings as described in [1]_.
Instead of starting with MIDI pitch `A0`, we start with `C0`... | [
"r",
"Helper",
"function",
"for",
"generating",
"center",
"frequency",
"and",
"sample",
"rate",
"pairs",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L958-L1002 | [
"def",
"mr_frequencies",
"(",
"tuning",
")",
":",
"center_freqs",
"=",
"midi_to_hz",
"(",
"np",
".",
"arange",
"(",
"24",
"+",
"tuning",
",",
"109",
"+",
"tuning",
")",
")",
"sample_rates",
"=",
"np",
".",
"asarray",
"(",
"len",
"(",
"np",
".",
"aran... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | semitone_filterbank | r'''Constructs a multirate filterbank of infinite-impulse response (IIR)
band-pass filters at user-defined center frequencies and sample rates.
By default, these center frequencies are set equal to the 88 fundamental
frequencies of the grand piano keyboard, according to a pitch tuning standard
of A440,... | librosa/filters.py | def semitone_filterbank(center_freqs=None, tuning=0.0, sample_rates=None, flayout='ba', **kwargs):
r'''Constructs a multirate filterbank of infinite-impulse response (IIR)
band-pass filters at user-defined center frequencies and sample rates.
By default, these center frequencies are set equal to the 88 fun... | def semitone_filterbank(center_freqs=None, tuning=0.0, sample_rates=None, flayout='ba', **kwargs):
r'''Constructs a multirate filterbank of infinite-impulse response (IIR)
band-pass filters at user-defined center frequencies and sample rates.
By default, these center frequencies are set equal to the 88 fun... | [
"r",
"Constructs",
"a",
"multirate",
"filterbank",
"of",
"infinite",
"-",
"impulse",
"response",
"(",
"IIR",
")",
"band",
"-",
"pass",
"filters",
"at",
"user",
"-",
"defined",
"center",
"frequencies",
"and",
"sample",
"rates",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L1005-L1090 | [
"def",
"semitone_filterbank",
"(",
"center_freqs",
"=",
"None",
",",
"tuning",
"=",
"0.0",
",",
"sample_rates",
"=",
"None",
",",
"flayout",
"=",
"'ba'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"center_freqs",
"is",
"None",
")",
"and",
"(",
"samp... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | __window_ss_fill | Helper function for window sum-square calculation. | librosa/filters.py | def __window_ss_fill(x, win_sq, n_frames, hop_length): # pragma: no cover
'''Helper function for window sum-square calculation.'''
n = len(x)
n_fft = len(win_sq)
for i in range(n_frames):
sample = i * hop_length
x[sample:min(n, sample + n_fft)] += win_sq[:max(0, min(n_fft, n - sample))... | def __window_ss_fill(x, win_sq, n_frames, hop_length): # pragma: no cover
'''Helper function for window sum-square calculation.'''
n = len(x)
n_fft = len(win_sq)
for i in range(n_frames):
sample = i * hop_length
x[sample:min(n, sample + n_fft)] += win_sq[:max(0, min(n_fft, n - sample))... | [
"Helper",
"function",
"for",
"window",
"sum",
"-",
"square",
"calculation",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L1094-L1101 | [
"def",
"__window_ss_fill",
"(",
"x",
",",
"win_sq",
",",
"n_frames",
",",
"hop_length",
")",
":",
"# pragma: no cover",
"n",
"=",
"len",
"(",
"x",
")",
"n_fft",
"=",
"len",
"(",
"win_sq",
")",
"for",
"i",
"in",
"range",
"(",
"n_frames",
")",
":",
"sa... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | window_sumsquare | Compute the sum-square envelope of a window function at a given hop length.
This is used to estimate modulation effects induced by windowing observations
in short-time fourier transforms.
Parameters
----------
window : string, tuple, number, callable, or list-like
Window specification, as ... | librosa/filters.py | def window_sumsquare(window, n_frames, hop_length=512, win_length=None, n_fft=2048,
dtype=np.float32, norm=None):
'''
Compute the sum-square envelope of a window function at a given hop length.
This is used to estimate modulation effects induced by windowing observations
in short-t... | def window_sumsquare(window, n_frames, hop_length=512, win_length=None, n_fft=2048,
dtype=np.float32, norm=None):
'''
Compute the sum-square envelope of a window function at a given hop length.
This is used to estimate modulation effects induced by windowing observations
in short-t... | [
"Compute",
"the",
"sum",
"-",
"square",
"envelope",
"of",
"a",
"window",
"function",
"at",
"a",
"given",
"hop",
"length",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L1104-L1175 | [
"def",
"window_sumsquare",
"(",
"window",
",",
"n_frames",
",",
"hop_length",
"=",
"512",
",",
"win_length",
"=",
"None",
",",
"n_fft",
"=",
"2048",
",",
"dtype",
"=",
"np",
".",
"float32",
",",
"norm",
"=",
"None",
")",
":",
"if",
"win_length",
"is",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | diagonal_filter | Build a two-dimensional diagonal filter.
This is primarily used for smoothing recurrence or self-similarity matrices.
Parameters
----------
window : string, tuple, number, callable, or list-like
The window function to use for the filter.
See `get_window` for details.
Note tha... | librosa/filters.py | def diagonal_filter(window, n, slope=1.0, angle=None, zero_mean=False):
'''Build a two-dimensional diagonal filter.
This is primarily used for smoothing recurrence or self-similarity matrices.
Parameters
----------
window : string, tuple, number, callable, or list-like
The window function ... | def diagonal_filter(window, n, slope=1.0, angle=None, zero_mean=False):
'''Build a two-dimensional diagonal filter.
This is primarily used for smoothing recurrence or self-similarity matrices.
Parameters
----------
window : string, tuple, number, callable, or list-like
The window function ... | [
"Build",
"a",
"two",
"-",
"dimensional",
"diagonal",
"filter",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L1179-L1238 | [
"def",
"diagonal_filter",
"(",
"window",
",",
"n",
",",
"slope",
"=",
"1.0",
",",
"angle",
"=",
"None",
",",
"zero_mean",
"=",
"False",
")",
":",
"if",
"angle",
"is",
"None",
":",
"angle",
"=",
"np",
".",
"arctan",
"(",
"slope",
")",
"win",
"=",
... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
test | spectral_centroid | Compute the spectral centroid.
Each frame of a magnitude spectrogram is normalized and treated as a
distribution over frequency bins, from which the mean (centroid) is
extracted per frame.
Parameters
----------
y : np.ndarray [shape=(n,)] or None
audio time series
sr : number > 0 ... | librosa/feature/spectral.py | def spectral_centroid(y=None, sr=22050, S=None, n_fft=2048, hop_length=512,
freq=None, win_length=None, window='hann', center=True,
pad_mode='reflect'):
'''Compute the spectral centroid.
Each frame of a magnitude spectrogram is normalized and treated as a
distrib... | def spectral_centroid(y=None, sr=22050, S=None, n_fft=2048, hop_length=512,
freq=None, win_length=None, window='hann', center=True,
pad_mode='reflect'):
'''Compute the spectral centroid.
Each frame of a magnitude spectrogram is normalized and treated as a
distrib... | [
"Compute",
"the",
"spectral",
"centroid",
"."
] | librosa/librosa | python | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/feature/spectral.py#L38-L168 | [
"def",
"spectral_centroid",
"(",
"y",
"=",
"None",
",",
"sr",
"=",
"22050",
",",
"S",
"=",
"None",
",",
"n_fft",
"=",
"2048",
",",
"hop_length",
"=",
"512",
",",
"freq",
"=",
"None",
",",
"win_length",
"=",
"None",
",",
"window",
"=",
"'hann'",
","... | 180e8e6eb8f958fa6b20b8cba389f7945d508247 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.