Module: Muze

Defined in:
lib/muze.rb,
lib/muze/errors.rb,
lib/muze/native.rb,
lib/muze/version.rb,
lib/muze/core/dct.rb,
lib/muze/core/stft.rb,
lib/muze/core/audio.rb,
lib/muze/core/cache.rb,
lib/muze/core/frames.rb,
lib/muze/core/matrix.rb,
lib/muze/filters/mel.rb,
lib/muze/core/windows.rb,
lib/muze/feature/mfcc.rb,
lib/muze/core/resample.rb,
lib/muze/feature/chroma.rb,
lib/muze/beat/beat_track.rb,
lib/muze/feature/context.rb,
lib/muze/io/audio_loader.rb,
lib/muze/io/audio_writer.rb,
lib/muze/display/specshow.rb,
lib/muze/feature/spectral.rb,
lib/muze/effects/streaming.rb,
lib/muze/onset/onset_detect.rb,
lib/muze/feature/aggregation.rb,
lib/muze/effects/time_stretch.rb,
lib/muze/filters/chroma_filter.rb,
lib/muze/effects/harmonic_percussive.rb,
lib/muze/io/audio_loader/ffmpeg_backend.rb,
lib/muze/io/audio_loader/wavify_backend.rb

Overview

Main entrypoint for Muze API.

Defined Under Namespace

Modules: Beat, Core, Display, Effects, Feature, Filters, IO, Native, Onset Classes: AudioLoadError, DependencyError, Error, ParameterError, UnsupportedFormatError

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.amplitude_to_db(s, ref: 1.0, amin: 1.0e-5, top_db: 80.0, abs: false) ⇒ Numo::SFloat

Parameters:

  • s (Numo::NArray)
  • ref (Float, Symbol, Proc) (defaults to: 1.0)
  • amin (Float) (defaults to: 1.0e-5)
  • top_db (Float, nil) (defaults to: 80.0)

Returns:

  • (Numo::SFloat)


102
103
104
# File 'lib/muze.rb', line 102

def amplitude_to_db(s, ref: 1.0, amin: 1.0e-5, top_db: 80.0, abs: false)
  Muze::Core::STFT.amplitude_to_db(s, ref:, amin:, top_db:, abs:)
end

.beat_sync(data, beats:, aggregate: :mean) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


257
258
259
# File 'lib/muze.rb', line 257

def beat_sync(data, beats:, aggregate: :mean)
  Muze::Feature.beat_sync(data, beats:, aggregate:)
end

.beat_track(y: nil, sr: 22_050, onset_envelope: nil, hop_length: 512, start_bpm: 120.0, tightness: 100, min_bpm: 30.0, max_bpm: 240.0, bpm: nil, fill_missing: true, return_metadata: false) ⇒ Array(Float, Array<Integer>)

Returns:

  • (Array(Float, Array<Integer>))


357
358
359
# File 'lib/muze.rb', line 357

def beat_track(y: nil, sr: 22_050, onset_envelope: nil, hop_length: 512, start_bpm: 120.0, tightness: 100, min_bpm: 30.0, max_bpm: 240.0, bpm: nil, fill_missing: true, return_metadata: false)
  Muze::Beat.beat_track(y:, sr:, onset_envelope:, hop_length:, start_bpm:, tightness:, min_bpm:, max_bpm:, bpm:, fill_missing:, return_metadata:)
end

.chroma(sr:, n_fft:, n_chroma: 12, tuning: 0.0, ctroct: nil, octwidth: nil) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


332
333
334
# File 'lib/muze.rb', line 332

def chroma(sr:, n_fft:, n_chroma: 12, tuning: 0.0, ctroct: nil, octwidth: nil)
  Muze::Filters.chroma(sr:, n_fft:, n_chroma:, tuning:, ctroct:, octwidth:)
end

.chroma_stft(y: nil, sr: 22_050, s: nil, n_chroma: 12, n_fft: 2048, hop_length: 512, norm: 2, tuning: 0.0, ctroct: nil, octwidth: nil) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


337
338
339
# File 'lib/muze.rb', line 337

def chroma_stft(y: nil, sr: 22_050, s: nil, n_chroma: 12, n_fft: 2048, hop_length: 512, norm: 2, tuning: 0.0, ctroct: nil, octwidth: nil)
  Muze::Feature.chroma_stft(y:, sr:, s:, n_chroma:, n_fft:, hop_length:, norm:, tuning:, ctroct:, octwidth:)
end

.db_to_amplitude(s_db, ref: 1.0) ⇒ Numo::SFloat

Parameters:

  • s_db (Numo::NArray)
  • ref (Float) (defaults to: 1.0)

Returns:

  • (Numo::SFloat)


118
119
120
# File 'lib/muze.rb', line 118

def db_to_amplitude(s_db, ref: 1.0)
  Muze::Core::STFT.db_to_amplitude(s_db, ref:)
end

.db_to_power(s_db, ref: 1.0) ⇒ Numo::SFloat

Parameters:

  • s_db (Numo::NArray)
  • ref (Float) (defaults to: 1.0)

Returns:

  • (Numo::SFloat)


125
126
127
# File 'lib/muze.rb', line 125

def db_to_power(s_db, ref: 1.0)
  Muze::Core::STFT.db_to_power(s_db, ref:)
end

.deemphasis(y, coef: 0.97) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


407
408
409
# File 'lib/muze.rb', line 407

def deemphasis(y, coef: 0.97)
  Muze::Effects.deemphasis(y, coef:)
end

.delta(data, order: 1, width: 9, mode: :interp) ⇒ Numo::SFloat

Parameters:

  • data (Numo::SFloat)
  • order (Integer) (defaults to: 1)
  • width (Integer) (defaults to: 9)
  • mode (Symbol) (defaults to: :interp)

Returns:

  • (Numo::SFloat)


237
238
239
# File 'lib/muze.rb', line 237

def delta(data, order: 1, width: 9, mode: :interp)
  Muze::Feature.delta(data, order:, width:, mode:)
end

.feature_context(y:, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect) ⇒ Muze::Feature::Context



242
243
244
# File 'lib/muze.rb', line 242

def feature_context(y:, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect)
  Muze::Feature.context(y:, sr:, n_fft:, hop_length:, center:, pad_mode:)
end

.feature_stack(y:, sr: 22_050, features: Muze::Feature::Context::DEFAULT_FEATURES, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect) ⇒ Hash

Returns:

  • (Hash)


252
253
254
# File 'lib/muze.rb', line 252

def feature_stack(y:, sr: 22_050, features: Muze::Feature::Context::DEFAULT_FEATURES, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect)
  Muze::Feature.extract(y:, sr:, features:, n_fft:, hop_length:, center:, pad_mode:)
end

.features(y:, sr: 22_050, features: Muze::Feature::Context::DEFAULT_FEATURES, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect) ⇒ Hash

Returns:

  • (Hash)


247
248
249
# File 'lib/muze.rb', line 247

def features(y:, sr: 22_050, features: Muze::Feature::Context::DEFAULT_FEATURES, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect)
  Muze::Feature.extract(y:, sr:, features:, n_fft:, hop_length:, center:, pad_mode:)
end

.fft_frequencies(sr:, n_fft:) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


130
131
132
# File 'lib/muze.rb', line 130

def fft_frequencies(sr:, n_fft:)
  Muze::Core::STFT.fft_frequencies(sr:, n_fft:)
end

.frames_to_samples(frames, hop_length:) ⇒ Integer, Numo::SFloat

Returns:

  • (Integer, Numo::SFloat)


145
146
147
# File 'lib/muze.rb', line 145

def frames_to_samples(frames, hop_length:)
  Muze::Core::STFT.frames_to_samples(frames, hop_length:)
end

.frames_to_time(frames, sr:, hop_length:) ⇒ Float, Numo::SFloat

Returns:

  • (Float, Numo::SFloat)


135
136
137
# File 'lib/muze.rb', line 135

def frames_to_time(frames, sr:, hop_length:)
  Muze::Core::STFT.frames_to_time(frames, sr:, hop_length:)
end

.hpss(y, kernel_size: 31, power: 2.0, margin: 1.0, n_fft: 2048, hop_length: 512, return_masks: false) ⇒ Array(Numo::SFloat, Numo::SFloat)

Returns:

  • (Array(Numo::SFloat, Numo::SFloat))


367
368
369
# File 'lib/muze.rb', line 367

def hpss(y, kernel_size: 31, power: 2.0, margin: 1.0, n_fft: 2048, hop_length: 512, return_masks: false)
  Muze::Effects.hpss(y, kernel_size:, power:, margin:, n_fft:, hop_length:, return_masks:)
end

.hpss_stream(chunks, kernel_size: 31, power: 2.0, margin: 1.0, n_fft: 2048, hop_length: 512, overlap: n_fft, &block) ⇒ Enumerator?

Returns:

  • (Enumerator, nil)


372
373
374
# File 'lib/muze.rb', line 372

def hpss_stream(chunks, kernel_size: 31, power: 2.0, margin: 1.0, n_fft: 2048, hop_length: 512, overlap: n_fft, &block)
  Muze::Effects.hpss_stream(chunks, kernel_size:, power:, margin:, n_fft:, hop_length:, overlap:, &block)
end

.info(path, format: nil) ⇒ Hash

Returns:

  • (Hash)


53
54
55
# File 'lib/muze.rb', line 53

def info(path, format: nil)
  Muze::IO::AudioLoader.info(path, format:)
end

.istft(stft_matrix, hop_length: 512, win_length: nil, window: :hann, center: true, length: nil, dtype: Numo::SFloat, periodic: false) ⇒ Numo::SFloat

Parameters:

  • stft_matrix (Numo::DComplex)
  • hop_length (Integer) (defaults to: 512)
  • win_length (Integer, nil) (defaults to: nil)
  • window (Symbol) (defaults to: :hann)
  • center (Boolean) (defaults to: true)
  • length (Integer, nil) (defaults to: nil)

Returns:

  • (Numo::SFloat)


82
83
84
# File 'lib/muze.rb', line 82

def istft(stft_matrix, hop_length: 512, win_length: nil, window: :hann, center: true, length: nil, dtype: Numo::SFloat, periodic: false)
  Muze::Core::STFT.istft(stft_matrix, hop_length:, win_length:, window:, center:, length:, dtype:, periodic:)
end

.load(path, sr: 22_050, mono: true, offset: 0.0, duration: nil, dtype: Numo::SFloat, normalize: false, format: nil, weights: nil, max_bytes: nil) ⇒ Array(Numo::SFloat, Integer)

Parameters:

  • path (String)
  • sr (Integer, nil) (defaults to: 22_050)
  • mono (Boolean, Symbol) (defaults to: true)
  • offset (Float) (defaults to: 0.0)
  • duration (Float, nil) (defaults to: nil)
  • dtype (Class, Symbol) (defaults to: Numo::SFloat)
  • normalize (Boolean) (defaults to: false)

Returns:

  • (Array(Numo::SFloat, Integer))


43
44
45
# File 'lib/muze.rb', line 43

def load(path, sr: 22_050, mono: true, offset: 0.0, duration: nil, dtype: Numo::SFloat, normalize: false, format: nil, weights: nil, max_bytes: nil)
  Muze::IO::AudioLoader.load(path, sr:, mono:, offset:, duration:, dtype:, normalize:, format:, weights:, max_bytes:)
end

.load_stream(path, sr: nil, mono: true, offset: 0.0, duration: nil, dtype: Numo::SFloat, format: nil, weights: nil, max_bytes: nil, chunk_frames: 16_384, &block) ⇒ Enumerator?

Returns:

  • (Enumerator, nil)


48
49
50
# File 'lib/muze.rb', line 48

def load_stream(path, sr: nil, mono: true, offset: 0.0, duration: nil, dtype: Numo::SFloat, format: nil, weights: nil, max_bytes: nil, chunk_frames: 16_384, &block)
  Muze::IO::AudioLoader.load_stream(path, sr:, mono:, offset:, duration:, dtype:, format:, weights:, max_bytes:, chunk_frames:, &block)
end

.magphase(stft_matrix, eps: Muze::Core::STFT::EPSILON, dtype: Numo::SFloat) ⇒ Array(Numo::SFloat, Numo::DComplex)

Parameters:

  • stft_matrix (Numo::DComplex)

Returns:

  • (Array(Numo::SFloat, Numo::DComplex))


88
89
90
# File 'lib/muze.rb', line 88

def magphase(stft_matrix, eps: Muze::Core::STFT::EPSILON, dtype: Numo::SFloat)
  Muze::Core::STFT.magphase(stft_matrix, eps:, dtype:)
end

.mel(sr: 22_050, n_fft: 2048, n_mels: 128, fmin: 0.0, fmax: nil, htk: false, norm: nil) ⇒ Numo::SFloat

Parameters:

  • sr (Integer) (defaults to: 22_050)
  • n_fft (Integer) (defaults to: 2048)
  • n_mels (Integer) (defaults to: 128)
  • fmin (Float) (defaults to: 0.0)
  • fmax (Float, nil) (defaults to: nil)
  • htk (Boolean) (defaults to: false)

Returns:

  • (Numo::SFloat)


196
197
198
# File 'lib/muze.rb', line 196

def mel(sr: 22_050, n_fft: 2048, n_mels: 128, fmin: 0.0, fmax: nil, htk: false, norm: nil)
  Muze::Filters.mel(sr:, n_fft:, n_mels:, fmin:, fmax:, htk:, norm:)
end

.mel_frequencies(n_mels:, fmin:, fmax:, htk: false) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


201
202
203
# File 'lib/muze.rb', line 201

def mel_frequencies(n_mels:, fmin:, fmax:, htk: false)
  Muze::Filters.mel_frequencies(n_mels:, fmin:, fmax:, htk:)
end

.melspectrogram(y: nil, sr: 22_050, s: nil, n_fft: 2048, hop_length: 512, n_mels: 128, fmin: 0.0, fmax: nil, power: 2.0, center: true, window: :hann, pad_mode: :reflect, norm: nil, s_kind: :power) ⇒ Numo::SFloat

Parameters:

  • y (Numo::SFloat, Array<Float>, nil) (defaults to: nil)
  • sr (Integer) (defaults to: 22_050)
  • s (Numo::SFloat, nil) (defaults to: nil)
  • n_fft (Integer) (defaults to: 2048)
  • hop_length (Integer) (defaults to: 512)
  • n_mels (Integer) (defaults to: 128)
  • fmin (Float) (defaults to: 0.0)
  • fmax (Float, nil) (defaults to: nil)

Returns:

  • (Numo::SFloat)


214
215
216
# File 'lib/muze.rb', line 214

def melspectrogram(y: nil, sr: 22_050, s: nil, n_fft: 2048, hop_length: 512, n_mels: 128, fmin: 0.0, fmax: nil, power: 2.0, center: true, window: :hann, pad_mode: :reflect, norm: nil, s_kind: :power)
  Muze::Feature.melspectrogram(y:, sr:, s:, n_fft:, hop_length:, n_mels:, fmin:, fmax:, power:, center:, window:, pad_mode:, norm:, s_kind:)
end

.mfcc(y: nil, sr: 22_050, s: nil, n_mfcc: 20, n_fft: 2048, hop_length: 512, n_mels: 128, fmin: 0.0, fmax: nil, dct_type: 2, lifter: 0, norm: :ortho, s_kind: :mel_power) ⇒ Numo::SFloat

Parameters:

  • y (Numo::SFloat, Array<Float>, nil) (defaults to: nil)
  • sr (Integer) (defaults to: 22_050)
  • s (Numo::SFloat, nil) (defaults to: nil)
  • n_mfcc (Integer) (defaults to: 20)
  • n_fft (Integer) (defaults to: 2048)
  • hop_length (Integer) (defaults to: 512)
  • n_mels (Integer) (defaults to: 128)
  • fmin (Float) (defaults to: 0.0)
  • fmax (Float, nil) (defaults to: nil)

Returns:

  • (Numo::SFloat)


228
229
230
# File 'lib/muze.rb', line 228

def mfcc(y: nil, sr: 22_050, s: nil, n_mfcc: 20, n_fft: 2048, hop_length: 512, n_mels: 128, fmin: 0.0, fmax: nil, dct_type: 2, lifter: 0, norm: :ortho, s_kind: :mel_power)
  Muze::Feature.mfcc(y:, sr:, s:, n_mfcc:, n_fft:, hop_length:, n_mels:, fmin:, fmax:, dct_type:, lifter:, norm:, s_kind:)
end

.normalize(y, peak: 1.0, axis: nil) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


170
171
172
# File 'lib/muze.rb', line 170

def normalize(y, peak: 1.0, axis: nil)
  Muze::Core::Audio.normalize(y, peak:, axis:)
end

.onset_detect(y: nil, sr: 22_050, onset_envelope: nil, hop_length: 512, backtrack: false, units: :frames, pre_max: 1, post_max: 1, pre_avg: 1, post_avg: 1, delta: nil, wait: 0, adaptive: false, energy: nil) ⇒ Array<Integer, Float>

Returns:

  • (Array<Integer, Float>)


352
353
354
# File 'lib/muze.rb', line 352

def onset_detect(y: nil, sr: 22_050, onset_envelope: nil, hop_length: 512, backtrack: false, units: :frames, pre_max: 1, post_max: 1, pre_avg: 1, post_avg: 1, delta: nil, wait: 0, adaptive: false, energy: nil)
  Muze::Onset.onset_detect(y:, sr:, onset_envelope:, hop_length:, backtrack:, units:, pre_max:, post_max:, pre_avg:, post_avg:, delta:, wait:, adaptive:, energy:)
end

.onset_strength(y: nil, sr: 22_050, s: nil, hop_length: 512, n_fft: 2048, lag: 1, log: false, max_size: 1, normalize: false) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


347
348
349
# File 'lib/muze.rb', line 347

def onset_strength(y: nil, sr: 22_050, s: nil, hop_length: 512, n_fft: 2048, lag: 1, log: false, max_size: 1, normalize: false)
  Muze::Onset.onset_strength(y:, sr:, s:, hop_length:, n_fft:, lag:, log:, max_size:, normalize:)
end

.onsetshow(onset_envelope, sr: 22_050, hop_length: 512, output: nil, width: 800, height: 160, normalize: true) ⇒ String

Returns:

  • (String)


422
423
424
# File 'lib/muze.rb', line 422

def onsetshow(onset_envelope, sr: 22_050, hop_length: 512, output: nil, width: 800, height: 160, normalize: true)
  Muze::Display.onsetshow(onset_envelope, sr:, hop_length:, output:, width:, height:, normalize:)
end

.pitch_shift(y, sr: 22_050, n_steps: 0, bins_per_octave: 12, res_type: :auto, normalize: false, clip: nil) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


387
388
389
# File 'lib/muze.rb', line 387

def pitch_shift(y, sr: 22_050, n_steps: 0, bins_per_octave: 12, res_type: :auto, normalize: false, clip: nil)
  Muze::Effects.pitch_shift(y, sr:, n_steps:, bins_per_octave:, res_type:, normalize:, clip:)
end

.pitch_shift_stream(chunks, sr: 22_050, n_steps: 0, bins_per_octave: 12, res_type: :auto, normalize: false, clip: nil, overlap: 2048, &block) ⇒ Enumerator?

Returns:

  • (Enumerator, nil)


392
393
394
# File 'lib/muze.rb', line 392

def pitch_shift_stream(chunks, sr: 22_050, n_steps: 0, bins_per_octave: 12, res_type: :auto, normalize: false, clip: nil, overlap: 2048, &block)
  Muze::Effects.pitch_shift_stream(chunks, sr:, n_steps:, bins_per_octave:, res_type:, normalize:, clip:, overlap:, &block)
end

.poly_features(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, order: 1, frequency: nil, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


312
313
314
# File 'lib/muze.rb', line 312

def poly_features(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, order: 1, frequency: nil, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.poly_features(y:, s:, sr:, n_fft:, hop_length:, order:, frequency:, center:, pad_mode:, s_kind:)
end

.power_to_db(s, ref: 1.0, amin: 1.0e-10, top_db: 80.0) ⇒ Numo::SFloat

Parameters:

  • s (Numo::NArray)
  • ref (Float, Symbol, Proc) (defaults to: 1.0)
  • amin (Float) (defaults to: 1.0e-10)
  • top_db (Float, nil) (defaults to: 80.0)

Returns:

  • (Numo::SFloat)


111
112
113
# File 'lib/muze.rb', line 111

def power_to_db(s, ref: 1.0, amin: 1.0e-10, top_db: 80.0)
  Muze::Core::STFT.power_to_db(s, ref:, amin:, top_db:)
end

.preemphasis(y, coef: 0.97) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


402
403
404
# File 'lib/muze.rb', line 402

def preemphasis(y, coef: 0.97)
  Muze::Effects.preemphasis(y, coef:)
end

.remix(y, intervals, units: :samples, sr: nil, hop_length: 512) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


175
176
177
# File 'lib/muze.rb', line 175

def remix(y, intervals, units: :samples, sr: nil, hop_length: 512)
  Muze::Core::Audio.remix(y, intervals, units:, sr:, hop_length:)
end

.resample(y, orig_sr:, target_sr:, res_type: :sinc, target_length: nil, taps: 16, beta: 8.6, cutoff: nil) ⇒ Numo::SFloat

Parameters:

  • y (Numo::SFloat, Array<Float>)
  • orig_sr (Integer)
  • target_sr (Integer)
  • res_type (Symbol) (defaults to: :sinc)
  • target_length (Integer, nil) (defaults to: nil)

Returns:

  • (Numo::SFloat)


185
186
187
# File 'lib/muze.rb', line 185

def resample(y, orig_sr:, target_sr:, res_type: :sinc, target_length: nil, taps: 16, beta: 8.6, cutoff: nil)
  Muze::Core::Resample.resample(y, orig_sr:, target_sr:, res_type:, target_length:, taps:, beta:, cutoff:)
end

.rms(y: nil, s: nil, frame_length: 2048, hop_length: 512, center: false) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


322
323
324
# File 'lib/muze.rb', line 322

def rms(y: nil, s: nil, frame_length: 2048, hop_length: 512, center: false)
  Muze::Feature.rms(y:, s:, frame_length:, hop_length:, center:)
end

.samples_to_frames(samples, hop_length:) ⇒ Integer, Numo::SFloat

Returns:

  • (Integer, Numo::SFloat)


150
151
152
# File 'lib/muze.rb', line 150

def samples_to_frames(samples, hop_length:)
  Muze::Core::STFT.samples_to_frames(samples, hop_length:)
end

.samples_to_time(samples, sr:) ⇒ Float, Numo::SFloat

Returns:

  • (Float, Numo::SFloat)


155
156
157
# File 'lib/muze.rb', line 155

def samples_to_time(samples, sr:)
  Muze::Core::STFT.samples_to_time(samples, sr:)
end

.specshow(data, sr: 22_050, hop_length: 512, x_axis: :time, y_axis: :linear, output: nil, width: 800, height: 400, cmap: :heat, vmin: nil, vmax: nil, fragment: false, render: :auto) ⇒ String

Returns:

  • (String)


412
413
414
# File 'lib/muze.rb', line 412

def specshow(data, sr: 22_050, hop_length: 512, x_axis: :time, y_axis: :linear, output: nil, width: 800, height: 400, cmap: :heat, vmin: nil, vmax: nil, fragment: false, render: :auto)
  Muze::Display.specshow(data, sr:, hop_length:, x_axis:, y_axis:, output:, width:, height:, cmap:, vmin:, vmax:, fragment:, render:)
end

.spectral_bandwidth(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, p: 2, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


267
268
269
# File 'lib/muze.rb', line 267

def spectral_bandwidth(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, p: 2, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_bandwidth(y:, s:, sr:, n_fft:, hop_length:, p:, center:, pad_mode:, s_kind:)
end

.spectral_centroid(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


262
263
264
# File 'lib/muze.rb', line 262

def spectral_centroid(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_centroid(y:, s:, sr:, n_fft:, hop_length:, center:, pad_mode:, s_kind:)
end

.spectral_contrast(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, n_bands: 6, quantile: 0.02, fmin: 200.0, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


282
283
284
# File 'lib/muze.rb', line 282

def spectral_contrast(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, n_bands: 6, quantile: 0.02, fmin: 200.0, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_contrast(y:, s:, sr:, n_fft:, hop_length:, n_bands:, quantile:, fmin:, center:, pad_mode:, s_kind:)
end

.spectral_crest(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


297
298
299
# File 'lib/muze.rb', line 297

def spectral_crest(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_crest(y:, s:, sr:, n_fft:, hop_length:, center:, pad_mode:, s_kind:)
end

.spectral_decrease(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


307
308
309
# File 'lib/muze.rb', line 307

def spectral_decrease(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_decrease(y:, s:, sr:, n_fft:, hop_length:, center:, pad_mode:, s_kind:)
end

.spectral_entropy(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


292
293
294
# File 'lib/muze.rb', line 292

def spectral_entropy(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_entropy(y:, s:, sr:, n_fft:, hop_length:, center:, pad_mode:, s_kind:)
end

.spectral_flatness(y: nil, s: nil, n_fft: 2048, hop_length: 512, amin: 1.0e-10, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


277
278
279
# File 'lib/muze.rb', line 277

def spectral_flatness(y: nil, s: nil, n_fft: 2048, hop_length: 512, amin: 1.0e-10, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_flatness(y:, s:, n_fft:, hop_length:, amin:, center:, pad_mode:, s_kind:)
end

.spectral_flux(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


287
288
289
# File 'lib/muze.rb', line 287

def spectral_flux(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_flux(y:, s:, sr:, n_fft:, hop_length:, center:, pad_mode:, s_kind:)
end

.spectral_rolloff(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, roll_percent: 0.85, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


272
273
274
# File 'lib/muze.rb', line 272

def spectral_rolloff(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, roll_percent: 0.85, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_rolloff(y:, s:, sr:, n_fft:, hop_length:, roll_percent:, center:, pad_mode:, s_kind:)
end

.spectral_slope(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


302
303
304
# File 'lib/muze.rb', line 302

def spectral_slope(y: nil, s: nil, sr: 22_050, n_fft: 2048, hop_length: 512, center: true, pad_mode: :reflect, s_kind: :magnitude)
  Muze::Feature.spectral_slope(y:, s:, sr:, n_fft:, hop_length:, center:, pad_mode:, s_kind:)
end

.stft(y, n_fft: 2048, hop_length: 512, win_length: nil, window: :hann, center: true, pad_mode: :reflect, pad_end: false, periodic: false) ⇒ Numo::DComplex

Parameters:

  • y (Numo::SFloat, Array<Float>)
  • n_fft (Integer) (defaults to: 2048)
  • hop_length (Integer) (defaults to: 512)
  • win_length (Integer, nil) (defaults to: nil)
  • window (Symbol) (defaults to: :hann)
  • center (Boolean) (defaults to: true)
  • pad_mode (Symbol) (defaults to: :reflect)
  • pad_end (Boolean) (defaults to: false)

Returns:

  • (Numo::DComplex)


71
72
73
# File 'lib/muze.rb', line 71

def stft(y, n_fft: 2048, hop_length: 512, win_length: nil, window: :hann, center: true, pad_mode: :reflect, pad_end: false, periodic: false)
  Muze::Core::STFT.stft(y, n_fft:, hop_length:, win_length:, window:, center:, pad_mode:, pad_end:, periodic:)
end

.stft_stream(chunks, n_fft: 2048, hop_length: 512, win_length: nil, window: :hann, center: false, pad_mode: :reflect, periodic: false, flush: true) ⇒ Array<Numo::DComplex>

Returns:

  • (Array<Numo::DComplex>)


93
94
95
# File 'lib/muze.rb', line 93

def stft_stream(chunks, n_fft: 2048, hop_length: 512, win_length: nil, window: :hann, center: false, pad_mode: :reflect, periodic: false, flush: true)
  Muze::Core::STFT.stft_stream(chunks, n_fft:, hop_length:, win_length:, window:, center:, pad_mode:, periodic:, flush:)
end

.tempo_frequencies(sr: 22_050, hop_length: 512, win_length: 384) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


362
363
364
# File 'lib/muze.rb', line 362

def tempo_frequencies(sr: 22_050, hop_length: 512, win_length: 384)
  Muze::Beat.tempo_frequencies(sr:, hop_length:, win_length:)
end

.tempogram(y: nil, onset_envelope: nil, sr: 22_050, hop_length: 512, win_length: 384, normalize: false) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


327
328
329
# File 'lib/muze.rb', line 327

def tempogram(y: nil, onset_envelope: nil, sr: 22_050, hop_length: 512, win_length: 384, normalize: false)
  Muze::Feature.tempogram(y:, onset_envelope:, sr:, hop_length:, win_length:, normalize:)
end

.time_stretch(y, rate: 1.0, n_fft: nil, hop_length: nil, method: :phase_vocoder, phase_lock: false, force_phase_vocoder: false) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


377
378
379
# File 'lib/muze.rb', line 377

def time_stretch(y, rate: 1.0, n_fft: nil, hop_length: nil, method: :phase_vocoder, phase_lock: false, force_phase_vocoder: false)
  Muze::Effects.time_stretch(y, rate:, n_fft:, hop_length:, method:, phase_lock:, force_phase_vocoder:)
end

.time_stretch_stream(chunks, rate: 1.0, n_fft: nil, hop_length: nil, method: :phase_vocoder, phase_lock: false, force_phase_vocoder: false, overlap: 2048, &block) ⇒ Enumerator?

Returns:

  • (Enumerator, nil)


382
383
384
# File 'lib/muze.rb', line 382

def time_stretch_stream(chunks, rate: 1.0, n_fft: nil, hop_length: nil, method: :phase_vocoder, phase_lock: false, force_phase_vocoder: false, overlap: 2048, &block)
  Muze::Effects.time_stretch_stream(chunks, rate:, n_fft:, hop_length:, method:, phase_lock:, force_phase_vocoder:, overlap:, &block)
end

.time_to_frames(times, sr:, hop_length:) ⇒ Integer, Numo::SFloat

Returns:

  • (Integer, Numo::SFloat)


140
141
142
# File 'lib/muze.rb', line 140

def time_to_frames(times, sr:, hop_length:)
  Muze::Core::STFT.time_to_frames(times, sr:, hop_length:)
end

.time_to_samples(times, sr:) ⇒ Integer, Numo::SFloat

Returns:

  • (Integer, Numo::SFloat)


160
161
162
# File 'lib/muze.rb', line 160

def time_to_samples(times, sr:)
  Muze::Core::STFT.time_to_samples(times, sr:)
end

.tonnetz(y: nil, chroma: nil, sr: 22_050, n_fft: 2048, hop_length: 512) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


342
343
344
# File 'lib/muze.rb', line 342

def tonnetz(y: nil, chroma: nil, sr: 22_050, n_fft: 2048, hop_length: 512)
  Muze::Feature.tonnetz(y:, chroma:, sr:, n_fft:, hop_length:)
end

.trim(y, top_db: 60, frame_length: 2048, hop_length: 512, ref: :max, aggregate: :mean, units: :samples, sr: nil) ⇒ Array(Numo::SFloat, Array<Integer>)

Returns:

  • (Array(Numo::SFloat, Array<Integer>))


397
398
399
# File 'lib/muze.rb', line 397

def trim(y, top_db: 60, frame_length: 2048, hop_length: 512, ref: :max, aggregate: :mean, units: :samples, sr: nil)
  Muze::Effects.trim(y, top_db:, frame_length:, hop_length:, ref:, aggregate:, units:, sr:)
end

.valid_audio?(y, allow_empty: false) ⇒ Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/muze.rb', line 165

def valid_audio?(y, allow_empty: false)
  Muze::Core::Audio.valid_audio?(y, allow_empty:)
end

.waveshow(y, sr: 22_050, output: nil, width: 800, height: 240, normalize: true, channels: :overlay) ⇒ String

Returns:

  • (String)


417
418
419
# File 'lib/muze.rb', line 417

def waveshow(y, sr: 22_050, output: nil, width: 800, height: 240, normalize: true, channels: :overlay)
  Muze::Display.waveshow(y, sr:, output:, width:, height:, normalize:, channels:)
end

.write(path, y, sr:, normalize: false, format: :wav) ⇒ Object

Returns the output path or IO object.

Returns:

  • (Object)

    the output path or IO object



58
59
60
# File 'lib/muze.rb', line 58

def write(path, y, sr:, normalize: false, format: :wav)
  Muze::IO::AudioWriter.write(path, y, sr:, normalize:, format:)
end

.zero_crossing_rate(y, frame_length: 2048, hop_length: 512, threshold: 0.0, center: false) ⇒ Numo::SFloat

Returns:

  • (Numo::SFloat)


317
318
319
# File 'lib/muze.rb', line 317

def zero_crossing_rate(y, frame_length: 2048, hop_length: 512, threshold: 0.0, center: false)
  Muze::Feature.zero_crossing_rate(y, frame_length:, hop_length:, threshold:, center:)
end