Miam-Player  0.8.0
A nice music player
chromaprint.h File Reference
#include <stdint.h>

Go to the source code of this file.

Macros

#define CHROMAPRINT_API
 
#define CHROMAPRINT_VERSION_MAJOR   1
 
#define CHROMAPRINT_VERSION_MINOR   4
 
#define CHROMAPRINT_VERSION_PATCH   2
 

Typedefs

typedef struct ChromaprintContextPrivate ChromaprintContext
 
typedef struct ChromaprintMatcherContextPrivate ChromaprintMatcherContext
 

Enumerations

enum  ChromaprintAlgorithm {
  CHROMAPRINT_ALGORITHM_TEST1 = 0, CHROMAPRINT_ALGORITHM_TEST2, CHROMAPRINT_ALGORITHM_TEST3, CHROMAPRINT_ALGORITHM_TEST4,
  CHROMAPRINT_ALGORITHM_TEST5, CHROMAPRINT_ALGORITHM_DEFAULT = CHROMAPRINT_ALGORITHM_TEST2
}
 

Functions

CHROMAPRINT_API const char * chromaprint_get_version (void)
 
CHROMAPRINT_API ChromaprintContextchromaprint_new (int algorithm)
 
CHROMAPRINT_API void chromaprint_free (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_get_algorithm (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_set_option (ChromaprintContext *ctx, const char *name, int value)
 
CHROMAPRINT_API int chromaprint_get_num_channels (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_get_sample_rate (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_get_item_duration (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_get_item_duration_ms (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_get_delay (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_get_delay_ms (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_start (ChromaprintContext *ctx, int sample_rate, int num_channels)
 
CHROMAPRINT_API int chromaprint_feed (ChromaprintContext *ctx, const int16_t *data, int size)
 
CHROMAPRINT_API int chromaprint_finish (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_get_fingerprint (ChromaprintContext *ctx, char **fingerprint)
 
CHROMAPRINT_API int chromaprint_get_raw_fingerprint (ChromaprintContext *ctx, uint32_t **fingerprint, int *size)
 
CHROMAPRINT_API int chromaprint_get_raw_fingerprint_size (ChromaprintContext *ctx, int *size)
 
CHROMAPRINT_API int chromaprint_get_fingerprint_hash (ChromaprintContext *ctx, uint32_t *hash)
 
CHROMAPRINT_API int chromaprint_clear_fingerprint (ChromaprintContext *ctx)
 
CHROMAPRINT_API int chromaprint_encode_fingerprint (const uint32_t *fp, int size, int algorithm, char **encoded_fp, int *encoded_size, int base64)
 
CHROMAPRINT_API int chromaprint_decode_fingerprint (const char *encoded_fp, int encoded_size, uint32_t **fp, int *size, int *algorithm, int base64)
 
CHROMAPRINT_API int chromaprint_hash_fingerprint (const uint32_t *fp, int size, uint32_t *hash)
 
CHROMAPRINT_API void chromaprint_dealloc (void *ptr)
 

Macro Definition Documentation

◆ CHROMAPRINT_API

#define CHROMAPRINT_API

◆ CHROMAPRINT_VERSION_MAJOR

#define CHROMAPRINT_VERSION_MAJOR   1

◆ CHROMAPRINT_VERSION_MINOR

#define CHROMAPRINT_VERSION_MINOR   4

◆ CHROMAPRINT_VERSION_PATCH

#define CHROMAPRINT_VERSION_PATCH   2

Typedef Documentation

◆ ChromaprintContext

typedef struct ChromaprintContextPrivate ChromaprintContext

◆ ChromaprintMatcherContext

typedef struct ChromaprintMatcherContextPrivate ChromaprintMatcherContext

Enumeration Type Documentation

◆ ChromaprintAlgorithm

Enumerator
CHROMAPRINT_ALGORITHM_TEST1 
CHROMAPRINT_ALGORITHM_TEST2 
CHROMAPRINT_ALGORITHM_TEST3 
CHROMAPRINT_ALGORITHM_TEST4 
CHROMAPRINT_ALGORITHM_TEST5 
CHROMAPRINT_ALGORITHM_DEFAULT 

Function Documentation

◆ chromaprint_clear_fingerprint()

CHROMAPRINT_API int chromaprint_clear_fingerprint ( ChromaprintContext ctx)

Clear the current fingerprint, but allow more data to be processed.

This is useful if you are processing a long stream and want to many smaller fingerprints, instead of waiting for the entire stream to be processed.

Parameters
[in]ctxChromaprint context pointer
Returns
0 on error, 1 on success

◆ chromaprint_dealloc()

CHROMAPRINT_API void chromaprint_dealloc ( void *  ptr)

Free memory allocated by any function from the Chromaprint API.

Parameters
ptrpointer to be deallocated

◆ chromaprint_decode_fingerprint()

CHROMAPRINT_API int chromaprint_decode_fingerprint ( const char *  encoded_fp,
int  encoded_size,
uint32_t **  fp,
int *  size,
int *  algorithm,
int  base64 
)

Uncompress and optionally base64-decode an encoded fingerprint

The caller is responsible for freeing the returned pointer using chromaprint_dealloc().

Parameters
[in]encoded_fppointer to an encoded fingerprint
[in]encoded_sizesize of the encoded fingerprint in bytes
[out]fppointer to a pointer, where the decoded raw fingerprint (array of 32-bit integers) will be stored
[out]sizeNumber of items in the returned raw fingerprint
[out]algorithmChromaprint algorithm version which was used to generate the raw fingerprint
[in]base64Whether the encoded_fp parameter contains binary data or base64-encoded ASCII data. If 1, it will base64-decode the data before uncompressing the fingerprint.
Returns
0 on error, 1 on success

◆ chromaprint_encode_fingerprint()

CHROMAPRINT_API int chromaprint_encode_fingerprint ( const uint32_t *  fp,
int  size,
int  algorithm,
char **  encoded_fp,
int *  encoded_size,
int  base64 
)

Compress and optionally base64-encode a raw fingerprint

The caller is responsible for freeing the returned pointer using chromaprint_dealloc().

Parameters
[in]fppointer to an array of 32-bit integers representing the raw fingerprint to be encoded
[in]sizenumber of items in the raw fingerprint
[in]algorithmChromaprint algorithm version which was used to generate the raw fingerprint
[out]encoded_fppointer to a pointer, where the encoded fingerprint will be stored
[out]encoded_sizesize of the encoded fingerprint in bytes
[in]base64Whether to return binary data or base64-encoded ASCII data. The compressed fingerprint will be encoded using base64 with the URL-safe scheme if you set this parameter to 1. It will return binary data if it's 0.
Returns
0 on error, 1 on success

◆ chromaprint_feed()

CHROMAPRINT_API int chromaprint_feed ( ChromaprintContext ctx,
const int16_t *  data,
int  size 
)

Send audio data to the fingerprint calculator.

Parameters
[in]ctxChromaprint context pointer
[in]dataraw audio data, should point to an array of 16-bit signed integers in native byte-order
[in]sizesize of the data buffer (in samples)
Returns
0 on error, 1 on success

◆ chromaprint_finish()

CHROMAPRINT_API int chromaprint_finish ( ChromaprintContext ctx)

Process any remaining buffered audio data.

Parameters
[in]ctxChromaprint context pointer
Returns
0 on error, 1 on success

◆ chromaprint_free()

CHROMAPRINT_API void chromaprint_free ( ChromaprintContext ctx)

Deallocate the Chromaprint context.

Note that when Chromaprint is compiled with FFTW, this function is not reentrant and you need to call it only from one thread at a time. This is not a problem when using FFmpeg or vDSP.

Parameters
[in]ctxChromaprint context pointer

◆ chromaprint_get_algorithm()

CHROMAPRINT_API int chromaprint_get_algorithm ( ChromaprintContext ctx)

Return the fingerprint algorithm this context is configured to use.

Parameters
[in]ctxChromaprint context pointer
Returns
current algorithm version

◆ chromaprint_get_delay()

CHROMAPRINT_API int chromaprint_get_delay ( ChromaprintContext ctx)

Get the duration of internal buffers that the fingerprinting algorithm uses.

Parameters
[in]ctxChromaprint context pointer
Returns
duration in samples

◆ chromaprint_get_delay_ms()

CHROMAPRINT_API int chromaprint_get_delay_ms ( ChromaprintContext ctx)

Get the duration of internal buffers that the fingerprinting algorithm uses.

Parameters
[in]ctxChromaprint context pointer
Returns
duration in milliseconds

◆ chromaprint_get_fingerprint()

CHROMAPRINT_API int chromaprint_get_fingerprint ( ChromaprintContext ctx,
char **  fingerprint 
)

Return the calculated fingerprint as a compressed string.

The caller is responsible for freeing the returned pointer using chromaprint_dealloc().

Parameters
[in]ctxChromaprint context pointer
[out]fingerprintpointer to a pointer, where a pointer to the allocated array will be stored
Returns
0 on error, 1 on success

◆ chromaprint_get_fingerprint_hash()

CHROMAPRINT_API int chromaprint_get_fingerprint_hash ( ChromaprintContext ctx,
uint32_t *  hash 
)

Return 32-bit hash of the calculated fingerprint.

See chromaprint_hash_fingerprint() for details on how to use the hash.

Parameters
[in]ctxChromaprint context pointer
[out]hashpointer to a 32-bit integer where the hash will be stored
Returns
0 on error, 1 on success

◆ chromaprint_get_item_duration()

CHROMAPRINT_API int chromaprint_get_item_duration ( ChromaprintContext ctx)

Get the duration of one item in the raw fingerprint in samples.

Parameters
[in]ctxChromaprint context pointer
Returns
duration in samples

◆ chromaprint_get_item_duration_ms()

CHROMAPRINT_API int chromaprint_get_item_duration_ms ( ChromaprintContext ctx)

Get the duration of one item in the raw fingerprint in milliseconds.

Parameters
[in]ctxChromaprint context pointer
Returns
duration in milliseconds

◆ chromaprint_get_num_channels()

CHROMAPRINT_API int chromaprint_get_num_channels ( ChromaprintContext ctx)

Get the number of channels that is internally used for fingerprinting.

Note
You normally don't need this. Just set the audio's actual number of channels when calling chromaprint_start() and everything will work. This is only used for certain optimized cases to control the audio source.
Parameters
[in]ctxChromaprint context pointer
Returns
number of channels

◆ chromaprint_get_raw_fingerprint()

CHROMAPRINT_API int chromaprint_get_raw_fingerprint ( ChromaprintContext ctx,
uint32_t **  fingerprint,
int *  size 
)

Return the calculated fingerprint as an array of 32-bit integers.

The caller is responsible for freeing the returned pointer using chromaprint_dealloc().

Parameters
[in]ctxChromaprint context pointer
[out]fingerprintpointer to a pointer, where a pointer to the allocated array will be stored
[out]sizenumber of items in the returned raw fingerprint
Returns
0 on error, 1 on success

◆ chromaprint_get_raw_fingerprint_size()

CHROMAPRINT_API int chromaprint_get_raw_fingerprint_size ( ChromaprintContext ctx,
int *  size 
)

Return the length of the current raw fingerprint.

Parameters
[in]ctxChromaprint context pointer
[out]sizenumber of items in the current raw fingerprint
Returns
0 on error, 1 on success

◆ chromaprint_get_sample_rate()

CHROMAPRINT_API int chromaprint_get_sample_rate ( ChromaprintContext ctx)

Get the sampling rate that is internally used for fingerprinting.

Note
You normally don't need this. Just set the audio's actual number of channels when calling chromaprint_start() and everything will work. This is only used for certain optimized cases to control the audio source.
Parameters
[in]ctxChromaprint context pointer
Returns
sampling rate

◆ chromaprint_get_version()

CHROMAPRINT_API const char* chromaprint_get_version ( void  )

Return the version number of Chromaprint.

◆ chromaprint_hash_fingerprint()

CHROMAPRINT_API int chromaprint_hash_fingerprint ( const uint32_t *  fp,
int  size,
uint32_t *  hash 
)

Generate a single 32-bit hash for a raw fingerprint.

If two fingerprints are similar, their hashes generated by this function will also be similar. If they are significantly different, their hashes will most likely be significantly different as well, but you can't rely on that.

You compare two hashes by counting the bits in which they differ. Normally that would be something like POPCNT(hash1 XOR hash2), which returns a number between 0 and 32. Anthing above 15 means the hashes are completely different.

Parameters
[in]fppointer to an array of 32-bit integers representing the raw fingerprint to be hashed
[in]sizenumber of items in the raw fingerprint
[out]hashpointer to a 32-bit integer where the hash will be stored
Returns
0 on error, 1 on success

◆ chromaprint_new()

CHROMAPRINT_API ChromaprintContext* chromaprint_new ( int  algorithm)

Allocate and initialize the Chromaprint context.

Note that when Chromaprint is compiled with FFTW, this function is not reentrant and you need to call it only from one thread at a time. This is not a problem when using FFmpeg or vDSP.

Parameters
algorithmthe fingerprint algorithm version you want to use, or CHROMAPRINT_ALGORITHM_DEFAULT for the default algorithm
Returns
ctx Chromaprint context pointer

◆ chromaprint_set_option()

CHROMAPRINT_API int chromaprint_set_option ( ChromaprintContext ctx,
const char *  name,
int  value 
)

Set a configuration option for the selected fingerprint algorithm.

DO NOT USE THIS FUNCTION IF YOU ARE PLANNING TO USE THE GENERATED FINGERPRINTS WITH THE ACOUSTID SERVICE.

Possible options:

  • silence_threshold: threshold for detecting silence, 0-32767
Parameters
[in]ctxChromaprint context pointer
[in]nameoption name
[in]valueoption value
Returns
0 on error, 1 on success

◆ chromaprint_start()

CHROMAPRINT_API int chromaprint_start ( ChromaprintContext ctx,
int  sample_rate,
int  num_channels 
)

Restart the computation of a fingerprint with a new audio stream.

Parameters
[in]ctxChromaprint context pointer
[in]sample_ratesample rate of the audio stream (in Hz)
[in]num_channelsnumbers of channels in the audio stream (1 or 2)
Returns
0 on error, 1 on success