Better structure
This commit is contained in:
1 parent
6ad9f6a1ef
commit
4c597cb4f8
15 files changed
+54
-44
No files matched your search
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "pitch.hh"
|
||||
#include "PitchWrapper.h"
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
@@ -40,8 +39,8 @@ void freeDoubleArray(double* floats){
|
||||
free(floats);
|
||||
}
|
||||
|
||||
double ToneToNote(const Tone* tone){
|
||||
return 12.0 * std::log(tone->freq / 127.09) / std::log(2.0) + 27.5 - 16; // 16 = C2
|
||||
double FreqToNote(double freq){
|
||||
return 12.0 * std::log(freq / 127.09) / std::log(2.0) + 27.5 - 16; // 16 = C2
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Some code is taken from Performous: https://github.com/performous/performous/tree/master/game
|
||||
From 25.03.2014
|
||||
@@ -168,21 +168,21 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="compatibility.cpp" />
|
||||
<ClCompile Include="pitch.cc" />
|
||||
<ClCompile Include="pitchTracker.cpp" />
|
||||
<ClCompile Include="performous\pitch.cc" />
|
||||
<ClCompile Include="pdaAKF.cpp" />
|
||||
<ClCompile Include="PitchWrapper.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="compatibility.h" />
|
||||
<ClInclude Include="Helper.h" />
|
||||
<ClInclude Include="libda\fft.hpp" />
|
||||
<ClInclude Include="libda\sample.hpp" />
|
||||
<ClInclude Include="pitchTracker.h" />
|
||||
<ClInclude Include="performous\libda\fft.hpp" />
|
||||
<ClInclude Include="performous\libda\sample.hpp" />
|
||||
<ClInclude Include="pdaAKF.h" />
|
||||
<ClInclude Include="PitchWrapper.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="pitch.hh" />
|
||||
<None Include="util.hh" />
|
||||
<None Include="performous\pitch.hh" />
|
||||
<None Include="performous\util.hh" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -13,47 +13,56 @@
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Quelldateien\performous">
|
||||
<UniqueIdentifier>{a47c9d33-78d2-453d-bb59-e5724cd85f67}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headerdateien\performous">
|
||||
<UniqueIdentifier>{4c72400a-ff2c-4842-8c20-54deb5df606d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headerdateien\performous\libda">
|
||||
<UniqueIdentifier>{d71782a0-47fc-4fe1-8569-0a0ce8fe9b45}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pitchTracker.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pitch.cc">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PitchWrapper.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compatibility.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="performous\pitch.cc">
|
||||
<Filter>Quelldateien\performous</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pdaAKF.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pitchTracker.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libda\fft.hpp">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compatibility.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libda\sample.hpp">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PitchWrapper.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Helper.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="performous\libda\fft.hpp">
|
||||
<Filter>Headerdateien\performous\libda</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="performous\libda\sample.hpp">
|
||||
<Filter>Headerdateien\performous\libda</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pdaAKF.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="pitch.hh">
|
||||
<Filter>Headerdateien</Filter>
|
||||
<None Include="performous\pitch.hh">
|
||||
<Filter>Headerdateien\performous</Filter>
|
||||
</None>
|
||||
<None Include="util.hh">
|
||||
<Filter>Headerdateien</Filter>
|
||||
<None Include="performous\util.hh">
|
||||
<Filter>Headerdateien\performous</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "PitchWrapper.h"
|
||||
#include "pitchTracker.h"
|
||||
#include "pdaAKF.h"
|
||||
#include "Helper.h"
|
||||
|
||||
AnalyzerExt::AnalyzerExt(double baseToneFrequency, int minHalfTone, int maxHalfTone, unsigned step): Analyzer(44100., "", step){
|
||||
PitchTracker::Init(baseToneFrequency, minHalfTone, maxHalfTone);
|
||||
PitchTrackerAKF::Init(baseToneFrequency, minHalfTone, maxHalfTone);
|
||||
}
|
||||
|
||||
AnalyzerExt::~AnalyzerExt(){
|
||||
PitchTracker::DeInit();
|
||||
PitchTrackerAKF::DeInit();
|
||||
}
|
||||
|
||||
int AnalyzerExt::GetNoteFast(double* maxVolume, float* weights){
|
||||
@@ -17,22 +17,22 @@ int AnalyzerExt::GetNoteFast(double* maxVolume, float* weights){
|
||||
m_fastAnalysisBuf.pop(size - m_SampleCt);
|
||||
if(!m_fastAnalysisBuf.read(AnaylsisBuf, AnaylsisBuf + m_SampleCt))
|
||||
return -1;
|
||||
return PitchTracker::GetTone(AnaylsisBuf, m_SampleCt, maxVolume, weights);
|
||||
return PitchTrackerAKF::GetTone(AnaylsisBuf, m_SampleCt, maxVolume, weights);
|
||||
}
|
||||
|
||||
void PtFast_Init(double baseToneFrequency, int minHalfTone, int maxHalfTone){
|
||||
PitchTracker::Init(baseToneFrequency, minHalfTone, maxHalfTone);
|
||||
PitchTrackerAKF::Init(baseToneFrequency, minHalfTone, maxHalfTone);
|
||||
}
|
||||
|
||||
void PtFast_DeInit(){
|
||||
PitchTracker::DeInit();
|
||||
PitchTrackerAKF::DeInit();
|
||||
}
|
||||
|
||||
int PtFast_GetTone(short* samples, int sampleCt, double* maxVolume, float* weights){
|
||||
if(sampleCt <= 0)
|
||||
return -1;
|
||||
double* dataDouble = short2DoubleArray(samples, sampleCt, false);
|
||||
int result = PitchTracker::GetTone(dataDouble, sampleCt, maxVolume, weights, true);
|
||||
int result = PitchTrackerAKF::GetTone(dataDouble, sampleCt, maxVolume, weights, true);
|
||||
freeDoubleArray(dataDouble);
|
||||
return result;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ double Analyzer_FindNote(AnalyzerExt* analyzer, double minFreq, double maxFreq){
|
||||
if(!analyzer)
|
||||
return -1;
|
||||
const Tone* tone = analyzer->findTone(minFreq, maxFreq);
|
||||
return (tone == NULL) ? -1 : ToneToNote(tone);
|
||||
return (tone == NULL) ? -1 : FreqToNote(tone->freq);
|
||||
}
|
||||
|
||||
int Analyzer_GetNoteFast(AnalyzerExt* analyzer, double* maxVolume, float* weights){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "pitch.hh"
|
||||
#include "performous/pitch.hh"
|
||||
|
||||
#define DllExport extern "C" __declspec(dllexport)
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "pitchTracker.h"
|
||||
#include "pdaAKF.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace PitchTracker{
|
||||
namespace PitchTrackerAKF{
|
||||
|
||||
static void doLog(const char* msg,...){
|
||||
va_list argptr = NULL;
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace PitchTracker{
|
||||
// A pitch detection that is based on the AKF and AMDF (initially from original Vocaluxe/USDx)
|
||||
namespace PitchTrackerAKF{
|
||||
void Init(double baseToneFrequency, int minHalfTone, int maxHalfTone);
|
||||
void DeInit();
|
||||
template<typename T> int GetTone(T *samples, int sampleCt, double* maxVolume, float *weights, bool scale = false);
|
||||
@@ -0,0 +1,3 @@
|
||||
code is based on Performous: https://github.com/performous/performous/tree/master/game
|
||||
Some modifications were made to make it compile with VS2012, fix warnings and make it suitable for our needs
|
||||
From 25.03.2014
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -5,7 +5,7 @@
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include "compatibility.h"
|
||||
#include "../compatibility.h"
|
||||
|
||||
/// struct to represent tones
|
||||
struct Tone {
|
||||
File renamed without changes.
Reference in new issue
Block a user