[TTBlue-devel] [434] branches/active: TTPulseSub is now working (as proven by tap. pulsesub~)
Status: Alpha
Brought to you by:
tap
From: <ti...@gr...> - 2008-05-18 15:49:13
|
<!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>[434] branches/active: TTPulseSub is now working (as proven by tap. pulsesub~)</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>434</dd> <dt>Author</dt> <dd>tim</dd> <dt>Date</dt> <dd>2008-05-18 15:49:15 +0000 (Sun, 18 May 2008)</dd> </dl> <h3>Log Message</h3> <pre>TTPulseSub is now working (as proven by tap.pulsesub~)</pre> <h3>Modified Paths</h3> <ul> <li><a href="#branchesactiveincludesunitsTTPulseSubh">branches/active/includes/units/TTPulseSub.h</a></li> <li><a href="#branchesactivesourceunitsTTPulseSubcpp">branches/active/source/units/TTPulseSub.cpp</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="branchesactiveincludesunitsTTPulseSubh"></a> <div class="modfile"><h4>Modified: branches/active/includes/units/TTPulseSub.h (433 => 434)</h4> <pre class="diff"><span> <span class="info">--- branches/active/includes/units/TTPulseSub.h 2008-05-18 15:47:37 UTC (rev 433) +++ branches/active/includes/units/TTPulseSub.h 2008-05-18 15:49:15 UTC (rev 434) </span><span class="lines">@@ -25,6 +25,8 @@ </span><span class="cx"> TTFloat64 attrRelease; </span><span class="cx"> TTBoolean attrTrigger; </span><span class="cx"> TTSymbol& attrMode; </span><ins>+ TTFloat64 attrFrequency; + TTFloat64 attrLength; </ins><span class="cx"> </span><span class="cx"> TTOperator* offset; </span><span class="cx"> TTPhasor* phasor; </span><span class="lines">@@ -43,6 +45,9 @@ </span><span class="cx"> TTErr setSustain(const TTAttribute&, const TTValue& newValue); </span><span class="cx"> TTErr setRelease(const TTAttribute&, const TTValue& newValue); </span><span class="cx"> TTErr setMode(const TTAttribute&, const TTValue& newValue); </span><ins>+ + TTErr TTPulseSub::setFrequency(const TTAttribute&, const TTValue& newValue); + TTErr TTPulseSub::setLength(const TTAttribute&, const TTValue& newValue); </ins><span class="cx"> </span><span class="cx"> TTErr processAudio(TTAudioSignal& in, TTAudioSignal& out); </span><span class="cx"> </span></span></pre></div> <a id="branchesactivesourceunitsTTPulseSubcpp"></a> <div class="modfile"><h4>Modified: branches/active/source/units/TTPulseSub.cpp (433 => 434)</h4> <pre class="diff"><span> <span class="info">--- branches/active/source/units/TTPulseSub.cpp 2008-05-18 15:47:37 UTC (rev 433) +++ branches/active/source/units/TTPulseSub.cpp 2008-05-18 15:49:15 UTC (rev 434) </span><span class="lines">@@ -11,12 +11,14 @@ </span><span class="cx"> TTPulseSub::TTPulseSub(TTUInt8 newMaxNumChannels) </span><span class="cx"> : TTAudioObject("audio.pulsesub", newMaxNumChannels), attrMode(TT("linear")) </span><span class="cx"> { </span><del>- registerAttribute(TT("attack"), kTypeFloat64, &attrAttack, (TTSetterMethod)&TTPulseSub::setAttack); - registerAttribute(TT("decay"), kTypeFloat64, &attrDecay, (TTSetterMethod)&TTPulseSub::setDecay); - registerAttribute(TT("release"), kTypeFloat64, &attrRelease, (TTSetterMethod)&TTPulseSub::setRelease); - registerAttribute(TT("sustain"), kTypeFloat64, &attrSustain, (TTSetterMethod)&TTPulseSub::setSustain); - registerAttribute(TT("trigger"), kTypeBoolean, &attrTrigger, (TTSetterMethod)&TTPulseSub::setTrigger); - registerAttribute(TT("mode"), kTypeSymbol, &attrMode, (TTSetterMethod)&TTPulseSub::setTrigger); </del><ins>+ registerAttribute(TT("attack"), kTypeFloat64, &attrAttack, (TTSetterMethod)&TTPulseSub::setAttack); + registerAttribute(TT("decay"), kTypeFloat64, &attrDecay, (TTSetterMethod)&TTPulseSub::setDecay); + registerAttribute(TT("release"), kTypeFloat64, &attrRelease, (TTSetterMethod)&TTPulseSub::setRelease); + registerAttribute(TT("sustain"), kTypeFloat64, &attrSustain, (TTSetterMethod)&TTPulseSub::setSustain); + registerAttribute(TT("trigger"), kTypeBoolean, &attrTrigger, (TTSetterMethod)&TTPulseSub::setTrigger); + registerAttribute(TT("mode"), kTypeSymbol, &attrMode, (TTSetterMethod)&TTPulseSub::setTrigger); + registerAttribute(TT("frequency"), kTypeFloat64, &attrFrequency, (TTSetterMethod)&TTPulseSub::setFrequency); + registerAttribute(TT("length"), kTypeFloat64, &attrLength, (TTSetterMethod)&TTPulseSub::setLength); </ins><span class="cx"> </span><span class="cx"> // register for notifications </span><span class="cx"> registerMessage(TT("updateMaxNumChannels"), (TTMethod)&TTPulseSub::updateMaxNumChannels); </span><span class="lines">@@ -28,14 +30,19 @@ </span><span class="cx"> offset->setAttributeValue(TT("operator"), TT("+")); </span><span class="cx"> scaler = new TTOperator(newMaxNumChannels); </span><span class="cx"> scaler->setAttributeValue(TT("operator"), TT("*")); </span><ins>+ </ins><span class="cx"> sig1 = new TTAudioSignal(1); </span><ins>+ sig1->setNumChannels(1); </ins><span class="cx"> sig2 = new TTAudioSignal(1); </span><ins>+ sig2->setNumChannels(1); </ins><span class="cx"> </span><span class="cx"> setAttributeValue(TT("attack"), 50.); </span><span class="cx"> setAttributeValue(TT("decay"), 100.); </span><span class="cx"> setAttributeValue(TT("sustain_db"), -6.); </span><span class="cx"> setAttributeValue(TT("release"), 500.); </span><span class="cx"> setAttributeValue(TT("mode"), TT("linear")); // <-- sets the process method </span><ins>+ + setProcess((TTProcessMethod)&TTPulseSub::processAudio); </ins><span class="cx"> } </span><span class="cx"> </span><span class="cx"> TTPulseSub::~TTPulseSub() </span><span class="lines">@@ -76,14 +83,14 @@ </span><span class="cx"> TTErr TTPulseSub::setDecay(const TTAttribute&, const TTValue& newValue) </span><span class="cx"> { </span><span class="cx"> attrDecay = newValue; </span><del>- return env_gen->setAttributeValue(TT("decay"), attrTrigger); </del><ins>+ return env_gen->setAttributeValue(TT("decay"), attrDecay); </ins><span class="cx"> } </span><span class="cx"> </span><span class="cx"> </span><span class="cx"> TTErr TTPulseSub::setSustain(const TTAttribute&, const TTValue& newValue) </span><span class="cx"> { </span><span class="cx"> attrSustain = newValue; </span><del>- return env_gen->setAttributeValue(TT("sustain"), newValue); </del><ins>+ return env_gen->setAttributeValue(TT("sustain_db"), newValue); </ins><span class="cx"> } </span><span class="cx"> </span><span class="cx"> TTErr TTPulseSub::setRelease(const TTAttribute&, const TTValue& newValue) </span><span class="lines">@@ -106,6 +113,19 @@ </span><span class="cx"> } </span><span class="cx"> </span><span class="cx"> </span><ins>+TTErr TTPulseSub::setFrequency(const TTAttribute&, const TTValue& newValue) +{ + attrFrequency = newValue; + return phasor->setAttributeValue(TT("frequency"), attrFrequency); +} + +TTErr TTPulseSub::setLength(const TTAttribute&, const TTValue& newValue) +{ + attrLength = newValue; + return offset->setAttributeValue(TT("operand"), attrLength - 0.5); +} + + </ins><span class="cx"> TTErr TTPulseSub::processAudio(TTAudioSignal& in, TTAudioSignal& out) </span><span class="cx"> { </span><span class="cx"> TTSampleValue* inSample; </span><span class="lines">@@ -115,8 +135,8 @@ </span><span class="cx"> inSample = in.sampleVectors[0]; </span><span class="cx"> outSample = out.sampleVectors[0]; </span><span class="cx"> </span><del>- sig1->setVectorSize(vs); - sig2->setVectorSize(vs); </del><ins>+ sig1->allocWithSize(vs); + sig2->allocWithSize(vs); </ins><span class="cx"> </span><span class="cx"> phasor->process(*sig1); // ramp wave, stored in a temporary vector </span><span class="cx"> offset->process(*sig1, *sig2); // offset the ramp wave, effectively altering the duty cycle </span></span></pre> </div> </div> </body> </html> |