Add step size

This commit is contained in:
Flamefire committed 2014-03-31 17:55:31 +02:00
1 parent f1a885b95e
commit 614a7e0ed2
5 files changed
+11 -8

No files matched your search

+2 -2
View File
@@ -58,8 +58,8 @@ bool Analyzer_OutputFloat(Analyzer* analyzer, float* data, int sampleCt, float r
return analyzer->output(data, data + sampleCt, rate);
}
DllExport PtAKF* PtAKF_Create(){
return new PtAKF();
DllExport PtAKF* PtAKF_Create(unsigned step){
return new PtAKF(step);
}
DllExport void PtAKF_Free(PtAKF* analyzer){
+1 -1
View File
@@ -15,7 +15,7 @@ DllExport double Analyzer_GetPeak(Analyzer* analyzer);
DllExport double Analyzer_FindNote(Analyzer* analyzer, double minFreq, double maxFreq);
DllExport bool Analyzer_OutputFloat(Analyzer* analyzer, float* data, int sampleCt, float rate);
DllExport PtAKF* PtAKF_Create();
DllExport PtAKF* PtAKF_Create(unsigned step);
DllExport void PtAKF_Free(PtAKF* analyzer);
DllExport int PtAKF_GetNumHalfTones();
DllExport void PtAKF_InputByte(PtAKF* analyzer, char* data, int sampleCt);
+3 -1
View File
@@ -21,7 +21,7 @@ static constexpr double HalftoneBase = 1.05946309436; // 2^(1/12) -> HalftoneBas
int PtAKF::_InitCount = 0;
float* PtAKF::_SamplesPerPeriodPerTone = NULL;
PtAKF::PtAKF(){
PtAKF::PtAKF(unsigned step){
_InitCount++;
if(_InitCount == 1){
_SamplesPerPeriodPerTone = new float[_MaxHalfTone + 1];
@@ -32,6 +32,7 @@ PtAKF::PtAKF(){
_SamplesPerPeriodPerTone[toneIndex] = static_cast<float>(44100.0 / freq); // samples in one period
}
}
_Step = step;
}
PtAKF::~PtAKF(){
@@ -49,6 +50,7 @@ int PtAKF::GetNote(double* maxVolume, float* weights){
_AnalysisBuf.pop(size - _SampleCt);
if(!_AnalysisBuf.read(AnaylsisBuf, AnaylsisBuf + _SampleCt))
return -1;
_AnalysisBuf.pop(_Step);
return _GetNote(AnaylsisBuf, maxVolume, weights);
}
+2 -1
View File
@@ -4,7 +4,7 @@
// A pitch detection that is based on the AKF and AMDF (initially from original Vocaluxe/USDx)
class PtAKF{
public:
PtAKF();
PtAKF(unsigned step);
~PtAKF();
void input(short* begin, short* end){
@@ -21,6 +21,7 @@ private:
constexpr static size_t _SampleCt = 4096;
RingBuffer<_SampleCt * 2> _AnalysisBuf;
unsigned _Step;
static int _GetNote(float* samples, double* maxVolume, float* weights);
static float _AnalyzeToneFunc(float* samples, int toneIndex);
+3 -3
View File
@@ -108,7 +108,7 @@ namespace Vocaluxe.Lib.Sound.Record
{
#region Imports
[DllImport("PitchTracker.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr PtAKF_Create();
private static extern IntPtr PtAKF_Create(uint step);
[DllImport("PitchTracker.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void PtAKF_Free(IntPtr analyzer);
@@ -125,9 +125,9 @@ namespace Vocaluxe.Lib.Sound.Record
private IntPtr _Instance;
public CPtAKF()
public CPtAKF(uint step = 200)
{
_Instance = PtAKF_Create();
_Instance = PtAKF_Create(step);
}
~CPtAKF()