| @@ -999,7 +999,7 @@ String MidiMessage::getMidiNoteName (int note, bool useSharps, bool includeOctav | |||||
| double MidiMessage::getMidiNoteInHertz (const int noteNumber, const double frequencyOfA) noexcept | double MidiMessage::getMidiNoteInHertz (const int noteNumber, const double frequencyOfA) noexcept | ||||
| { | { | ||||
| return frequencyOfA * pow (2.0, (noteNumber - 69) / 12.0); | |||||
| return frequencyOfA * std::pow (2.0, (noteNumber - 69) / 12.0); | |||||
| } | } | ||||
| bool MidiMessage::isMidiNoteBlack (int noteNumber) noexcept | bool MidiMessage::isMidiNoteBlack (int noteNumber) noexcept | ||||
| @@ -672,7 +672,7 @@ private: | |||||
| float* table = muls[k]; | float* table = muls[k]; | ||||
| for (int j = 3, i = 0; i < 63; ++i, --j) | for (int j = 3, i = 0; i < 63; ++i, --j) | ||||
| *table++ = (float) (multipliers[k] * pow (2.0, j / 3.0)); | |||||
| *table++ = (float) (multipliers[k] * std::pow (2.0, j / 3.0)); | |||||
| *table++ = 0; | *table++ = 0; | ||||
| } | } | ||||
| } | } | ||||
| @@ -681,10 +681,10 @@ private: | |||||
| { | { | ||||
| int i, j; | int i, j; | ||||
| for (i = -256; i < 118 + 4; ++i) | for (i = -256; i < 118 + 4; ++i) | ||||
| powToGains[i + 256] = (float) pow (2.0, -0.25 * (i + 210)); | |||||
| powToGains[i + 256] = (float) std::pow (2.0, -0.25 * (i + 210)); | |||||
| for (i = 0; i < 8207; ++i) | for (i = 0; i < 8207; ++i) | ||||
| nToThe4Over3[i] = (float) pow ((double) i, 4.0 / 3.0); | |||||
| nToThe4Over3[i] = (float) std::pow ((double) i, 4.0 / 3.0); | |||||
| for (i = 0; i < 8; ++i) | for (i = 0; i < 8; ++i) | ||||
| { | { | ||||
| @@ -737,12 +737,12 @@ private: | |||||
| if (i > 0) | if (i > 0) | ||||
| { | { | ||||
| const double base = pow (2.0, -0.25 * (j + 1)); | |||||
| const double base = std::pow (2.0, -0.25 * (j + 1)); | |||||
| if (i & 1) | if (i & 1) | ||||
| p1 = pow (base, (i + 1) * 0.5); | |||||
| p1 = std::pow (base, (i + 1) * 0.5); | |||||
| else | else | ||||
| p2 = pow (base, i * 0.5); | |||||
| p2 = std::pow (base, i * 0.5); | |||||
| } | } | ||||
| pow1_1[j][i] = (float) p1; | pow1_1[j][i] = (float) p1; | ||||
| @@ -274,14 +274,14 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||||
| jassert (magnitudeRangeMaximum > magnitudeRangeMinimum); | jassert (magnitudeRangeMaximum > magnitudeRangeMinimum); | ||||
| const double doubleMin = jlimit (0.0, (double) std::numeric_limits<int>::max(), magnitudeRangeMinimum * std::numeric_limits<int>::max()); | |||||
| const double doubleMax = jlimit (doubleMin, (double) std::numeric_limits<int>::max(), magnitudeRangeMaximum * std::numeric_limits<int>::max()); | |||||
| const int intMagnitudeRangeMinimum = roundToInt (doubleMin); | |||||
| const int intMagnitudeRangeMaximum = roundToInt (doubleMax); | |||||
| auto doubleMin = jlimit (0.0, (double) std::numeric_limits<int>::max(), magnitudeRangeMinimum * std::numeric_limits<int>::max()); | |||||
| auto doubleMax = jlimit (doubleMin, (double) std::numeric_limits<int>::max(), magnitudeRangeMaximum * std::numeric_limits<int>::max()); | |||||
| auto intMagnitudeRangeMinimum = roundToInt (doubleMin); | |||||
| auto intMagnitudeRangeMaximum = roundToInt (doubleMax); | |||||
| while (numSamplesToSearch != 0) | while (numSamplesToSearch != 0) | ||||
| { | { | ||||
| const int numThisTime = (int) jmin (abs64 (numSamplesToSearch), (int64) bufferSize); | |||||
| auto numThisTime = (int) jmin (abs64 (numSamplesToSearch), (int64) bufferSize); | |||||
| int64 bufferStart = startSample; | int64 bufferStart = startSample; | ||||
| if (numSamplesToSearch < 0) | if (numSamplesToSearch < 0) | ||||
| @@ -291,15 +291,15 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||||
| break; | break; | ||||
| read (tempBuffer, 2, bufferStart, numThisTime, false); | read (tempBuffer, 2, bufferStart, numThisTime, false); | ||||
| auto num = numThisTime; | |||||
| int num = numThisTime; | |||||
| while (--num >= 0) | while (--num >= 0) | ||||
| { | { | ||||
| if (numSamplesToSearch < 0) | if (numSamplesToSearch < 0) | ||||
| --startSample; | --startSample; | ||||
| bool matches = false; | bool matches = false; | ||||
| const int index = (int) (startSample - bufferStart); | |||||
| auto index = (int) (startSample - bufferStart); | |||||
| if (usesFloatingPointData) | if (usesFloatingPointData) | ||||
| { | { | ||||
| @@ -320,7 +320,7 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const int sample1 = abs (tempBuffer[0] [index]); | |||||
| const int sample1 = std::abs (tempBuffer[0] [index]); | |||||
| if (sample1 >= intMagnitudeRangeMinimum | if (sample1 >= intMagnitudeRangeMinimum | ||||
| && sample1 <= intMagnitudeRangeMaximum) | && sample1 <= intMagnitudeRangeMaximum) | ||||
| @@ -329,7 +329,7 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||||
| } | } | ||||
| else if (numChannels > 1) | else if (numChannels > 1) | ||||
| { | { | ||||
| const int sample2 = abs (tempBuffer[1][index]); | |||||
| const int sample2 = std::abs (tempBuffer[1][index]); | |||||
| matches = (sample2 >= intMagnitudeRangeMinimum | matches = (sample2 >= intMagnitudeRangeMinimum | ||||
| && sample2 <= intMagnitudeRangeMaximum); | && sample2 <= intMagnitudeRangeMaximum); | ||||
| @@ -30,23 +30,16 @@ namespace juce | |||||
| SamplerSound::SamplerSound (const String& soundName, | SamplerSound::SamplerSound (const String& soundName, | ||||
| AudioFormatReader& source, | AudioFormatReader& source, | ||||
| const BigInteger& notes, | const BigInteger& notes, | ||||
| const int midiNoteForNormalPitch, | |||||
| const double attackTimeSecs, | |||||
| const double releaseTimeSecs, | |||||
| const double maxSampleLengthSeconds) | |||||
| int midiNoteForNormalPitch, | |||||
| double attackTimeSecs, | |||||
| double releaseTimeSecs, | |||||
| double maxSampleLengthSeconds) | |||||
| : name (soundName), | : name (soundName), | ||||
| sourceSampleRate (source.sampleRate), | |||||
| midiNotes (notes), | midiNotes (notes), | ||||
| midiRootNote (midiNoteForNormalPitch) | midiRootNote (midiNoteForNormalPitch) | ||||
| { | { | ||||
| sourceSampleRate = source.sampleRate; | |||||
| if (sourceSampleRate <= 0 || source.lengthInSamples <= 0) | |||||
| { | |||||
| length = 0; | |||||
| attackSamples = 0; | |||||
| releaseSamples = 0; | |||||
| } | |||||
| else | |||||
| if (sourceSampleRate > 0 && source.lengthInSamples > 0) | |||||
| { | { | ||||
| length = jmin ((int) source.lengthInSamples, | length = jmin ((int) source.lengthInSamples, | ||||
| (int) (maxSampleLengthSeconds * sourceSampleRate)); | (int) (maxSampleLengthSeconds * sourceSampleRate)); | ||||
| @@ -55,7 +48,7 @@ SamplerSound::SamplerSound (const String& soundName, | |||||
| source.read (data, 0, length + 4, 0, true, true); | source.read (data, 0, length + 4, 0, true, true); | ||||
| attackSamples = roundToInt (attackTimeSecs * sourceSampleRate); | |||||
| attackSamples = roundToInt (attackTimeSecs * sourceSampleRate); | |||||
| releaseSamples = roundToInt (releaseTimeSecs * sourceSampleRate); | releaseSamples = roundToInt (releaseTimeSecs * sourceSampleRate); | ||||
| } | } | ||||
| } | } | ||||
| @@ -66,7 +59,7 @@ SamplerSound::~SamplerSound() | |||||
| bool SamplerSound::appliesToNote (int midiNoteNumber) | bool SamplerSound::appliesToNote (int midiNoteNumber) | ||||
| { | { | ||||
| return midiNotes [midiNoteNumber]; | |||||
| return midiNotes[midiNoteNumber]; | |||||
| } | } | ||||
| bool SamplerSound::appliesToChannel (int /*midiChannel*/) | bool SamplerSound::appliesToChannel (int /*midiChannel*/) | ||||
| @@ -75,32 +68,19 @@ bool SamplerSound::appliesToChannel (int /*midiChannel*/) | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| SamplerVoice::SamplerVoice() | |||||
| : pitchRatio (0.0), | |||||
| sourceSamplePosition (0.0), | |||||
| lgain (0.0f), rgain (0.0f), | |||||
| attackReleaseLevel (0), attackDelta (0), releaseDelta (0), | |||||
| isInAttack (false), isInRelease (false) | |||||
| { | |||||
| } | |||||
| SamplerVoice::~SamplerVoice() | |||||
| { | |||||
| } | |||||
| SamplerVoice::SamplerVoice() {} | |||||
| SamplerVoice::~SamplerVoice() {} | |||||
| bool SamplerVoice::canPlaySound (SynthesiserSound* sound) | bool SamplerVoice::canPlaySound (SynthesiserSound* sound) | ||||
| { | { | ||||
| return dynamic_cast<const SamplerSound*> (sound) != nullptr; | return dynamic_cast<const SamplerSound*> (sound) != nullptr; | ||||
| } | } | ||||
| void SamplerVoice::startNote (const int midiNoteNumber, | |||||
| const float velocity, | |||||
| SynthesiserSound* s, | |||||
| const int /*currentPitchWheelPosition*/) | |||||
| void SamplerVoice::startNote (int midiNoteNumber, float velocity, SynthesiserSound* s, int /*currentPitchWheelPosition*/) | |||||
| { | { | ||||
| if (const SamplerSound* const sound = dynamic_cast<const SamplerSound*> (s)) | |||||
| if (auto* sound = dynamic_cast<const SamplerSound*> (s)) | |||||
| { | { | ||||
| pitchRatio = pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0) | |||||
| pitchRatio = std::pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0) | |||||
| * sound->sourceSampleRate / getSampleRate(); | * sound->sourceSampleRate / getSampleRate(); | ||||
| sourceSamplePosition = 0.0; | sourceSamplePosition = 0.0; | ||||
| @@ -145,36 +125,30 @@ void SamplerVoice::stopNote (float /*velocity*/, bool allowTailOff) | |||||
| } | } | ||||
| } | } | ||||
| void SamplerVoice::pitchWheelMoved (const int /*newValue*/) | |||||
| { | |||||
| } | |||||
| void SamplerVoice::controllerMoved (const int /*controllerNumber*/, | |||||
| const int /*newValue*/) | |||||
| { | |||||
| } | |||||
| void SamplerVoice::pitchWheelMoved (int /*newValue*/) {} | |||||
| void SamplerVoice::controllerMoved (int /*controllerNumber*/, int /*newValue*/) {} | |||||
| //============================================================================== | //============================================================================== | ||||
| void SamplerVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) | void SamplerVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) | ||||
| { | { | ||||
| if (const SamplerSound* const playingSound = static_cast<SamplerSound*> (getCurrentlyPlayingSound().get())) | |||||
| if (auto* playingSound = static_cast<SamplerSound*> (getCurrentlyPlayingSound().get())) | |||||
| { | { | ||||
| const float* const inL = playingSound->data->getReadPointer (0); | |||||
| const float* const inR = playingSound->data->getNumChannels() > 1 | |||||
| ? playingSound->data->getReadPointer (1) : nullptr; | |||||
| auto& data = *playingSound->data; | |||||
| const float* const inL = data.getReadPointer (0); | |||||
| const float* const inR = data.getNumChannels() > 1 ? data.getReadPointer (1) : nullptr; | |||||
| float* outL = outputBuffer.getWritePointer (0, startSample); | float* outL = outputBuffer.getWritePointer (0, startSample); | ||||
| float* outR = outputBuffer.getNumChannels() > 1 ? outputBuffer.getWritePointer (1, startSample) : nullptr; | float* outR = outputBuffer.getNumChannels() > 1 ? outputBuffer.getWritePointer (1, startSample) : nullptr; | ||||
| while (--numSamples >= 0) | while (--numSamples >= 0) | ||||
| { | { | ||||
| const int pos = (int) sourceSamplePosition; | |||||
| const float alpha = (float) (sourceSamplePosition - pos); | |||||
| const float invAlpha = 1.0f - alpha; | |||||
| auto pos = (int) sourceSamplePosition; | |||||
| auto alpha = (float) (sourceSamplePosition - pos); | |||||
| auto invAlpha = 1.0f - alpha; | |||||
| // just using a very simple linear interpolation here.. | // just using a very simple linear interpolation here.. | ||||
| float l = (inL [pos] * invAlpha + inL [pos + 1] * alpha); | |||||
| float r = (inR != nullptr) ? (inR [pos] * invAlpha + inR [pos + 1] * alpha) | |||||
| float l = (inL[pos] * invAlpha + inL[pos + 1] * alpha); | |||||
| float r = (inR != nullptr) ? (inR[pos] * invAlpha + inR[pos + 1] * alpha) | |||||
| : l; | : l; | ||||
| l *= lgain; | l *= lgain; | ||||
| @@ -95,8 +95,8 @@ private: | |||||
| ScopedPointer<AudioSampleBuffer> data; | ScopedPointer<AudioSampleBuffer> data; | ||||
| double sourceSampleRate; | double sourceSampleRate; | ||||
| BigInteger midiNotes; | BigInteger midiNotes; | ||||
| int length, attackSamples, releaseSamples; | |||||
| int midiRootNote; | |||||
| int length = 0, attackSamples = 0, releaseSamples = 0; | |||||
| int midiRootNote = 0; | |||||
| JUCE_LEAK_DETECTOR (SamplerSound) | JUCE_LEAK_DETECTOR (SamplerSound) | ||||
| }; | }; | ||||
| @@ -135,10 +135,10 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| double pitchRatio; | |||||
| double sourceSamplePosition; | |||||
| float lgain, rgain, attackReleaseLevel, attackDelta, releaseDelta; | |||||
| bool isInAttack, isInRelease; | |||||
| double pitchRatio = 0; | |||||
| double sourceSamplePosition = 0; | |||||
| float lgain = 0, rgain = 0, attackReleaseLevel = 0, attackDelta = 0, releaseDelta = 0; | |||||
| bool isInAttack = false, isInRelease = false; | |||||
| JUCE_LEAK_DETECTOR (SamplerVoice) | JUCE_LEAK_DETECTOR (SamplerVoice) | ||||
| }; | }; | ||||
| @@ -2417,7 +2417,7 @@ private: | |||||
| || ((w == 0 && rw > 0) || (h == 0 && rh > 0))) | || ((w == 0 && rw > 0) || (h == 0 && rh > 0))) | ||||
| { | { | ||||
| // very dodgy logic to decide which size is right. | // very dodgy logic to decide which size is right. | ||||
| if (abs (rw - w) > 350 || abs (rh - h) > 350) | |||||
| if (std::abs (rw - w) > 350 || std::abs (rh - h) > 350) | |||||
| { | { | ||||
| SetWindowPos (pluginHWND, 0, | SetWindowPos (pluginHWND, 0, | ||||
| 0, 0, rw, rh, | 0, 0, rw, rh, | ||||
| @@ -281,26 +281,27 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||||
| { | { | ||||
| const bool isInput = (dir > 0); | const bool isInput = (dir > 0); | ||||
| Array<AudioChannelSet>& currentLayouts = (isInput ? currentState.inputBuses : currentState.outputBuses); | |||||
| const Array<AudioChannelSet>& bestLayouts = (isInput ? bestSupported.inputBuses : bestSupported.outputBuses); | |||||
| const Array<AudioChannelSet>& requestedLayouts = (isInput ? desiredLayout.inputBuses : desiredLayout.outputBuses); | |||||
| const Array<AudioChannelSet>& originalLayouts = (isInput ? originalState.inputBuses : originalState.outputBuses); | |||||
| auto& currentLayouts = (isInput ? currentState.inputBuses : currentState.outputBuses); | |||||
| auto& bestLayouts = (isInput ? bestSupported.inputBuses : bestSupported.outputBuses); | |||||
| auto& requestedLayouts = (isInput ? desiredLayout.inputBuses : desiredLayout.outputBuses); | |||||
| auto& originalLayouts = (isInput ? originalState.inputBuses : originalState.outputBuses); | |||||
| for (int busIdx = 0; busIdx < requestedLayouts.size(); ++busIdx) | for (int busIdx = 0; busIdx < requestedLayouts.size(); ++busIdx) | ||||
| { | { | ||||
| AudioChannelSet& best = bestLayouts .getReference (busIdx); | |||||
| const AudioChannelSet& requested = requestedLayouts.getReference (busIdx); | |||||
| const AudioChannelSet& original = originalLayouts .getReference (busIdx); | |||||
| auto& best = bestLayouts .getReference (busIdx); | |||||
| auto& requested = requestedLayouts.getReference (busIdx); | |||||
| auto& original = originalLayouts .getReference (busIdx); | |||||
| // do we need to do anything | // do we need to do anything | ||||
| if (original == requested) | if (original == requested) | ||||
| continue; | continue; | ||||
| currentState = bestSupported; | currentState = bestSupported; | ||||
| AudioChannelSet& current = currentLayouts .getReference (busIdx); | |||||
| auto& current = currentLayouts .getReference (busIdx); | |||||
| // already supported? | // already supported? | ||||
| current = requested; | current = requested; | ||||
| if (checkBusesLayoutSupported (currentState)) | if (checkBusesLayoutSupported (currentState)) | ||||
| { | { | ||||
| bestSupported = currentState; | bestSupported = currentState; | ||||
| @@ -309,9 +310,10 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||||
| // try setting the opposite bus to the identical layout | // try setting the opposite bus to the identical layout | ||||
| const bool oppositeDirection = ! isInput; | const bool oppositeDirection = ! isInput; | ||||
| if (getBusCount (oppositeDirection) > busIdx) | if (getBusCount (oppositeDirection) > busIdx) | ||||
| { | { | ||||
| AudioChannelSet& oppositeLayout = (oppositeDirection ? currentState.inputBuses : currentState.outputBuses).getReference (busIdx); | |||||
| auto& oppositeLayout = (oppositeDirection ? currentState.inputBuses : currentState.outputBuses).getReference (busIdx); | |||||
| oppositeLayout = requested; | oppositeLayout = requested; | ||||
| if (checkBusesLayoutSupported (currentState)) | if (checkBusesLayoutSupported (currentState)) | ||||
| @@ -322,6 +324,7 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||||
| // try setting the default layout | // try setting the default layout | ||||
| oppositeLayout = getBus (oppositeDirection, busIdx)->getDefaultLayout(); | oppositeLayout = getBus (oppositeDirection, busIdx)->getDefaultLayout(); | ||||
| if (checkBusesLayoutSupported (currentState)) | if (checkBusesLayoutSupported (currentState)) | ||||
| { | { | ||||
| bestSupported = currentState; | bestSupported = currentState; | ||||
| @@ -331,10 +334,11 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||||
| // try setting all other buses to the identical layout | // try setting all other buses to the identical layout | ||||
| BusesLayout allTheSame; | BusesLayout allTheSame; | ||||
| for (int oDir = 0; oDir < 2; ++oDir) | for (int oDir = 0; oDir < 2; ++oDir) | ||||
| { | { | ||||
| const bool oIsInput = (oDir == 0); | |||||
| const int oBusNum = getBusCount (oIsInput); | |||||
| bool oIsInput = (oDir == 0); | |||||
| auto oBusNum = getBusCount (oIsInput); | |||||
| for (int oBusIdx = 0; oBusIdx < oBusNum; ++oBusIdx) | for (int oBusIdx = 0; oBusIdx < oBusNum; ++oBusIdx) | ||||
| (oIsInput ? allTheSame.inputBuses : allTheSame.outputBuses).add (requested); | (oIsInput ? allTheSame.inputBuses : allTheSame.outputBuses).add (requested); | ||||
| @@ -347,12 +351,13 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||||
| } | } | ||||
| // what is closer the default or the current layout? | // what is closer the default or the current layout? | ||||
| int distance = abs (best.size() - requested.size()); | |||||
| const AudioChannelSet& defaultLayout = getBus (isInput, busIdx)->getDefaultLayout(); | |||||
| auto distance = std::abs (best.size() - requested.size()); | |||||
| auto& defaultLayout = getBus (isInput, busIdx)->getDefaultLayout(); | |||||
| if (abs (defaultLayout.size() - requested.size()) < distance) | |||||
| if (std::abs (defaultLayout.size() - requested.size()) < distance) | |||||
| { | { | ||||
| current = defaultLayout; | current = defaultLayout; | ||||
| if (checkBusesLayoutSupported (currentState)) | if (checkBusesLayoutSupported (currentState)) | ||||
| bestSupported = currentState; | bestSupported = currentState; | ||||
| } | } | ||||
| @@ -414,8 +419,8 @@ static int countTotalChannels (const OwnedArray<AudioProcessor::Bus>& buses) noe | |||||
| { | { | ||||
| int n = 0; | int n = 0; | ||||
| for (int i = 0; i < buses.size(); ++i) | |||||
| n += buses[i]->getNumberOfChannels(); | |||||
| for (auto* bus : buses) | |||||
| n += bus->getNumberOfChannels(); | |||||
| return n; | return n; | ||||
| } | } | ||||
| @@ -426,7 +431,7 @@ void AudioProcessor::processorLayoutsChanged() {} | |||||
| int AudioProcessor::getChannelIndexInProcessBlockBuffer (bool isInput, int busIndex, int channelIndex) const noexcept | int AudioProcessor::getChannelIndexInProcessBlockBuffer (bool isInput, int busIndex, int channelIndex) const noexcept | ||||
| { | { | ||||
| const OwnedArray<Bus>& ioBus = isInput ? inputBuses : outputBuses; | |||||
| auto& ioBus = isInput ? inputBuses : outputBuses; | |||||
| jassert (isPositiveAndBelow(busIndex, ioBus.size())); | jassert (isPositiveAndBelow(busIndex, ioBus.size())); | ||||
| for (int i = 0; i < ioBus.size() && i < busIndex; ++i) | for (int i = 0; i < ioBus.size() && i < busIndex; ++i) | ||||
| @@ -437,13 +442,13 @@ int AudioProcessor::getChannelIndexInProcessBlockBuffer (bool isInput, int busIn | |||||
| int AudioProcessor::getOffsetInBusBufferForAbsoluteChannelIndex (bool isInput, int absoluteChannelIndex, /*out*/ int& busIdx) const noexcept | int AudioProcessor::getOffsetInBusBufferForAbsoluteChannelIndex (bool isInput, int absoluteChannelIndex, /*out*/ int& busIdx) const noexcept | ||||
| { | { | ||||
| const int n = getBusCount (isInput); | |||||
| auto numBuses = getBusCount (isInput); | |||||
| int numChannels = 0; | int numChannels = 0; | ||||
| for (busIdx = 0; busIdx < n && absoluteChannelIndex >= (numChannels = getChannelLayoutOfBus (isInput, busIdx).size()); ++busIdx) | |||||
| for (busIdx = 0; busIdx < numBuses && absoluteChannelIndex >= (numChannels = getChannelLayoutOfBus (isInput, busIdx).size()); ++busIdx) | |||||
| absoluteChannelIndex -= numChannels; | absoluteChannelIndex -= numChannels; | ||||
| return busIdx >= n ? -1 : absoluteChannelIndex; | |||||
| return busIdx >= numBuses ? -1 : absoluteChannelIndex; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -461,20 +466,19 @@ void AudioProcessor::setLatencySamples (const int newLatency) | |||||
| } | } | ||||
| } | } | ||||
| void AudioProcessor::setParameterNotifyingHost (const int parameterIndex, | |||||
| const float newValue) | |||||
| void AudioProcessor::setParameterNotifyingHost (int parameterIndex, float newValue) | |||||
| { | { | ||||
| setParameter (parameterIndex, newValue); | setParameter (parameterIndex, newValue); | ||||
| sendParamChangeMessageToListeners (parameterIndex, newValue); | sendParamChangeMessageToListeners (parameterIndex, newValue); | ||||
| } | } | ||||
| AudioProcessorListener* AudioProcessor::getListenerLocked (const int index) const noexcept | |||||
| AudioProcessorListener* AudioProcessor::getListenerLocked (int index) const noexcept | |||||
| { | { | ||||
| const ScopedLock sl (listenerLock); | const ScopedLock sl (listenerLock); | ||||
| return listeners [index]; | return listeners [index]; | ||||
| } | } | ||||
| void AudioProcessor::sendParamChangeMessageToListeners (const int parameterIndex, const float newValue) | |||||
| void AudioProcessor::sendParamChangeMessageToListeners (int parameterIndex, float newValue) | |||||
| { | { | ||||
| if (isPositiveAndBelow (parameterIndex, getNumParameters())) | if (isPositiveAndBelow (parameterIndex, getNumParameters())) | ||||
| { | { | ||||
| @@ -522,7 +526,7 @@ void AudioProcessor::endParameterChangeGesture (int parameterIndex) | |||||
| #endif | #endif | ||||
| for (int i = listeners.size(); --i >= 0;) | for (int i = listeners.size(); --i >= 0;) | ||||
| if (AudioProcessorListener* l = getListenerLocked (i)) | |||||
| if (auto* l = getListenerLocked (i)) | |||||
| l->audioProcessorParameterChangeGestureEnd (this, parameterIndex); | l->audioProcessorParameterChangeGestureEnd (this, parameterIndex); | ||||
| } | } | ||||
| else | else | ||||
| @@ -534,7 +538,7 @@ void AudioProcessor::endParameterChangeGesture (int parameterIndex) | |||||
| void AudioProcessor::updateHostDisplay() | void AudioProcessor::updateHostDisplay() | ||||
| { | { | ||||
| for (int i = listeners.size(); --i >= 0;) | for (int i = listeners.size(); --i >= 0;) | ||||
| if (AudioProcessorListener* l = getListenerLocked (i)) | |||||
| if (auto* l = getListenerLocked (i)) | |||||
| l->audioProcessorChanged (this); | l->audioProcessorChanged (this); | ||||
| } | } | ||||
| @@ -795,7 +799,7 @@ AudioProcessor::BusesProperties AudioProcessor::busesPropertiesFromLayoutArray ( | |||||
| AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const BusesLayout& layouts, | AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const BusesLayout& layouts, | ||||
| const Array<InOutChannelPair>& legacyLayouts) const | const Array<InOutChannelPair>& legacyLayouts) const | ||||
| { | { | ||||
| const int numChannelConfigs = legacyLayouts.size(); | |||||
| auto numChannelConfigs = legacyLayouts.size(); | |||||
| jassert (numChannelConfigs > 0); | jassert (numChannelConfigs > 0); | ||||
| bool hasInputs = false, hasOutputs = false; | bool hasInputs = false, hasOutputs = false; | ||||
| @@ -818,26 +822,26 @@ AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const Buses | |||||
| } | } | ||||
| } | } | ||||
| BusesLayout nearest = layouts; | |||||
| auto nearest = layouts; | |||||
| nearest.inputBuses .resize (hasInputs ? 1 : 0); | nearest.inputBuses .resize (hasInputs ? 1 : 0); | ||||
| nearest.outputBuses.resize (hasOutputs ? 1 : 0); | nearest.outputBuses.resize (hasOutputs ? 1 : 0); | ||||
| AudioChannelSet* inBus = (hasInputs ? &nearest.inputBuses. getReference (0) : nullptr); | |||||
| AudioChannelSet* outBus = (hasOutputs ? &nearest.outputBuses.getReference (0) : nullptr); | |||||
| auto* inBus = (hasInputs ? &nearest.inputBuses. getReference (0) : nullptr); | |||||
| auto* outBus = (hasOutputs ? &nearest.outputBuses.getReference (0) : nullptr); | |||||
| const int16 inNumChannelsRequested = static_cast<int16> (inBus != nullptr ? inBus->size() : 0); | |||||
| const int16 outNumChannelsRequested = static_cast<int16> (outBus != nullptr ? outBus->size() : 0); | |||||
| auto inNumChannelsRequested = static_cast<int16> (inBus != nullptr ? inBus->size() : 0); | |||||
| auto outNumChannelsRequested = static_cast<int16> (outBus != nullptr ? outBus->size() : 0); | |||||
| int32 distance = std::numeric_limits<int32>::max(); | |||||
| auto distance = std::numeric_limits<int32>::max(); | |||||
| int bestConfiguration = 0; | int bestConfiguration = 0; | ||||
| for (int i = 0; i < numChannelConfigs; ++i) | for (int i = 0; i < numChannelConfigs; ++i) | ||||
| { | { | ||||
| const int16 inChannels = legacyLayouts.getReference (i).inChannels; | |||||
| const int16 outChannels = legacyLayouts.getReference (i).outChannels; | |||||
| auto inChannels = legacyLayouts.getReference (i).inChannels; | |||||
| auto outChannels = legacyLayouts.getReference (i).outChannels; | |||||
| const int32 channelDifference = ((std::abs (inChannels - inNumChannelsRequested) & 0xffff) << 16) | | |||||
| ((std::abs (outChannels - outNumChannelsRequested) & 0xffff) << 0); | |||||
| auto channelDifference = ((std::abs (inChannels - inNumChannelsRequested) & 0xffff) << 16) | |||||
| | ((std::abs (outChannels - outNumChannelsRequested) & 0xffff) << 0); | |||||
| if (channelDifference < distance) | if (channelDifference < distance) | ||||
| { | { | ||||
| @@ -845,17 +849,17 @@ AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const Buses | |||||
| bestConfiguration = i; | bestConfiguration = i; | ||||
| // we can exit if we found a perfect match | // we can exit if we found a perfect match | ||||
| if (distance == 0) return nearest; | |||||
| if (distance == 0) | |||||
| return nearest; | |||||
| } | } | ||||
| } | } | ||||
| const int16 inChannels = legacyLayouts.getReference (bestConfiguration).inChannels; | |||||
| const int16 outChannels = legacyLayouts.getReference (bestConfiguration).outChannels; | |||||
| BusesLayout currentState = getBusesLayout(); | |||||
| AudioChannelSet currentInLayout = (getBusCount (true) > 0 ? currentState.inputBuses .getReference(0) : AudioChannelSet()); | |||||
| AudioChannelSet currentOutLayout = (getBusCount (false) > 0 ? currentState.outputBuses.getReference(0) : AudioChannelSet()); | |||||
| auto inChannels = legacyLayouts.getReference (bestConfiguration).inChannels; | |||||
| auto outChannels = legacyLayouts.getReference (bestConfiguration).outChannels; | |||||
| auto currentState = getBusesLayout(); | |||||
| auto currentInLayout = (getBusCount (true) > 0 ? currentState.inputBuses .getReference(0) : AudioChannelSet()); | |||||
| auto currentOutLayout = (getBusCount (false) > 0 ? currentState.outputBuses.getReference(0) : AudioChannelSet()); | |||||
| if (inBus != nullptr) | if (inBus != nullptr) | ||||
| { | { | ||||
| @@ -890,7 +894,7 @@ bool AudioProcessor::containsLayout (const BusesLayout& layouts, const Array<InO | |||||
| //============================================================================== | //============================================================================== | ||||
| bool AudioProcessor::disableNonMainBuses() | bool AudioProcessor::disableNonMainBuses() | ||||
| { | { | ||||
| BusesLayout layouts = getBusesLayout(); | |||||
| auto layouts = getBusesLayout(); | |||||
| for (int busIdx = 1; busIdx < layouts.inputBuses.size(); ++busIdx) | for (int busIdx = 1; busIdx < layouts.inputBuses.size(); ++busIdx) | ||||
| layouts.inputBuses.getReference (busIdx) = AudioChannelSet::disabled(); | layouts.inputBuses.getReference (busIdx) = AudioChannelSet::disabled(); | ||||
| @@ -921,11 +925,11 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||||
| if (layouts == getBusesLayout()) | if (layouts == getBusesLayout()) | ||||
| return true; | return true; | ||||
| const int numInputBuses = getBusCount (true); | |||||
| const int numOutputBuses = getBusCount (false); | |||||
| auto numInputBuses = getBusCount (true); | |||||
| auto numOutputBuses = getBusCount (false); | |||||
| const int oldNumberOfIns = getTotalNumInputChannels(); | |||||
| const int oldNumberOfOuts = getTotalNumOutputChannels(); | |||||
| auto oldNumberOfIns = getTotalNumInputChannels(); | |||||
| auto oldNumberOfOuts = getTotalNumOutputChannels(); | |||||
| if (layouts.inputBuses. size() != numInputBuses | if (layouts.inputBuses. size() != numInputBuses | ||||
| || layouts.outputBuses.size() != numOutputBuses) | || layouts.outputBuses.size() != numOutputBuses) | ||||
| @@ -935,10 +939,10 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||||
| for (int busIdx = 0; busIdx < numInputBuses; ++busIdx) | for (int busIdx = 0; busIdx < numInputBuses; ++busIdx) | ||||
| { | { | ||||
| Bus& bus = *getBus (true, busIdx); | |||||
| const AudioChannelSet& set = layouts.getChannelSet (true, busIdx); | |||||
| auto& bus = *getBus (true, busIdx); | |||||
| const auto& set = layouts.getChannelSet (true, busIdx); | |||||
| bus.layout = set; | bus.layout = set; | ||||
| if (! set.isDisabled()) | if (! set.isDisabled()) | ||||
| bus.lastLayout = set; | bus.lastLayout = set; | ||||
| @@ -947,10 +951,10 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||||
| for (int busIdx = 0; busIdx < numOutputBuses; ++busIdx) | for (int busIdx = 0; busIdx < numOutputBuses; ++busIdx) | ||||
| { | { | ||||
| Bus& bus = *getBus (false, busIdx); | |||||
| const AudioChannelSet& set = layouts.getChannelSet (false, busIdx); | |||||
| auto& bus = *getBus (false, busIdx); | |||||
| const auto& set = layouts.getChannelSet (false, busIdx); | |||||
| bus.layout = set; | bus.layout = set; | ||||
| if (! set.isDisabled()) | if (! set.isDisabled()) | ||||
| bus.lastLayout = set; | bus.lastLayout = set; | ||||
| @@ -965,19 +969,17 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||||
| void AudioProcessor::audioIOChanged (bool busNumberChanged, bool channelNumChanged) | void AudioProcessor::audioIOChanged (bool busNumberChanged, bool channelNumChanged) | ||||
| { | { | ||||
| const int numInputBuses = getBusCount (true); | |||||
| const int numOutputBuses = getBusCount (false); | |||||
| auto numInputBuses = getBusCount (true); | |||||
| auto numOutputBuses = getBusCount (false); | |||||
| for (int dir = 0; dir < 2; ++dir) | for (int dir = 0; dir < 2; ++dir) | ||||
| { | { | ||||
| const bool isInput = (dir == 0); | const bool isInput = (dir == 0); | ||||
| const int n = (isInput ? numInputBuses : numOutputBuses); | |||||
| auto num = (isInput ? numInputBuses : numOutputBuses); | |||||
| for (int i = 0; i < n; ++i) | |||||
| { | |||||
| if (Bus* bus = getBus (isInput, i)) | |||||
| for (int i = 0; i < num; ++i) | |||||
| if (auto* bus = getBus (isInput, i)) | |||||
| bus->updateChannelCount(); | bus->updateChannelCount(); | ||||
| } | |||||
| } | } | ||||
| cachedTotalIns = countTotalChannels (inputBuses); | cachedTotalIns = countTotalChannels (inputBuses); | ||||
| @@ -1008,7 +1010,7 @@ AudioProcessorEditor* AudioProcessor::createEditorIfNeeded() | |||||
| if (activeEditor != nullptr) | if (activeEditor != nullptr) | ||||
| return activeEditor; | return activeEditor; | ||||
| AudioProcessorEditor* const ed = createEditor(); | |||||
| auto* ed = createEditor(); | |||||
| if (ed != nullptr) | if (ed != nullptr) | ||||
| { | { | ||||
| @@ -1063,7 +1065,7 @@ XmlElement* AudioProcessor::getXmlFromBinary (const void* data, const int sizeIn | |||||
| if (sizeInBytes > 8 | if (sizeInBytes > 8 | ||||
| && ByteOrder::littleEndianInt (data) == magicXmlNumber) | && ByteOrder::littleEndianInt (data) == magicXmlNumber) | ||||
| { | { | ||||
| const int stringLength = (int) ByteOrder::littleEndianInt (addBytesToPointer (data, 4)); | |||||
| auto stringLength = (int) ByteOrder::littleEndianInt (addBytesToPointer (data, 4)); | |||||
| if (stringLength > 0) | if (stringLength > 0) | ||||
| return XmlDocument::parse (String::fromUTF8 (static_cast<const char*> (data) + 8, | return XmlDocument::parse (String::fromUTF8 (static_cast<const char*> (data) + 8, | ||||
| @@ -1079,10 +1081,11 @@ bool AudioProcessor::canApplyBusCountChange (bool isInput, bool isAdding, | |||||
| if ( isAdding && ! canAddBus (isInput)) return false; | if ( isAdding && ! canAddBus (isInput)) return false; | ||||
| if (! isAdding && ! canRemoveBus (isInput)) return false; | if (! isAdding && ! canRemoveBus (isInput)) return false; | ||||
| const int num = getBusCount (isInput); | |||||
| auto num = getBusCount (isInput); | |||||
| // No way for me to find out the default layout if there are no other busses!! | // No way for me to find out the default layout if there are no other busses!! | ||||
| if (num == 0) return false; | |||||
| if (num == 0) | |||||
| return false; | |||||
| if (isAdding) | if (isAdding) | ||||
| { | { | ||||
| @@ -1096,7 +1099,7 @@ bool AudioProcessor::canApplyBusCountChange (bool isInput, bool isAdding, | |||||
| //============================================================================== | //============================================================================== | ||||
| AudioProcessor::Bus::Bus (AudioProcessor& processor, const String& busName, | AudioProcessor::Bus::Bus (AudioProcessor& processor, const String& busName, | ||||
| const AudioChannelSet& defaultLayout, bool isDfltEnabled) | |||||
| const AudioChannelSet& defaultLayout, bool isDfltEnabled) | |||||
| : owner (processor), name (busName), | : owner (processor), name (busName), | ||||
| layout (isDfltEnabled ? defaultLayout : AudioChannelSet()), | layout (isDfltEnabled ? defaultLayout : AudioChannelSet()), | ||||
| dfltLayout (defaultLayout), lastLayout (defaultLayout), | dfltLayout (defaultLayout), lastLayout (defaultLayout), | ||||
| @@ -1220,13 +1223,9 @@ bool AudioProcessor::Bus::isLayoutSupported (const AudioChannelSet& set, BusesLa | |||||
| if (actualBuses.getReference (busIdx) == set) | if (actualBuses.getReference (busIdx) == set) | ||||
| return true; | return true; | ||||
| BusesLayout desiredLayout = currentLayout; | |||||
| { | |||||
| Array<AudioChannelSet>& desiredBuses = | |||||
| (isInputBus ? desiredLayout.inputBuses : desiredLayout.outputBuses); | |||||
| desiredBuses.getReference (busIdx) = set; | |||||
| } | |||||
| auto desiredLayout = currentLayout; | |||||
| (isInputBus ? desiredLayout.inputBuses | |||||
| : desiredLayout.outputBuses).getReference (busIdx) = set; | |||||
| owner.getNextBestLayout (desiredLayout, currentLayout); | owner.getNextBestLayout (desiredLayout, currentLayout); | ||||
| @@ -1238,23 +1237,26 @@ bool AudioProcessor::Bus::isLayoutSupported (const AudioChannelSet& set, BusesLa | |||||
| jassert (currentLayout.inputBuses. size() == owner.getBusCount (true) | jassert (currentLayout.inputBuses. size() == owner.getBusCount (true) | ||||
| && currentLayout.outputBuses.size() == owner.getBusCount (false)); | && currentLayout.outputBuses.size() == owner.getBusCount (false)); | ||||
| return (actualBuses.getReference (busIdx) == set); | |||||
| return actualBuses.getReference (busIdx) == set; | |||||
| } | } | ||||
| bool AudioProcessor::Bus::isNumberOfChannelsSupported (int channels) const | bool AudioProcessor::Bus::isNumberOfChannelsSupported (int channels) const | ||||
| { | { | ||||
| if (channels == 0) return isLayoutSupported(AudioChannelSet::disabled()); | |||||
| if (channels == 0) | |||||
| return isLayoutSupported(AudioChannelSet::disabled()); | |||||
| const AudioChannelSet set = supportedLayoutWithChannels (channels); | |||||
| auto set = supportedLayoutWithChannels (channels); | |||||
| return (! set.isDisabled()) && isLayoutSupported (set); | return (! set.isDisabled()) && isLayoutSupported (set); | ||||
| } | } | ||||
| AudioChannelSet AudioProcessor::Bus::supportedLayoutWithChannels (int channels) const | AudioChannelSet AudioProcessor::Bus::supportedLayoutWithChannels (int channels) const | ||||
| { | { | ||||
| if (channels == 0) return AudioChannelSet::disabled(); | |||||
| if (channels == 0) | |||||
| return AudioChannelSet::disabled(); | |||||
| { | { | ||||
| AudioChannelSet set; | AudioChannelSet set; | ||||
| if (! (set = AudioChannelSet::namedChannelSet (channels)).isDisabled() && isLayoutSupported (set)) | if (! (set = AudioChannelSet::namedChannelSet (channels)).isDisabled() && isLayoutSupported (set)) | ||||
| return set; | return set; | ||||
| @@ -1262,16 +1264,9 @@ AudioChannelSet AudioProcessor::Bus::supportedLayoutWithChannels (int channels) | |||||
| return set; | return set; | ||||
| } | } | ||||
| Array<AudioChannelSet> sets = AudioChannelSet::channelSetsWithNumberOfChannels (channels); | |||||
| const int n = sets.size(); | |||||
| for (int i = 0; i < n; ++i) | |||||
| { | |||||
| const AudioChannelSet set = sets.getReference (i); | |||||
| for (auto& set : AudioChannelSet::channelSetsWithNumberOfChannels (channels)) | |||||
| if (isLayoutSupported (set)) | if (isLayoutSupported (set)) | ||||
| return set; | return set; | ||||
| } | |||||
| return AudioChannelSet::disabled(); | return AudioChannelSet::disabled(); | ||||
| } | } | ||||
| @@ -1282,7 +1277,7 @@ AudioProcessor::BusesLayout AudioProcessor::Bus::getBusesLayoutForLayoutChangeOf | |||||
| int busIdx; | int busIdx; | ||||
| busDirAndIndex (isInputBus, busIdx); | busDirAndIndex (isInputBus, busIdx); | ||||
| BusesLayout layouts = owner.getBusesLayout(); | |||||
| auto layouts = owner.getBusesLayout(); | |||||
| isLayoutSupported (set, &layouts); | isLayoutSupported (set, &layouts); | ||||
| return layouts; | return layouts; | ||||
| @@ -1321,9 +1316,8 @@ AudioProcessor::BusesProperties AudioProcessor::BusesProperties::withInput (con | |||||
| const AudioChannelSet& dfltLayout, | const AudioChannelSet& dfltLayout, | ||||
| bool isActivatedByDefault) const | bool isActivatedByDefault) const | ||||
| { | { | ||||
| BusesProperties retval (*this); | |||||
| auto retval = *this; | |||||
| retval.addBus (true, name, dfltLayout, isActivatedByDefault); | retval.addBus (true, name, dfltLayout, isActivatedByDefault); | ||||
| return retval; | return retval; | ||||
| } | } | ||||
| @@ -1331,9 +1325,8 @@ AudioProcessor::BusesProperties AudioProcessor::BusesProperties::withOutput (con | |||||
| const AudioChannelSet& dfltLayout, | const AudioChannelSet& dfltLayout, | ||||
| bool isActivatedByDefault) const | bool isActivatedByDefault) const | ||||
| { | { | ||||
| BusesProperties retval (*this); | |||||
| auto retval = *this; | |||||
| retval.addBus (false, name, dfltLayout, isActivatedByDefault); | retval.addBus (false, name, dfltLayout, isActivatedByDefault); | ||||
| return retval; | return retval; | ||||
| } | } | ||||
| @@ -1343,10 +1336,11 @@ int32 AudioProcessor::getAAXPluginIDForMainBusConfig (const AudioChannelSet& mai | |||||
| const bool idForAudioSuite) const | const bool idForAudioSuite) const | ||||
| { | { | ||||
| int uniqueFormatId = 0; | int uniqueFormatId = 0; | ||||
| for (int dir = 0; dir < 2; ++dir) | for (int dir = 0; dir < 2; ++dir) | ||||
| { | { | ||||
| const bool isInput = (dir == 0); | const bool isInput = (dir == 0); | ||||
| const AudioChannelSet& set = (isInput ? mainInputLayout : mainOutputLayout); | |||||
| auto& set = (isInput ? mainInputLayout : mainOutputLayout); | |||||
| int aaxFormatIndex = 0; | int aaxFormatIndex = 0; | ||||
| if (set == AudioChannelSet::disabled()) aaxFormatIndex = 0; | if (set == AudioChannelSet::disabled()) aaxFormatIndex = 0; | ||||
| @@ -1384,10 +1378,7 @@ void AudioProcessorListener::audioProcessorParameterChangeGestureBegin (AudioPro | |||||
| void AudioProcessorListener::audioProcessorParameterChangeGestureEnd (AudioProcessor*, int) {} | void AudioProcessorListener::audioProcessorParameterChangeGestureEnd (AudioProcessor*, int) {} | ||||
| //============================================================================== | //============================================================================== | ||||
| AudioProcessorParameter::AudioProcessorParameter() noexcept | |||||
| : processor (nullptr), parameterIndex (-1) | |||||
| {} | |||||
| AudioProcessorParameter::AudioProcessorParameter() noexcept {} | |||||
| AudioProcessorParameter::~AudioProcessorParameter() {} | AudioProcessorParameter::~AudioProcessorParameter() {} | ||||
| void AudioProcessorParameter::setValueNotifyingHost (float newValue) | void AudioProcessorParameter::setValueNotifyingHost (float newValue) | ||||
| @@ -31,17 +31,17 @@ struct PluginBusUtilities; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| Base class for audio processing filters or plugins. | |||||
| Base class for audio processing classes or plugins. | |||||
| This is intended to act as a base class of audio filter that is general enough to | |||||
| be wrapped as a VST, AU, RTAS, etc, or used internally. | |||||
| This is intended to act as a base class of audio processor that is general enough | |||||
| to be wrapped as a VST, AU, RTAS, etc, or used internally. | |||||
| It is also used by the plugin hosting code as the wrapper around an instance | It is also used by the plugin hosting code as the wrapper around an instance | ||||
| of a loaded plugin. | of a loaded plugin. | ||||
| Derive your filter class from this base class, and if you're building a plugin, | |||||
| you should implement a global function called createPluginFilter() which creates | |||||
| and returns a new instance of your subclass. | |||||
| You should derive your own class from this base class, and if you're building a | |||||
| plugin, you should implement a global function called createPluginFilter() which | |||||
| creates and returns a new instance of your subclass. | |||||
| */ | */ | ||||
| class JUCE_API AudioProcessor | class JUCE_API AudioProcessor | ||||
| { | { | ||||
| @@ -107,7 +107,7 @@ public: | |||||
| virtual StringArray getAlternateDisplayNames() const; | virtual StringArray getAlternateDisplayNames() const; | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Called before playback starts, to let the filter prepare itself. | |||||
| /** Called before playback starts, to let the processor prepare itself. | |||||
| The sample rate is the target sample rate, and will remain constant until | The sample rate is the target sample rate, and will remain constant until | ||||
| playback stops. | playback stops. | ||||
| @@ -128,7 +128,7 @@ public: | |||||
| virtual void prepareToPlay (double sampleRate, | virtual void prepareToPlay (double sampleRate, | ||||
| int maximumExpectedSamplesPerBlock) = 0; | int maximumExpectedSamplesPerBlock) = 0; | ||||
| /** Called after playback has stopped, to let the filter free up any resources it | |||||
| /** Called after playback has stopped, to let the object free up any resources it | |||||
| no longer needs. | no longer needs. | ||||
| */ | */ | ||||
| virtual void releaseResources() = 0; | virtual void releaseResources() = 0; | ||||
| @@ -137,16 +137,16 @@ public: | |||||
| When this method is called, the buffer contains a number of channels which is | When this method is called, the buffer contains a number of channels which is | ||||
| at least as great as the maximum number of input and output channels that | at least as great as the maximum number of input and output channels that | ||||
| this filter is using. It will be filled with the filter's input data and | |||||
| should be replaced with the filter's output. | |||||
| this processor is using. It will be filled with the processor's input data and | |||||
| should be replaced with the processor's output. | |||||
| So for example if your filter has a total of 2 input channels and 4 output | |||||
| So for example if your processor has a total of 2 input channels and 4 output | |||||
| channels, then the buffer will contain 4 channels, the first two being filled | channels, then the buffer will contain 4 channels, the first two being filled | ||||
| with the input data. Your filter should read these, do its processing, and | |||||
| with the input data. Your processor should read these, do its processing, and | |||||
| replace the contents of all 4 channels with its output. | replace the contents of all 4 channels with its output. | ||||
| Or if your filter has a total of 5 inputs and 2 outputs, the buffer will have 5 | |||||
| channels, all filled with data, and your filter should overwrite the first 2 of | |||||
| Or if your processor has a total of 5 inputs and 2 outputs, the buffer will have 5 | |||||
| channels, all filled with data, and your processor should overwrite the first 2 of | |||||
| these with its output. But be VERY careful not to write anything to the last 3 | these with its output. But be VERY careful not to write anything to the last 3 | ||||
| channels, as these might be mapped to memory that the host assumes is read-only! | channels, as these might be mapped to memory that the host assumes is read-only! | ||||
| @@ -162,7 +162,7 @@ public: | |||||
| let this pass through without being overwritten or cleared. | let this pass through without being overwritten or cleared. | ||||
| Also note that the buffer may have more channels than are strictly necessary, | Also note that the buffer may have more channels than are strictly necessary, | ||||
| but you should only read/write from the ones that your filter is supposed to | |||||
| but you should only read/write from the ones that your processor is supposed to | |||||
| be using. | be using. | ||||
| The number of samples in these buffers is NOT guaranteed to be the same for every | The number of samples in these buffers is NOT guaranteed to be the same for every | ||||
| @@ -173,12 +173,12 @@ public: | |||||
| Also note that some hosts will occasionally decide to pass a buffer containing | Also note that some hosts will occasionally decide to pass a buffer containing | ||||
| zero samples, so make sure that your algorithm can deal with that! | zero samples, so make sure that your algorithm can deal with that! | ||||
| If the filter is receiving a midi input, then the midiMessages array will be filled | |||||
| with the midi messages for this block. Each message's timestamp will indicate the | |||||
| If the processor is receiving a MIDI input, then the midiMessages array will be filled | |||||
| with the MIDI messages for this block. Each message's timestamp will indicate the | |||||
| message's time, as a number of samples from the start of the block. | message's time, as a number of samples from the start of the block. | ||||
| Any messages left in the midi buffer when this method has finished are assumed to | |||||
| be the filter's midi output. This means that your filter should be careful to | |||||
| Any messages left in the MIDI buffer when this method has finished are assumed to | |||||
| be the processor's MIDI output. This means that your processor should be careful to | |||||
| clear any incoming messages from the array if it doesn't want them to be passed-on. | clear any incoming messages from the array if it doesn't want them to be passed-on. | ||||
| Be very careful about what you do in this callback - it's going to be called by | Be very careful about what you do in this callback - it's going to be called by | ||||
| @@ -191,7 +191,6 @@ public: | |||||
| @see AudiobusLayout::getBusBuffer | @see AudiobusLayout::getBusBuffer | ||||
| */ | */ | ||||
| virtual void processBlock (AudioBuffer<float>& buffer, | virtual void processBlock (AudioBuffer<float>& buffer, | ||||
| MidiBuffer& midiMessages) = 0; | MidiBuffer& midiMessages) = 0; | ||||
| @@ -199,16 +198,16 @@ public: | |||||
| When this method is called, the buffer contains a number of channels which is | When this method is called, the buffer contains a number of channels which is | ||||
| at least as great as the maximum number of input and output channels that | at least as great as the maximum number of input and output channels that | ||||
| this filter is using. It will be filled with the filter's input data and | |||||
| should be replaced with the filter's output. | |||||
| this processor is using. It will be filled with the processor's input data and | |||||
| should be replaced with the processor's output. | |||||
| So for example if your filter has a combined total of 2 input channels and | |||||
| So for example if your processor has a combined total of 2 input channels and | |||||
| 4 output channels, then the buffer will contain 4 channels, the first two | 4 output channels, then the buffer will contain 4 channels, the first two | ||||
| being filled with the input data. Your filter should read these, do its | |||||
| being filled with the input data. Your processor should read these, do its | |||||
| processing, and replace the contents of all 4 channels with its output. | processing, and replace the contents of all 4 channels with its output. | ||||
| Or if your filter has 5 inputs and 2 outputs, the buffer will have 5 channels, | |||||
| all filled with data, and your filter should overwrite the first 2 of these | |||||
| Or if your processor has 5 inputs and 2 outputs, the buffer will have 5 channels, | |||||
| all filled with data, and your processor should overwrite the first 2 of these | |||||
| with its output. But be VERY careful not to write anything to the last 3 | with its output. But be VERY careful not to write anything to the last 3 | ||||
| channels, as these might be mapped to memory that the host assumes is read-only! | channels, as these might be mapped to memory that the host assumes is read-only! | ||||
| @@ -224,7 +223,7 @@ public: | |||||
| let this pass through without being overwritten or cleared. | let this pass through without being overwritten or cleared. | ||||
| Also note that the buffer may have more channels than are strictly necessary, | Also note that the buffer may have more channels than are strictly necessary, | ||||
| but you should only read/write from the ones that your filter is supposed to | |||||
| but you should only read/write from the ones that your processor is supposed to | |||||
| be using. | be using. | ||||
| If your plugin uses buses, then you should use AudiobusLayout::getBusBuffer() | If your plugin uses buses, then you should use AudiobusLayout::getBusBuffer() | ||||
| @@ -239,12 +238,12 @@ public: | |||||
| Also note that some hosts will occasionally decide to pass a buffer containing | Also note that some hosts will occasionally decide to pass a buffer containing | ||||
| zero samples, so make sure that your algorithm can deal with that! | zero samples, so make sure that your algorithm can deal with that! | ||||
| If the filter is receiving a midi input, then the midiMessages array will be filled | |||||
| with the midi messages for this block. Each message's timestamp will indicate the | |||||
| If the processor is receiving a MIDI input, then the midiMessages array will be filled | |||||
| with the MIDI messages for this block. Each message's timestamp will indicate the | |||||
| message's time, as a number of samples from the start of the block. | message's time, as a number of samples from the start of the block. | ||||
| Any messages left in the midi buffer when this method has finished are assumed to | |||||
| be the filter's midi output. This means that your filter should be careful to | |||||
| Any messages left in the MIDI buffer when this method has finished are assumed to | |||||
| be the processor's MIDI output. This means that your processor should be careful to | |||||
| clear any incoming messages from the array if it doesn't want them to be passed-on. | clear any incoming messages from the array if it doesn't want them to be passed-on. | ||||
| Be very careful about what you do in this callback - it's going to be called by | Be very careful about what you do in this callback - it's going to be called by | ||||
| @@ -300,12 +299,12 @@ public: | |||||
| /** Get the number of channels of a particular bus */ | /** Get the number of channels of a particular bus */ | ||||
| int getNumChannels (bool isInput, int busIndex) const noexcept | int getNumChannels (bool isInput, int busIndex) const noexcept | ||||
| { | { | ||||
| const Array<AudioChannelSet>& bus = (isInput ? inputBuses : outputBuses); | |||||
| auto& bus = (isInput ? inputBuses : outputBuses); | |||||
| return isPositiveAndBelow (busIndex, bus.size()) ? bus.getReference (busIndex).size() : 0; | return isPositiveAndBelow (busIndex, bus.size()) ? bus.getReference (busIndex).size() : 0; | ||||
| } | } | ||||
| /** Get the channel set of a particular bus */ | /** Get the channel set of a particular bus */ | ||||
| AudioChannelSet& getChannelSet (bool isInput, int busIndex) | |||||
| AudioChannelSet& getChannelSet (bool isInput, int busIndex) noexcept | |||||
| { | { | ||||
| return (isInput ? inputBuses : outputBuses).getReference (busIndex); | return (isInput ? inputBuses : outputBuses).getReference (busIndex); | ||||
| } | } | ||||
| @@ -363,7 +362,6 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** The bus's current layout. This will be AudioChannelSet::disabled() if the current | /** The bus's current layout. This will be AudioChannelSet::disabled() if the current | ||||
| layout is dfisabled. | layout is dfisabled. | ||||
| @see AudioChannelSet | @see AudioChannelSet | ||||
| */ | */ | ||||
| const AudioChannelSet& getCurrentLayout() const noexcept { return layout; } | const AudioChannelSet& getCurrentLayout() const noexcept { return layout; } | ||||
| @@ -371,7 +369,6 @@ public: | |||||
| /** Return the bus's last active channel layout. | /** Return the bus's last active channel layout. | ||||
| If the bus is currently enabled then the result will be identical to getCurrentLayout | If the bus is currently enabled then the result will be identical to getCurrentLayout | ||||
| otherwise it will return the last enabled layout. | otherwise it will return the last enabled layout. | ||||
| @see AudioChannelSet | @see AudioChannelSet | ||||
| */ | */ | ||||
| const AudioChannelSet& getLastEnabledLayout() const noexcept { return lastLayout; } | const AudioChannelSet& getLastEnabledLayout() const noexcept { return lastLayout; } | ||||
| @@ -383,9 +380,7 @@ public: | |||||
| bool setCurrentLayout (const AudioChannelSet& layout); | bool setCurrentLayout (const AudioChannelSet& layout); | ||||
| /** Sets the bus's current layout without changing the enabled state. | /** Sets the bus's current layout without changing the enabled state. | ||||
| If the AudioProcessor does not support this layout then this will return false. | If the AudioProcessor does not support this layout then this will return false. | ||||
| @see AudioChannelSet | @see AudioChannelSet | ||||
| */ | */ | ||||
| bool setCurrentLayoutWithoutEnabling (const AudioChannelSet& layout); | bool setCurrentLayoutWithoutEnabling (const AudioChannelSet& layout); | ||||
| @@ -485,13 +480,11 @@ public: | |||||
| int getBusCount (bool isInput) const noexcept { return (isInput ? inputBuses : outputBuses).size(); } | int getBusCount (bool isInput) const noexcept { return (isInput ? inputBuses : outputBuses).size(); } | ||||
| /** Returns the audio bus with a given index and direction. | /** Returns the audio bus with a given index and direction. | ||||
| If busIdx is invalid then this method will return a nullptr. | If busIdx is invalid then this method will return a nullptr. | ||||
| */ | */ | ||||
| Bus* getBus (bool isInput, int busIdx) noexcept { return (isInput ? inputBuses : outputBuses)[busIdx]; } | Bus* getBus (bool isInput, int busIdx) noexcept { return (isInput ? inputBuses : outputBuses)[busIdx]; } | ||||
| /** Returns the audio bus with a given index and direction. | /** Returns the audio bus with a given index and direction. | ||||
| If busIdx is invalid then this method will return a nullptr. | If busIdx is invalid then this method will return a nullptr. | ||||
| */ | */ | ||||
| const Bus* getBus (bool isInput, int busIdx) const noexcept { return const_cast<AudioProcessor*> (this)->getBus (isInput, busIdx); } | const Bus* getBus (bool isInput, int busIdx) const noexcept { return const_cast<AudioProcessor*> (this)->getBus (isInput, busIdx); } | ||||
| @@ -800,34 +793,34 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** This returns the number of samples delay that the filter imposes on the audio | |||||
| /** This returns the number of samples delay that the processor imposes on the audio | |||||
| passing through it. | passing through it. | ||||
| The host will call this to find the latency - the filter itself should set this value | |||||
| The host will call this to find the latency - the processor itself should set this value | |||||
| by calling setLatencySamples() as soon as it can during its initialisation. | by calling setLatencySamples() as soon as it can during its initialisation. | ||||
| */ | */ | ||||
| int getLatencySamples() const noexcept { return latencySamples; } | int getLatencySamples() const noexcept { return latencySamples; } | ||||
| /** The filter should call this to set the number of samples delay that it introduces. | |||||
| /** Your processor subclass should call this to set the number of samples delay that it introduces. | |||||
| The filter should call this as soon as it can during initialisation, and can call it | |||||
| The processor should call this as soon as it can during initialisation, and can call it | |||||
| later if the value changes. | later if the value changes. | ||||
| */ | */ | ||||
| void setLatencySamples (int newLatency); | void setLatencySamples (int newLatency); | ||||
| /** Returns the length of the filter's tail, in seconds. */ | |||||
| /** Returns the length of the processor's tail, in seconds. */ | |||||
| virtual double getTailLengthSeconds() const = 0; | virtual double getTailLengthSeconds() const = 0; | ||||
| /** Returns true if the processor wants midi messages. */ | |||||
| /** Returns true if the processor wants MIDI messages. */ | |||||
| virtual bool acceptsMidi() const = 0; | virtual bool acceptsMidi() const = 0; | ||||
| /** Returns true if the processor produces midi messages. */ | |||||
| /** Returns true if the processor produces MIDI messages. */ | |||||
| virtual bool producesMidi() const = 0; | virtual bool producesMidi() const = 0; | ||||
| /** Returns true if the processor supports MPE. */ | /** Returns true if the processor supports MPE. */ | ||||
| virtual bool supportsMPE() const { return false; } | virtual bool supportsMPE() const { return false; } | ||||
| /** Returns true if this is a midi effect plug-in and does no audio processing. */ | |||||
| /** Returns true if this is a MIDI effect plug-in and does no audio processing. */ | |||||
| virtual bool isMidiEffect() const { return false; } | virtual bool isMidiEffect() const { return false; } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -863,7 +856,7 @@ public: | |||||
| @endcode | @endcode | ||||
| If the host tries to make an audio callback while processing is suspended, the | If the host tries to make an audio callback while processing is suspended, the | ||||
| filter will return an empty buffer, but won't block the audio thread like it would | |||||
| processor will return an empty buffer, but won't block the audio thread like it would | |||||
| do if you use the getCallbackLock() critical section to synchronise access. | do if you use the getCallbackLock() critical section to synchronise access. | ||||
| Any code that calls processBlock() should call isSuspended() before doing so, and | Any code that calls processBlock() should call isSuspended() before doing so, and | ||||
| @@ -905,36 +898,37 @@ public: | |||||
| virtual void setNonRealtime (bool isNonRealtime) noexcept; | virtual void setNonRealtime (bool isNonRealtime) noexcept; | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates the filter's UI. | |||||
| /** Creates the processor's GUI. | |||||
| This can return nullptr if you want a UI-less filter, in which case the host may create | |||||
| a generic UI that lets the user twiddle the parameters directly. | |||||
| This can return nullptr if you want a GUI-less processor, in which case the host | |||||
| may create a generic UI that lets the user twiddle the parameters directly. | |||||
| If you do want to pass back a component, the component should be created and set to | If you do want to pass back a component, the component should be created and set to | ||||
| the correct size before returning it. If you implement this method, you must | the correct size before returning it. If you implement this method, you must | ||||
| also implement the hasEditor() method and make it return true. | also implement the hasEditor() method and make it return true. | ||||
| Remember not to do anything silly like allowing your filter to keep a pointer to | |||||
| Remember not to do anything silly like allowing your processor to keep a pointer to | |||||
| the component that gets created - it could be deleted later without any warning, which | the component that gets created - it could be deleted later without any warning, which | ||||
| would make your pointer into a dangler. Use the getActiveEditor() method instead. | would make your pointer into a dangler. Use the getActiveEditor() method instead. | ||||
| The correct way to handle the connection between an editor component and its | The correct way to handle the connection between an editor component and its | ||||
| filter is to use something like a ChangeBroadcaster so that the editor can | |||||
| processor is to use something like a ChangeBroadcaster so that the editor can | |||||
| register itself as a listener, and be told when a change occurs. This lets them | register itself as a listener, and be told when a change occurs. This lets them | ||||
| safely unregister themselves when they are deleted. | safely unregister themselves when they are deleted. | ||||
| Here are a few things to bear in mind when writing an editor: | Here are a few things to bear in mind when writing an editor: | ||||
| - Initially there won't be an editor, until the user opens one, or they might | - Initially there won't be an editor, until the user opens one, or they might | ||||
| not open one at all. Your filter mustn't rely on it being there. | |||||
| not open one at all. Your processor mustn't rely on it being there. | |||||
| - An editor object may be deleted and a replacement one created again at any time. | - An editor object may be deleted and a replacement one created again at any time. | ||||
| - It's safe to assume that an editor will be deleted before its filter. | |||||
| - It's safe to assume that an editor will be deleted before its processor. | |||||
| @see hasEditor | @see hasEditor | ||||
| */ | */ | ||||
| virtual AudioProcessorEditor* createEditor() = 0; | virtual AudioProcessorEditor* createEditor() = 0; | ||||
| /** Your filter must override this and return true if it can create an editor component. | |||||
| /** Your processor subclass must override this and return true if it can create an | |||||
| editor component. | |||||
| @see createEditor | @see createEditor | ||||
| */ | */ | ||||
| virtual bool hasEditor() const = 0; | virtual bool hasEditor() const = 0; | ||||
| @@ -977,7 +971,7 @@ public: | |||||
| */ | */ | ||||
| virtual String getParameterID (int index); | virtual String getParameterID (int index); | ||||
| /** Called by the host to find out the value of one of the filter's parameters. | |||||
| /** Called by the host to find out the value of one of the processor's parameters. | |||||
| The host will expect the value returned to be between 0 and 1.0. | The host will expect the value returned to be between 0 and 1.0. | ||||
| @@ -1089,10 +1083,10 @@ public: | |||||
| */ | */ | ||||
| virtual bool isParameterOrientationInverted (int index) const; | virtual bool isParameterOrientationInverted (int index) const; | ||||
| /** The host will call this method to change the value of one of the filter's parameters. | |||||
| /** The host will call this method to change the value of one of the processor's parameters. | |||||
| The host may call this at any time, including during the audio processing | The host may call this at any time, including during the audio processing | ||||
| callback, so the filter has to process this very fast and avoid blocking. | |||||
| callback, so the processor has to process this very fast and avoid blocking. | |||||
| If you want to set the value of a parameter internally, e.g. from your | If you want to set the value of a parameter internally, e.g. from your | ||||
| editor component, then don't call this directly - instead, use the | editor component, then don't call this directly - instead, use the | ||||
| @@ -1107,7 +1101,7 @@ public: | |||||
| */ | */ | ||||
| virtual void setParameter (int parameterIndex, float newValue); | virtual void setParameter (int parameterIndex, float newValue); | ||||
| /** Your filter can call this when it needs to change one of its parameters. | |||||
| /** Your processor can call this when it needs to change one of its parameters. | |||||
| This could happen when the editor or some other internal operation changes | This could happen when the editor or some other internal operation changes | ||||
| a parameter. This method will call the setParameter() method to change the | a parameter. This method will call the setParameter() method to change the | ||||
| @@ -1173,7 +1167,7 @@ public: | |||||
| */ | */ | ||||
| void endParameterChangeGesture (int parameterIndex); | void endParameterChangeGesture (int parameterIndex); | ||||
| /** The filter can call this when something (apart from a parameter value) has changed. | |||||
| /** The processor can call this when something (apart from a parameter value) has changed. | |||||
| It sends a hint to the host that something like the program, number of parameters, | It sends a hint to the host that something like the program, number of parameters, | ||||
| etc, has changed, and that it should update itself. | etc, has changed, and that it should update itself. | ||||
| @@ -1191,7 +1185,7 @@ public: | |||||
| const OwnedArray<AudioProcessorParameter>& getParameters() const noexcept; | const OwnedArray<AudioProcessorParameter>& getParameters() const noexcept; | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the number of preset programs the filter supports. | |||||
| /** Returns the number of preset programs the processor supports. | |||||
| The value returned must be valid as soon as this object is created, and | The value returned must be valid as soon as this object is created, and | ||||
| must not change over its lifetime. | must not change over its lifetime. | ||||
| @@ -1213,13 +1207,13 @@ public: | |||||
| virtual void changeProgramName (int index, const String& newName) = 0; | virtual void changeProgramName (int index, const String& newName) = 0; | ||||
| //============================================================================== | //============================================================================== | ||||
| /** The host will call this method when it wants to save the filter's internal state. | |||||
| /** The host will call this method when it wants to save the processor's internal state. | |||||
| This must copy any info about the filter's state into the block of memory provided, | |||||
| This must copy any info about the processor's state into the block of memory provided, | |||||
| so that the host can store this and later restore it using setStateInformation(). | so that the host can store this and later restore it using setStateInformation(). | ||||
| Note that there's also a getCurrentProgramStateInformation() method, which only | Note that there's also a getCurrentProgramStateInformation() method, which only | ||||
| stores the current program, not the state of the entire filter. | |||||
| stores the current program, not the state of the entire processor. | |||||
| See also the helper function copyXmlToBinary() for storing settings as XML. | See also the helper function copyXmlToBinary() for storing settings as XML. | ||||
| @@ -1227,7 +1221,7 @@ public: | |||||
| */ | */ | ||||
| virtual void getStateInformation (juce::MemoryBlock& destData) = 0; | virtual void getStateInformation (juce::MemoryBlock& destData) = 0; | ||||
| /** The host will call this method if it wants to save the state of just the filter's | |||||
| /** The host will call this method if it wants to save the state of just the processor's | |||||
| current program. | current program. | ||||
| Unlike getStateInformation, this should only return the current program's state. | Unlike getStateInformation, this should only return the current program's state. | ||||
| @@ -1240,11 +1234,11 @@ public: | |||||
| */ | */ | ||||
| virtual void getCurrentProgramStateInformation (juce::MemoryBlock& destData); | virtual void getCurrentProgramStateInformation (juce::MemoryBlock& destData); | ||||
| /** This must restore the filter's state from a block of data previously created | |||||
| /** This must restore the processor's state from a block of data previously created | |||||
| using getStateInformation(). | using getStateInformation(). | ||||
| Note that there's also a setCurrentProgramStateInformation() method, which tries | Note that there's also a setCurrentProgramStateInformation() method, which tries | ||||
| to restore just the current program, not the state of the entire filter. | |||||
| to restore just the current program, not the state of the entire processor. | |||||
| See also the helper function getXmlFromBinary() for loading settings as XML. | See also the helper function getXmlFromBinary() for loading settings as XML. | ||||
| @@ -1252,7 +1246,7 @@ public: | |||||
| */ | */ | ||||
| virtual void setStateInformation (const void* data, int sizeInBytes) = 0; | virtual void setStateInformation (const void* data, int sizeInBytes) = 0; | ||||
| /** The host will call this method if it wants to restore the state of just the filter's | |||||
| /** The host will call this method if it wants to restore the state of just the processor's | |||||
| current program. | current program. | ||||
| Not all hosts support this, and if you don't implement it, the base class | Not all hosts support this, and if you don't implement it, the base class | ||||
| @@ -1395,7 +1389,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Helper function that just converts an xml element into a binary blob. | /** Helper function that just converts an xml element into a binary blob. | ||||
| Use this in your filter's getStateInformation() method if you want to | |||||
| Use this in your processor's getStateInformation() method if you want to | |||||
| store its state as xml. | store its state as xml. | ||||
| Then use getXmlFromBinary() to reverse this operation and retrieve the XML | Then use getXmlFromBinary() to reverse this operation and retrieve the XML | ||||
| @@ -51,10 +51,11 @@ public: | |||||
| */ | */ | ||||
| virtual float getValue() const = 0; | virtual float getValue() const = 0; | ||||
| /** The host will call this method to change the value of one of the filter's parameters. | |||||
| /** The host will call this method to change the value of a parameter. | |||||
| The host may call this at any time, including during the audio processing | The host may call this at any time, including during the audio processing | ||||
| callback, so the filter has to process this very fast and avoid blocking. | |||||
| callback, so your implementation has to process this very efficiently and | |||||
| avoid any kind of locking. | |||||
| If you want to set the value of a parameter internally, e.g. from your | If you want to set the value of a parameter internally, e.g. from your | ||||
| editor component, then don't call this directly - instead, use the | editor component, then don't call this directly - instead, use the | ||||
| @@ -66,7 +67,7 @@ public: | |||||
| */ | */ | ||||
| virtual void setValue (float newValue) = 0; | virtual void setValue (float newValue) = 0; | ||||
| /** Your filter can call this when it needs to change one of its parameters. | |||||
| /** A processor should call this when it needs to change one of its parameters. | |||||
| This could happen when the editor or some other internal operation changes | This could happen when the editor or some other internal operation changes | ||||
| a parameter. This method will call the setValue() method to change the | a parameter. This method will call the setValue() method to change the | ||||
| @@ -188,8 +189,8 @@ public: | |||||
| private: | private: | ||||
| friend class AudioProcessor; | friend class AudioProcessor; | ||||
| AudioProcessor* processor; | |||||
| int parameterIndex; | |||||
| AudioProcessor* processor = nullptr; | |||||
| int parameterIndex = -1; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorParameter) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorParameter) | ||||
| }; | }; | ||||
| @@ -478,7 +478,7 @@ namespace NumberToStringConverters | |||||
| { | { | ||||
| auto* end = buffer + numChars; | auto* end = buffer + numChars; | ||||
| auto* t = end; | auto* t = end; | ||||
| auto v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5); | |||||
| auto v = (int64) (std::pow (10.0, numDecPlaces) * std::abs (n) + 0.5); | |||||
| *--t = (char) 0; | *--t = (char) 0; | ||||
| while (numDecPlaces >= 0 || v > 0) | while (numDecPlaces >= 0 || v > 0) | ||||
| @@ -27,9 +27,9 @@ | |||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| ImageConvolutionKernel::ImageConvolutionKernel (const int size_) | |||||
| : values ((size_t) (size_ * size_)), | |||||
| size (size_) | |||||
| ImageConvolutionKernel::ImageConvolutionKernel (int sizeToUse) | |||||
| : values ((size_t) (sizeToUse * sizeToUse)), | |||||
| size (sizeToUse) | |||||
| { | { | ||||
| clear(); | clear(); | ||||
| } | } | ||||
| @@ -92,10 +92,10 @@ void ImageConvolutionKernel::createGaussianBlur (const float radius) | |||||
| { | { | ||||
| for (int x = size; --x >= 0;) | for (int x = size; --x >= 0;) | ||||
| { | { | ||||
| const int cx = x - centre; | |||||
| const int cy = y - centre; | |||||
| auto cx = x - centre; | |||||
| auto cy = y - centre; | |||||
| values [x + y * size] = (float) exp (radiusFactor * (cx * cx + cy * cy)); | |||||
| values [x + y * size] = (float) std::exp (radiusFactor * (cx * cx + cy * cy)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -122,13 +122,13 @@ void ImageConvolutionKernel::applyToImage (Image& destImage, | |||||
| } | } | ||||
| } | } | ||||
| const Rectangle<int> area (destinationArea.getIntersection (destImage.getBounds())); | |||||
| auto area = destinationArea.getIntersection (destImage.getBounds()); | |||||
| if (area.isEmpty()) | if (area.isEmpty()) | ||||
| return; | return; | ||||
| const int right = area.getRight(); | |||||
| const int bottom = area.getBottom(); | |||||
| auto right = area.getRight(); | |||||
| auto bottom = area.getBottom(); | |||||
| const Image::BitmapData destData (destImage, area.getX(), area.getY(), area.getWidth(), area.getHeight(), | const Image::BitmapData destData (destImage, area.getX(), area.getY(), area.getWidth(), area.getHeight(), | ||||
| Image::BitmapData::writeOnly); | Image::BitmapData::writeOnly); | ||||
| @@ -582,8 +582,8 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con | |||||
| { | { | ||||
| if (dragType == notDragging) | if (dragType == notDragging) | ||||
| { | { | ||||
| if (abs (caretPos.getPosition() - selectionStart.getPosition()) | |||||
| < abs (caretPos.getPosition() - selectionEnd.getPosition())) | |||||
| if (std::abs (caretPos.getPosition() - selectionStart.getPosition()) | |||||
| < std::abs (caretPos.getPosition() - selectionEnd.getPosition())) | |||||
| dragType = draggingSelectionStart; | dragType = draggingSelectionStart; | ||||
| else | else | ||||
| dragType = draggingSelectionEnd; | dragType = draggingSelectionEnd; | ||||
| @@ -595,7 +595,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con | |||||
| if (selectionEnd.getPosition() < selectionStart.getPosition()) | if (selectionEnd.getPosition() < selectionStart.getPosition()) | ||||
| { | { | ||||
| const CodeDocument::Position temp (selectionStart); | |||||
| auto temp = selectionStart; | |||||
| selectionStart = selectionEnd; | selectionStart = selectionEnd; | ||||
| selectionEnd = temp; | selectionEnd = temp; | ||||
| @@ -608,7 +608,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con | |||||
| if (selectionEnd.getPosition() < selectionStart.getPosition()) | if (selectionEnd.getPosition() < selectionStart.getPosition()) | ||||
| { | { | ||||
| const CodeDocument::Position temp (selectionStart); | |||||
| auto temp = selectionStart; | |||||
| selectionStart = selectionEnd; | selectionStart = selectionEnd; | ||||
| selectionEnd = temp; | selectionEnd = temp; | ||||