Clementine Adore Mod
 All Classes Namespaces Files Functions Variables Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AdoreStreamer Class Reference

This class handles the received audio buffers. More...

#include <adorestreamer.h>

Inheritance diagram for AdoreStreamer:

Public Member Functions

 AdoreStreamer ()
 
 ~AdoreStreamer ()
 
void SetEngine (GstEngine *engine)
 Pass the GStreamer Engine object to the class and get a BufferConsumer hook. More...
 
void ConsumeBuffer (GstBuffer *buffer, int pipeline_id)
 
void StartProbing ()
 tell ConsumeBuffer() to start collecting audio buffers for later fingerprinting More...
 
void StopProbing ()
 stops collecting buffers and erases existing audio data from the fingerprinting buffer More...
 
QString & GetLastFingerprint ()
 public read-only access to the private fingerprint_ member variable. More...
 
QString & GetFingerprintingAlgorithm ()
 public read-only access to the private fingerprinting_algorithm_ member variable. More...
 
QString & GetFingerprintingAlgorithmVersion ()
 public read-only access to the private fingerprinting_algorithm_version_ member variable. More...
 
void ResetLastFingerprint ()
 erases a previously created fingerprint. More...
 

Private Member Functions

void MonoMix (const short *source_buffer, int source_numsamples, int source_numberofchannels, int source_samplingrate, short *target_buffer, int target_buffer_size)
 
void GetFingerprint (QString &fingerprint)
 
QString ChromaPrint (short *data, int size)
 
QString EchoPrint (short *data, int size)
 

Private Attributes

GstEngine * engine_
 the GStreamer engine object, necessary to peek into the audio stream More...
 
QBuffer buffer_
 fingerprinting buffer to collect audio buffers for some seconds before creating a fingerprint More...
 
bool probing_
 controls the collection. More...
 
QTime probing_start_time
 used to measure when MINIMUM_PROBING_DURATION has been reached and then create a fingerprint More...
 
int samplerate_
 computed in ConsumeBuffer() and stored to determine whether the rate has changed and the audio buffer collection needs a restart. More...
 
QString fingerprint_
 ascii (base64) representation of the result created by GetFingerprint(). More...
 
QString fingerprinting_algorithm_
 either 'echoprint' or 'chromapint', depending on the #define uncommented in the cpp file. This is set in the constructor. More...
 
QString fingerprinting_algorithm_version_
 current version of the fingerprinting algorithm. This is set in the constructor. More...
 

Detailed Description

This class handles the received audio buffers.

It computes the sample rate, converts the stereo stream to mono, and draws a fingerprint from the probed audio data.

Constructor & Destructor Documentation

AdoreStreamer::AdoreStreamer ( )
AdoreStreamer::~AdoreStreamer ( )

Member Function Documentation

QString AdoreStreamer::ChromaPrint ( short *  data,
int  size 
)
private

Creates a ChromaPrint audio fingerprint as used by MusicBrainz. The parameter size holds the number of shorts in data.

void AdoreStreamer::ConsumeBuffer ( GstBuffer *  buffer,
int  pipeline_id 
)

Callback for receiving audio buffers. This member function collects audio data for MINIMUM_PROBING_DURATION seconds after StartProbing() was initiated, then GetFingerprint() is being called.

See Also
StartProbing()
SetEngine() for hooking
~AdoreStreamer() for unhooking
QString AdoreStreamer::EchoPrint ( short *  data,
int  size 
)
private

Creates a EchoPrint audio fingerprint as used by EchoNest/last.fm. The parameter size holds the number of shorts in data. Note that the short int samples in the mono buffer have to be converted to floats before passing to the fingerprinting algorithm.

void AdoreStreamer::GetFingerprint ( QString &  fingerprint)
private

After enough audio data has been collected in buffer_ a fingerprint is being created from a mono downmix. Currently, EchoPrint and ChromaPrint are implemented. Just uncomment the corresponding #define at the start of the cpp file.

See Also
ChromaPrint()
EchoPrint()
QString& AdoreStreamer::GetFingerprintingAlgorithm ( )
inline

public read-only access to the private fingerprinting_algorithm_ member variable.

QString& AdoreStreamer::GetFingerprintingAlgorithmVersion ( )
inline

public read-only access to the private fingerprinting_algorithm_version_ member variable.

QString& AdoreStreamer::GetLastFingerprint ( )
inline

public read-only access to the private fingerprint_ member variable.

void AdoreStreamer::MonoMix ( const short *  source_buffer,
int  source_numsamples,
int  source_numberofchannels,
int  source_samplingrate,
short *  target_buffer,
int  target_buffer_size 
)
private

This private member is called by GetFingerprint() and creates a mono mix from stereo or multichannel audio data. Note: target_buffer has to be source_numsamples / source_numberofchannels in size

void AdoreStreamer::ResetLastFingerprint ( )
inline

erases a previously created fingerprint.

See Also
GetLastFingerprint()
void AdoreStreamer::SetEngine ( GstEngine *  engine)

Pass the GStreamer Engine object to the class and get a BufferConsumer hook.

void AdoreStreamer::StartProbing ( )

tell ConsumeBuffer() to start collecting audio buffers for later fingerprinting

void AdoreStreamer::StopProbing ( )

stops collecting buffers and erases existing audio data from the fingerprinting buffer

Member Data Documentation

QBuffer AdoreStreamer::buffer_
private

fingerprinting buffer to collect audio buffers for some seconds before creating a fingerprint

GstEngine* AdoreStreamer::engine_
private

the GStreamer engine object, necessary to peek into the audio stream

QString AdoreStreamer::fingerprint_
private

ascii (base64) representation of the result created by GetFingerprint().

See Also
GetFingerprint()
GetLastFingerprint()
QString AdoreStreamer::fingerprinting_algorithm_
private

either 'echoprint' or 'chromapint', depending on the #define uncommented in the cpp file. This is set in the constructor.

See Also
GetFingerprintingAlgorithm()
QString AdoreStreamer::fingerprinting_algorithm_version_
private

current version of the fingerprinting algorithm. This is set in the constructor.

See Also
GetFingerprintingAlgorithmVersion()
bool AdoreStreamer::probing_
private

controls the collection.

See Also
StartProbing()
StopProbing()
QTime AdoreStreamer::probing_start_time
private

used to measure when MINIMUM_PROBING_DURATION has been reached and then create a fingerprint

int AdoreStreamer::samplerate_
private

computed in ConsumeBuffer() and stored to determine whether the rate has changed and the audio buffer collection needs a restart.

See Also
ConsumeBuffer()

The documentation for this class was generated from the following files: