Example #1
0
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() );
}
Example #2
0
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();
}
Example #3
0
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() );
}
Example #4
0
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();
	};
}