Struct chromaprint_rust::Context
source · [−]pub struct Context { /* private fields */ }
Implementations
sourceimpl Context
impl Context
sourcepub fn new(algorithm: Algorithm) -> Self
pub fn new(algorithm: Algorithm) -> Self
Creates a new Chromaprint context with the given algorithm. To use the default algorithm,
call default
.
pub fn algorithm(&self) -> Algorithm
sourcepub fn sample_rate(&self) -> u32
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.
sourcepub fn start(&mut self, sample_rate: u32, num_channels: u16) -> Result<(), Error>
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.
sourcepub fn feed(&mut self, data: &[i16]) -> Result<(), Error>
pub fn feed(&mut self, data: &[i16]) -> Result<(), Error>
Feeds a set of audio samples to the fingerprinter.
sourcepub fn finish(&mut self) -> Result<(), Error>
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.
sourcepub fn get_fingerprint_raw(&self) -> Result<Fingerprint<Raw>, Error>
pub fn get_fingerprint_raw(&self) -> Result<Fingerprint<Raw>, Error>
Returns the raw fingerprint.
sourcepub fn get_fingerprint_hash(&self) -> Result<Fingerprint<Hash>, Error>
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.
sourcepub fn get_fingerprint_base64(&self) -> Result<Fingerprint<Base64>, Error>
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.
pub fn clear_fingerprint(&mut self) -> Result<(), Error>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more