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