Skip to main content

StreamingHaitsma

Struct StreamingHaitsma 

Source
pub struct StreamingHaitsma { /* private fields */ }
Expand description

Streaming Haitsma–Kalker fingerprinter.

Trivially incremental: each output bit-frame depends only on the current and previous frames’ band energies, so we just keep one previous-frame energy vector. No spectrogram window, no peak picker, no per-second adaptive threshold. Per-push CPU cost is proportional to the number of new samples, independent of total stream length, and latency is bounded by the STFT window length (n_fft / sr ≈ 410 ms) — much lower than the landmark extractors.

Output is bit-exactly equivalent to Haitsma::extract.

Implementations§

Source§

impl StreamingHaitsma

Source

pub fn new(cfg: HaitsmaConfig) -> Self

Build a streaming Haitsma extractor with the given config.

§Panics

Panics if cfg.fmin <= 0, cfg.fmax <= cfg.fmin, or cfg.fmax >= HAITSMA_SR / 2 (above Nyquist). Use try_new for a fallible alternative.

Source

pub fn try_new(cfg: HaitsmaConfig) -> Result<Self>

Fallible constructor — returns AfpError::Config on invalid fmin/fmax/Nyquist instead of panicking.

Source

pub fn config(&self) -> &HaitsmaConfig

Borrow the configuration this stream was built with.

Source

pub fn reset(&mut self)

Reset all internal state. The stream behaves as if freshly constructed: no buffered audio, no pending frames, frame counter restarted. Call between independent input streams sharing one instance.

Trait Implementations§

Source§

impl Default for StreamingHaitsma

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl StreamingFingerprinter for StreamingHaitsma

Source§

type Frame = u32

One unit of fingerprint material the stream emits.
Source§

fn required_sample_rate(&self) -> u32

Sample rate, in hertz, the stream expects its input at. Read more
Source§

fn push(&mut self, samples: &[f32]) -> Result<Vec<(TimestampMs, Self::Frame)>>

Feed PCM samples and return any fingerprints that became available during this push. Read more
Source§

fn push_with<F>(&mut self, samples: &[f32], callback: F) -> Result<usize>
where F: FnMut(TimestampMs, &Self::Frame),

Feed PCM samples and invoke callback for each fingerprint frame that became available during this push. Read more
Source§

fn flush(&mut self) -> Result<Vec<(TimestampMs, Self::Frame)>>

Drain any pending fingerprint material at end-of-stream. Read more
Source§

fn flush_with<F>(&mut self, callback: F) -> Result<usize>
where F: FnMut(TimestampMs, &Self::Frame),

Drain any pending fingerprint material at end-of-stream, invoking callback for each frame. Read more
Source§

fn latency_ms(&self) -> u32

Conservative upper bound on emission latency: from the time a sample enters push to the time the fingerprint covering it is returned.
Source§

fn push_strict( &mut self, samples: &[f32], ) -> Result<Vec<(TimestampMs, Self::Frame)>>

Like push, but fail fast on non-finite input instead of sanitizing it to 0.0. Read more
Source§

impl ZeroAllocStreaming for StreamingHaitsma

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.