Download::Download(UserConnection& conn, QueueItem& qi, const string& path, bool supportsTrees) throw() : Transfer(conn, path, qi.getTTH()), tempTarget(qi.getTempTarget()), file(0), treeValid(false) { conn.setDownload(this); if(qi.isSet(QueueItem::FLAG_PARTIAL_LIST)) { setType(TYPE_PARTIAL_LIST); } else if(qi.isSet(QueueItem::FLAG_USER_LIST)) { setType(TYPE_FULL_LIST); } if(qi.getSize() != -1) { if(HashManager::getInstance()->getTree(getTTH(), getTigerTree())) { setTreeValid(true); setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), conn.getChunkSize())); } else if(supportsTrees && !qi.getSource(conn.getUser())->isSet(QueueItem::Source::FLAG_NO_TREE) && qi.getSize() > HashManager::MIN_BLOCK_SIZE) { // Get the tree unless the file is small (for small files, we'd probably only get the root anyway) setType(TYPE_TREE); getTigerTree().setFileSize(qi.getSize()); setSegment(Segment(0, -1)); } else { // Use the root as tree to get some sort of validation at least... getTigerTree() = TigerTree(qi.getSize(), qi.getSize(), getTTH()); setTreeValid(true); setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), 0)); } } }
int main (void) { uint32_t analogValue; //Set segment A-G+DP pins as outputs GPIOSetDir( SEG_A_PORT, SEG_A_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_A_PORT, SEG_A_PIN, LED_OFF); GPIOSetDir( SEG_B_PORT, SEG_B_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_B_PORT, SEG_B_PIN, LED_OFF); GPIOSetDir( SEG_C_PORT, SEG_C_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_C_PORT, SEG_C_PIN, LED_OFF); GPIOSetDir( SEG_D_PORT, SEG_D_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_D_PORT, SEG_D_PIN, LED_OFF); GPIOSetDir( SEG_E_PORT, SEG_E_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_E_PORT, SEG_E_PIN, LED_OFF); GPIOSetDir( SEG_F_PORT, SEG_F_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_F_PORT, SEG_F_PIN, LED_OFF); GPIOSetDir( SEG_G_PORT, SEG_G_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_G_PORT, SEG_G_PIN, LED_OFF); GPIOSetDir( SEG_DP_PORT, SEG_DP_PIN, GPIO_OUTPUT); GPIOSetValue( SEG_DP_PORT, SEG_DP_PIN, LED_OFF); GPIOSetDir( DIG1_PORT, DIG1_PIN, GPIO_OUTPUT); GPIOSetValue( DIG1_PORT, DIG1_PIN, 1); GPIOSetDir( DIG2_PORT, DIG2_PIN, GPIO_OUTPUT); GPIOSetValue( DIG2_PORT, DIG2_PIN, 1); //Set SW2/SW3 pins as inputs GPIOSetDir( SW2_PORT, SW2_PIN, GPIO_INPUT); GPIOSetDir( SW3_PORT, SW3_PIN, GPIO_INPUT); //Extra, turn buzzer off GPIOSetDir( BUZZ_PORT, BUZZ_PIN, GPIO_OUTPUT); GPIOSetValue( BUZZ_PORT, BUZZ_PIN, BUZZ_OFF); //Initialize ADC peripheral and pin-mixing ADCInit(4500000); //4.5MHz ADC clock //get initial value analogValue = getADC(AIN0); //AIN0 = trimming pot for intensity while(1) { uint8_t outputValue; outputValue = convert00_99(getADC(AIN0)); GPIOSetValue( DIG1_PORT, DIG1_PIN, 1); GPIOSetValue( DIG2_PORT, DIG2_PIN, 0); setSegment(outputValue / 10); delayMS(10); GPIOSetValue( DIG2_PORT, DIG2_PIN, 1); GPIOSetValue( DIG1_PORT, DIG1_PIN, 0); setSegment(outputValue % 10); delayMS(10); } return 0; }
void ShutterFunctionDialog::slotNodesUpdated() { qDebug() << "slotNodesUpdated();"; if (m_segment+1 >= m_project->nodes()->size() && m_project->nodes()->size() >= 2) { setSegment(m_project->nodes()->size()-2); } else { setSegment(m_segment); } }
//--------------------------------------------------------------------- void kuNavigator::setDuration( float duration ) { if ( duration != duration_ ) { duration_ = duration; //setSegment( 0, duration ); setSegment( duration * 0.25, duration * 0.5 ); } }
void FrameSequence::openFrameSequence() { if (!_resFork->hasResFork()) return; Common::SeekableReadStream *res = _resFork->getResource(MKTAG('P', 'F', 'r', 'm'), 0x80); if (!res) return; uint32 scale = res->readUint32BE(); _bounds.top = res->readUint16BE(); _bounds.left = res->readUint16BE(); _bounds.bottom = res->readUint16BE(); _bounds.right = res->readUint16BE(); _numFrames = res->readUint16BE(); _duration = 0; _frameTimes.clear(); for (uint32 i = 0; i < _numFrames; i++) { TimeValue time = res->readUint32BE(); _frameTimes.push_back(_duration); _duration += time; } setScale(scale); setSegment(0, _duration); setTime(0); _currentFrameNum = 0; newFrame(_currentFrameNum); triggerRedraw(); delete res; }
void LedCircular::refreshFlash(unsigned char tick_inc) { unsigned char j; bool state; unsigned char onticks = 0; unsigned char offticks = 0; for(j=0;j<16;++j) { if(flashCnt_[j]>0) { flashTick_[j] += tick_inc; state = getSegment(j); onticks = getFlashOnticks(j); offticks = getFlashOffTicks(j); if((state==true && flashTick_[j]>=onticks) || (state==false && flashTick_[j]>=offticks)) { if(state==true) { flashTick_[j] -= onticks; } else { flashTick_[j] -= offticks; } setSegment(j,!state); if(flashCnt_[j]<255) { flashCnt_[j]--; } } } } }
ShuttleWeapon::ShuttleWeapon() : IdlerAnimation(kNoDisplayElement) { setScale(kShuttleWeaponScale); _weaponDuration = kShuttleWeaponScale * 2; setSegment(0, _weaponDuration); setBounds(kShuttleWindowLeft, kShuttleWindowTop, kShuttleWindowLeft + kShuttleWindowWidth, kShuttleWindowTop + kShuttleWindowHeight); setDisplayOrder(kShuttleWeaponFrontOrder); }
void LedCircular::flash(unsigned char segment, unsigned char flashes, unsigned char onTicks, unsigned char offTicks, bool startOn) { flashCnt_[segment] = flashes; flashTick_[segment] = 0; setFlashOnTicks(segment,onTicks); setFlashOffTicks(segment,offTicks); setSegment(segment,startOn); }
//--------------------------------------------------------------------- //обработка событий мыши //type 0 - move, 1 - press, 2 - drag, 3 - release //mouseState - указатель, использует ли кто-то мышь void kuNavigator::mouse( int x, int y, int button, void *&mouseState, int type ) { bool mouseCaptured = ( mouseState != 0 ); bool captured = mouseCaptured && (mouseState == this); if ( mouseCaptured && !captured ) { return; } if ( type == 0 ) { //move return; } float time0 = time0Pix(); float time1 = time1Pix(); if ( type == 1 ) { //press if ( ofInRange( x, time0 - 5, time1 + 5 ) && ofInRange( y, y_, y_+h_+8 ) ) { dragLeft = ( (time0 + 5 < time1 && x < time0 + 5 ) || (time0 + 5 >= time1 && x < time0 ) ); dragRight = ( (time1 - 5 > time0 && x > time1 - 5 ) || (time1 - 5 <= time0 && x > time1 ) ); if ( !dragLeft && !dragRight ) { //если очень узкая - тащим оба конца dragLeft = dragRight = true; } dragLeftDelta = ( time0 - x ); dragRightDelta = ( time1 - x ); state = 1; mouseState = this; } return; } if ( type == 2 ) { //drag if ( captured ) { float newtime0 = ( dragLeft ) ? ( pixToTime(dragLeftDelta + x)) : time0_; float newtime1 = ( dragRight ) ? ( pixToTime(dragRightDelta + x)) : time1_; if ( dragLeft && newtime0 > newtime1 ) newtime0 = newtime1; newtime1 = max( newtime0, newtime1 ); float len = newtime1 - newtime0; if ( !ofInRange( newtime0, 0, duration_ ) ) { newtime0 = ofClamp( newtime0, 0, duration_ ); if ( dragRight ) newtime1 = newtime0 + len; } if ( !ofInRange( newtime1, 0, duration_ ) ) { newtime1 = ofClamp( newtime1, 0, duration_ ); if ( dragLeft ) newtime0 = newtime1 - len; } setSegment( newtime0, newtime1 ); } return; } if ( type == 3 ) { //release if ( captured ) { mouseState = 0; } state = 0; return; } }
Download::Download(UserConnection& conn, QueueItem& qi, const string& path, bool supportsTrees) noexcept : Transfer(conn, path, qi.getTTH()), tempTarget(qi.getTempTarget()), file(0), treeValid(false) { conn.setDownload(this); QueueItem::SourceConstIter source = qi.getSource(getUser()); if(qi.isSet(QueueItem::FLAG_PARTIAL_LIST)) { setType(TYPE_PARTIAL_LIST); } else if(qi.isSet(QueueItem::FLAG_USER_LIST)) { setType(TYPE_FULL_LIST); } if(getType() == TYPE_FILE && qi.getSize() != -1) { if(HashManager::getInstance()->getTree(getTTH(), getTigerTree())) { setTreeValid(true); setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), conn.getChunkSize(),conn.getSpeed(), source->getPartialSource())); } else if(supportsTrees && conn.isSet(UserConnection::FLAG_SUPPORTS_TTHL) && !qi.getSource(conn.getUser())->isSet(QueueItem::Source::FLAG_NO_TREE) && qi.getSize() > HashManager::MIN_BLOCK_SIZE) { // Get the tree unless the file is small (for small files, we'd probably only get the root anyway) setType(TYPE_TREE); getTigerTree().setFileSize(qi.getSize()); setSegment(Segment(0, -1)); } else { // Use the root as tree to get some sort of validation at least... getTigerTree() = TigerTree(qi.getSize(), qi.getSize(), getTTH()); setTreeValid(true); setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), 0, 0, source->getPartialSource())); } if(getSegment().getOverlapped()) { setFlag(FLAG_OVERLAP); // set overlapped flag to original segment for(DownloadList::const_iterator i = qi.getDownloads().begin(); i != qi.getDownloads().end(); ++i) { if((*i)->getSegment().contains(getSegment())) { (*i)->setOverlapped(true); break; } } } } }
void Blinker::startBlinking(Sprite *sprite, int32 frame1, int32 frame2, uint32 numBlinks, TimeValue blinkDuration, TimeScale blinkScale) { stopBlinking(); _sprite = sprite; _frame1 = frame1; _frame2 = frame2; _blinkDuration = blinkDuration; setScale(blinkScale); setSegment(0, blinkDuration * numBlinks * 2, blinkScale); setTime(0); start(); }
void ControlRuler::setViewSegment(ViewSegment *viewSegment) { m_viewSegment = viewSegment; // If this ruler is connected to a NotationStaff then this will return a valid pointer // otherwise, it will return zero. This can be used to check whether we're connected // to a matrix or notation editor later m_notationStaff = dynamic_cast <NotationStaff *> (viewSegment); setSegment(&m_viewSegment->getSegment()); }
void ShutterFunctionDialog::loadProject(Project_sV *project) { qDebug() << "loadProject();"; m_project = project; ui->cbFunction->blockSignals(true); ui->cbFunction->clear(); ui->cbFunction->addItem(emptyFunction); for (int i = 0; i < project->shutterFunctions()->size(); i++) { ui->cbFunction->addItem(m_project->shutterFunctions()->at(i)->id()); } ui->cbFunction->blockSignals(false); setSegment(0); }
void Upload::resume(int64_t aStart, int64_t aSize) noexcept { setSegment(Segment(aStart, aSize)); setFlag(Upload::FLAG_RESUMED); delayTime = 0; auto s = stream.get()->releaseRootStream(); s->setPos(aStart); stream.reset(s); resetPos(); if((aStart + aSize) < fileSize) { stream.reset(new LimitedInputStream<true>(stream.release(), aSize)); } }
/* * Class: android_pplive_media_subtitle_SimpleSubTitleParser * Method: native_next * Signature: (Landroid/pplive/media/subtitle/SubTitleSegment;)Z */ JNIEXPORT jboolean JNICALL Java_android_pplive_media_subtitle_SimpleSubTitleParser_native_1next(JNIEnv *env, jobject thiz, jobject segment) { LOGD("native_next"); ISubtitles* parser = getSubTitleParser(env, thiz); if (NULL == parser) { JNU_ThrowByName(env, "java/lang/IllegalStateException", "Subtitle parser not found"); return false; } STSSegment* src = NULL; if (parser->getNextSubtitleSegment(&src)) { return setSegment(env, src, segment); } return false; }
void ControlRulerWidget::setSegments(RosegardenDocument *document, std::vector<Segment *> segments) { m_document = document; // m_segments = segments; // connect(m_document, SIGNAL(pointerPositionChanged(timeT)), // this, SLOT(slotPointerPositionChanged(timeT))); Composition &comp = document->getComposition(); Track *track = comp.getTrackById(segments[0]->getTrack()); Instrument *instr = document->getStudio(). getInstrumentById(track->getInstrument()); if (instr) { Device *device = instr->getDevice(); // Cast to a Controllable if possible, otherwise leave c NULL. Controllable *c = dynamic_cast<MidiDevice *>(device); if (!c) { c = dynamic_cast<SoftSynthDevice *>(device); } if (c) { m_controlList = &(c->getControlParameters()); } } SegmentSelection selection; selection.insert(segments.begin(), segments.end()); delete m_scale; setRulerScale(new SegmentsRulerScale(&m_document->getComposition(), selection, 0, Note(Note::Shortest).getDuration() / 2.0)); // This is single segment code setSegment(segments[0]); }
void AutoDragger::autoDrag(DisplayElement *dragElement, const Common::Point &startPoint, const Common::Point &stopPoint, TimeValue dragTime, TimeScale dragScale) { _draggingElement = dragElement; if (_draggingElement) { _startLocation = startPoint; _stopLocation = stopPoint; _lastTime = 0; _done = false; _draggingElement->moveElementTo(_startLocation.x, _startLocation.y); setScale(dragScale); setSegment(0, dragTime); setTime(0); scheduleCallBack(kTriggerAtStop, 0, 0); startIdling(); start(); } else { stopDragging(); } }
EnergyMonitor::EnergyMonitor() : IdlerAnimation(kEnergyBarID), _energyLight(kWarningLightID) { PegasusEngine *vm = (PegasusEngine *)g_engine; _stage = kStageNoStage; _calibrating = false; _dontFlash = false; setBounds(338, 48, 434, 54); setDisplayOrder(kEnergyBarOrder); startDisplaying(); SpriteFrame *frame = new SpriteFrame(); frame->initFromPICTResource(vm->_resFork, kLightOffID); _energyLight.addFrame(frame, 0, 0); frame = new SpriteFrame(); frame->initFromPICTResource(vm->_resFork, kLightYellowID); _energyLight.addFrame(frame, 0, 0); frame = new SpriteFrame(); frame->initFromPICTResource(vm->_resFork, kLightOrangeID); _energyLight.addFrame(frame, 0, 0); frame = new SpriteFrame(); frame->initFromPICTResource(vm->_resFork, kLightRedID); _energyLight.addFrame(frame, 0, 0); _energyLight.setBounds(540, 35, 600, 59); _energyLight.setDisplayOrder(kEnergyLightOrder); _energyLight.startDisplaying(); setScale(1); setSegment(0, kMaxJMPEnergy); setEnergyValue(kCasualEnergy); g_energyMonitor = this; }
BEGIN_UGEN_NAMESPACE #include "ugen_EnvGen.h" #include "../basics/ugen_InlineUnaryOps.h" #include "../basics/ugen_InlineBinaryOps.h" #include "../core/ugen_Constants.h" EnvGenUGenInternal::EnvGenUGenInternal(Env const& env, const UGen::DoneAction doneAction) throw() : ReleasableUGenInternal(0), env_(env), doneAction_(doneAction), currentValue(0.0), stepsUntilTarget(0), shouldDeleteValue(doneAction_ == UGen::DeleteWhenDone) { currentValue = env_.getLevels().getSampleUnchecked(0); setSegment(0, UGen::getSampleRate()); initValue(currentValue); }
void ShutterFunctionDialog::slotNextSegment() { qDebug() << "slotNextSegment();"; setSegment(m_segment+1); }
void ShutterFunctionDialog::slotPrevSegment() { qDebug() << "slotPrevSegment();"; setSegment(m_segment-1); }
Segment& Segment::operator=(const Segment& rhs) { setSegment(rhs.start.x, rhs.start.y, rhs.end.x, rhs.end.y); return *this; }
void LedCircular::flashStop(unsigned char segment) { flashCnt_[segment] = 0; setSegment(segment,false); }
EnvGenUGenInternalK::EnvGenUGenInternalK (Env const& env, const UGen::DoneAction doneAction) throw() : EnvGenUGenInternal(env, doneAction) { rate = ControlRate; setSegment(0, UGen::getSampleRate() / UGen::getControlRateBlockSize()); }
void ControllerEventsRuler::setViewSegment(ViewSegment *segment) { RG_DEBUG << "ControllerEventsRuler::setSegment(" << segment << ")" << endl; setSegment(&segment->getSegment()); }
void EnvGenUGenInternalK::processBlock(bool& shouldDelete, const unsigned int blockID, const int channel) throw() { const int krBlockSize = UGen::getControlRateBlockSize(); unsigned int blockPosition = blockID % krBlockSize; int numSamplesToProcess = uGenOutput.getBlockSize(); float* outputSamples = uGenOutput.getSampleData(); int numKrSamples = blockPosition % krBlockSize; double prevValue = currentValue; if(isDone()) goto exit; while(numSamplesToProcess > 0) { prevValue = currentValue; if(numKrSamples == 0) { if(isStealing() == false && shouldSteal() == true) { setIsStealing(); const int numLevels = env_.getLevels().size(); float stealValue = (float)currentValue; float targetValue = env_.getLevels().getSampleUnchecked(numLevels-1); float inc = (targetValue - stealValue) / (float)numSamplesToProcess; while(numSamplesToProcess) { *outputSamples++ = stealValue; stealValue += inc; --numSamplesToProcess; } shouldDelete = shouldDelete ? true : shouldDeleteValue; currentValue = targetValue; currentCurve = EnvCurve(EnvCurve::Empty); setIsDone(); return; } else { if(isReleasing() == false && shouldRelease() == true) { int releaseNode = env_.getReleaseNode(); // if(releaseNode < 0) // { // releaseNode = env_.getTimes().size() - 1; // } // // setSegment(releaseNode, UGen::getSampleRate() / krBlockSize); if(releaseNode >= 0) // try this.. { setSegment(releaseNode, UGen::getSampleRate() / krBlockSize); } } --stepsUntilTarget; double y0; switch(currentCurve.getType()) { case EnvCurve::Numerical: currentValue = a2 - b1; b1 *= grow; break; case EnvCurve::Linear: currentValue += grow; break; case EnvCurve::Exponential: currentValue *= grow; break; case EnvCurve::Sine: y0 = b1 * y1 - y2; currentValue = a2 - y0; y2 = y1; y1 = y0; break; case EnvCurve::Welch: y0 = b1 * y1 - y2; currentValue = a2 + y0; y2 = y1; y1 = y0; break; case EnvCurve::Empty: case EnvCurve::Step: default: ; } if(stepsUntilTarget <= 0) { if(setSegment(currentSegment + 1, UGen::getSampleRate() / krBlockSize) == true) { shouldDelete = shouldDelete ? true : shouldDeleteValue; const int numLevels = env_.getLevels().size(); currentValue = env_.getLevels().getSampleUnchecked(numLevels-1); currentCurve = EnvCurve(EnvCurve::Empty); goto exit; } } } } numKrSamples = krBlockSize - numKrSamples; blockPosition += numKrSamples; if(prevValue == currentValue) { while(numSamplesToProcess && numKrSamples) { *outputSamples++ = (float)prevValue; --numSamplesToProcess; --numKrSamples; } } else { double valueSlope = (currentValue - prevValue) / (double)UGen::getControlRateBlockSize(); while(numSamplesToProcess && numKrSamples) { *outputSamples++ = (float)prevValue; prevValue += valueSlope; --numSamplesToProcess; --numKrSamples; } } } return; exit: if(prevValue == currentValue) { while(numSamplesToProcess > 0) { *outputSamples++ = (float)prevValue; --numSamplesToProcess; } } else { double valueSlope = (currentValue - prevValue) / (double)numSamplesToProcess; while(numSamplesToProcess > 0) { *outputSamples++ = (float)prevValue; prevValue += valueSlope; --numSamplesToProcess; } } setIsDone(); }
Download::Download(UserConnection& conn, QueueItem& qi) noexcept : Transfer(conn, qi.getTarget(), qi.getTTH()), tempTarget(qi.getTempTarget()) { conn.setDownload(this); QueueItem::SourceConstIter source = qi.getSource(getUser()); if(qi.isSet(QueueItem::FLAG_PARTIAL_LIST)) { setType(TYPE_PARTIAL_LIST); } else if(qi.isSet(QueueItem::FLAG_USER_LIST)) { setType(TYPE_FULL_LIST); } if(source->isSet(QueueItem::Source::FLAG_PARTIAL)) setFlag(FLAG_PARTIAL); if(qi.isSet(QueueItem::FLAG_CLIENT_VIEW)) setFlag(FLAG_VIEW); if(qi.isSet(QueueItem::FLAG_MATCH_QUEUE)) setFlag(FLAG_QUEUE); if(qi.isSet(QueueItem::FLAG_VIEW_NFO)) setFlag(FLAG_NFO); if(qi.isSet(QueueItem::FLAG_RECURSIVE_LIST)) setFlag(FLAG_RECURSIVE); if(qi.isSet(QueueItem::FLAG_TTHLIST_BUNDLE)) setFlag(FLAG_TTHLIST_BUNDLE); if (qi.getPriority() == QueueItemBase::HIGHEST) setFlag(FLAG_HIGHEST_PRIO); if (qi.getBundle()) { dcassert(!qi.isSet(QueueItem::FLAG_USER_LIST)); dcassert(!qi.isSet(QueueItem::FLAG_TEXT)); setBundle(qi.getBundle()); } if(getType() == TYPE_FILE && qi.getSize() != -1) { if(HashManager::getInstance()->getTree(getTTH(), getTigerTree())) { setTreeValid(true); setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), conn.getChunkSize(), conn.getSpeed(), source->getPartialSource(), true)); qi.setBlockSize(getTigerTree().getBlockSize()); } else if(conn.isSet(UserConnection::FLAG_SUPPORTS_TTHL) && !source->isSet(QueueItem::Source::FLAG_NO_TREE) && qi.getSize() > HashManager::MIN_BLOCK_SIZE) { // Get the tree unless the file is small (for small files, we'd probably only get the root anyway) setType(TYPE_TREE); getTigerTree().setFileSize(qi.getSize()); setSegment(Segment(0, -1)); } else { // Use the root as tree to get some sort of validation at least... getTigerTree() = TigerTree(qi.getSize(), qi.getSize(), getTTH()); setTreeValid(true); setSegment(qi.getNextSegment(getTigerTree().getBlockSize(), 0, 0, source->getPartialSource(), true)); } if ((getStartPos() + getSegmentSize()) != qi.getSize() || (conn.getDownload() && conn.getDownload()->isSet(FLAG_CHUNKED))) { setFlag(FLAG_CHUNKED); } if(getSegment().getOverlapped()) { setFlag(FLAG_OVERLAP); // set overlapped flag to original segment for(auto d: qi.getDownloads()) { if(d->getSegment().contains(getSegment())) { d->setOverlapped(true); break; } } } } }
Segment::Segment(const Segment& copy) { setSegment(copy.start.x, copy.start.y, copy.end.x, copy.end.y); }
void EnvGenUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int channel) throw() { int numSamplesToProcess = uGenOutput.getBlockSize(); float* outputSamples = uGenOutput.getSampleData(); if(isStealing() == false && shouldSteal() == true) { setIsStealing(); const int numLevels = env_.getLevels().size(); float stealValue = (float)currentValue; float targetValue = env_.getLevels().getSampleUnchecked(numLevels-1); float inc = (targetValue - stealValue) / (float)numSamplesToProcess; while(numSamplesToProcess) { *outputSamples++ = stealValue; stealValue += inc; --numSamplesToProcess; } shouldDelete = shouldDelete ? true : shouldDeleteValue; currentValue = targetValue; currentCurve = EnvCurve(EnvCurve::Empty); setIsDone(); } else { if(isReleasing() == false && shouldRelease() == true) { int releaseNode = env_.getReleaseNode(); if(releaseNode >= 0) // try this, - don't release if releaseNode is -1 { setSegment(releaseNode, UGen::getSampleRate()); } } while(numSamplesToProcess && isDone() == false) { int samplesThisTime = min(stepsUntilTarget, numSamplesToProcess); numSamplesToProcess -= samplesThisTime; stepsUntilTarget -= samplesThisTime; // select from different curves here..., use a different loop switch(currentCurve.getType()) { case EnvCurve::Numerical: while(samplesThisTime) { *outputSamples++ = (float)currentValue; b1 *= grow; currentValue = a2 - b1; --samplesThisTime; } break; case EnvCurve::Linear: while(samplesThisTime) { *outputSamples++ = (float)currentValue; currentValue += grow; --samplesThisTime; } break; case EnvCurve::Exponential: while(samplesThisTime) { *outputSamples++ = (float)currentValue; currentValue *= grow; --samplesThisTime; } break; case EnvCurve::Sine: while(samplesThisTime) { *outputSamples++ = (float)currentValue; double y0 = b1 * y1 - y2; currentValue = a2 - y0; y2 = y1; y1 = y0; --samplesThisTime; } break; case EnvCurve::Welch: while(samplesThisTime) { *outputSamples++ = (float)currentValue; double y0 = b1 * y1 - y2; currentValue = a2 + y0; y2 = y1; y1 = y0; --samplesThisTime; } break; case EnvCurve::Empty: case EnvCurve::Step: default: while(samplesThisTime) { *outputSamples++ = (float)currentValue; --samplesThisTime; } } if(stepsUntilTarget <= 0) { if(setSegment(currentSegment + 1, UGen::getSampleRate()) == true) { shouldDelete = shouldDelete ? true : shouldDeleteValue; const int numLevels = env_.getLevels().size(); currentValue = env_.getLevels().getSampleUnchecked(numLevels-1); currentCurve = EnvCurve(EnvCurve::Empty); goto exit; } } } } while(numSamplesToProcess--) { *outputSamples++ = (float)currentValue; } return; exit: while(numSamplesToProcess--) { *outputSamples++ = (float)currentValue; } setIsDone(); sendDoneInternal(); }
Segment::Segment() { setSegment(0.0, 0.0, 0.0, 0.0); }