Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

VizKit::VisualAudioLab Class Reference

#include <VisualAudioLab.h>

Collaboration diagram for VizKit::VisualAudioLab:
Collaboration graph
[legend]

List of all members.

Classes

struct  BeatGuess
struct  RMSValue

Public Member Functions

void processAudioData (uint8 numWaveformChannels, uint16 numWaveformEntries, const uint8 *const currWaveformData, uint8 numSpectrumChannels, uint16 numSpectrumEntries, const uint8 *const currSpectrumData)
void resetData (void)
uint32 getCurrTimestampIDOfRenderData (void)
void setCurrTimestampIDOfRenderData (const uint32 timestampID)
void setTotalTimeOfCurrentTrack (const uint32 totalTimeInMS)
void setStartTimeOfCurrentTrack (const uint32 startTimeInMS)
void setStopTimeOfCurrentTrack (const uint32 stopTimeInMS)
bool remainingTimeOfCurrentTrackIsKnown (void)
uint32 getRemainingTimeOfCurrentTrack (void)
uint32 getTotalTimeOfCurrentTrack (void)
sint16 getCurrMusicDataHistory (void)
sint16 getPrevMusicDataHistory (void)
uint8 getRMSIntensity (void)
uint8 getWaveformDataOfChannelAtIndex (const uint16 channel, const uint16 index)
const uint8 ***const getSpectrumDataArray (void)
const sint16 **const getWaveformDataMonoArray (void)
uint8 getMonoWaveformDataAtIndex (const uint16 index)
uint8 getWaveformDataOfChannelAtIndexWithHistoryNum (const uint16 channel, const uint16 index, const uint16 historyNum)
uint8 getMonoWaveformDataAtIndexWithHistoryNum (const uint16 index, const uint16 historyNum)
uint8 getDCIntensity (void)
void checkForBeatImpulse (void)
uint8 getBeatMeter (void)
void HannWindow (const int N, double TimeSamples[])
const sint8 *const getWaveformShapeArray (void)
uint32 getNumberOfAudioSpectrumDataEntries (void)
uint32 getNumberOfWaveformEntries (void)
uint32 getNumberOfSpectrumEntries (void)
uint16 getMaxNumberOfWaveformShapeHistory (void)
uint16 getNumberOfDataChannels (void)
uint16 getMaxNumberOfMusicDataHistories (void)
const uint32 *const getBeatHistogram (void)

Static Public Member Functions

static VisualAudioLabgetInstance (void)
static void dispose (void)
static void setMaxNumberOfAudioDataChannels (uint16 aNumberOfMaxAudioDataChannels)
static void setNumberOfAudioWaveformDataEntries (uint32 aNumberOfAudioWaveformDataEntries)
static void setNumberOfAudioSpectrumDataEntries (uint32 aNumberOfAudioSpectrumDataEntries)

Private Member Functions

 VisualAudioLab ()
 ~VisualAudioLab ()
 VisualAudioLab (const VisualAudioLab &other)
VisualAudioLaboperator= (const VisualAudioLab &other)
void init (void)
void processWaveformData (uint8 numWaveformChannels, uint16 numWaveformEntries, const uint8 *const currWaveformData)
void processSpectrumData (const uint8 numSpectrumChannels, const uint16 numSpectrumEntries, const uint8 *const currSpectrumData)
void incrementMusicDataHistory (void)
void storeBeatImpulse (bool beatImpulse)
void addToWaveformShape (sint8 minWaveformPoint, sint8 maxWaveformPoint)
void addToBeatRecords (void)
void addToBeatGapHistogram (uint16 gapInMilliseconds)
void resetBeatGapHistogram (void)
void calcBeatConfidence (void)
uint32 getBestBeatMSInterval (void)
uint8 isBeatMeter (uint32 elapsedMSSinceStartOfTrack)

Private Attributes

uint32 totalTimeOfTrack
uint32 elapsedTimeOfTrack
uint32 startTimeOfTrack
uint32 stopTimeOfTrack
uint32 currTimestampIDOfRenderData
sint8 numberOfMusicDataHistoryInt
sint8 *** waveformData
sint16 ** waveformDataMono
uint8 *** spectrumData
double * amplitudeEnvelope
sint32mean
double * tappingBuffer
double ** rms
double * rmsMono
double rmsMonoAvg
uint32beatGapHistogram
uint32 beatTimeDeltaInMS
double rmsMonoMax
sint16 currMusicDataHistory
uint8minSpectrumLevel
uint8maxSpectrumLevel
uint8 spectrumDCLevel
float avgSpectrumDCLevel
float spectrumDCLevelSum
sint8minWaveformVal
sint8maxWaveformVal
sint8 minWaveformValMono
sint8 maxWaveformValMono
uint32waveformValSum
uint32peakWaveformValSum
uint32prevWaveformValSum
uint32avgWaveformValSum
uint32avgWaveformValSumCounter
bool isBeatImpulse
RMSValue rmsBuffer [2000]
uint16 currRMSValue
uint8 currRecordedBeat
BeatGuessbeatsRecordedInBeatAnalyseTimeFrame

Static Private Attributes

static VisualAudioLabtheVisualAudioLab = NULL
static uint16 maxNumberOfAudioDataChannels = 0
static uint32 numberOfAudioWaveformDataEntries = 0
static uint32 numberOfAudioSpectrumDataEntries = 0
static const uint8 beatTimeTolerance = 25
static const uint16 beatThreshold = 300
static const uint16 beatAnalyseTimeFrame = 10000
static const uint16 maximumBeatInterval = 2000
static const uint16 numberOfMillisecondsOfRMSBuffer = 3000
static const uint16 numberOfRMSBufferEntries = 2000
static const uint16 maxNumberOfWaveformShapeHistory = 1400
static const uint16 maxNumberOfMusicDataHistory = 40
static const uint16 tappingBufferLength = 4096
static const uint16 maxNumberOfBeatHistogramBins = 100
static const uint16 maxNumberOfBeatsRecordedInAnalyseTimeframe = 200

Detailed Description

A collection of routines dealing with processing, analyzing and interpretation of audio data.


Constructor & Destructor Documentation

VisualAudioLab::VisualAudioLab (  )  [private]

The constructor. VisualAudioLab is a singleton class. The constructor is private. New instance of class can only be created internally.

VisualAudioLab::~VisualAudioLab (  )  [private]

The destructor. VisualAudioLab is a singleton class. The destructor is private. Instance of class can only be destructed internally.

VizKit::VisualAudioLab::VisualAudioLab ( const VisualAudioLab other  )  [private]

Copy constructor.

Parameters:
other Another VisualAudioLab.
Remarks:
Explicitely declared in private section and not implemented to enforce uniqueness of singleton pattern.

Member Function Documentation

void VisualAudioLab::addToBeatGapHistogram ( uint16  gapInMilliseconds  )  [private]

Adds a value to beatGapHistogram.

Parameters:
gapInMilliseconds The gap to previous beat detection in milliseconds.
void VisualAudioLab::addToBeatRecords ( void   )  [private]

Adds a value to beatsRecordedInBeatAnalyseTimeFrame.

void VizKit::VisualAudioLab::addToWaveformShape ( sint8  minWaveformPoint,
sint8  maxWaveformPoint 
) [private]

Adds the minimum and maximum waveform data value to the waveform shape.

Parameters:
minWaveformPoint The minimum waveform data value.
maxWaveformPoint The maximum waveform data value.
void VisualAudioLab::calcBeatConfidence ( void   )  [private]

Calculates the confidence of the beat estimation.

void VisualAudioLab::checkForBeatImpulse ( void   ) 

Checks for the beat impulse and sends a notification in case a beat impulse is detected.

void VisualAudioLab::dispose ( void   )  [static]

Disposes the VisualAudiolab.

const uint32 *const VisualAudioLab::getBeatHistogram ( void   ) 

Returns a pointer to the histogram of the gaps between detected beat events.

Returns:
A pointer to the histogram of the gaps between detected beat events.
uint8 VisualAudioLab::getBeatMeter ( void   ) 

Answers the question whether the current timestamp suggests a beat impulse.

Returns:
1 if the current timestamp suggests a beat impulse, 0 if not.
uint32 VisualAudioLab::getBestBeatMSInterval ( void   )  [private]

Returns the best guess for the beat interval in milliseconds. The best guess for the beat interval in milliseconds.

sint16 VisualAudioLab::getCurrMusicDataHistory ( void   ) 

Returns the current music data history.

Returns:
The current music data history.
uint32 VisualAudioLab::getCurrTimestampIDOfRenderData ( void   ) 

Returns the last processed timestampID of the kVisualPluginRenderMessage.

Returns:
The last processed timestampID of the kVisualPluginRenderMessage.
uint8 VisualAudioLab::getDCIntensity ( void   ) 

Returns the DC intensity. The DC intensity is the intensity of the direct current.

Returns:
The DC intensity.
VisualAudioLab * VisualAudioLab::getInstance ( void   )  [static]

Returns the VisualAudioLab. The VisualAudiolab is initialized if required. The VisualAudioLab is a singleton.

uint16 VisualAudioLab::getMaxNumberOfMusicDataHistories ( void   ) 

Returns the maximum number of histories in waveform data.

Returns:
The maximum number of histories in waveform data.
uint16 VisualAudioLab::getMaxNumberOfWaveformShapeHistory ( void   ) 

Returns the maximum history number.

Returns:
The maximum history number.
uint8 VisualAudioLab::getMonoWaveformDataAtIndex ( const uint16  index  ) 

Returns the waveform data value of a specific index position.

Parameters:
index The index of the requested waveform data.
Returns:
The mono waveform data at a specific index.
uint8 VisualAudioLab::getMonoWaveformDataAtIndexWithHistoryNum ( const uint16  index,
const uint16  historyNum 
)

Returns the mono waveform data of a specific history at a specific index.

Parameters:
index The index of the requested waveform data.
historyNum The history of the requested waveform data.
Returns:
The mono waveform data of a specific history at a specific index.
uint32 VizKit::VisualAudioLab::getNumberOfAudioSpectrumDataEntries ( void   ) 

Returns the number of audio spectrum data entries.

Returns:
The number of audio spectrum data entries.
uint16 VisualAudioLab::getNumberOfDataChannels ( void   ) 

Returns the number of data channels.

Returns:
The number of data channels.
uint32 VisualAudioLab::getNumberOfSpectrumEntries ( void   ) 

Returns the number of spectrum data entries.

Returns:
The number of spectrum data entries.
uint32 VisualAudioLab::getNumberOfWaveformEntries ( void   ) 

Returns the number of waveform data entries.

Returns:
The number of waveform data entries.
sint16 VisualAudioLab::getPrevMusicDataHistory ( void   ) 

Returns the previous music data history. The previous music data history is the one that was current before the one that is now current.

Returns:
The previous music data history.
uint32 VisualAudioLab::getRemainingTimeOfCurrentTrack ( void   ) 

Returns the remaining time of the currently playing audio track measured in milliseconds.

Returns:
The remaining time of the currently playing audio track measured in milliseconds.
uint8 VisualAudioLab::getRMSIntensity ( void   ) 

Returns the RMS (root-mean-square) intensity. The RMS intensity is the computed root-mean-square value.

Returns:
The RMS intensity.
const uint8 ***const VisualAudioLab::getSpectrumDataArray ( void   ) 

Returns a pointer to the spectrum data array.

Returns:
A pointer to the spectrum data array.
uint32 VisualAudioLab::getTotalTimeOfCurrentTrack ( void   ) 

Returns the total time of the currently playing audio track measured in milliseconds.

Returns:
The total time of the currently playing audio track measured in milliseconds.
const sint16 **const VisualAudioLab::getWaveformDataMonoArray ( void   ) 

Returns a pointer to the mono waveform data array. The mono waveform data consists of the averaged values of the waveform data of all available channels.

Returns:
A pointer to the mono waveform data array.
uint8 VisualAudioLab::getWaveformDataOfChannelAtIndex ( const uint16  channel,
const uint16  index 
)

Returns the single waveform data of a specific channel at a specific index position.

Parameters:
channel The channel.
index The index of the waveform data.
Returns:
The single waveform data of a specific channel at a specific index position.
uint8 VisualAudioLab::getWaveformDataOfChannelAtIndexWithHistoryNum ( const uint16  channel,
const uint16  index,
const uint16  historyNum 
)

Returns the waveform data of a specific channel of a specific history at a specific index.

Parameters:
channel The cannel of the requested waveform data.
index The index of the requested waveform data.
historyNum The history of the requested waveform data.
Returns:
The waveform data of a specific channel of a specific history at a specific index.
const sint8* const VizKit::VisualAudioLab::getWaveformShapeArray ( void   ) 

Returns a pointer to the waveform shape array.

Returns:
A pointer to the waveform shape array.
void VisualAudioLab::HannWindow ( const int  N,
double  TimeSamples[] 
)

Processes the sample data with a Hann window.

Parameters:
N The number of samples.
TimeSamples The sample data.
void VisualAudioLab::incrementMusicDataHistory ( void   )  [private]

Increments the current history number of music data. Music data is stored for a number of histories.

void VisualAudioLab::init ( void   )  [private]

Allocates and initializes the buffers of the VisualAudioLab.

uint8 VisualAudioLab::isBeatMeter ( uint32  elapsedMSSinceStartOfTrack  )  [private]
Parameters:
elapsedMSSinceStartOfTrack The number of milliseconds elapsed since start of audio track.
Returns:
1 if time is in frame of beat meter, 0 if not.
VisualAudioLab& VizKit::VisualAudioLab::operator= ( const VisualAudioLab other  )  [private]

Assignment operator.

Remarks:
Explicitely declared in private section and not implemented to enforce uniqueness of singleton pattern.
void VisualAudioLab::processAudioData ( uint8  numWaveformChannels,
uint16  numWaveformEntries,
const uint8 *const   currWaveformData,
uint8  numSpectrumChannels,
uint16  numSpectrumEntries,
const uint8 *const   currSpectrumData 
)

Processes the audio data chunks. With each RenderMessage iTunes delivers waveform data and spectrum data. The spectrum data is a fft (Fast Fourier Transform) of the waveform data.

Parameters:
numWaveformChannels The number of waveform data channels.
numWaveformEntries The number of waveform data entries per channel.
currWaveformData A pointer to the waveform data.
numSpectrumChannels The number of spectrum data channels.
numSpectrumEntries The number of spectrum data entries per channel.
currSpectrumData A pointer to the spectrum data.
void VisualAudioLab::processSpectrumData ( const uint8  numSpectrumChannels,
const uint16  numSpectrumEntries,
const uint8 *const   currSpectrumData 
) [private]

Processes the spectrum data.

Parameters:
numSpectrumChannels The number of spectrum data channels (e.g. two for stereo sound)..
numSpectrumEntries The number of data points per channel.
currSpectrumData A pointer to the current spectrum data.
void VisualAudioLab::processWaveformData ( uint8  numWaveformChannels,
uint16  numWaveformEntries,
const uint8 *const   currWaveformData 
) [private]

Processes the waveform data.

Parameters:
numWaveformChannels The number of waveform data channels (e.g. two for stereo sound).
numWaveformEntries The number of data points per channel.
currWaveformData A pointer to the current waveform data.
bool VisualAudioLab::remainingTimeOfCurrentTrackIsKnown ( void   ) 

Answers the question whether the remaining time of the current track is known. Streamed audio has no info about remaining time of current track.

Returns:
True if the remaining time of the current track is known, false if not.
void VisualAudioLab::resetBeatGapHistogram ( void   )  [private]

Resets the beatGapHistogram.

void VisualAudioLab::resetData ( void   ) 

Resets the stored values of the VisualAudioLab. The VisualAudioLab stores analyzed values of an audio track. Typically the values are resetted when a new track starts playing.

void VisualAudioLab::setCurrTimestampIDOfRenderData ( const uint32  timestampID  ) 

Sets the last processed timestampID of the kVisualPluginRenderMessage.

Parameters:
timestampID The last processed timestampID of the kVisualPluginRenderMessage.
void VisualAudioLab::setMaxNumberOfAudioDataChannels ( uint16  aNumberOfMaxAudioDataChannels  )  [static]

Sets the maximum number of audio data channels (2 channels means stereo).

Parameters:
aNumberOfMaxAudioDataChannels The maximum number of audio data channels.
void VisualAudioLab::setNumberOfAudioSpectrumDataEntries ( uint32  aNumberOfAudioSpectrumDataEntries  )  [static]

Sets the number of audio spectrum data entries.

Parameters:
aNumberOfAudioSpectrumDataEntries The number of audio spectrum data entries.
void VisualAudioLab::setNumberOfAudioWaveformDataEntries ( uint32  aNumberOfAudioWaveformDataEntries  )  [static]

Sets the number of audio waveform data entries.

Parameters:
aNumberOfAudioWaveformDataEntries The number of audio waveform data entries.
void VisualAudioLab::setStartTimeOfCurrentTrack ( const uint32  startTimeInMS  ) 

Stores the start time of the current track.

Parameters:
startTimeInMS The start time of the currently playing audio track measured in milliseconds.
void VisualAudioLab::setStopTimeOfCurrentTrack ( const uint32  stopTimeInMS  ) 

Stores the stop time of the current track.

Parameters:
stopTimeInMS The stop time of the currently playing audio track measured in milliseconds.
void VisualAudioLab::setTotalTimeOfCurrentTrack ( const uint32  totalTimeInMS  ) 

Stores the total time of the current track.

Parameters:
totalTimeInMS The total time of the currently playing audio track measured in milliseconds.
void VisualAudioLab::storeBeatImpulse ( bool  beatImpulse  )  [private]

Stores the beat impulse.

Parameters:
beatImpulse True if the current waveform data indicates a beat impulse, false if not.

Member Data Documentation

The amplitude envelope array.

The average spectrum DC level.

The average value of the sum of the waveform data values.

The counter for the calculation o the average value of the sum of the waveform data values.

const uint16 VisualAudioLab::beatAnalyseTimeFrame = 10000 [static, private]

The time frame in which beats are recorded and analysed. Measured in milliseconds.

A histogram of the gaps between detected beat events.

Array in which the detected beats are stored with their elapsed milliseconds timestamp since start of track. Ringbuffer.

const uint16 VisualAudioLab::beatThreshold = 300 [static, private]

The threshold after which we are free to detect a new beat. Measured in milliseconds.

The delta between beats.

const uint8 VisualAudioLab::beatTimeTolerance = 25 [static, private]

The smallest time a beat is considered to be the same. Measured in milliseconds.

The current history number.

The current index of array beatsRecordedInBeatAnalyseTimeFrame.

The current index of array rmsBuffer.

The last processed timestampID of the kVisualPluginRenderMessage.

The accumulated play time of the current audio track measured in milliseconds.

1 if the current waveform data indicates a beat impulse, 0 if not.

const uint16 VisualAudioLab::maximumBeatInterval = 2000 [static, private]

The maximum beat interval. Measured in milliseconds.

The maximum number of audio data channels (2 channels means stereo).

The maximum spectrum level. 0-128.

The maximum waveform data value. 0-255. -128 ...127.

The maximum mono waveform data value.

The mean values.

The minimum spectrum level. 0-128.

The minimum waveform data value. 0-255. -128 ...127.

The minimum mono waveform data value.

The number of audio spectrum data entries.

The number of audio waveform data entries.

The number of milliseconds rms values are collected.

The number of music data history.

const uint16 VisualAudioLab::numberOfRMSBufferEntries = 2000 [static, private]

The number of records in rmsBuffer. Must be greater than: Audio sample rate (44100) / kVisualNumWaveformEntries * (numberOfMillisecondsOfRMSBuffer / 1000).

The peak values of the sum of the waveform data values.

The previous sum of the waveform data values.

double** VizKit::VisualAudioLab::rms [private]

The rms values.

Array containg rms mono values for the last numberOfMillisecondsOfRMSBuffer milliseconds. Ringbuffer. RMSValues with ((currentMSSinceStartOfTrack - timeInMillisecondsSinceStartOfTrack) > numberOfMillisecondsOfRMSBuffer) are discarded.

The mono rms values.

The average rms value.

The maximum mono rms value. Timeframe numberOfMillisecondsOfRMSBuffer.

The spectrum data array. The spectrum data array is 3-dimensional with data values, channels and history.

The spectrum DC level. 0-256 (?). Direct Current of FFT (mono).

The sum of the spectrum DC level. sum of data (for calc of avg).

The start time of the currently playing audio track measured in milliseconds. iTunes allows to set a custom start time for a track.

The stop time of the currently playing audio track measured in milliseconds. iTunes allows to set a custom stop time for a track.

A special buffer for beat detection.

const uint16 VisualAudioLab::tappingBufferLength = 4096 [static, private]

VisualAudioLab is a singleton class. Pointer to private instance is handled internally.

The total time of the currently playing audio track measured in milliseconds.

The waveform data array. The waveform data array is 3-dimensional with data values, channels and history.

The mono waveform data array. The mono waveform data array is 2-dimensional with data values, and history.

The sum of the absolute waveform data values that are higher or lower than 128.


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

Generated on Sun Sep 26 2010 13:29:36 for VizKit by doxygen 1.7.1