[TTBlue-devel] [425] branches/active: Initial support for working with side-chains in TTBlue audio
Status: Alpha
Brought to you by:
tap
From: <ti...@gr...> - 2008-05-17 23:21:44
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[425] branches/active: Initial support for working with side-chains in TTBlue audio objects.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>425</dd> <dt>Author</dt> <dd>tim</dd> <dt>Date</dt> <dd>2008-05-17 23:21:48 +0000 (Sat, 17 May 2008)</dd> </dl> <h3>Log Message</h3> <pre>Initial support for working with side-chains in TTBlue audio objects.</pre> <h3>Modified Paths</h3> <ul> <li><a href="#branchesactiveincludescoreTTAudioObjecth">branches/active/includes/core/TTAudioObject.h</a></li> <li><a href="#branchesactivesourcecoreTTAudioObjectcpp">branches/active/source/core/TTAudioObject.cpp</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="branchesactiveincludescoreTTAudioObjecth"></a> <div class="modfile"><h4>Modified: branches/active/includes/core/TTAudioObject.h (424 => 425)</h4> <pre class="diff"><span> <span class="info">--- branches/active/includes/core/TTAudioObject.h 2008-05-17 23:19:37 UTC (rev 424) +++ branches/active/includes/core/TTAudioObject.h 2008-05-17 23:21:48 UTC (rev 425) </span><span class="lines">@@ -21,7 +21,10 @@ </span><span class="cx"> /** A type that can be used to store a pointer to a process method */ </span><span class="cx"> typedef TTErr (TTAudioObject::*TTProcessMethod)(TTAudioSignal& in, TTAudioSignal& out); </span><span class="cx"> </span><ins>+/** A type that can be used to store a pointer to a process method */ +typedef TTErr (TTAudioObject::*TTProcessWithSidechainsMethod)(TTAudioSignal& in1, TTAudioSignal& in2, TTAudioSignal& out1, TTAudioSignal& out2); </ins><span class="cx"> </span><ins>+ </ins><span class="cx"> /****************************************************************************************************/ </span><span class="cx"> // Class Specification </span><span class="cx"> </span><span class="lines">@@ -37,19 +40,24 @@ </span><span class="cx"> friend class TTGlobal; ///< Declare that the global object is friend so it can access the globalSr member </span><span class="cx"> </span><span class="cx"> protected: </span><del>- static TTUInt32 globalSr; ///< Current sample rate as understood by the environment as a whole - TTUInt32 sr; ///< Current sample rate being used by this object - TTFloat64 srInv; ///< 1.0 over the current sample rate (inverse) - TTFloat64 srMill; ///< 1/1000 of the current sample rate (samples per millisecond) - TTUInt8 maxNumChannels; ///< This is the maximum number of channels that can be guaranteed to work - TTBoolean attrProcessInPlace; ///< This flag indicates that the object should process the samples "in-place", such that the processed samples are actually in the input - TTBoolean attrBypass; ///< Are we bypassing the processMethod? - TTProcessMethod processMethod; ///< This function pointer points to the active (non-bypass) processing routine - TTProcessMethod currentProcessMethod; ///< This function pointer always points to the current processing routine </del><ins>+ static TTUInt32 globalSr; ///< Current sample rate as understood by the environment as a whole + TTUInt32 sr; ///< Current sample rate being used by this object + TTFloat64 srInv; ///< 1.0 over the current sample rate (inverse) + TTFloat64 srMill; ///< 1/1000 of the current sample rate (samples per millisecond) + TTUInt8 maxNumChannels; ///< This is the maximum number of channels that can be guaranteed to work + TTBoolean attrProcessInPlace; ///< This flag indicates that the object should process the samples "in-place", such that the processed samples are actually in the input + TTBoolean attrBypass; ///< Are we bypassing the processMethod? + TTProcessMethod processMethod; ///< This function pointer points to the active (non-bypass) processing routine + TTProcessMethod currentProcessMethod; ///< This function pointer always points to the current processing routine + TTProcessWithSidechainsMethod processWithSidechainMethod; ///< This function pointer points to the active (non-bypass) processing routine with sidechains, if applicable + TTProcessWithSidechainsMethod currentProcessWithSidechainMethod; ///< This function pointer always points to the current processing routine with sidechains, if applicable </ins><span class="cx"> </span><span class="cx"> /** Set the audio processing routine to point to a method that is defined as an arg to this function. */ </span><span class="cx"> TTErr setProcess(TTProcessMethod processMethod); </span><span class="cx"> </span><ins>+ /** Set the audio processing routine to point to a method that is defined as an arg to this function. */ + TTErr setProcessWithSidechain(TTProcessWithSidechainsMethod processMethod); + </ins><span class="cx"> /** Bypass the audio processing routine and copy all input samples to the output unchanged. */ </span><span class="cx"> TTErr setBypass(const TTAttribute&, const TTValue& value); </span><span class="cx"> </span><span class="lines">@@ -67,23 +75,43 @@ </span><span class="cx"> virtual ~TTAudioObject(); </span><span class="cx"> </span><span class="cx"> /** Process the input signal, resulting in an output signal. This method wraps the actual process method </span><del>- * that will be called. - * @param in The input signal. - * @param out The output signal. - * @return A TTBlue error code. */ </del><ins>+ that will be called. + @param in The input signal. + @param out The output signal. + @return A TTBlue error code. */ </ins><span class="cx"> TTErr process(TTAudioSignal& in, TTAudioSignal& out); </span><span class="cx"> </span><span class="cx"> /** Process the an output signal only, e.g. for a signal generator. This method wraps the actual process method </span><del>- * that will be called. - * @param in The input signal. - * @param out The output signal. - * @return A TTBlue error code. */ </del><ins>+ that will be called. + @param in The input signal. + @param out The output signal. + @return A TTBlue error code. */ </ins><span class="cx"> TTErr process(TTAudioSignal& out); </span><ins>+ + /** Process two input signals, resulting in two output signals. + This method wraps the actual process method, which may use the extra signal as a sidechain or other input. + @param in1 The main input signal. + @param in2 A secondary or sidechain input signal. + @param in1 The main output signal. + @param in2 A secondary or sidechain output signal. + @return A TTBlue error code. */ + TTErr TTAudioObject::process(TTAudioSignal& in1, TTAudioSignal& in2, TTAudioSignal& out1, TTAudioSignal& out2); </ins><span class="cx"> </span><ins>+ /** Process two input signals, resulting in an output signal. + This method wraps the actual process method that will be called. + @param in1 The main input signal. + @param in2 A secondary or sidechain input signal. + @param out The output signal. + @return A TTBlue error code. */ + TTErr TTAudioObject::process(TTAudioSignal& in1, TTAudioSignal& in2, TTAudioSignal& out); + </ins><span class="cx"> /** The default audio processing method, which simply copies a signal through with no modifications. */ </span><span class="cx"> TTErr bypassProcess(TTAudioSignal& in, TTAudioSignal& out); </span><span class="cx"> </span><ins>+ /** The default audio processing method for calls with side chains, which simply copies the signals through with no modifications. */ + TTErr bypassWithSidechainProcess(TTAudioSignal& in1, TTAudioSignal& in2, TTAudioSignal& out1, TTAudioSignal& out2); </ins><span class="cx"> </span><ins>+ </ins><span class="cx"> // UTILITIES </span><span class="cx"> </span><span class="cx"> /** Convert Hertz to radians. </span></span></pre></div> <a id="branchesactivesourcecoreTTAudioObjectcpp"></a> <div class="modfile"><h4>Modified: branches/active/source/core/TTAudioObject.cpp (424 => 425)</h4> <pre class="diff"><span> <span class="info">--- branches/active/source/core/TTAudioObject.cpp 2008-05-17 23:19:37 UTC (rev 424) +++ branches/active/source/core/TTAudioObject.cpp 2008-05-17 23:21:48 UTC (rev 425) </span><span class="lines">@@ -25,6 +25,7 @@ </span><span class="cx"> setAttributeValue(TT("maxNumChannels"), newMaxNumChannels); </span><span class="cx"> setAttributeValue(TT("sr"), globalSr); </span><span class="cx"> setProcess(&TTAudioObject::bypassProcess); </span><ins>+ setProcessWithSidechain(&TTAudioObject::bypassWithSidechainProcess); </ins><span class="cx"> setAttributeValue(TT("bypass"), *kTTBoolNo); </span><span class="cx"> setAttributeValue(TT("processInPlace"), *kTTBoolNo); </span><span class="cx"> } </span><span class="lines">@@ -73,6 +74,33 @@ </span><span class="cx"> } </span><span class="cx"> </span><span class="cx"> </span><ins>+TTErr TTAudioObject::bypassWithSidechainProcess(TTAudioSignal& in1, TTAudioSignal& in2, TTAudioSignal& out1, TTAudioSignal& out2) +{ + TTUInt16 vs; + TTSampleValue *inSample, + *outSample; + TTUInt8 numChannelsMain = TTAudioSignal::getMinChannelCount(in1, out1); + TTUInt8 numChannelsSidechain = TTAudioSignal::getMinChannelCount(in2, out2); + TTUInt8 channel; + + for(channel=0; channel<numChannelsMain; channel++){ + inSample = in1.sampleVectors[channel]; + outSample = out1.sampleVectors[channel]; + vs = in1.getVectorSize(); + while(vs--) + *outSample++ = *inSample++; + } + for(channel=0; channel<numChannelsSidechain; channel++){ + inSample = in2.sampleVectors[channel]; + outSample = out2.sampleVectors[channel]; + vs = in2.getVectorSize(); + while(vs--) + *outSample++ = *inSample++; + } + return kTTErrNone; +} + + </ins><span class="cx"> TTErr TTAudioObject::setProcess(TTProcessMethod newProcessMethod) </span><span class="cx"> { </span><span class="cx"> processMethod = newProcessMethod; </span><span class="lines">@@ -82,13 +110,26 @@ </span><span class="cx"> } </span><span class="cx"> </span><span class="cx"> </span><ins>+TTErr TTAudioObject::setProcessWithSidechain(TTProcessWithSidechainsMethod newProcessMethod) +{ + processWithSidechainMethod = newProcessMethod; + if(!attrBypass) + currentProcessWithSidechainMethod = processWithSidechainMethod; + return kTTErrNone; +} + + </ins><span class="cx"> TTErr TTAudioObject::setBypass(const TTAttribute&, const TTValue& value) </span><span class="cx"> { </span><span class="cx"> attrBypass = value; </span><del>- if(attrBypass) </del><ins>+ if(attrBypass){ </ins><span class="cx"> currentProcessMethod = &TTAudioObject::bypassProcess; </span><del>- else </del><ins>+ currentProcessWithSidechainMethod = &TTAudioObject::bypassWithSidechainProcess; + } + else{ </ins><span class="cx"> currentProcessMethod = processMethod; </span><ins>+ currentProcessWithSidechainMethod = processWithSidechainMethod; + } </ins><span class="cx"> return kTTErrNone; </span><span class="cx"> } </span><span class="cx"> </span><span class="lines">@@ -105,6 +146,18 @@ </span><span class="cx"> } </span><span class="cx"> </span><span class="cx"> </span><ins>+TTErr TTAudioObject::process(TTAudioSignal& in1, TTAudioSignal& in2, TTAudioSignal& out1, TTAudioSignal& out2) +{ + return (this->*currentProcessWithSidechainMethod)(in1, in2, out1, out2); +} + + +TTErr TTAudioObject::process(TTAudioSignal& in1, TTAudioSignal& in2, TTAudioSignal& out) +{ + return (this->*currentProcessWithSidechainMethod)(in1, in2, out, out); +} + + </ins><span class="cx"> #if 0 </span><span class="cx"> #pragma mark - </span><span class="cx"> #pragma mark Utilities </span></span></pre> </div> </div> </body> </html> |