diff --git a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp index de5d5ccf63..28fe3ab0f7 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp @@ -951,8 +951,7 @@ String MidiMessage::getMidiNoteName (int note, bool useSharps, bool includeOctav const double MidiMessage::getMidiNoteInHertz (int noteNumber, const double frequencyOfA) noexcept { - noteNumber -= 12 * 6 + 9; // now 0 = A - return frequencyOfA * pow (2.0, noteNumber / 12.0); + return frequencyOfA * pow (2.0, (noteNumber - 69) / 12.0); } String MidiMessage::getGMInstrumentName (const int n) diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 62a229489a..504508d046 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -918,7 +918,7 @@ void AudioDeviceManager::playTestSound() AudioSampleBuffer* const newSound = new AudioSampleBuffer (1, soundLength); float* samples = newSound->getSampleData (0); - const double frequency = MidiMessage::getMidiNoteInHertz (80); + const double frequency = 440.0; const float amplitude = 0.5f; const double phasePerSample = double_Pi * 2.0 / (sampleRate / frequency); diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/modules/juce_audio_formats/sampler/juce_Sampler.cpp index 73a5d9fdea..7e12f9bac7 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/modules/juce_audio_formats/sampler/juce_Sampler.cpp @@ -23,7 +23,7 @@ ============================================================================== */ -//============================================================================== + SamplerSound::SamplerSound (const String& name_, AudioFormatReader& source, const BigInteger& midiNotes_, @@ -61,7 +61,6 @@ SamplerSound::~SamplerSound() { } -//============================================================================== bool SamplerSound::appliesToNote (const int midiNoteNumber) { return midiNotes [midiNoteNumber]; @@ -72,7 +71,6 @@ bool SamplerSound::appliesToChannel (const int /*midiChannel*/) return true; } - //============================================================================== SamplerVoice::SamplerVoice() : pitchRatio (0.0), @@ -103,10 +101,8 @@ void SamplerVoice::startNote (const int midiNoteNumber, if (sound != nullptr) { - const double targetFreq = MidiMessage::getMidiNoteInHertz (midiNoteNumber); - const double naturalFreq = MidiMessage::getMidiNoteInHertz (sound->midiRootNote); - - pitchRatio = (targetFreq * sound->sourceSampleRate) / (naturalFreq * getSampleRate()); + pitchRatio = pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0) + * sound->sourceSampleRate / getSampleRate(); sourceSamplePosition = 0.0; lgain = velocity; @@ -127,13 +123,9 @@ void SamplerVoice::startNote (const int midiNoteNumber, } if (sound->releaseSamples > 0) - { releaseDelta = (float) (-pitchRatio / sound->releaseSamples); - } else - { releaseDelta = 0.0f; - } } } @@ -162,9 +154,7 @@ void SamplerVoice::controllerMoved (const int /*controllerNumber*/, //============================================================================== void SamplerVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) { - const SamplerSound* const playingSound = static_cast (getCurrentlyPlayingSound().get()); - - if (playingSound != nullptr) + if (const SamplerSound* const playingSound = static_cast (getCurrentlyPlayingSound().get())) { const float* const inL = playingSound->data->getSampleData (0, 0); const float* const inR = playingSound->data->getNumChannels() > 1 diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h index 3085319c29..9f655cd179 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h @@ -63,6 +63,11 @@ public: */ PluginDescription* getType (int index) const noexcept { return types [index]; } + /** Type iteration. */ + PluginDescription** begin() const noexcept { return types.begin(); } + /** Type iteration. */ + PluginDescription** end() const noexcept { return types.end(); } + /** Looks for a type in the list which comes from this file. */ PluginDescription* getTypeForFile (const String& fileOrIdentifier) const;