Пример #1
0
void Synth::setHoldPedal(int value) {
    if (value < 64) {
        holdPedal = false;
        allNoteOff();
    } else {
        holdPedal = true;
    }
}
Пример #2
0
void pdsp::ScoreSection::processSection(const double &startPlayHead, 
                                const double &endPlayHead, 
                                const double &playHeadDifference, 
                                const double &maxBars,
                                const double &barsPerSample, 
                                const int &bufferSize) noexcept {
    
        if( scheduledTime >= maxBars+playHeadDifference ){ scheduledTime -= maxBars; } //wraps scheduled time around
        
        
        // if we have launched a cell schedules the triggering
        if(launchingCell){
            
            if(quantizedLaunch && startPlayHead!=0.0){
                double timeToQuantize = startPlayHead + launchQuantization;
                int rounded = static_cast<int> ( timeToQuantize / launchQuantization ); 
                launchSchedule = static_cast<double>(rounded) * launchQuantization ;
                launchedPattern2 = launchedPattern;
            }else{
                launchSchedule = std::numeric_limits<double>::infinity();
                scheduledTime = startPlayHead;
                scheduledPattern = launchedPattern;
            }
            launchingCell = false;
            run = true;
        }
        
        // activate a scheduled launch when it's time
        if( launchSchedule <= scheduledTime ){
            scheduledTime = launchSchedule;
            scheduledPattern = launchedPattern2;
            if(patterns[scheduledPattern].sequence!=nullptr && scheduledPattern!=-1) {
                patterns[scheduledPattern].sequence->resetCount();
            }
            launchSchedule = std::numeric_limits<double>::infinity();
        }


        if( run && ((int)patterns.size())>0 ){
            clearBuffers();
            double oneSlashBarsPerSample = 1.0 / barsPerSample;

            if(scheduledTime >= endPlayHead){   //more likely
                if(patternIndex!=-1 && patterns[patternIndex].sequence!=nullptr) playScore(playHeadDifference, 0.0, oneSlashBarsPerSample);
                
            }else if(scheduledTime == startPlayHead){ 
                
                onSchedule();
                if(clearOnChangeFlag) allNoteOff(0.0, oneSlashBarsPerSample); 
                if(patternIndex!=-1 && patterns[patternIndex].sequence!=nullptr) playScore(playHeadDifference, 0.0, oneSlashBarsPerSample);

            }else if(scheduledTime > startPlayHead && scheduledTime < endPlayHead ){
                double schedulePoint = scheduledTime - startPlayHead;

                if(patternIndex!=-1 && patterns[patternIndex].sequence!=nullptr) playScore(schedulePoint, 0.0, oneSlashBarsPerSample); //process old clip
                onSchedule();
                if(clearOnChangeFlag) allNoteOff(schedulePoint, oneSlashBarsPerSample);

                if(patternIndex!=-1 && patterns[patternIndex].sequence!=nullptr) playScore(playHeadDifference, schedulePoint, oneSlashBarsPerSample);//process new clip
            }
            
            processBuffersDestinations(bufferSize);
            
        }else if(clear==true){
            //empty message buffers and process destinations
            clearBuffers();
            processBuffersDestinations(bufferSize);
            clear = false;
        }

        atomic_meter_playhead.store(scorePlayHead);  
         
        if(atomic_meter_length > 0.0f){
            float percent = scorePlayHead / atomic_meter_length;
            atomic_meter_percent.store( percent );
            patterns[patternIndex].sequence->atomic_meter_percent.store( percent );
        } else{
            atomic_meter_percent.store(0.0f);
        }
    
}