bool LV2Effect::Process() { CopyInputTracks(); bool bGoodResult = true; TrackListIterator iter(mOutputTracks); int count = 0; Track *left = iter.First(); Track *right = NULL; while (left) { sampleCount lstart = 0, rstart = 0; sampleCount len; GetSamples((WaveTrack *)left, &lstart, &len); right = NULL; if (left->GetLinked() && mAudioInputs.GetCount() > 1) { right = iter.Next(); GetSamples((WaveTrack *)right, &rstart, &len); } if (mAudioInputs.GetCount() < 2 && right) { // If the effect is mono, apply to each channel separately bGoodResult = ProcessStereo(count, (WaveTrack *)left, NULL, lstart, 0, len) && ProcessStereo(count, (WaveTrack *)right, NULL, rstart, 0, len); } else { bGoodResult = ProcessStereo(count, (WaveTrack *)left, (WaveTrack *)right, lstart, rstart, len); } if (!bGoodResult) { break; } left = iter.Next(); count++; } ReplaceProcessedTracks(bGoodResult); return bGoodResult; }
void CKVerbDSP::Process(tfloat** ppfSamplesOut, const tfloat** ppfSamplesIn, tuint32 iNrOfSamples) { if (muiChannels == 1) { ProcessMono(ppfSamplesOut, ppfSamplesIn, iNrOfSamples); } else { ProcessStereo(ppfSamplesOut, ppfSamplesIn, iNrOfSamples); } }
bool EffectSoundTouch::Process() { // Assumes that mSoundTouch has already been initialized // by the subclass for subclass-specific parameters. //Iterate over each track TrackListIterator iter(mWaveTracks); WaveTrack* leftTrack = (WaveTrack*)(iter.First()); WaveTrack* rightTrack = NULL; mCurTrackNum = 0; m_maxNewLength = 0.0; while (leftTrack) { //Get start and end times from track double trackStart = leftTrack->GetStartTime(); double trackEnd = leftTrack->GetEndTime(); //Set the current bounds to whichever left marker is //greater and whichever right marker is less: mCurT0 = mT0 < trackStart? trackStart: mT0; mCurT1 = mT1 > trackEnd? trackEnd: mT1; // Process only if the right marker is to the right of the left marker if (mCurT1 > mCurT0) { //Transform the marker timepoints to samples longSampleCount start = leftTrack->TimeToLongSamples(mCurT0); longSampleCount end = leftTrack->TimeToLongSamples(mCurT1); rightTrack = NULL; if (leftTrack->GetLinked()) { rightTrack = (WaveTrack*)(iter.Next()); mSoundTouch->setChannels(2); if (!ProcessStereo(leftTrack, rightTrack, start, end)) return false; mCurTrackNum++; // Increment for rightTrack, too. } else { mSoundTouch->setChannels(1); //ProcessOne() (implemented below) processes a single track if (!ProcessOne(leftTrack, start, end)) return false; } } //Iterate to the next track leftTrack = (WaveTrack*)(iter.Next()); mCurTrackNum++; } delete mSoundTouch; mSoundTouch = NULL; mT1 = mT0 + m_maxNewLength; // Update selection. return true; }
bool LadspaEffect::Process() { this->CopyInputWaveTracks(); // Set up mOutputWaveTracks. bool bGoodResult = true; TrackListIterator iter(mOutputWaveTracks); int count = 0; Track *left = iter.First(); Track *right; while(left) { sampleCount lstart = 0, rstart = 0; sampleCount len; GetSamples((WaveTrack *)left, &lstart, &len); right = NULL; if (left->GetLinked() && inputs>1) { right = iter.Next(); GetSamples((WaveTrack *)right, &rstart, &len); } if (inputs < 2 && right) { // If the effect is mono, apply to each channel separately bGoodResult = ProcessStereo(count, (WaveTrack *)left, NULL, lstart, 0, len) && ProcessStereo(count, (WaveTrack *)right, NULL, rstart, 0, len); } else bGoodResult = ProcessStereo(count, (WaveTrack *)left, (WaveTrack *)right, lstart, rstart, len); if (!bGoodResult) break; left = iter.Next(); count++; } this->ReplaceProcessedWaveTracks(bGoodResult); return bGoodResult; }
bool LadspaEffect::Process() { TrackListIterator iter(mWaveTracks); int count = 0; Track *left = iter.First(); Track *right; while(left) { longSampleCount lstart, rstart; sampleCount len; GetSamples((WaveTrack *)left, &lstart, &len); right = NULL; if (left->GetLinked() && inputs>1) { right = iter.Next(); GetSamples((WaveTrack *)right, &rstart, &len); } bool success = false; if (inputs < 2 && right) { // If the effect is mono, apply to each channel separately success = ProcessStereo(count, (WaveTrack *)left, NULL, lstart, 0, len); if (success) success = ProcessStereo(count, (WaveTrack *)right, NULL, rstart, 0, len); } else success = ProcessStereo(count, (WaveTrack *)left, (WaveTrack *)right, lstart, rstart, len); if (!success) return false; left = iter.Next(); count++; } return true; }
void WiredLADSPAInstance::Process(float **input, float **output, long sample_length) { if (IsLoaded() == false || _InputAudioPluginsPorts.empty() || _OutputAudioPluginsPorts.empty() || (LADSPA_IS_INPLACE_BROKEN(_Properties) && *input == *output) || _IsPlaying == false || _Bypass == true) { memcpy(output[0], input[0], sample_length * sizeof(float)); memcpy(output[1], input[1], sample_length * sizeof(float)); } else { if (_InputAudioPluginsPorts.size() >= 2 && _OutputAudioPluginsPorts.size() >= 2) { //memcpy(output[0], input[0], sample_length * sizeof(float)); //memcpy(output[1], input[1], sample_length * sizeof(float)); ProcessStereo(input, output, sample_length); } else ProcessMono(input, output, sample_length); } }
bool VSTEffect::Process() { CopyInputTracks(); bool bGoodResult = true; mInBuffer = NULL; mOutBuffer = NULL; TrackListIterator iter(mOutputTracks); int count = 0; bool clear = false; WaveTrack *left = (WaveTrack *) iter.First(); while (left) { WaveTrack *right; sampleCount len; sampleCount lstart; sampleCount rstart; GetSamples(left, &lstart, &len); mChannels = 1; right = NULL; rstart = 0; if (left->GetLinked() && mInputs > 1) { right = (WaveTrack *) iter.Next(); GetSamples(right, &rstart, &len); clear = false; mChannels = 2; } if (mBlockSize == 0) { mBlockSize = left->GetMaxBlockSize() * 2; // Some VST effects (Antress Modern is an example), do not like // overly large block sizes. Unfortunately, I have not found a // way to determine if the effect has a maximum it will support, // so just limit to small value for now. This will increase // processing time and, it's a shame, because most plugins seem // to be able to handle much larger sizes. if (mBlockSize > 8192) { // The Antress limit mBlockSize = 8192; } mInBuffer = new float *[mInputs]; for (int i = 0; i < mInputs; i++) { mInBuffer[i] = new float[mBlockSize]; } mOutBuffer = new float *[mOutputs]; for (int i = 0; i < mOutputs; i++) { mOutBuffer[i] = new float[mBlockSize]; } // Turn the power off callDispatcher(effMainsChanged, 0, 0, NULL, 0.0); // Set processing parameters callDispatcher(effSetSampleRate, 0, 0, NULL, left->GetRate()); callDispatcher(effSetBlockSize, 0, mBlockSize, NULL, 0.0); } // Clear unused input buffers if (!right && !clear) { for (int i = 1; i < mInputs; i++) { for (int j = 0; j < mBlockSize; j++) { mInBuffer[i][j] = 0.0; } } clear = true; } bGoodResult = ProcessStereo(count, left, right, lstart, rstart, len); if (!bGoodResult) { break; } left = (WaveTrack *) iter.Next(); count++; } if (mOutBuffer) { for (int i = 0; i < mOutputs; i++) { delete mOutBuffer[i]; } delete [] mOutBuffer; mOutBuffer = NULL; } if (mInBuffer) { for (int i = 0; i < mInputs; i++) { delete mInBuffer[i]; } delete [] mInBuffer; mInBuffer = NULL; } ReplaceProcessedTracks(bGoodResult); return bGoodResult; }
bool EffectSoundTouch::Process() { // Assumes that mSoundTouch has already been initialized // by the subclass for subclass-specific parameters. The // time warper should also be set. // Check if this effect will alter the selection length; if so, we need // to operate on sync-lock selected tracks. bool mustSync = true; if (mT1 == GetTimeWarper()->Warp(mT1)) { mustSync = false; } //Iterate over each track // Needs Track::All for sync-lock grouping. this->CopyInputTracks(Track::All); bool bGoodResult = true; TrackListIterator iter(mOutputTracks); Track* t; mCurTrackNum = 0; m_maxNewLength = 0.0; t = iter.First(); while (t != NULL) { if (t->GetKind() == Track::Label && (t->GetSelected() || (mustSync && t->IsSyncLockSelected())) ) { if (!ProcessLabelTrack(t)) { bGoodResult = false; break; } } #ifdef USE_MIDI else if (t->GetKind() == Track::Note && (t->GetSelected() || (mustSync && t->IsSyncLockSelected()))) { if (!ProcessNoteTrack(t)) { bGoodResult = false; break; } } #endif else if (t->GetKind() == Track::Wave && t->GetSelected()) { WaveTrack* leftTrack = (WaveTrack*)t; //Get start and end times from track mCurT0 = leftTrack->GetStartTime(); mCurT1 = leftTrack->GetEndTime(); //Set the current bounds to whichever left marker is //greater and whichever right marker is less mCurT0 = wxMax(mT0, mCurT0); mCurT1 = wxMin(mT1, mCurT1); // Process only if the right marker is to the right of the left marker if (mCurT1 > mCurT0) { sampleCount start, end; if (leftTrack->GetLinked()) { double t; WaveTrack* rightTrack = (WaveTrack*)(iter.Next()); //Adjust bounds by the right tracks markers t = rightTrack->GetStartTime(); t = wxMax(mT0, t); mCurT0 = wxMin(mCurT0, t); t = rightTrack->GetEndTime(); t = wxMin(mT1, t); mCurT1 = wxMax(mCurT1, t); //Transform the marker timepoints to samples start = leftTrack->TimeToLongSamples(mCurT0); end = leftTrack->TimeToLongSamples(mCurT1); //Inform soundtouch there's 2 channels mSoundTouch->setChannels(2); //ProcessStereo() (implemented below) processes a stereo track if (!ProcessStereo(leftTrack, rightTrack, start, end)) { bGoodResult = false; break; } mCurTrackNum++; // Increment for rightTrack, too. } else { //Transform the marker timepoints to samples start = leftTrack->TimeToLongSamples(mCurT0); end = leftTrack->TimeToLongSamples(mCurT1); //Inform soundtouch there's a single channel mSoundTouch->setChannels(1); //ProcessOne() (implemented below) processes a single track if (!ProcessOne(leftTrack, start, end)) { bGoodResult = false; break; } } } mCurTrackNum++; } else if (mustSync && t->IsSyncLockSelected()) { t->SyncLockAdjust(mT1, GetTimeWarper()->Warp(mT1)); } //Iterate to the next track t = iter.Next(); } if (bGoodResult) ReplaceProcessedTracks(bGoodResult); delete mSoundTouch; mSoundTouch = NULL; // mT0 = mCurT0; // mT1 = mCurT0 + m_maxNewLength; // Update selection. return bGoodResult; }