本文整理汇总了C++中keyfinder::AudioData::getSample方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioData::getSample方法的具体用法?C++ AudioData::getSample怎么用?C++ AudioData::getSample使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keyfinder::AudioData
的用法示例。
在下文中一共展示了AudioData::getSample方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST (LowPassFilterTest, WorksOnRepetitiveWaves) {
// make two sine waves, but this time, several seconds long
unsigned int samples = frameRate * 5;
KeyFinder::AudioData a;
a.setChannels(1);
a.setFrameRate(frameRate);
a.addToSampleCount(samples);
for (unsigned int i = 0; i < samples; i++) {
float sample = 0.0;
sample += sine_wave(i, highFrequency, frameRate, magnitude); // high freq
sample += sine_wave(i, lowFrequency, frameRate, magnitude); // low freq
a.setSample(i, sample);
// ensure repetition of sine waves is perfect...
if (i >= frameRate) {
ASSERT_NEAR(a.getSample(i), a.getSample(i - frameRate), tolerance);
}
}
KeyFinder::LowPassFilter* lpf = new KeyFinder::LowPassFilter(filterOrder, frameRate, cornerFrequency, filterFFT);
KeyFinder::Workspace w;
lpf->filter(a, w);
delete lpf;
// test for lower wave only
for (unsigned int i = 0; i < samples; i++) {
float expected = sine_wave(i, lowFrequency, frameRate, magnitude);
ASSERT_NEAR(expected, a.getSample(i), tolerance);
}
}
示例2:
TEST(AudioDataTest, SamplesBasic){
KeyFinder::AudioData a;
a.addToSampleCount(100);
ASSERT_EQ(100, a.getSampleCount());
// init values
for(int i=0; i<100; i++){
ASSERT_EQ(0.0, a.getSample(i));
}
a.setSample(0, 10.0);
ASSERT_EQ(10.0, a.getSample(0));
}
示例3:
TEST (AudioDataTest, SampleMutatorBounds) {
KeyFinder::AudioData a;
a.addToSampleCount(5);
ASSERT_THROW(a.getSample(-1), KeyFinder::Exception);
ASSERT_THROW(a.getSample(5), KeyFinder::Exception);
ASSERT_THROW(a.setSample(-1, 1.0), KeyFinder::Exception);
ASSERT_THROW(a.setSample(5, 1.0), KeyFinder::Exception);
ASSERT_THROW(a.setSample(0, INFINITY), KeyFinder::Exception);
ASSERT_THROW(a.setSample(0, NAN), KeyFinder::Exception);
}
示例4: while
TEST (AudioDataTest, SliceFromBack) {
KeyFinder::AudioData a;
a.setChannels(1);
a.setFrameRate(1);
KeyFinder::AudioData* b = NULL;
KeyFinder::AudioData* nullPtr = NULL;
ASSERT_THROW(b = a.sliceSamplesFromBack(1), KeyFinder::Exception);
ASSERT_EQ(nullPtr, b);
a.addToFrameCount(10);
ASSERT_THROW(b = a.sliceSamplesFromBack(11), KeyFinder::Exception);
ASSERT_EQ(nullPtr, b);
a.resetIterators();
float v = 0;
while (a.writeIteratorWithinUpperBound()) {
a.setSampleAtWriteIterator(v);
a.advanceWriteIterator();
v += 1.0;
}
ASSERT_NO_THROW(b = a.sliceSamplesFromBack(5));
ASSERT_NE(nullPtr, b);
ASSERT_EQ(5, a.getSampleCount());
ASSERT_EQ(5, b->getSampleCount());
ASSERT_FLOAT_EQ(5.0, b->getSample(0));
ASSERT_FLOAT_EQ(9.0, b->getSample(4));
delete b;
}