当前位置: 首页>>代码示例>>C++>>正文


C++ TTAudioSignalPtr::fill方法代码示例

本文整理汇总了C++中TTAudioSignalPtr::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ TTAudioSignalPtr::fill方法的具体用法?C++ TTAudioSignalPtr::fill怎么用?C++ TTAudioSignalPtr::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TTAudioSignalPtr的用法示例。


在下文中一共展示了TTAudioSignalPtr::fill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test

TTErr TukeyWindow::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioObjectBasePtr	windowObject = NULL;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	int					N = 128;
	TTValue				v;
	TTFloat64			testAlpha = 0.5;
	
	// setup windowObject
	TTObjectBaseInstantiate(TT("WindowFunction"), &windowObject, TTValue(1));
	windowObject->setAttributeValue(TT("function"), TT("tukey"));
	windowObject->setAttributeValue(TT("mode"), TT("apply"));
	
	// set the value for alpha
	windowObject->setAttributeValue(TT("alpha"), testAlpha);
	TTTestLog("alpha was set to %.10f for test", testAlpha);
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
									
	// create a signal to be transformed and then process it)
	input->fill(1.0);
	windowObject->process(input, output);
	
	// now test the output
	for (int n=0; n<N; n++)
	{
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], sTukeyWindowCoefficients128[n]);
		badSampleCount += result;
		if (result) 
			TTTestLog("BAD SAMPLE @ n=%i ( value=%.10f	expected=%.10f )", n, output->mSampleVectors[0][n], sTukeyWindowCoefficients128[n]);
	}
	
	TTTestAssertion("Produces correct window coefficients", 
					badSampleCount == 0,
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	TTObjectBaseRelease(&windowObject);

	
	// wrap up test results and pass back to whoever called test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);

}
开发者ID:ChristianFrisson,项目名称:JamomaCore,代码行数:57,代码来源:TTTukeyWindow.test.cpp

示例2: test

TTErr RosenbergGlottalPulseWindow::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	
	TTAudioObjectBasePtr	windowObject = NULL;
	
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	
	int					N = 101;
	TTValue				v, aReturnWeDontCareAbout;
	
	// create the object, keep the default ratio parameter
	TTObjectBaseInstantiate(TT("WindowFunction"), &windowObject, TTValue(1));
	windowObject->setAttributeValue(TT("function"), TT("rosenbergGlottalPulse"));
	windowObject->setAttributeValue(TT("mode"), TT("apply"));
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
	
	// create a signal to be transformed, and then process it
	input->fill(1.0);
	windowObject->process(input, output);
		
	// now test the output
	int	badSampleCount = 0;
	for (int n=0; n<N; n++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], expectedResult1[n]);
		badSampleCount += result;
		if (result)
			TTTestLog("BAD SAMPLE @ n=%i  ( value=%.10f   expected=%.10f )", n, output->mSampleVectors[0][n], expectedResult1[n]);
	}

	TTTestAssertion("Produces correct window shape for with default ratio attribute", 
					badSampleCount == 0, 
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	v.resize(2);
	v.set(0, TT("ratio"));
	v.set(1, 0.8);
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	// Again create a signal to be transformed, and then process it
	input->fill(1.0);
	windowObject->process(input, output);
	
	// now test the output
	badSampleCount = 0;
	for (int n=0; n<N; n++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], expectedResult2[n]);
		badSampleCount += result;
		if (result)
			TTTestLog("BAD SAMPLE @ n=%i  ( value=%.10f   expected=%.10f )", n, output->mSampleVectors[0][n], expectedResult2[n]);
	}
	
	TTTestAssertion("Produces correct window shape for with ratio set to 0.8",
					badSampleCount == 0,
					testAssertionCount,
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	TTObjectBaseRelease(&windowObject);
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
开发者ID:ChristianFrisson,项目名称:JamomaCore,代码行数:77,代码来源:TTRosenbergGlottalPulseWindow.test.cpp

示例3: test

TTErr KaiserWindow::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioObjectBasePtr	windowObject = NULL;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	int					N = 128;
	TTValue				v, aReturnWeDontCareAbout;
	
	// create the object and set the beta parameter
	TTObjectBaseInstantiate(TT("WindowFunction"), &windowObject, TTValue(1));
	windowObject->setAttributeValue(TT("function"), TT("kaiser"));
	windowObject->setAttributeValue(TT("mode"), TT("apply"));
	
	v.resize(2);
	v[0] = TT("beta");
	v[1] = 6.0;
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	TTTestAssertion("Internal intermediate value 1 (zeroth-order bessel fn of the first kind, taken of beta = 6.0) is correct.",
					TTTestFloatEquivalence(((KaiserWindow*)((WindowFunction*)windowObject)->mFunctionObject)->mBesselIOofBeta, 67.2344069764780),
					testAssertionCount,
					errorCount);
	
	// change the alpha parameter and test Bessel function again
	v.resize(2);
	v[0] = TT("alpha");
	v[1] = 2.0;
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	TTTestAssertion("Internal intermediate value 2 (zeroth-order bessel fn of the first kind, taken of alpha = 2) is correct.",
					TTTestFloatEquivalence(((KaiserWindow*)((WindowFunction*)windowObject)->mFunctionObject)->mBesselIOofBeta, 87.10851065339077),
					testAssertionCount,
					errorCount);  // added 4/26 by Wolek
	
	// change the beta parameter and try applying the window
	v.resize(2);
	v[0] = TT("beta");
	v[1] = 3.0 * kTTPi;
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	TTTestAssertion("Internal intermediate value 2 (zeroth-order bessel fn of the first kind, taken of beta = 3 * pi) is correct.",
					TTTestFloatEquivalence(((KaiserWindow*)((WindowFunction*)windowObject)->mFunctionObject)->mBesselIOofBeta, 1633.090522058824),
					testAssertionCount,
					errorCount);  // added 4/26 by Wolek
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
	
	// create a signal to be transformed, and then process it
	input->fill(1.0);
	windowObject->process(input, output);
		
	// now test the output
	for (int n=0; n<N; n++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], sKaiserB3PiWindowCoefficients128[n]);
		badSampleCount += result;
		if (result)
			TTTestLog("BAD SAMPLE @ n=%i  ( value=%.10f   expected=%.10f )", n, output->mSampleVectors[0][n], sKaiserB3PiWindowCoefficients128[n]);
	}

	TTTestAssertion("Produces correct window shape for beta = 3 pi", 
					badSampleCount == 0, 
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	TTObjectBaseRelease(&windowObject);
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
开发者ID:EQ4,项目名称:JamomaCore,代码行数:81,代码来源:TTKaiserWindow.test.cpp


注:本文中的TTAudioSignalPtr::fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。