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


C++ audio::GainNodeRef类代码示例

本文整理汇总了C++中audio::GainNodeRef的典型用法代码示例。如果您正苦于以下问题:C++ GainNodeRef类的具体用法?C++ GainNodeRef怎么用?C++ GainNodeRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setup

void DeviceTestApp::setup()
{
    console() << audio::Device::printDevicesToString();

    auto ctx = audio::master();

    mMonitor = ctx->makeNode( new audio::MonitorNode( audio::MonitorNode::Format().windowSize( 1024 ) ) );
    mGain = ctx->makeNode( new audio::GainNode() );
    mGain->setValue( 0.4f );

    mGain->connect( mMonitor );

    setOutputDevice( audio::Device::getDefaultOutput() );
    setInputDevice( audio::Device::getDefaultInput() );
    //setInputDevice( audio::Device::getDefaultInput(), 1 ); // force mono input

    //setupMultiChannelDevice( "PreSonus FIREPOD (1431)" );
//	setupMultiChannelDeviceWindows( "MOTU Analog (MOTU Audio Wave for 64 bit)" );

    mRecorder = ctx->makeNode( new audio::BufferRecorderNode( RECORD_SECONDS * ctx->getSampleRate() ) );
    mRecorder->setEnabled( false );
    mGain >> mRecorder;


//	setupInputPulled();
//	setupIOClean();

    PRINT_GRAPH( ctx );

    setupUI();

    CI_LOG_V( "Context samplerate: " << ctx->getSampleRate() );
}
开发者ID:ffimusic,项目名称:Cinder,代码行数:33,代码来源:DeviceTestApp.cpp

示例2: setupFilePlayerNode

void SamplePlayerNodeTestApp::setupFilePlayerNode()
{
	mGain->disconnectAllInputs();

	auto ctx = audio::master();

//	mSourceFile->setMaxFramesPerRead( 8192 );
	bool asyncRead = mAsyncButton.mEnabled;
	CI_LOG_V( "async read: " << asyncRead );
	mSamplePlayerNode = ctx->makeNode( new audio::FilePlayerNode( mSourceFile, asyncRead ) );

	// TODO: it is pretty surprising when you recreate mMonitor here without checking if there has already been one added.
	//	- user will no longer see the old mMonitor, but the context still owns a reference to it, so another gets added each time we call this method.
	if( ! mMonitor )
		mMonitor = ctx->makeNode( new audio::MonitorNode( audio::MonitorNode::Format().windowSize( 1024 ) ) );

	// when these connections are called, some (GainNode and Pan) will already be connected, but this is okay, they should silently no-op.

	// or connect in series (it is added to the Context's 'auto pulled list')
	mSamplePlayerNode >> mGain >> mPan >> ctx->getOutput();
	mPan >> mMonitor;

	mSamplePlayerNode->setLoopEnabled( mLoopButton.mEnabled );
	mSamplePlayerNode->setLoopBeginTime( mLoopBeginSlider.mValueScaled );
	mSamplePlayerNode->setLoopEndTime( mLoopEndSlider.mValueScaled != 0 ? mLoopEndSlider.mValueScaled : mSamplePlayerNode->getNumSeconds() );

	PRINT_GRAPH( audio::master() );
}
开发者ID:DSDev-NickHogle,项目名称:Cinder,代码行数:28,代码来源:SampleTestApp.cpp

示例3: setup

void ParamTestApp::setup()
{
	auto ctx = audio::master();
	mGain = ctx->makeNode( new audio::GainNode() );
	mGain->setValue( 0.8f );

	mPan = ctx->makeNode( new audio::Pan2dNode() );

	mGen = ctx->makeNode( new audio::GenSineNode() );
//	mGen = ctx->makeNode( new audio::GenTriangleNode() );
//	mGen = ctx->makeNode( new audio::GenPhasorNode() );
	mGen = ctx->makeNode( new audio::GenPulseNode );

	mGen->setFreq( 220 );

	mLowPass = ctx->makeNode( new audio::FilterLowPassNode() );

	setupBasic();

	setupUI();

	PRINT_GRAPH( ctx );

	testApply();
//	testApply2();
//	connectProcessor();
}
开发者ID:LRitesh,项目名称:Cinder,代码行数:27,代码来源:ParamTestApp.cpp

示例4: setup

void SamplePlayerNodeTestApp::setup()
{
	mUnderrunFade = mOverrunFade = mRecorderOverrunFade = 0;
	mSamplePlayerNodeEnabledState = false;

	printSupportedExtensions();

	setSourceFile( loadResource( INITIAL_AUDIO_RES ) );

	auto ctx = audio::master();

	mPan = ctx->makeNode( new audio::Pan2dNode() );
//	mPan->setStereoInputModeEnabled( false );

	mGain = ctx->makeNode( new audio::GainNode() );
	mGain->setValue( 0.6f );

	mGain >> mPan >> ctx->getOutput();

	setupBufferPlayerNode();
//	setupFilePlayerNode();

	setupUI();

	ctx->enable();
	mEnableSamplePlayerNodeButton.setEnabled( true );

	CI_LOG_V( "context samplerate: " << ctx->getSampleRate() );
}
开发者ID:DSDev-NickHogle,项目名称:Cinder,代码行数:29,代码来源:SampleTestApp.cpp

示例5: mouseDrag

void DelayFeedback::mouseDrag( MouseEvent event )
{
	float freq = quantizePitch( event.getPos() );
	float gain = 1.0f - (float)event.getPos().y / (float)getWindowHeight();

	gain *= MAX_VOLUME;

	mOsc->getParamFreq()->applyRamp( freq, 0.04f );
	mGain->getParam()->applyRamp( gain, 0.1f );

	addSplash( event.getPos() );
}
开发者ID:CinimodStudio,项目名称:Cinder,代码行数:12,代码来源:DelayFeedbackApp.cpp

示例6: processDrag

void SamplePlayerNodeTestApp::processDrag( Vec2i pos )
{
	if( mGainSlider.hitTest( pos ) )
		mGain->setValue( mGainSlider.mValueScaled );
	else if( mPanSlider.hitTest( pos ) )
		mPan->setPos( mPanSlider.mValueScaled );
	else if( mLoopBeginSlider.hitTest( pos ) )
		mSamplePlayerNode->setLoopBeginTime( mLoopBeginSlider.mValueScaled );
	else if( mLoopEndSlider.hitTest( pos ) )
		mSamplePlayerNode->setLoopEndTime( mLoopEndSlider.mValueScaled );
	else if( pos.y > getWindowCenter().y )
		seek( pos.x );
}
开发者ID:DSDev-NickHogle,项目名称:Cinder,代码行数:13,代码来源:SampleTestApp.cpp

示例7: setupIOProcessed

void DeviceTestApp::setupIOProcessed()
{
    auto ctx = audio::master();
    auto mod = ctx->makeNode( new audio::GenSineNode( audio::Node::Format().autoEnable() ) );
    mod->setFreq( 200 );

    auto ringMod = audio::master()->makeNode( new audio::GainNode );
    ringMod->setName( "RingModGain" );
    ringMod->getParam()->setProcessor( mod );

    mGain->disconnectAllInputs();
    mInputDeviceNode >> ringMod >> mGain;

    mInputDeviceNode->enable();
}
开发者ID:ffimusic,项目名称:Cinder,代码行数:15,代码来源:DeviceTestApp.cpp

示例8: setup

void WebAudioApp::setup()
{

  Context::setMaster( new ContextWebAudio, new DeviceManagerWebAudio );

  auto ctx = audio::master();
  mGen = ctx->makeNode( new audio::GenSineNode );
  mGain = ctx->makeNode( new audio::GainNode );

  mGen->setFreq( 220 );
  mGain->setValue( 0.5f );

  // connections can be made this way or with connect(). The master Context's getOutput() is the speakers by default.
  mGen >> mGain >> ctx->getOutput();
  mGen->enable();
  ctx->enable();
}
开发者ID:sortofsleepy,项目名称:Cinder,代码行数:17,代码来源:NodeBasic.cpp

示例9: setup

void NodeBasic::setup()
{
	// You use the audio::Context to make new audio::Node instances (audio::master() is the speaker-facing Context).
	auto ctx = audio::master();
	mGen = ctx->makeNode( new audio::GenSineNode );
	mGain = ctx->makeNode( new audio::GainNode );

	mGen->setFreq( 220 );
	mGain->setValue( 0.5f );

	// connections can be made this way or with connect(). The master Context's getOutput() is the speakers by default.
	mGen >> mGain >> ctx->getOutput();

	// Node's need to be enabled to process audio. EffectNode's are enabled by default, while NodeSource's (like Gen) need to be switched on.
	mGen->enable();

	// Context also must be started. Starting and stopping this controls the entire DSP graph.
	ctx->enable();
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:19,代码来源:NodeBasicApp.cpp

示例10: processDrag

void SamplePlayerNodeTestApp::processDrag( ivec2 pos )
{
	if( mGainSlider.hitTest( pos ) )
		mGain->setValue( mGainSlider.mValueScaled );
	else if( mPanSlider.hitTest( pos ) ) {
#if TEST_STEREO_INPUT_PANNING
		mPan->getParamPos()->applyRamp( mPanSlider.mValueScaled, 0.6f );
#else
		mPan->setPos( mPanSlider.mValueScaled );
#endif
	}
	else if( mLoopBeginSlider.hitTest( pos ) )
		mSamplePlayerNode->setLoopBeginTime( mLoopBeginSlider.mValueScaled );
	else if( mLoopEndSlider.hitTest( pos ) )
		mSamplePlayerNode->setLoopEndTime( mLoopEndSlider.mValueScaled );
	else if( mTriggerDelaySlider.hitTest( pos ) ) {
	}
	else if( pos.y > getWindowCenter().y )
		seek( pos.x );
}
开发者ID:Drakesinger,项目名称:Cinder,代码行数:20,代码来源:SampleTestApp.cpp

示例11: setup

void NodeAdvancedApp::setup()
{
	auto ctx = audio::Context::master();

	// Here we're using a GenTriangleNode, which generates a triangle waveform that contains many upper harmonics.
	// To reduce the sharpness, a lowpass filter is used to cut down the higher frequences.
	mGen = ctx->makeNode( new audio::GenTriangleNode( audio::Node::Format().autoEnable() ) );
	mLowpass = ctx->makeNode( new audio::FilterLowPassNode );
	mGain = ctx->makeNode( new audio::GainNode );
	mMonitor = ctx->makeNode( new audio::MonitorNode );

	mLowpass->setFreq( 400 );

	// Below we tell the Gain's Param to ramp from 0 to 0.5 over 2 seconds, making it slowly fade in.!
	mGain->getParam()->applyRamp( 0, 0.5f, 2.0f );

	// make the synthesis connection
	mGen >> mLowpass >> mGain >> ctx->getOutput();

	// Also feed the Gain to our Scope so that we can see what the waveform looks like.
	mGain >> mMonitor;

	ctx->enable();

	// Many times it is easier to specify musical pitches in MIDI format, which is linear rather than in hertz.
	// Below is the pentatonic notes for the C major scale from C3-C5, represented in MIDI values.
	mCPentatonicScale.push_back( 48 );
	mCPentatonicScale.push_back( 50 );
	mCPentatonicScale.push_back( 52 );
	mCPentatonicScale.push_back( 55 );
	mCPentatonicScale.push_back( 57 );
	mCPentatonicScale.push_back( 60 );
	mCPentatonicScale.push_back( 62 );
	mCPentatonicScale.push_back( 64 );
	mCPentatonicScale.push_back( 67 );
	mCPentatonicScale.push_back( 69 );
	mCPentatonicScale.push_back( 72 );

	mFreqRampTime = 0.015f;
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:40,代码来源:NodeAdvancedApp.cpp

示例12: setupTest

void DeviceTestApp::setupTest( string test )
{
    if( test.empty() )
        test = "sinewave";

    CI_LOG_V( "test: " << test );

    // FIXME: Switching from 'noise' to 'i/o' on mac is causing a deadlock when initializing InputDeviceNodeAudioUnit.
    //	- it shouldn't have to be stopped, need to check why.
    //  - temp fix: stop / start context around reconfig
    audio::master()->disable();

    mGain->disconnectAllInputs();

    if( test == "sinewave" )
        setupSine();
    else if( test == "noise" )
        setupNoise();
    else if( test == "input (pulled)" )
        setupInputPulled();
    else if( test == "I/O (clean)" )
        setupIOClean();
    else if( test == "I/O (processed)" )
        setupIOProcessed();
    else if( test == "I/O and sine" )
        setupIOAndSine();
    else if( test == "send" )
        setupSend();
    else if( test == "send stereo" )
        setupSendStereo();
    else
        CI_ASSERT_NOT_REACHABLE();

    if( mPlayButton.mEnabled )
        audio::master()->enable();

    PRINT_GRAPH( audio::master() );
}
开发者ID:ffimusic,项目名称:Cinder,代码行数:38,代码来源:DeviceTestApp.cpp

示例13: setupBufferPlayerNode

void SamplePlayerNodeTestApp::setupBufferPlayerNode()
{
	auto bufferPlayer = audio::master()->makeNode( new audio::BufferPlayerNode() );

	auto loadFn = [bufferPlayer, this] {
		bufferPlayer->loadBuffer( mSourceFile );
		mWaveformPlot.load( bufferPlayer->getBuffer(), getWindowBounds() );
		CI_LOG_V( "loaded source buffer, frames: " << bufferPlayer->getBuffer()->getNumFrames() );

	};

	auto connectFn = [bufferPlayer, this] {
		mGain->disconnectAllInputs();
		mSamplePlayerNode = bufferPlayer;
		mSamplePlayerNode >> mGain >> mPan >> audio::master()->getOutput();
		PRINT_GRAPH( audio::master() );
		mSamplePlayerNode->setLoopEnabled( mLoopButton.mEnabled );
		mSamplePlayerNode->setLoopBeginTime( mLoopBeginSlider.mValueScaled );
		mSamplePlayerNode->setLoopEndTime( mLoopEndSlider.mValueScaled != 0 ? mLoopEndSlider.mValueScaled : mSamplePlayerNode->getNumSeconds() );
	};

	bool asyncLoad = mAsyncButton.mEnabled;
	CI_LOG_V( "async load: " << boolalpha << asyncLoad << dec );
	if( asyncLoad ) {
		mWaveformPlot.clear();
		mAsyncLoadFuture = std::async( [=] {
			loadFn();
			dispatchAsync( [=] {
				connectFn();
			} );
		} );
	}
	else {
		loadFn();
		connectFn();
	};
}
开发者ID:DSDev-NickHogle,项目名称:Cinder,代码行数:37,代码来源:SampleTestApp.cpp

示例14: makeNodes

void NodeEffectsTestApp::makeNodes()
{
	auto ctx = audio::master();

	mGain = ctx->makeNode( new audio::GainNode );
	mGain->setValue( 0.25f );

	mPan = ctx->makeNode( new audio::Pan2dNode );

	CI_LOG_V( "gen button enabled: " << mGenButton.mEnabled );
	auto genFmt = audio::Node::Format().autoEnable();
	if( mGenButton.mEnabled )
		mGen = ctx->makeNode( new audio::GenSineNode( 220, genFmt ) );
	else
		mGen = ctx->makeNode( new audio::GenNoiseNode( genFmt ) );

	mLowPass = ctx->makeNode( new audio::FilterLowPassNode() );
	mLowPass->setCutoffFreq( 400 );
//	mLowPass = ctx->makeNode( new audio::FilterHighPassNode() );

	mDelay = ctx->makeNode( new audio::DelayNode );
	mDelay->setDelaySeconds( 0.5f );
//	mDelay->setDelaySeconds( 100.0f / (float)ctx->getSampleRate() );
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:24,代码来源:NodeEffectsTestApp.cpp

示例15: mouseUp

void DelayFeedback::mouseUp( MouseEvent event )
{
	mGain->getParam()->applyRamp( 0, 1.5, audio::Param::Options().rampFn( &audio::rampOutQuad ) );
}
开发者ID:CinimodStudio,项目名称:Cinder,代码行数:4,代码来源:DelayFeedbackApp.cpp


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