Main class that sets up and runs a pipeline. More...
#include <soundanalyser.h>
Public Member Functions | |
SoundAnalyser (bool live=false) | |
Sets up a new sound analyser. | |
~SoundAnalyser () | |
Destructor. | |
void | resetExtractors () |
Extractors management. | |
void | cleanExtractors () |
Clean the data in the extractors. | |
void | registerExtractor (string name, FeatureExtractor *extr, bool used=true, bool drawLines=true) |
Adds a new extractor. | |
FeatureExtractor * | getExtractor (string name) |
Find an extractor. | |
bool | setupPipeline (string filename) |
Setup. | |
void | setNormalization (float min, float max) |
Set up unified bounds for all features. | |
bool | compute (string url) |
Compute the features of a given file. | |
void | waitComputed () |
Wait up to the end of the computation. | |
unsigned int | nbFeatures () |
Features management : sizes. | |
unsigned int | nbElems (unsigned int n) |
Return the number of elements of the nth feature. | |
unsigned int | nbSamples () |
Return the number of sample we've been computing. | |
unsigned int | dimension () |
Get the dimension : sum of all the nbElems(i) | |
unsigned int | realDimension () |
Get the real dimension : sum of all the nbElems we care (the values which are actually used for detection) | |
double ** | features (unsigned int n) |
Return the array of features for the nth sample. | |
void | clearFeatures () |
Clears the features. | |
void | cleanOldFeatures (unsigned int newestCount) |
Removes the old features so that the newest remain. | |
bool | isUsed (unsigned int index) |
Features management : individual properties. | |
bool | isDrawnWithLines (unsigned int index) |
Should this feature be drawn as a lines or a shade of grey ? | |
string | name (unsigned int n) |
Get the name of the nth feature. | |
int | getFeatureByName (string name) |
Get the id of the feature named so (-1 if not found) | |
void | useBuffer () |
Callbacks. | |
void | sequenceEnds () |
End the computation. | |
virtual void | useFeatures () |
Callback called when the buffer has been used (the features are ready to be used) | |
unsigned int | samplingFrequency () |
Mirrors. |
Additional Inherited Members | |
Protected Member Functions inherited from StreamPlayer | |
StreamPlayer (bool live=false, bool verbose=true) | |
Default constructor. Starts VLC instance. | |
~StreamPlayer () | |
Default destructor. Frees memory and closes VLC. | |
string | url () |
Returns URL of the currently playing stream. | |
void | setUrl (string url) |
Defines the URL of the stream to play. | |
void | setOverlapping (float factor) |
Turns on / off audio chunk overlapping. | |
void | setChunkSize (int size) |
Changes the audio chunk size. | |
int | chunkSize () |
Get the current chunk size. | |
void | play () |
Plays the media. | |
libvlc_time_t | playingTime () |
Returns the playing time. | |
libvlc_time_t | totalTime () |
Returns the total time (played + to be played) | |
void | stop () |
Stops playing. | |
bool | isLive () |
Are we playing a live stream ? | |
void | setVolume (int vol) |
Changes the volume (between 0 and 100) | |
int | volume () |
Gets the current volume. | |
virtual void | sequenceStarts () |
Callback called when we start playing a file. | |
void | watch () |
Watching thread. | |
uint16_t | buffer (int i) |
Buffer acces (for the user) | |
int | bufferSize () |
Current buffer size (internal) | |
void | fillBuffer (uint16_t value) |
Fill buffer with a new value (internal) | |
void | flushBuffer () |
Flush buffer (just keep the overlapping part) | |
Static Protected Member Functions inherited from StreamPlayer | |
static uint16_t * | convert8to16 (const uint8_t *source, int size) |
Converts an array of uint8_t to another array of uint16_t (assuming the values are coded on two bytes) The returned pointer has to be deleted by the user. | |
static uint16_t * | average (uint16_t *source, int size, int passes, int scale=1) |
Computes the average value of the stream, on a given frequency The returned pointer has to be deleted by the user. | |
static void | reduce (uint16_t *source, uint16_t *dest, int size, int passes, int scale=1) |
Reduces the stream, keeping only the extreme values. | |
static void | addOffset (uint16_t *source, uint16_t *dest, int size, int offset) |
Adds an offset to each value of the array. | |
static int | pow2 (int n) |
Get 2^n. | |
Protected Attributes inherited from StreamPlayer | |
std::deque< uint16_t > | mBuffer |
Feature extraction : those variables need to be public (I know, I can write accessors...) | |
QMutex | mLock |
char * | mAudioData |
unsigned int | mAudioDataSize |
unsigned int | mFrequency |
bool | mVerbose |
Main class that sets up and runs a pipeline.
A pipeline is a network of features and filters connected to the input stream.
Some explanations about the behaviour of the class :
A feature is a set of values computed by an algorithm. The number of values it outputs on a single audio chunk is the number of elements.
In the pipeline, some features are labelled as "used" : it means they are sent to the application to be used for classification, visualization, etc. The others are not outputted directly and can only be used as input for filters. The "real dimension" is the number of used features (x their number of elements). The "dimension" is the number of computed features and filters (again, x their number of elements).
Note : the feature named _spectrum is usually not labelled as "used" but is displayed by FeatureDrawer.
Forces the outputs of the features (and filters) to be in a given range.
void SoundAnalyser::cleanExtractors | ( | ) |
Clean the data in the extractors.
Clears the data in the extractors.
double ** SoundAnalyser::features | ( | unsigned int | n | ) |
Return the array of features for the nth sample.
Return the array of features at a given time.
bool SoundAnalyser::isUsed | ( | unsigned int | index | ) |
Features management : individual properties.
Is this feature used for detection ?
|
inline |
Features management : sizes.
Return the number of different features we computed
void SoundAnalyser::resetExtractors | ( | ) |
Extractors management.
Unregisters all the extractors.
Unregisters all the extractors
|
inline |
Mirrors.
Get the sampling frequency
void SoundAnalyser::setNormalization | ( | float | min, |
float | max | ||
) |
Set up unified bounds for all features.
Enable feature normalization.
bool SoundAnalyser::setupPipeline | ( | string | filename | ) |
Setup.
Set up from an XML file.
Set up the extractors from an XML file
Reimplemented in CorpusBuilder.
|
virtual |