Example #1
0
  void VoiceHandler::process() {
    global_router_.process();

    int polyphony = static_cast<int>(input(kPolyphony)->at(0));
    setPolyphony(utils::iclamp(polyphony, 1, polyphony));
    for (int i = 0; i < numOutputs(); ++i) {
      int buffer_size = voice_outputs_[i]->owner->getBufferSize();
      memset(output(i)->buffer, 0, buffer_size * sizeof(mopo_float));
    }

    std::list<Voice*>::iterator iter = active_voices_.begin();
    while (iter != active_voices_.end()) {
      Voice* voice = *iter;
      prepareVoiceTriggers(voice);
      processVoice(voice);

      // Remove voice if the right processor has a full silent buffer.
      if (voice_killer_ && voice->state().event != kVoiceOn &&
          utils::isSilent(voice_killer_->buffer, buffer_size_)) {
        free_voices_.push_back(voice);
        iter = active_voices_.erase(iter);
      }
      else
        iter++;
    }
  }
Example #2
0
 VoiceHandler::VoiceHandler(size_t polyphony) :
     ProcessorRouter(kNumInputs, 0), polyphony_(0), sustain_(false),
     legato_(false), voice_killer_(0), last_played_note_(-1.0) {
   setPolyphony(polyphony);
   voice_router_.router(this);
   global_router_.router(this);
 }
Example #3
0
  void VoiceHandler::process() {
    global_router_.process();

    size_t polyphony = static_cast<size_t>(inputs_[kPolyphony]->at(0));
    setPolyphony(CLAMP(polyphony, 1, polyphony));
    memset(outputs_[0]->buffer, 0, BUFFER_SIZE * sizeof(mopo_float));

    std::list<Voice*>::iterator iter = active_voices_.begin();
    while (iter != active_voices_.end()) {
      Voice* voice = *iter;
      prepareVoiceTriggers(voice);
      processVoice(voice);

      // Remove voice if the right processor has a full silent buffer.
      if (voice_killer_ &&
          utils::isSilent(voice_killer_->buffer, BUFFER_SIZE)) {
        free_voices_.push_back(voice);
        iter = active_voices_.erase(iter);
      }
      else
        iter++;
    }
  }
Example #4
0
 VoiceHandler::VoiceHandler(size_t polyphony) :
     Processor(kNumInputs, 1), polyphony_(0), sustain_(false),
     voice_output_(0), voice_killer_(0) {
   setPolyphony(polyphony);
 }
AudioFilePlayer::AudioFilePlayer(int samplerPadNumber, ModeSampler &ref, TimeSliceThread* audioTransportSourceThread_)
                                    :   padNumber(samplerPadNumber),
                                        modeSamplerRef(ref)
{
    audioTransportSourceThread = audioTransportSourceThread_;
    
    currentAudioFileSource = NULL;
	AudioFormatManager formatManager;
	formatManager.registerBasicFormats();
    
    //init all effects to be null
    gainAndPan = nullptr;
    lowPassFilter = nullptr;
    highPassFilter = nullptr;
    bandPassFilter = nullptr;
    reverb = nullptr;
    delay = nullptr;
    flanger = nullptr;
    tremolo = nullptr;
	distortion = nullptr;
	bitcrusher = nullptr;
    
    //set a default sample rate value here as if we load up a Sampler Pad wth reverb already applied
    //to it the application will crash otherwise, as the reverb object sample rate will attempt to be set before
    //prepareToPlay() is called that sets the correct sample rate.
    sampleRate_ = 44100;
    
    //grab the setting values (so that if this object is deleted and recreated, it will hold the previous settings)
    //do i need to enter shared memory here?
    
    gain = PAD_SETTINGS->getSamplerGain(); //should this be cubed?
    panLeft = PanControl::leftChanPan_(PAD_SETTINGS->getSamplerPan());
    panRight = PanControl::rightChanPan_(PAD_SETTINGS->getSamplerPan());
    triggerMode = PAD_SETTINGS->getSamplerTriggerMode();
    shouldLoop = PAD_SETTINGS->getSamplerShouldLoop();
    indestructible = PAD_SETTINGS->getSamplerIndestructible();
    shouldFinishLoop = PAD_SETTINGS->getSamplerShouldFinishLoop();
    sticky = PAD_SETTINGS->getSamplerSticky();
    currentPlayingState = currentPressureValue = 0;
    //set effect to default 0, and then call set effect to create the effect object
    //This alg. prevents any crashes caused within prepareToPlay when trying to
    //set the sampleRate, where the effect object must exist
    effect = 0;
    setEffect(PAD_SETTINGS->getSamplerEffect());
    quantizeMode = PAD_SETTINGS->getQuantizeMode();
    attackTime = PAD_SETTINGS->getSamplerAttackTime();
    releaseTime = PAD_SETTINGS->getSamplerReleaseTime();
    
    triggerModeData.playingStatus = 0;
    prevPadValue = pressureValue =  0;
    playingLastLoop = false;
    
    attackSamples = attackTime * sampleRate_;
    releaseSamples = releaseTime * sampleRate_;
    isInAttack = isInRelease = isInStartRamp = false;
    attackPosition = releasePosition = startRampPosition = 0;
    attRelGainL = attRelGainR = prevGainL = prevGainR = 0;
    velocityGain = 1.0;
    velocity = 127;
    
    currentFile = File::nonexistent;
    setPolyphony(PAD_SETTINGS->getSamplerPolyphony());
    setAudioFile(PAD_SETTINGS->getSamplerAudioFilePath());
    
    columnNumber = sequenceNumber = 0;
    
    nextFileSourceIndex = 0;
    hasAlertedGui = false;
    
    broadcaster.addActionListener(this);
}