const float* Param::getValueArray() { if( ! mIsVaryingThisBlock ) { initInternalBuffer(); dsp::fill( mValue, mInternalBuffer.getData(), mInternalBuffer.getSize() ); } return mInternalBuffer.getData(); }
EventRef Param::applyRamp( float valueBegin, float valueEnd, float rampSeconds, const Options &options ) { initInternalBuffer(); auto ctx = getContext(); float timeBegin = (float)ctx->getNumProcessedSeconds() + options.getDelay(); float timeEnd = timeBegin + rampSeconds; EventRef event( new Event( timeBegin, timeEnd, valueBegin, valueEnd, options.getRampFn() ) ); lock_guard<mutex> lock( ctx->getMutex() ); resetImpl(); mEvents.push_back( event ); return event; }
void Param::setProcessor( const NodeRef &node ) { if( ! node ) return; initInternalBuffer(); lock_guard<mutex> lock( getContext()->getMutex() ); resetImpl(); // force node to be mono and initialize it node->setNumChannels( 1 ); node->initializeImpl(); mProcessor = node; }
EventRef Param::appendRamp( float valueEnd, float rampSeconds, const Options &options ) { initInternalBuffer(); auto ctx = getContext(); auto endTimeAndValue = findEndTimeAndValue(); float timeBegin = endTimeAndValue.first + options.getDelay(); float timeEnd = timeBegin + rampSeconds; EventRef event( new Event( timeBegin, timeEnd, endTimeAndValue.second, valueEnd, options.getRampFn() ) ); lock_guard<mutex> lock( ctx->getMutex() ); mEvents.push_back( event ); return event; }
void Param::setProcessor( const NodeRef &node ) { if( ! node ) return; initInternalBuffer(); lock_guard<mutex> lock( getContext()->getMutex() ); resetImpl(); // force node to be mono and initialize it node->setNumChannels( 1 ); node->initializeImpl(); mProcessor = node; mIsVaryingThisBlock = true; // stays true until there is no more processor and eval() sets this to false. }
EventRef Param::appendRamp( float valueBegin, float valueEnd, double rampSeconds, const Options &options ) { initInternalBuffer(); auto ctx = getContext(); auto endTimeAndValue = findEndTimeAndValue(); double timeBegin = ( options.getBeginTime() >= 0 ? options.getBeginTime() : endTimeAndValue.first + options.getDelay() ); double timeEnd = timeBegin + rampSeconds; EventRef event( new Event( timeBegin, timeEnd, valueBegin, valueEnd, false, options.getRampFn() ) ); if( ! options.getLabel().empty() ) event->mLabel = options.getLabel(); lock_guard<mutex> lock( ctx->getMutex() ); mEvents.push_back( event ); return event; }
EventRef Param::applyRamp( float valueEnd, double rampSeconds, const Options &options ) { initInternalBuffer(); auto ctx = getContext(); double timeBegin = ( options.getBeginTime() >= 0 ? options.getBeginTime() : ctx->getNumProcessedSeconds() + options.getDelay() ); double timeEnd = timeBegin + rampSeconds; EventRef event( new Event( timeBegin, timeEnd, mValue, valueEnd, true, options.getRampFn() ) ); if( ! options.getLabel().empty() ) event->mLabel = options.getLabel(); lock_guard<mutex> lock( ctx->getMutex() ); removeEventsAt( timeBegin ); if( mProcessor ) mProcessor.reset(); mEvents.push_back( event ); return event; }