I propose the audio trigger is changed from the currently implemented Schmitt trigger.
A better implementation is to use a a sound energy algorithm where the instant sound energy is compared to the average sound energy.
This link gives a good description on how to detect a beat.
I have looked at the source of current audio trigger and not much modification is needed.
Proper Beat detection with AudioTrigger
-
- Posts: 6
- Joined: Mon Apr 11, 2016 4:02 pm
- Real Name: Toon SMits
I have trouble finding identifying parts of the AudioTrigger.
But where it could be added is at AudioBar::checkWidgetFunctionality() and the AudioBar object/class.
For each subband a register should be assigned that keeps the last values.
User could change the C value, the variance threshold V, the size of the memory or the size of the audiocapture window.
But where it could be added is at AudioBar::checkWidgetFunctionality() and the AudioBar object/class.
For each subband a register should be assigned that keeps the last values.
Code: Select all
// Initialise
private int pos = 0;
private double *register = new double[registerSize];
private double average = 0;
// Variables that could be changed
private int registerSize = 43;
private double C = 150.0, V = 250.0;
// write all zeros to register
//Example in
//AudioBar::checkWidgetFunctionality()
// m_value is the new value coming from the audiocapture class
// average contains the average energy of the window
// register[pos] is the oldest value in the window
average += (m_value - register[pos]) / registerSize;
register[pos] = m_value;
pos = (pos+1)%registerSize;
bool beat = m_value > C * average;
// additional extra check is to use the variance.
double variance = 0;
for(int i = 0; i < registerSize;i++){
variance += (register[i] - average)*(register[i] - average);
}
//then your beat check would be
bool beat = (m_value > C * average) && (variance > V) ;
-
- Posts: 6
- Joined: Mon Apr 11, 2016 4:02 pm
- Real Name: Toon SMits
It is possible to drop that for loop.
Code: Select all
// Initialise
private int pos = 0;
private double *register = new double[registerSize];
private double average = 0.0;
private double sum = 0.0;
// Variables that could be changed
private int registerSize = 43;
private double C = 150.0, V = 250.0;
// write all zeros to register
//Example in
//AudioBar::checkWidgetFunctionality()
// m_value is the new value coming from the audiocapture class
// average contains the average energy of the window
// sum containt the average of the energy²
// register[pos] is the oldest value in the window
average += (m_value - register[pos]) / registerSize;
sum += (m_value * m_value - register[pos] * register[pos]) / registerSize
// updating register
register[pos] = m_value;
pos = (pos+1)%registerSize;
bool beat = (m_value > C * average) && (sum - average* average > V) ;
- mcallegari
- Posts: 4711
- Joined: Sun Apr 12, 2015 9:09 am
- Location: Italy
- Real Name: Massimo Callegari
- Contact:
Moved to the software development section.
I'll have a look at your observations when I have some time. Thanks
I'll have a look at your observations when I have some time. Thanks
-
- Posts: 6
- Joined: Mon Apr 11, 2016 4:02 pm
- Real Name: Toon SMits
I have added the lines to audiobar.cpp but I having issues.
Audiobar objects only get int values between 0 - 255. A lot of information is lost.
I probably need to reduce the windows of the AudioCapture class. Where is this AUDIO_DEFAULT_BUFFER_SIZE located?
Audiobar objects only get int values between 0 - 255. A lot of information is lost.
I probably need to reduce the windows of the AudioCapture class. Where is this AUDIO_DEFAULT_BUFFER_SIZE located?
Code: Select all
// audiocapture.cpp
int bufferSize = AUDIO_DEFAULT_BUFFER_SIZE;
-
- Posts: 1325
- Joined: Mon Apr 13, 2015 7:05 am
- Location: Bratislava, Slovakia
- Real Name: Jano Svitok
- Contact:
phoz,
I keep (update from time to time) doxygen-generated source documentation at http://qlcplus.zvukari.sk/doxygen You can browse classes
and methods and also go to their definition. The constant is documented here: http://qlcplus.zvukari.sk/doxygen/df/db ... ac632e19c1
You may create the same documentation on your hdd:
- install doxygen (http://doxygen.org or apt-get install doxygen) and graphviz (for class diagrams; http://www.graphviz.org/ or apt-get install graphviz)
- go to doxygen dir in qlc+ source tree
- run doxygen qlcplus.dox
- go to doxygen/html and open index.html
I keep (update from time to time) doxygen-generated source documentation at http://qlcplus.zvukari.sk/doxygen You can browse classes
and methods and also go to their definition. The constant is documented here: http://qlcplus.zvukari.sk/doxygen/df/db ... ac632e19c1
You may create the same documentation on your hdd:
- install doxygen (http://doxygen.org or apt-get install doxygen) and graphviz (for class diagrams; http://www.graphviz.org/ or apt-get install graphviz)
- go to doxygen dir in qlc+ source tree
- run doxygen qlcplus.dox
- go to doxygen/html and open index.html
-
- Posts: 1325
- Joined: Mon Apr 13, 2015 7:05 am
- Location: Bratislava, Slovakia
- Real Name: Jano Svitok
- Contact: