| @@ -999,7 +999,7 @@ String MidiMessage::getMidiNoteName (int note, bool useSharps, bool includeOctav | |||
| 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 | |||
| @@ -672,7 +672,7 @@ private: | |||
| float* table = muls[k]; | |||
| 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; | |||
| } | |||
| } | |||
| @@ -681,10 +681,10 @@ private: | |||
| { | |||
| int i, j; | |||
| 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) | |||
| 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) | |||
| { | |||
| @@ -737,12 +737,12 @@ private: | |||
| 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) | |||
| p1 = pow (base, (i + 1) * 0.5); | |||
| p1 = std::pow (base, (i + 1) * 0.5); | |||
| else | |||
| p2 = pow (base, i * 0.5); | |||
| p2 = std::pow (base, i * 0.5); | |||
| } | |||
| pow1_1[j][i] = (float) p1; | |||
| @@ -274,14 +274,14 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||
| 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) | |||
| { | |||
| const int numThisTime = (int) jmin (abs64 (numSamplesToSearch), (int64) bufferSize); | |||
| auto numThisTime = (int) jmin (abs64 (numSamplesToSearch), (int64) bufferSize); | |||
| int64 bufferStart = startSample; | |||
| if (numSamplesToSearch < 0) | |||
| @@ -291,15 +291,15 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||
| break; | |||
| read (tempBuffer, 2, bufferStart, numThisTime, false); | |||
| auto num = numThisTime; | |||
| int num = numThisTime; | |||
| while (--num >= 0) | |||
| { | |||
| if (numSamplesToSearch < 0) | |||
| --startSample; | |||
| bool matches = false; | |||
| const int index = (int) (startSample - bufferStart); | |||
| auto index = (int) (startSample - bufferStart); | |||
| if (usesFloatingPointData) | |||
| { | |||
| @@ -320,7 +320,7 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||
| } | |||
| else | |||
| { | |||
| const int sample1 = abs (tempBuffer[0] [index]); | |||
| const int sample1 = std::abs (tempBuffer[0] [index]); | |||
| if (sample1 >= intMagnitudeRangeMinimum | |||
| && sample1 <= intMagnitudeRangeMaximum) | |||
| @@ -329,7 +329,7 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||
| } | |||
| else if (numChannels > 1) | |||
| { | |||
| const int sample2 = abs (tempBuffer[1][index]); | |||
| const int sample2 = std::abs (tempBuffer[1][index]); | |||
| matches = (sample2 >= intMagnitudeRangeMinimum | |||
| && sample2 <= intMagnitudeRangeMaximum); | |||
| @@ -30,23 +30,16 @@ namespace juce | |||
| SamplerSound::SamplerSound (const String& soundName, | |||
| AudioFormatReader& source, | |||
| 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), | |||
| sourceSampleRate (source.sampleRate), | |||
| midiNotes (notes), | |||
| 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, | |||
| (int) (maxSampleLengthSeconds * sourceSampleRate)); | |||
| @@ -55,7 +48,7 @@ SamplerSound::SamplerSound (const String& soundName, | |||
| source.read (data, 0, length + 4, 0, true, true); | |||
| attackSamples = roundToInt (attackTimeSecs * sourceSampleRate); | |||
| attackSamples = roundToInt (attackTimeSecs * sourceSampleRate); | |||
| releaseSamples = roundToInt (releaseTimeSecs * sourceSampleRate); | |||
| } | |||
| } | |||
| @@ -66,7 +59,7 @@ SamplerSound::~SamplerSound() | |||
| bool SamplerSound::appliesToNote (int midiNoteNumber) | |||
| { | |||
| return midiNotes [midiNoteNumber]; | |||
| return midiNotes[midiNoteNumber]; | |||
| } | |||
| 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) | |||
| { | |||
| 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(); | |||
| 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) | |||
| { | |||
| 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* outR = outputBuffer.getNumChannels() > 1 ? outputBuffer.getWritePointer (1, startSample) : nullptr; | |||
| 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.. | |||
| 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 *= lgain; | |||
| @@ -95,8 +95,8 @@ private: | |||
| ScopedPointer<AudioSampleBuffer> data; | |||
| double sourceSampleRate; | |||
| BigInteger midiNotes; | |||
| int length, attackSamples, releaseSamples; | |||
| int midiRootNote; | |||
| int length = 0, attackSamples = 0, releaseSamples = 0; | |||
| int midiRootNote = 0; | |||
| JUCE_LEAK_DETECTOR (SamplerSound) | |||
| }; | |||
| @@ -135,10 +135,10 @@ public: | |||
| 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) | |||
| }; | |||
| @@ -2417,7 +2417,7 @@ private: | |||
| || ((w == 0 && rw > 0) || (h == 0 && rh > 0))) | |||
| { | |||
| // 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, | |||
| 0, 0, rw, rh, | |||
| @@ -281,26 +281,27 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||
| { | |||
| 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) | |||
| { | |||
| 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 | |||
| if (original == requested) | |||
| continue; | |||
| currentState = bestSupported; | |||
| AudioChannelSet& current = currentLayouts .getReference (busIdx); | |||
| auto& current = currentLayouts .getReference (busIdx); | |||
| // already supported? | |||
| current = requested; | |||
| if (checkBusesLayoutSupported (currentState)) | |||
| { | |||
| bestSupported = currentState; | |||
| @@ -309,9 +310,10 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||
| // try setting the opposite bus to the identical layout | |||
| const bool oppositeDirection = ! isInput; | |||
| if (getBusCount (oppositeDirection) > busIdx) | |||
| { | |||
| AudioChannelSet& oppositeLayout = (oppositeDirection ? currentState.inputBuses : currentState.outputBuses).getReference (busIdx); | |||
| auto& oppositeLayout = (oppositeDirection ? currentState.inputBuses : currentState.outputBuses).getReference (busIdx); | |||
| oppositeLayout = requested; | |||
| if (checkBusesLayoutSupported (currentState)) | |||
| @@ -322,6 +324,7 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||
| // try setting the default layout | |||
| oppositeLayout = getBus (oppositeDirection, busIdx)->getDefaultLayout(); | |||
| if (checkBusesLayoutSupported (currentState)) | |||
| { | |||
| bestSupported = currentState; | |||
| @@ -331,10 +334,11 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL | |||
| // try setting all other buses to the identical layout | |||
| BusesLayout allTheSame; | |||
| 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) | |||
| (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? | |||
| 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; | |||
| if (checkBusesLayoutSupported (currentState)) | |||
| bestSupported = currentState; | |||
| } | |||
| @@ -414,8 +419,8 @@ static int countTotalChannels (const OwnedArray<AudioProcessor::Bus>& buses) noe | |||
| { | |||
| int n = 0; | |||
| for (int i = 0; i < buses.size(); ++i) | |||
| n += buses[i]->getNumberOfChannels(); | |||
| for (auto* bus : buses) | |||
| n += bus->getNumberOfChannels(); | |||
| return n; | |||
| } | |||
| @@ -426,7 +431,7 @@ void AudioProcessor::processorLayoutsChanged() {} | |||
| 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())); | |||
| 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 | |||
| { | |||
| const int n = getBusCount (isInput); | |||
| auto numBuses = getBusCount (isInput); | |||
| 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; | |||
| 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); | |||
| sendParamChangeMessageToListeners (parameterIndex, newValue); | |||
| } | |||
| AudioProcessorListener* AudioProcessor::getListenerLocked (const int index) const noexcept | |||
| AudioProcessorListener* AudioProcessor::getListenerLocked (int index) const noexcept | |||
| { | |||
| const ScopedLock sl (listenerLock); | |||
| return listeners [index]; | |||
| } | |||
| void AudioProcessor::sendParamChangeMessageToListeners (const int parameterIndex, const float newValue) | |||
| void AudioProcessor::sendParamChangeMessageToListeners (int parameterIndex, float newValue) | |||
| { | |||
| if (isPositiveAndBelow (parameterIndex, getNumParameters())) | |||
| { | |||
| @@ -522,7 +526,7 @@ void AudioProcessor::endParameterChangeGesture (int parameterIndex) | |||
| #endif | |||
| for (int i = listeners.size(); --i >= 0;) | |||
| if (AudioProcessorListener* l = getListenerLocked (i)) | |||
| if (auto* l = getListenerLocked (i)) | |||
| l->audioProcessorParameterChangeGestureEnd (this, parameterIndex); | |||
| } | |||
| else | |||
| @@ -534,7 +538,7 @@ void AudioProcessor::endParameterChangeGesture (int parameterIndex) | |||
| void AudioProcessor::updateHostDisplay() | |||
| { | |||
| for (int i = listeners.size(); --i >= 0;) | |||
| if (AudioProcessorListener* l = getListenerLocked (i)) | |||
| if (auto* l = getListenerLocked (i)) | |||
| l->audioProcessorChanged (this); | |||
| } | |||
| @@ -795,7 +799,7 @@ AudioProcessor::BusesProperties AudioProcessor::busesPropertiesFromLayoutArray ( | |||
| AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const BusesLayout& layouts, | |||
| const Array<InOutChannelPair>& legacyLayouts) const | |||
| { | |||
| const int numChannelConfigs = legacyLayouts.size(); | |||
| auto numChannelConfigs = legacyLayouts.size(); | |||
| jassert (numChannelConfigs > 0); | |||
| 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.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; | |||
| 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) | |||
| { | |||
| @@ -845,17 +849,17 @@ AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const Buses | |||
| bestConfiguration = i; | |||
| // 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) | |||
| { | |||
| @@ -890,7 +894,7 @@ bool AudioProcessor::containsLayout (const BusesLayout& layouts, const Array<InO | |||
| //============================================================================== | |||
| bool AudioProcessor::disableNonMainBuses() | |||
| { | |||
| BusesLayout layouts = getBusesLayout(); | |||
| auto layouts = getBusesLayout(); | |||
| for (int busIdx = 1; busIdx < layouts.inputBuses.size(); ++busIdx) | |||
| layouts.inputBuses.getReference (busIdx) = AudioChannelSet::disabled(); | |||
| @@ -921,11 +925,11 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||
| if (layouts == getBusesLayout()) | |||
| 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 | |||
| || layouts.outputBuses.size() != numOutputBuses) | |||
| @@ -935,10 +939,10 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||
| 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; | |||
| if (! set.isDisabled()) | |||
| bus.lastLayout = set; | |||
| @@ -947,10 +951,10 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||
| 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; | |||
| if (! set.isDisabled()) | |||
| bus.lastLayout = set; | |||
| @@ -965,19 +969,17 @@ bool AudioProcessor::applyBusLayouts (const BusesLayout& layouts) | |||
| 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) | |||
| { | |||
| 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(); | |||
| } | |||
| } | |||
| cachedTotalIns = countTotalChannels (inputBuses); | |||
| @@ -1008,7 +1010,7 @@ AudioProcessorEditor* AudioProcessor::createEditorIfNeeded() | |||
| if (activeEditor != nullptr) | |||
| return activeEditor; | |||
| AudioProcessorEditor* const ed = createEditor(); | |||
| auto* ed = createEditor(); | |||
| if (ed != nullptr) | |||
| { | |||
| @@ -1063,7 +1065,7 @@ XmlElement* AudioProcessor::getXmlFromBinary (const void* data, const int sizeIn | |||
| if (sizeInBytes > 8 | |||
| && ByteOrder::littleEndianInt (data) == magicXmlNumber) | |||
| { | |||
| const int stringLength = (int) ByteOrder::littleEndianInt (addBytesToPointer (data, 4)); | |||
| auto stringLength = (int) ByteOrder::littleEndianInt (addBytesToPointer (data, 4)); | |||
| if (stringLength > 0) | |||
| 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 && ! 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!! | |||
| if (num == 0) return false; | |||
| if (num == 0) | |||
| return false; | |||
| if (isAdding) | |||
| { | |||
| @@ -1096,7 +1099,7 @@ bool AudioProcessor::canApplyBusCountChange (bool isInput, bool isAdding, | |||
| //============================================================================== | |||
| AudioProcessor::Bus::Bus (AudioProcessor& processor, const String& busName, | |||
| const AudioChannelSet& defaultLayout, bool isDfltEnabled) | |||
| const AudioChannelSet& defaultLayout, bool isDfltEnabled) | |||
| : owner (processor), name (busName), | |||
| layout (isDfltEnabled ? defaultLayout : AudioChannelSet()), | |||
| dfltLayout (defaultLayout), lastLayout (defaultLayout), | |||
| @@ -1220,13 +1223,9 @@ bool AudioProcessor::Bus::isLayoutSupported (const AudioChannelSet& set, BusesLa | |||
| if (actualBuses.getReference (busIdx) == set) | |||
| 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); | |||
| @@ -1238,23 +1237,26 @@ bool AudioProcessor::Bus::isLayoutSupported (const AudioChannelSet& set, BusesLa | |||
| jassert (currentLayout.inputBuses. size() == owner.getBusCount (true) | |||
| && currentLayout.outputBuses.size() == owner.getBusCount (false)); | |||
| return (actualBuses.getReference (busIdx) == set); | |||
| return actualBuses.getReference (busIdx) == set; | |||
| } | |||
| 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); | |||
| } | |||
| AudioChannelSet AudioProcessor::Bus::supportedLayoutWithChannels (int channels) const | |||
| { | |||
| if (channels == 0) return AudioChannelSet::disabled(); | |||
| if (channels == 0) | |||
| return AudioChannelSet::disabled(); | |||
| { | |||
| AudioChannelSet set; | |||
| if (! (set = AudioChannelSet::namedChannelSet (channels)).isDisabled() && isLayoutSupported (set)) | |||
| return set; | |||
| @@ -1262,16 +1264,9 @@ AudioChannelSet AudioProcessor::Bus::supportedLayoutWithChannels (int channels) | |||
| 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)) | |||
| return set; | |||
| } | |||
| return AudioChannelSet::disabled(); | |||
| } | |||
| @@ -1282,7 +1277,7 @@ AudioProcessor::BusesLayout AudioProcessor::Bus::getBusesLayoutForLayoutChangeOf | |||
| int busIdx; | |||
| busDirAndIndex (isInputBus, busIdx); | |||
| BusesLayout layouts = owner.getBusesLayout(); | |||
| auto layouts = owner.getBusesLayout(); | |||
| isLayoutSupported (set, &layouts); | |||
| return layouts; | |||
| @@ -1321,9 +1316,8 @@ AudioProcessor::BusesProperties AudioProcessor::BusesProperties::withInput (con | |||
| const AudioChannelSet& dfltLayout, | |||
| bool isActivatedByDefault) const | |||
| { | |||
| BusesProperties retval (*this); | |||
| auto retval = *this; | |||
| retval.addBus (true, name, dfltLayout, isActivatedByDefault); | |||
| return retval; | |||
| } | |||
| @@ -1331,9 +1325,8 @@ AudioProcessor::BusesProperties AudioProcessor::BusesProperties::withOutput (con | |||
| const AudioChannelSet& dfltLayout, | |||
| bool isActivatedByDefault) const | |||
| { | |||
| BusesProperties retval (*this); | |||
| auto retval = *this; | |||
| retval.addBus (false, name, dfltLayout, isActivatedByDefault); | |||
| return retval; | |||
| } | |||
| @@ -1343,10 +1336,11 @@ int32 AudioProcessor::getAAXPluginIDForMainBusConfig (const AudioChannelSet& mai | |||
| const bool idForAudioSuite) const | |||
| { | |||
| int uniqueFormatId = 0; | |||
| for (int dir = 0; dir < 2; ++dir) | |||
| { | |||
| const bool isInput = (dir == 0); | |||
| const AudioChannelSet& set = (isInput ? mainInputLayout : mainOutputLayout); | |||
| auto& set = (isInput ? mainInputLayout : mainOutputLayout); | |||
| int aaxFormatIndex = 0; | |||
| if (set == AudioChannelSet::disabled()) aaxFormatIndex = 0; | |||
| @@ -1384,10 +1378,7 @@ void AudioProcessorListener::audioProcessorParameterChangeGestureBegin (AudioPro | |||
| void AudioProcessorListener::audioProcessorParameterChangeGestureEnd (AudioProcessor*, int) {} | |||
| //============================================================================== | |||
| AudioProcessorParameter::AudioProcessorParameter() noexcept | |||
| : processor (nullptr), parameterIndex (-1) | |||
| {} | |||
| AudioProcessorParameter::AudioProcessorParameter() noexcept {} | |||
| AudioProcessorParameter::~AudioProcessorParameter() {} | |||
| 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 | |||
| 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 | |||
| { | |||
| @@ -107,7 +107,7 @@ public: | |||
| 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 | |||
| playback stops. | |||
| @@ -128,7 +128,7 @@ public: | |||
| virtual void prepareToPlay (double sampleRate, | |||
| 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. | |||
| */ | |||
| virtual void releaseResources() = 0; | |||
| @@ -137,16 +137,16 @@ public: | |||
| 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 | |||
| 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 | |||
| 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. | |||
| 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 | |||
| 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. | |||
| 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. | |||
| 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 | |||
| 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. | |||
| 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. | |||
| 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 | |||
| */ | |||
| virtual void processBlock (AudioBuffer<float>& buffer, | |||
| MidiBuffer& midiMessages) = 0; | |||
| @@ -199,16 +198,16 @@ public: | |||
| 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 | |||
| 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 | |||
| 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. | |||
| 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 | |||
| 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. | |||
| 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. | |||
| 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 | |||
| 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. | |||
| 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. | |||
| 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 */ | |||
| 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; | |||
| } | |||
| /** 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); | |||
| } | |||
| @@ -363,7 +362,6 @@ public: | |||
| //============================================================================== | |||
| /** The bus's current layout. This will be AudioChannelSet::disabled() if the current | |||
| layout is dfisabled. | |||
| @see AudioChannelSet | |||
| */ | |||
| const AudioChannelSet& getCurrentLayout() const noexcept { return layout; } | |||
| @@ -371,7 +369,6 @@ public: | |||
| /** Return the bus's last active channel layout. | |||
| If the bus is currently enabled then the result will be identical to getCurrentLayout | |||
| otherwise it will return the last enabled layout. | |||
| @see AudioChannelSet | |||
| */ | |||
| const AudioChannelSet& getLastEnabledLayout() const noexcept { return lastLayout; } | |||
| @@ -383,9 +380,7 @@ public: | |||
| bool setCurrentLayout (const AudioChannelSet& layout); | |||
| /** Sets the bus's current layout without changing the enabled state. | |||
| If the AudioProcessor does not support this layout then this will return false. | |||
| @see AudioChannelSet | |||
| */ | |||
| bool setCurrentLayoutWithoutEnabling (const AudioChannelSet& layout); | |||
| @@ -485,13 +480,11 @@ public: | |||
| int getBusCount (bool isInput) const noexcept { return (isInput ? inputBuses : outputBuses).size(); } | |||
| /** Returns the audio bus with a given index and direction. | |||
| If busIdx is invalid then this method will return a nullptr. | |||
| */ | |||
| Bus* getBus (bool isInput, int busIdx) noexcept { return (isInput ? inputBuses : outputBuses)[busIdx]; } | |||
| /** Returns the audio bus with a given index and direction. | |||
| 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); } | |||
| @@ -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. | |||
| 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. | |||
| */ | |||
| 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. | |||
| */ | |||
| 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; | |||
| /** Returns true if the processor wants midi messages. */ | |||
| /** Returns true if the processor wants MIDI messages. */ | |||
| 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; | |||
| /** Returns true if the processor supports MPE. */ | |||
| 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; } | |||
| //============================================================================== | |||
| @@ -863,7 +856,7 @@ public: | |||
| @endcode | |||
| 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. | |||
| Any code that calls processBlock() should call isSuspended() before doing so, and | |||
| @@ -905,36 +898,37 @@ public: | |||
| 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 | |||
| the correct size before returning it. If you implement this method, you must | |||
| 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 | |||
| 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 | |||
| 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 | |||
| safely unregister themselves when they are deleted. | |||
| 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 | |||
| 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. | |||
| - 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 | |||
| */ | |||
| 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 | |||
| */ | |||
| virtual bool hasEditor() const = 0; | |||
| @@ -977,7 +971,7 @@ public: | |||
| */ | |||
| 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. | |||
| @@ -1089,10 +1083,10 @@ public: | |||
| */ | |||
| 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 | |||
| 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 | |||
| editor component, then don't call this directly - instead, use the | |||
| @@ -1107,7 +1101,7 @@ public: | |||
| */ | |||
| 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 | |||
| a parameter. This method will call the setParameter() method to change the | |||
| @@ -1173,7 +1167,7 @@ public: | |||
| */ | |||
| 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, | |||
| etc, has changed, and that it should update itself. | |||
| @@ -1191,7 +1185,7 @@ public: | |||
| 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 | |||
| must not change over its lifetime. | |||
| @@ -1213,13 +1207,13 @@ public: | |||
| 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(). | |||
| 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. | |||
| @@ -1227,7 +1221,7 @@ public: | |||
| */ | |||
| 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. | |||
| Unlike getStateInformation, this should only return the current program's state. | |||
| @@ -1240,11 +1234,11 @@ public: | |||
| */ | |||
| 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(). | |||
| 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. | |||
| @@ -1252,7 +1246,7 @@ public: | |||
| */ | |||
| 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. | |||
| 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. | |||
| 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. | |||
| Then use getXmlFromBinary() to reverse this operation and retrieve the XML | |||
| @@ -51,10 +51,11 @@ public: | |||
| */ | |||
| 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 | |||
| 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 | |||
| editor component, then don't call this directly - instead, use the | |||
| @@ -66,7 +67,7 @@ public: | |||
| */ | |||
| 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 | |||
| a parameter. This method will call the setValue() method to change the | |||
| @@ -188,8 +189,8 @@ public: | |||
| private: | |||
| friend class AudioProcessor; | |||
| AudioProcessor* processor; | |||
| int parameterIndex; | |||
| AudioProcessor* processor = nullptr; | |||
| int parameterIndex = -1; | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorParameter) | |||
| }; | |||
| @@ -478,7 +478,7 @@ namespace NumberToStringConverters | |||
| { | |||
| auto* end = buffer + numChars; | |||
| 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; | |||
| while (numDecPlaces >= 0 || v > 0) | |||
| @@ -27,9 +27,9 @@ | |||
| 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(); | |||
| } | |||
| @@ -92,10 +92,10 @@ void ImageConvolutionKernel::createGaussianBlur (const float radius) | |||
| { | |||
| 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()) | |||
| 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(), | |||
| Image::BitmapData::writeOnly); | |||
| @@ -582,8 +582,8 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con | |||
| { | |||
| 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; | |||
| else | |||
| dragType = draggingSelectionEnd; | |||
| @@ -595,7 +595,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con | |||
| if (selectionEnd.getPosition() < selectionStart.getPosition()) | |||
| { | |||
| const CodeDocument::Position temp (selectionStart); | |||
| auto temp = selectionStart; | |||
| selectionStart = selectionEnd; | |||
| selectionEnd = temp; | |||
| @@ -608,7 +608,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con | |||
| if (selectionEnd.getPosition() < selectionStart.getPosition()) | |||
| { | |||
| const CodeDocument::Position temp (selectionStart); | |||
| auto temp = selectionStart; | |||
| selectionStart = selectionEnd; | |||
| selectionEnd = temp; | |||