Struct Context

Source
pub struct Context { /* private fields */ }

Implementations§

Source§

impl Context

Source

pub fn new(algorithm: Algorithm) -> Self

Creates a new Chromaprint context with the given algorithm. To use the default algorithm, call default.

Source

pub fn algorithm(&self) -> Algorithm

Source

pub fn sample_rate(&self) -> u32

Returns the sample rate used internally by Chromaprint. If you want to avoid having Chromaprint internally resample audio, make sure to use this sample rate.

Source

pub fn start( &mut self, sample_rate: u32, num_channels: u16, ) -> Result<(), Error>

Starts a fingerprinting session. Audio samples will be buffered by Chromaprint until finish is called.

Source

pub fn feed(&mut self, data: &[i16]) -> Result<(), Error>

Feeds a set of audio samples to the fingerprinter.

Source

pub fn finish(&mut self) -> Result<(), Error>

Signals to the fingerprinter that the audio clip is complete. You must call this method before extracting a fingerprint.

Important note: before calling finish, you should provide at least 3 seconds worth of audio samples. The reason is that the size of the raw fingerprint is directly related to the amount of audio data fed to the fingerprinter.

In general, the raw fingerprint size is ~= (duration_in_secs * 11025 - 4096) / 1365 - 15 - 4 + 1

See detailed discussion here.

Source

pub fn get_fingerprint_raw(&self) -> Result<Fingerprint<Raw>, Error>

Returns the raw fingerprint.

Source

pub fn get_fingerprint_hash(&self) -> Result<Fingerprint<Hash>, Error>

Returns a hash of the raw fingerprint.

Under the hood, Chromaprint computes a 32-bit SimHash of the raw fingerprint.

Source

pub fn get_fingerprint_base64(&self) -> Result<Fingerprint<Base64>, Error>

Returns a compressed version of the raw fingerprint in Base64 format. This is the format used by the AcousticID service.

Source

pub fn get_delay(&self) -> Result<Duration, Error>

Returns the current delay for the fingerprint.

This value represents the duration of samples that had to be buffered before Chromaprint could start generating the fingerprint.

Source

pub fn get_item_duration(&self) -> Result<Duration, Error>

Returns the duration of a single item in the raw fingerprint.

For example, if you compute a raw fingerprint and it contains 1000 32-bit values, the duration returned by this method will tell you how much time (in audio samples) is represented by each 32-bit value in the fingerprint.

Source

pub fn clear_fingerprint(&mut self) -> Result<(), Error>

Clear the current fingerprint.

Trait Implementations§

Source§

impl Default for Context

Source§

fn default() -> Self

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

impl Drop for Context

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.