pub struct Context { /* private fields */ }
Implementations§
Source§impl 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.
Sourcepub fn get_delay(&self) -> Result<Duration, Error>
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.
Sourcepub fn get_item_duration(&self) -> Result<Duration, Error>
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.
Sourcepub fn clear_fingerprint(&mut self) -> Result<(), Error>
pub fn clear_fingerprint(&mut self) -> Result<(), Error>
Clear the current fingerprint.