| @@ -26,7 +26,7 @@ namespace juce | |||||
| namespace | namespace | ||||
| { | { | ||||
| const uint8 noLSBValueReceived = 0xff; | const uint8 noLSBValueReceived = 0xff; | ||||
| const Range<int> allChannels = Range<int> (1, 17); | |||||
| const Range<int> allChannels { 1, 17 }; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -45,7 +45,7 @@ MPEInstrument::MPEInstrument() noexcept | |||||
| legacyMode.isEnabled = false; | legacyMode.isEnabled = false; | ||||
| legacyMode.pitchbendRange = 2; | legacyMode.pitchbendRange = 2; | ||||
| legacyMode.channelRange = Range<int> (1, 17); | |||||
| legacyMode.channelRange = allChannels; | |||||
| } | } | ||||
| MPEInstrument::~MPEInstrument() | MPEInstrument::~MPEInstrument() | ||||
| @@ -91,7 +91,7 @@ Range<int> MPEInstrument::getLegacyModeChannelRange() const noexcept | |||||
| void MPEInstrument::setLegacyModeChannelRange (Range<int> channelRange) | void MPEInstrument::setLegacyModeChannelRange (Range<int> channelRange) | ||||
| { | { | ||||
| jassert (Range<int>(1, 17).contains (channelRange)); | |||||
| jassert (allChannels.contains (channelRange)); | |||||
| releaseAllNotes(); | releaseAllNotes(); | ||||
| const ScopedLock sl (lock); | const ScopedLock sl (lock); | ||||
| @@ -218,7 +218,7 @@ void MPEInstrument::processMidiAllNotesOffMessage (const MidiMessage& message) | |||||
| if (legacyMode.isEnabled && legacyMode.channelRange.contains (message.getChannel())) | if (legacyMode.isEnabled && legacyMode.channelRange.contains (message.getChannel())) | ||||
| { | { | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -233,7 +233,7 @@ void MPEInstrument::processMidiAllNotesOffMessage (const MidiMessage& message) | |||||
| } | } | ||||
| else if (auto* zone = zoneLayout.getZoneByMasterChannel (message.getChannel())) | else if (auto* zone = zoneLayout.getZoneByMasterChannel (message.getChannel())) | ||||
| { | { | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -251,7 +251,7 @@ void MPEInstrument::processMidiAllNotesOffMessage (const MidiMessage& message) | |||||
| //============================================================================== | //============================================================================== | ||||
| void MPEInstrument::handlePressureMSB (int midiChannel, int value) noexcept | void MPEInstrument::handlePressureMSB (int midiChannel, int value) noexcept | ||||
| { | { | ||||
| const uint8 lsb = lastPressureLowerBitReceivedOnChannel[midiChannel - 1]; | |||||
| auto lsb = lastPressureLowerBitReceivedOnChannel[midiChannel - 1]; | |||||
| pressure (midiChannel, lsb == noLSBValueReceived ? MPEValue::from7BitInt (value) | pressure (midiChannel, lsb == noLSBValueReceived ? MPEValue::from7BitInt (value) | ||||
| : MPEValue::from14BitInt (lsb + (value << 7))); | : MPEValue::from14BitInt (lsb + (value << 7))); | ||||
| @@ -264,7 +264,7 @@ void MPEInstrument::handlePressureLSB (int midiChannel, int value) noexcept | |||||
| void MPEInstrument::handleTimbreMSB (int midiChannel, int value) noexcept | void MPEInstrument::handleTimbreMSB (int midiChannel, int value) noexcept | ||||
| { | { | ||||
| const uint8 lsb = lastTimbreLowerBitReceivedOnChannel[midiChannel - 1]; | |||||
| auto lsb = lastTimbreLowerBitReceivedOnChannel[midiChannel - 1]; | |||||
| timbre (midiChannel, lsb == noLSBValueReceived ? MPEValue::from7BitInt (value) | timbre (midiChannel, lsb == noLSBValueReceived ? MPEValue::from7BitInt (value) | ||||
| : MPEValue::from14BitInt (lsb + (value << 7))); | : MPEValue::from14BitInt (lsb + (value << 7))); | ||||
| @@ -383,7 +383,7 @@ void MPEInstrument::updateDimension (int midiChannel, MPEDimension& dimension, M | |||||
| { | { | ||||
| if (dimension.trackingMode == allNotesOnChannel) | if (dimension.trackingMode == allNotesOnChannel) | ||||
| { | { | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -404,7 +404,7 @@ void MPEInstrument::updateDimensionMaster (const MPEZone& zone, MPEDimension& di | |||||
| { | { | ||||
| auto channels = zone.getNoteChannelRange(); | auto channels = zone.getNoteChannelRange(); | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -495,7 +495,7 @@ void MPEInstrument::handleSustainOrSostenuto (int midiChannel, bool isDown, bool | |||||
| if (legacyMode.isEnabled ? (! legacyMode.channelRange.contains (midiChannel)) : (affectedZone == nullptr)) | if (legacyMode.isEnabled ? (! legacyMode.channelRange.contains (midiChannel)) : (affectedZone == nullptr)) | ||||
| return; | return; | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -525,7 +525,7 @@ void MPEInstrument::handleSustainOrSostenuto (int midiChannel, bool isDown, bool | |||||
| if (legacyMode.isEnabled) | if (legacyMode.isEnabled) | ||||
| isNoteChannelSustained[midiChannel - 1] = isDown; | isNoteChannelSustained[midiChannel - 1] = isDown; | ||||
| else | else | ||||
| for (int i = affectedZone->getFirstNoteChannel(); i <= affectedZone->getLastNoteChannel(); ++i) | |||||
| for (auto i = affectedZone->getFirstNoteChannel(); i <= affectedZone->getLastNoteChannel(); ++i) | |||||
| isNoteChannelSustained[i - 1] = isDown; | isNoteChannelSustained[i - 1] = isDown; | ||||
| } | } | ||||
| } | } | ||||
| @@ -558,7 +558,7 @@ MPENote MPEInstrument::getNote (int midiChannel, int midiNoteNumber) const noexc | |||||
| if (auto* note = getNotePtr (midiChannel, midiNoteNumber)) | if (auto* note = getNotePtr (midiChannel, midiNoteNumber)) | ||||
| return *note; | return *note; | ||||
| return MPENote(); | |||||
| return {}; | |||||
| } | } | ||||
| MPENote MPEInstrument::getNote (int index) const noexcept | MPENote MPEInstrument::getNote (int index) const noexcept | ||||
| @@ -572,12 +572,12 @@ MPENote MPEInstrument::getMostRecentNote (int midiChannel) const noexcept | |||||
| if (auto* note = getLastNotePlayedPtr (midiChannel)) | if (auto* note = getLastNotePlayedPtr (midiChannel)) | ||||
| return *note; | return *note; | ||||
| return MPENote(); | |||||
| return {}; | |||||
| } | } | ||||
| MPENote MPEInstrument::getMostRecentNoteOtherThan (MPENote otherThanThisNote) const noexcept | MPENote MPEInstrument::getMostRecentNoteOtherThan (MPENote otherThanThisNote) const noexcept | ||||
| { | { | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -585,7 +585,7 @@ MPENote MPEInstrument::getMostRecentNoteOtherThan (MPENote otherThanThisNote) co | |||||
| return note; | return note; | ||||
| } | } | ||||
| return MPENote(); | |||||
| return {}; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -629,7 +629,7 @@ MPENote* MPEInstrument::getNotePtr (int midiChannel, TrackingMode mode) noexcept | |||||
| //============================================================================== | //============================================================================== | ||||
| const MPENote* MPEInstrument::getLastNotePlayedPtr (int midiChannel) const noexcept | const MPENote* MPEInstrument::getLastNotePlayedPtr (int midiChannel) const noexcept | ||||
| { | { | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -650,11 +650,11 @@ MPENote* MPEInstrument::getLastNotePlayedPtr (int midiChannel) noexcept | |||||
| const MPENote* MPEInstrument::getHighestNotePtr (int midiChannel) const noexcept | const MPENote* MPEInstrument::getHighestNotePtr (int midiChannel) const noexcept | ||||
| { | { | ||||
| int initialNoteMax = -1; | int initialNoteMax = -1; | ||||
| const MPENote* result = nullptr; | |||||
| MPENote* result = nullptr; | |||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| const auto& note = notes.getReference (i); | |||||
| auto& note = notes.getReference (i); | |||||
| if (note.midiChannel == midiChannel | if (note.midiChannel == midiChannel | ||||
| && (note.keyState == MPENote::keyDown || note.keyState == MPENote::keyDownAndSustained) | && (note.keyState == MPENote::keyDown || note.keyState == MPENote::keyDownAndSustained) | ||||
| @@ -676,9 +676,9 @@ MPENote* MPEInstrument::getHighestNotePtr (int midiChannel) noexcept | |||||
| const MPENote* MPEInstrument::getLowestNotePtr (int midiChannel) const noexcept | const MPENote* MPEInstrument::getLowestNotePtr (int midiChannel) const noexcept | ||||
| { | { | ||||
| int initialNoteMin = 128; | int initialNoteMin = 128; | ||||
| const MPENote* result = nullptr; | |||||
| MPENote* result = nullptr; | |||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| @@ -704,7 +704,7 @@ void MPEInstrument::releaseAllNotes() | |||||
| { | { | ||||
| const ScopedLock sl (lock); | const ScopedLock sl (lock); | ||||
| for (int i = notes.size(); --i >= 0;) | |||||
| for (auto i = notes.size(); --i >= 0;) | |||||
| { | { | ||||
| auto& note = notes.getReference (i); | auto& note = notes.getReference (i); | ||||
| note.keyState = MPENote::off; | note.keyState = MPENote::off; | ||||
| @@ -25,10 +25,10 @@ namespace juce | |||||
| MidiBuffer MPEMessages::addZone (MPEZone zone) | MidiBuffer MPEMessages::addZone (MPEZone zone) | ||||
| { | { | ||||
| MidiBuffer buffer (MidiRPNGenerator::generate (zone.getFirstNoteChannel(), | |||||
| zoneLayoutMessagesRpnNumber, | |||||
| zone.getNumNoteChannels(), | |||||
| false, false)); | |||||
| auto buffer = MidiRPNGenerator::generate (zone.getFirstNoteChannel(), | |||||
| zoneLayoutMessagesRpnNumber, | |||||
| zone.getNumNoteChannels(), | |||||
| false, false); | |||||
| buffer.addEvents (perNotePitchbendRange (zone), 0, -1, 0); | buffer.addEvents (perNotePitchbendRange (zone), 0, -1, 0); | ||||
| buffer.addEvents (masterPitchbendRange (zone), 0, -1, 0); | buffer.addEvents (masterPitchbendRange (zone), 0, -1, 0); | ||||
| @@ -49,25 +49,13 @@ MPENote::MPENote (int midiChannel_, | |||||
| pitchbend (pitchbend_), | pitchbend (pitchbend_), | ||||
| pressure (pressure_), | pressure (pressure_), | ||||
| timbre (timbre_), | timbre (timbre_), | ||||
| noteOffVelocity (MPEValue::minValue()), | |||||
| keyState (keyState_) | keyState (keyState_) | ||||
| { | { | ||||
| jassert (keyState != MPENote::off); | jassert (keyState != MPENote::off); | ||||
| jassert (isValid()); | jassert (isValid()); | ||||
| } | } | ||||
| MPENote::MPENote() noexcept | |||||
| : noteID (0), | |||||
| midiChannel (0), | |||||
| initialNote (0), | |||||
| noteOnVelocity (MPEValue::minValue()), | |||||
| pitchbend (MPEValue::centreValue()), | |||||
| pressure (MPEValue::centreValue()), | |||||
| timbre (MPEValue::centreValue()), | |||||
| noteOffVelocity (MPEValue::minValue()), | |||||
| keyState (MPENote::off) | |||||
| { | |||||
| } | |||||
| MPENote::MPENote() noexcept {} | |||||
| //============================================================================== | //============================================================================== | ||||
| bool MPENote::isValid() const noexcept | bool MPENote::isValid() const noexcept | ||||
| @@ -78,7 +66,7 @@ bool MPENote::isValid() const noexcept | |||||
| //============================================================================== | //============================================================================== | ||||
| double MPENote::getFrequencyInHertz (double frequencyOfA) const noexcept | double MPENote::getFrequencyInHertz (double frequencyOfA) const noexcept | ||||
| { | { | ||||
| double pitchInSemitones = double (initialNote) + totalPitchbendInSemitones; | |||||
| auto pitchInSemitones = double (initialNote) + totalPitchbendInSemitones; | |||||
| return frequencyOfA * std::pow (2.0, (pitchInSemitones - 69.0) / 12.0); | return frequencyOfA * std::pow (2.0, (pitchInSemitones - 69.0) / 12.0); | ||||
| } | } | ||||
| @@ -92,17 +92,17 @@ struct JUCE_API MPENote | |||||
| sounding notes that may use the same note number or MIDI channel. | sounding notes that may use the same note number or MIDI channel. | ||||
| This should never change during the lifetime of a note object. | This should never change during the lifetime of a note object. | ||||
| */ | */ | ||||
| uint16 noteID; | |||||
| uint16 noteID = 0; | |||||
| /** The MIDI channel which this note uses. | /** The MIDI channel which this note uses. | ||||
| This should never change during the lifetime of an MPENote object. | This should never change during the lifetime of an MPENote object. | ||||
| */ | */ | ||||
| uint8 midiChannel; | |||||
| uint8 midiChannel = 0; | |||||
| /** The MIDI note number that was sent when the note was triggered. | /** The MIDI note number that was sent when the note was triggered. | ||||
| This should never change during the lifetime of an MPENote object. | This should never change during the lifetime of an MPENote object. | ||||
| */ | */ | ||||
| uint8 initialNote; | |||||
| uint8 initialNote = 0; | |||||
| //============================================================================== | //============================================================================== | ||||
| // The five dimensions of continuous expressive control | // The five dimensions of continuous expressive control | ||||
| @@ -110,7 +110,7 @@ struct JUCE_API MPENote | |||||
| /** The velocity ("strike") of the note-on. | /** The velocity ("strike") of the note-on. | ||||
| This dimension will stay constant after the note has been turned on. | This dimension will stay constant after the note has been turned on. | ||||
| */ | */ | ||||
| MPEValue noteOnVelocity; | |||||
| MPEValue noteOnVelocity { MPEValue::minValue() }; | |||||
| /** Current per-note pitchbend of the note (in units of MIDI pitchwheel | /** Current per-note pitchbend of the note (in units of MIDI pitchwheel | ||||
| position). This dimension can be modulated while the note sounds. | position). This dimension can be modulated while the note sounds. | ||||
| @@ -122,18 +122,18 @@ struct JUCE_API MPENote | |||||
| @see totalPitchbendInSemitones, getFrequencyInHertz | @see totalPitchbendInSemitones, getFrequencyInHertz | ||||
| */ | */ | ||||
| MPEValue pitchbend; | |||||
| MPEValue pitchbend { MPEValue::centreValue() }; | |||||
| /** Current pressure with which the note is held down. | /** Current pressure with which the note is held down. | ||||
| This dimension can be modulated while the note sounds. | This dimension can be modulated while the note sounds. | ||||
| */ | */ | ||||
| MPEValue pressure; | |||||
| MPEValue pressure { MPEValue::centreValue() }; | |||||
| /** Current value of the note's third expressive dimension, tyically | /** Current value of the note's third expressive dimension, tyically | ||||
| encoding some kind of timbre parameter. | encoding some kind of timbre parameter. | ||||
| This dimension can be modulated while the note sounds. | This dimension can be modulated while the note sounds. | ||||
| */ | */ | ||||
| MPEValue timbre; | |||||
| MPEValue timbre { MPEValue::centreValue() }; | |||||
| /** The release velocity ("lift") of the note after a note-off has been | /** The release velocity ("lift") of the note after a note-off has been | ||||
| received. | received. | ||||
| @@ -141,7 +141,7 @@ struct JUCE_API MPENote | |||||
| been received for the note (and keyState is set to MPENote::off or | been received for the note (and keyState is set to MPENote::off or | ||||
| MPENOte::sustained). Initially, the value is undefined. | MPENOte::sustained). Initially, the value is undefined. | ||||
| */ | */ | ||||
| MPEValue noteOffVelocity; | |||||
| MPEValue noteOffVelocity { MPEValue::minValue() }; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Current effective pitchbend of the note in units of semitones, relative | /** Current effective pitchbend of the note in units of semitones, relative | ||||
| @@ -158,7 +158,7 @@ struct JUCE_API MPENote | |||||
| /** Current key state. Indicates whether the note key is currently down (pressed) | /** Current key state. Indicates whether the note key is currently down (pressed) | ||||
| and/or the note is sustained (by a sustain or sostenuto pedal). | and/or the note is sustained (by a sustain or sostenuto pedal). | ||||
| */ | */ | ||||
| KeyState keyState; | |||||
| KeyState keyState { MPENote::off }; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the current frequency of the note in Hertz. This is the a sum of | /** Returns the current frequency of the note in Hertz. This is the a sum of | ||||
| @@ -26,7 +26,7 @@ namespace juce | |||||
| MPESynthesiser::MPESynthesiser() | MPESynthesiser::MPESynthesiser() | ||||
| { | { | ||||
| MPEZoneLayout zoneLayout; | MPEZoneLayout zoneLayout; | ||||
| zoneLayout.addZone (MPEZone (1, 15)); | |||||
| zoneLayout.addZone ({ 1, 15 }); | |||||
| setZoneLayout (zoneLayout); | setZoneLayout (zoneLayout); | ||||
| } | } | ||||
| @@ -58,7 +58,7 @@ void MPESynthesiser::noteAdded (MPENote newNote) | |||||
| { | { | ||||
| const ScopedLock sl (voicesLock); | const ScopedLock sl (voicesLock); | ||||
| if (MPESynthesiserVoice* voice = findFreeVoice (newNote, shouldStealVoices)) | |||||
| if (auto* voice = findFreeVoice (newNote, shouldStealVoices)) | |||||
| startVoice (voice, newNote); | startVoice (voice, newNote); | ||||
| } | } | ||||
| @@ -66,10 +66,8 @@ void MPESynthesiser::notePressureChanged (MPENote changedNote) | |||||
| { | { | ||||
| const ScopedLock sl (voicesLock); | const ScopedLock sl (voicesLock); | ||||
| for (int i = 0; i < voices.size(); ++i) | |||||
| for (auto* voice : voices) | |||||
| { | { | ||||
| MPESynthesiserVoice* voice = voices.getUnchecked (i); | |||||
| if (voice->isCurrentlyPlayingNote (changedNote)) | if (voice->isCurrentlyPlayingNote (changedNote)) | ||||
| { | { | ||||
| voice->currentlyPlayingNote = changedNote; | voice->currentlyPlayingNote = changedNote; | ||||
| @@ -82,10 +80,8 @@ void MPESynthesiser::notePitchbendChanged (MPENote changedNote) | |||||
| { | { | ||||
| const ScopedLock sl (voicesLock); | const ScopedLock sl (voicesLock); | ||||
| for (int i = 0; i < voices.size(); ++i) | |||||
| for (auto* voice : voices) | |||||
| { | { | ||||
| MPESynthesiserVoice* voice = voices.getUnchecked (i); | |||||
| if (voice->isCurrentlyPlayingNote (changedNote)) | if (voice->isCurrentlyPlayingNote (changedNote)) | ||||
| { | { | ||||
| voice->currentlyPlayingNote = changedNote; | voice->currentlyPlayingNote = changedNote; | ||||
| @@ -98,10 +94,8 @@ void MPESynthesiser::noteTimbreChanged (MPENote changedNote) | |||||
| { | { | ||||
| const ScopedLock sl (voicesLock); | const ScopedLock sl (voicesLock); | ||||
| for (int i = 0; i < voices.size(); ++i) | |||||
| for (auto* voice : voices) | |||||
| { | { | ||||
| MPESynthesiserVoice* voice = voices.getUnchecked (i); | |||||
| if (voice->isCurrentlyPlayingNote (changedNote)) | if (voice->isCurrentlyPlayingNote (changedNote)) | ||||
| { | { | ||||
| voice->currentlyPlayingNote = changedNote; | voice->currentlyPlayingNote = changedNote; | ||||
| @@ -114,10 +108,8 @@ void MPESynthesiser::noteKeyStateChanged (MPENote changedNote) | |||||
| { | { | ||||
| const ScopedLock sl (voicesLock); | const ScopedLock sl (voicesLock); | ||||
| for (int i = 0; i < voices.size(); ++i) | |||||
| for (auto* voice : voices) | |||||
| { | { | ||||
| MPESynthesiserVoice* voice = voices.getUnchecked (i); | |||||
| if (voice->isCurrentlyPlayingNote (changedNote)) | if (voice->isCurrentlyPlayingNote (changedNote)) | ||||
| { | { | ||||
| voice->currentlyPlayingNote = changedNote; | voice->currentlyPlayingNote = changedNote; | ||||
| @@ -132,7 +124,7 @@ void MPESynthesiser::noteReleased (MPENote finishedNote) | |||||
| for (int i = voices.size(); --i >= 0;) | for (int i = voices.size(); --i >= 0;) | ||||
| { | { | ||||
| MPESynthesiserVoice* const voice = voices.getUnchecked (i); | |||||
| auto* voice = voices.getUnchecked (i); | |||||
| if (voice->isCurrentlyPlayingNote(finishedNote)) | if (voice->isCurrentlyPlayingNote(finishedNote)) | ||||
| stopVoice (voice, finishedNote, true); | stopVoice (voice, finishedNote, true); | ||||
| @@ -165,10 +157,8 @@ MPESynthesiserVoice* MPESynthesiser::findFreeVoice (MPENote noteToFindVoiceFor, | |||||
| { | { | ||||
| const ScopedLock sl (voicesLock); | const ScopedLock sl (voicesLock); | ||||
| for (int i = 0; i < voices.size(); ++i) | |||||
| for (auto* voice : voices) | |||||
| { | { | ||||
| MPESynthesiserVoice* const voice = voices.getUnchecked (i); | |||||
| if (! voice->isActive()) | if (! voice->isActive()) | ||||
| return voice; | return voice; | ||||
| } | } | ||||
| @@ -297,7 +287,7 @@ void MPESynthesiser::reduceNumVoices (const int newNumVoices) | |||||
| while (voices.size() > newNumVoices) | while (voices.size() > newNumVoices) | ||||
| { | { | ||||
| if (MPESynthesiserVoice* voice = findFreeVoice (MPENote(), true)) | |||||
| if (MPESynthesiserVoice* voice = findFreeVoice ({}, true)) | |||||
| voices.removeObject (voice); | voices.removeObject (voice); | ||||
| else | else | ||||
| voices.remove (0); // if there's no voice to steal, kill the oldest voice | voices.remove (0); // if there's no voice to steal, kill the oldest voice | ||||
| @@ -308,8 +298,8 @@ void MPESynthesiser::turnOffAllVoices (bool allowTailOff) | |||||
| { | { | ||||
| // first turn off all voices (it's more efficient to do this immediately | // first turn off all voices (it's more efficient to do this immediately | ||||
| // rather than to go through the MPEInstrument for this). | // rather than to go through the MPEInstrument for this). | ||||
| for (int i = voices.size(); --i >= 0;) | |||||
| voices.getUnchecked (i)->noteStopped (allowTailOff); | |||||
| for (auto* voice : voices) | |||||
| voice->noteStopped (allowTailOff); | |||||
| // finally make sure the MPE Instrument also doesn't have any notes anymore. | // finally make sure the MPE Instrument also doesn't have any notes anymore. | ||||
| instrument->releaseAllNotes(); | instrument->releaseAllNotes(); | ||||
| @@ -318,10 +308,8 @@ void MPESynthesiser::turnOffAllVoices (bool allowTailOff) | |||||
| //============================================================================== | //============================================================================== | ||||
| void MPESynthesiser::renderNextSubBlock (AudioBuffer<float>& buffer, int startSample, int numSamples) | void MPESynthesiser::renderNextSubBlock (AudioBuffer<float>& buffer, int startSample, int numSamples) | ||||
| { | { | ||||
| for (int i = voices.size(); --i >= 0;) | |||||
| for (auto* voice : voices) | |||||
| { | { | ||||
| MPESynthesiserVoice* voice = voices.getUnchecked (i); | |||||
| if (voice->isActive()) | if (voice->isActive()) | ||||
| voice->renderNextBlock (buffer, startSample, numSamples); | voice->renderNextBlock (buffer, startSample, numSamples); | ||||
| } | } | ||||
| @@ -329,10 +317,8 @@ void MPESynthesiser::renderNextSubBlock (AudioBuffer<float>& buffer, int startSa | |||||
| void MPESynthesiser::renderNextSubBlock (AudioBuffer<double>& buffer, int startSample, int numSamples) | void MPESynthesiser::renderNextSubBlock (AudioBuffer<double>& buffer, int startSample, int numSamples) | ||||
| { | { | ||||
| for (int i = voices.size(); --i >= 0;) | |||||
| for (auto* voice : voices) | |||||
| { | { | ||||
| MPESynthesiserVoice* voice = voices.getUnchecked (i); | |||||
| if (voice->isActive()) | if (voice->isActive()) | ||||
| voice->renderNextBlock (buffer, startSample, numSamples); | voice->renderNextBlock (buffer, startSample, numSamples); | ||||
| } | } | ||||
| @@ -24,18 +24,13 @@ namespace juce | |||||
| { | { | ||||
| MPESynthesiserBase::MPESynthesiserBase() | MPESynthesiserBase::MPESynthesiserBase() | ||||
| : instrument (new MPEInstrument), | |||||
| sampleRate (0), | |||||
| minimumSubBlockSize (32), | |||||
| subBlockSubdivisionIsStrict (false) | |||||
| : instrument (new MPEInstrument) | |||||
| { | { | ||||
| instrument->addListener (this); | instrument->addListener (this); | ||||
| } | } | ||||
| MPESynthesiserBase::MPESynthesiserBase (MPEInstrument* inst) | MPESynthesiserBase::MPESynthesiserBase (MPEInstrument* inst) | ||||
| : instrument (inst), | |||||
| sampleRate (0), | |||||
| minimumSubBlockSize (32) | |||||
| : instrument (inst) | |||||
| { | { | ||||
| jassert (instrument != nullptr); | jassert (instrument != nullptr); | ||||
| instrument->addListener (this); | instrument->addListener (this); | ||||
| @@ -132,7 +127,7 @@ void MPESynthesiserBase::renderNextBlock (AudioBuffer<floatType>& outputAudio, | |||||
| return; | return; | ||||
| } | } | ||||
| const int samplesToNextMidiMessage = midiEventPos - startSample; | |||||
| auto samplesToNextMidiMessage = midiEventPos - startSample; | |||||
| if (samplesToNextMidiMessage >= numSamples) | if (samplesToNextMidiMessage >= numSamples) | ||||
| { | { | ||||
| @@ -198,9 +198,9 @@ protected: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| CriticalSection noteStateLock; | CriticalSection noteStateLock; | ||||
| double sampleRate; | |||||
| int minimumSubBlockSize; | |||||
| bool subBlockSubdivisionIsStrict; | |||||
| double sampleRate = 0.0; | |||||
| int minimumSubBlockSize = 32; | |||||
| bool subBlockSubdivisionIsStrict = false; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserBase) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserBase) | ||||
| }; | }; | ||||
| @@ -24,7 +24,6 @@ namespace juce | |||||
| { | { | ||||
| MPESynthesiserVoice::MPESynthesiserVoice() | MPESynthesiserVoice::MPESynthesiserVoice() | ||||
| : currentSampleRate (0), noteStartTime (0) | |||||
| { | { | ||||
| } | } | ||||
| @@ -174,13 +174,13 @@ protected: | |||||
| void clearCurrentNote() noexcept; | void clearCurrentNote() noexcept; | ||||
| //============================================================================== | //============================================================================== | ||||
| double currentSampleRate; | |||||
| double currentSampleRate = 0.0; | |||||
| MPENote currentlyPlayingNote; | MPENote currentlyPlayingNote; | ||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| friend class MPESynthesiser; | friend class MPESynthesiser; | ||||
| uint32 noteStartTime; | |||||
| uint32 noteStartTime = 0; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserVoice) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserVoice) | ||||
| }; | }; | ||||
| @@ -23,27 +23,24 @@ | |||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| MPEValue::MPEValue() noexcept : normalisedValue (8192) | |||||
| { | |||||
| } | |||||
| MPEValue::MPEValue (int value) : normalisedValue (value) | |||||
| { | |||||
| } | |||||
| MPEValue::MPEValue() noexcept {} | |||||
| MPEValue::MPEValue (int value) : normalisedValue (value) {} | |||||
| //============================================================================== | //============================================================================== | ||||
| MPEValue MPEValue::from7BitInt (int value) noexcept | MPEValue MPEValue::from7BitInt (int value) noexcept | ||||
| { | { | ||||
| jassert (value >= 0 && value <= 127); | jassert (value >= 0 && value <= 127); | ||||
| const int valueAs14Bit = value <= 64 ? value << 7 : int (jmap<float> (float (value - 64), 0.0f, 63.0f, 0.0f, 8191.0f)) + 8192; | |||||
| return MPEValue (valueAs14Bit); | |||||
| auto valueAs14Bit = value <= 64 ? value << 7 | |||||
| : int (jmap<float> (float (value - 64), 0.0f, 63.0f, 0.0f, 8191.0f)) + 8192; | |||||
| return { valueAs14Bit }; | |||||
| } | } | ||||
| MPEValue MPEValue::from14BitInt (int value) noexcept | MPEValue MPEValue::from14BitInt (int value) noexcept | ||||
| { | { | ||||
| jassert (value >= 0 && value <= 16383); | jassert (value >= 0 && value <= 16383); | ||||
| return MPEValue (value); | |||||
| return { value }; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -86,7 +86,7 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| MPEValue (int normalisedValue); | MPEValue (int normalisedValue); | ||||
| int normalisedValue; | |||||
| int normalisedValue = 8192; | |||||
| }; | }; | ||||
| } // namespace juce | } // namespace juce | ||||
| @@ -35,7 +35,7 @@ namespace | |||||
| // was not within the allowed range! | // was not within the allowed range! | ||||
| // we fit this back into the allowed range here to maintain a valid | // we fit this back into the allowed range here to maintain a valid | ||||
| // state for the zone, but probably the resulting zone is not what you | // state for the zone, but probably the resulting zone is not what you | ||||
| //wanted it to be! | |||||
| // wanted it to be! | |||||
| jassertfalse; | jassertfalse; | ||||
| valueToCheckAndLimit = jlimit (minValue, maxValue, valueToCheckAndLimit); | valueToCheckAndLimit = jlimit (minValue, maxValue, valueToCheckAndLimit); | ||||
| @@ -134,7 +134,7 @@ bool MPEZone::overlapsWith (MPEZone other) const noexcept | |||||
| //============================================================================== | //============================================================================== | ||||
| bool MPEZone::truncateToFit (MPEZone other) noexcept | bool MPEZone::truncateToFit (MPEZone other) noexcept | ||||
| { | { | ||||
| const int masterChannelDiff = other.masterChannel - masterChannel; | |||||
| auto masterChannelDiff = other.masterChannel - masterChannel; | |||||
| // we need at least 2 channels to be left after truncation: | // we need at least 2 channels to be left after truncation: | ||||
| // 1 master channel and 1 note channel. otherwise we can't truncate. | // 1 master channel and 1 note channel. otherwise we can't truncate. | ||||
| @@ -23,9 +23,7 @@ | |||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| MPEZoneLayout::MPEZoneLayout() noexcept | |||||
| { | |||||
| } | |||||
| MPEZoneLayout::MPEZoneLayout() noexcept {} | |||||
| MPEZoneLayout::MPEZoneLayout (const MPEZoneLayout& other) | MPEZoneLayout::MPEZoneLayout (const MPEZoneLayout& other) | ||||
| : zones (other.zones) | : zones (other.zones) | ||||