From 54582df4e5d5392393c3e56bf11855264179cf20 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 25 Nov 2022 22:54:01 +0100 Subject: [PATCH] Code refactoring --- BUILDING.md | 7 +- lib-src/libnyquist/nyquist/cmt/cext.c | 6 +- lib-src/libnyquist/nyquist/cmt/cmtio.h | 2 +- lib-src/libnyquist/nyquist/cmt/midifile.c | 3 +- lib-src/libnyquist/nyquist/cmt/midifns.c | 5 +- lib-src/libnyquist/nyquist/cmt/midifns.h | 2 +- lib-src/libnyquist/nyquist/cmt/musiprog.h | 6 +- lib-src/libnyquist/nyquist/cmt/seq.c | 4 +- lib-src/libnyquist/nyquist/cmt/seq.h | 38 +-- lib-src/libnyquist/nyquist/cmt/seqmwrite.c | 4 +- lib-src/libnyquist/nyquist/cmt/seqread.c | 12 +- lib-src/libnyquist/nyquist/cmt/timebase.h | 4 +- lib-src/libnyquist/nyquist/cmt/userio.c | 2 +- lib-src/libnyquist/nyquist/cmt/userio.h | 2 +- lib-src/libnyquist/nyquist/cmupv/src/cmupv.c | 2 +- lib-src/libnyquist/nyquist/ffts/src/fftlib.c | 4 +- lib-src/libnyquist/nyquist/nyqsrc/f0.cpp | 6 +- .../libnyquist/nyquist/nyqsrc/ffilterkit.c | 4 +- .../libnyquist/nyquist/nyqsrc/ffilterkit.h | 4 +- lib-src/libnyquist/nyquist/nyqsrc/lpanal.c | 2 +- lib-src/libnyquist/nyquist/nyqsrc/multiseq.c | 8 +- lib-src/libnyquist/nyquist/nyqsrc/sndread.c | 2 +- lib-src/libnyquist/nyquist/nyqsrc/sndread.h | 2 +- lib-src/libnyquist/nyquist/nyqsrc/sound.h | 30 +-- .../libnyquist/nyquist/nyqstk/include/ADSR.h | 16 +- .../nyquist/nyqstk/include/BandedWG.h | 12 +- .../nyquist/nyqstk/include/BiQuad.h | 14 +- .../nyquist/nyqstk/include/BowTable.h | 4 +- .../libnyquist/nyquist/nyqstk/include/Bowed.h | 14 +- .../nyquist/nyqstk/include/Chorus.h | 8 +- .../nyquist/nyqstk/include/Clarinet.h | 14 +- .../libnyquist/nyquist/nyqstk/include/Delay.h | 14 +- .../nyquist/nyqstk/include/DelayA.h | 8 +- .../nyquist/nyqstk/include/DelayL.h | 8 +- .../nyquist/nyqstk/include/Effect.h | 4 +- .../nyquist/nyqstk/include/Envelope.h | 12 +- .../nyquist/nyqstk/include/FileRead.h | 14 +- .../nyquist/nyqstk/include/FileWvIn.h | 18 +- .../nyquist/nyqstk/include/Filter.h | 10 +- .../libnyquist/nyquist/nyqstk/include/Flute.h | 12 +- .../nyquist/nyqstk/include/Function.h | 2 +- .../nyquist/nyqstk/include/Generator.h | 10 +- .../nyquist/nyqstk/include/Instrmnt.h | 6 +- .../libnyquist/nyquist/nyqstk/include/JCRev.h | 6 +- .../nyquist/nyqstk/include/JetTable.h | 4 +- .../nyquist/nyqstk/include/Mandolin.h | 8 +- .../libnyquist/nyquist/nyqstk/include/Modal.h | 12 +- .../nyquist/nyqstk/include/ModalBar.h | 4 +- .../libnyquist/nyquist/nyqstk/include/NRev.h | 6 +- .../libnyquist/nyquist/nyqstk/include/Noise.h | 6 +- .../nyquist/nyqstk/include/OnePole.h | 14 +- .../nyquist/nyqstk/include/OneZero.h | 14 +- .../nyquist/nyqstk/include/PRCRev.h | 6 +- .../nyquist/nyqstk/include/PitShift.h | 6 +- .../nyquist/nyqstk/include/PluckTwo.h | 8 +- .../nyquist/nyqstk/include/PoleZero.h | 14 +- .../nyquist/nyqstk/include/ReedTable.h | 4 +- .../nyquist/nyqstk/include/Saxofony.h | 12 +- .../nyquist/nyqstk/include/SineWave.h | 8 +- .../libnyquist/nyquist/nyqstk/include/Sitar.h | 10 +- .../libnyquist/nyquist/nyqstk/include/Stk.h | 43 ++-- .../nyquist/nyqstk/include/WaveLoop.h | 6 +- .../libnyquist/nyquist/nyqstk/include/WvIn.h | 12 +- lib-src/libnyquist/nyquist/nyqstk/instr.cpp | 8 +- .../libnyquist/nyquist/nyqstk/src/ADSR.cpp | 5 +- .../libnyquist/nyquist/nyqstk/src/BiQuad.cpp | 6 +- .../nyquist/nyqstk/src/BowTable.cpp | 2 +- .../libnyquist/nyquist/nyqstk/src/Delay.cpp | 14 +- .../libnyquist/nyquist/nyqstk/src/DelayA.cpp | 4 +- .../libnyquist/nyquist/nyqstk/src/DelayL.cpp | 4 +- .../libnyquist/nyquist/nyqstk/src/Effect.cpp | 2 +- .../nyquist/nyqstk/src/Envelope.cpp | 12 +- .../nyquist/nyqstk/src/FileRead.cpp | 35 +-- .../nyquist/nyqstk/src/FileWvIn.cpp | 15 +- .../libnyquist/nyquist/nyqstk/src/Filter.cpp | 16 +- .../nyquist/nyqstk/src/Generator.cpp | 2 +- .../nyquist/nyqstk/src/Instrmnt.cpp | 6 +- .../libnyquist/nyquist/nyqstk/src/JCRev.cpp | 2 +- .../nyquist/nyqstk/src/Mandolin.cpp | 32 +-- .../libnyquist/nyquist/nyqstk/src/Modal.cpp | 2 +- .../nyquist/nyqstk/src/ModalBar.cpp | 2 +- .../libnyquist/nyquist/nyqstk/src/NRev.cpp | 2 +- .../libnyquist/nyquist/nyqstk/src/Noise.cpp | 6 +- .../libnyquist/nyquist/nyqstk/src/OnePole.cpp | 6 +- .../libnyquist/nyquist/nyqstk/src/OneZero.cpp | 8 +- .../libnyquist/nyquist/nyqstk/src/PRCRev.cpp | 2 +- .../nyquist/nyqstk/src/PoleZero.cpp | 6 +- .../nyquist/nyqstk/src/SineWave.cpp | 6 +- .../libnyquist/nyquist/nyqstk/src/Sitar.cpp | 4 +- lib-src/libnyquist/nyquist/nyqstk/src/Stk.cpp | 16 +- .../nyquist/nyqstk/src/WaveLoop.cpp | 7 +- .../libnyquist/nyquist/nyqstk/src/WvIn.cpp | 4 +- lib-src/libnyquist/nyquist/nyqstk/stkinit.cpp | 6 +- lib-src/libnyquist/nyquist/nyqstk/stkint.cpp | 10 +- lib-src/libnyquist/nyquist/xlisp/security.c | 1 - lib-src/libnyquist/nyquist/xlisp/xlcont.c | 2 +- lib-src/libnyquist/nyquist/xlisp/xldmem.h | 6 +- lib-src/libnyquist/nyquist/xlisp/xlisp.h | 14 +- libraries/lib-basic-ui/GenericUIAssert.cpp | 4 +- .../lib-components/ComponentInterfaceSymbol.h | 12 +- .../EffectAutomationParameters.h | 32 +-- libraries/lib-components/EffectInterface.h | 10 +- libraries/lib-components/ModuleInterface.h | 2 +- .../lib-exceptions/InconsistencyException.h | 2 +- .../lib-exceptions/SaucedacityException.cpp | 5 +- .../lib-exceptions/SaucedacityException.h | 11 +- .../lib-ffmpeg-support/AVCodecFunctions.h | 2 +- .../lib-ffmpeg-support/AVFormatFunctions.h | 4 +- .../lib-ffmpeg-support/AVUtilFunctions.h | 2 +- .../lib-ffmpeg-support/FFmpegFunctions.cpp | 4 +- .../lib-ffmpeg-support/FFmpegFunctions.h | 20 +- libraries/lib-ffmpeg-support/FFmpegTypes.h | 8 +- .../impl/FFmpegAPIResolver.h | 2 +- .../avcodec/AVCodecContextWrapperImpl.inl | 42 +-- .../impl/avcodec/AVCodecWrapperImpl.inl | 24 +- .../impl/avcodec/AVPacketWrapperImpl.inl | 22 +- .../avformat/AVFormatContextWrapperImpl.inl | 78 +++--- .../impl/avformat/AVIOContextWrapperImpl.inl | 22 +- .../avformat/AVInputFormatWrapperImpl.inl | 12 +- .../avformat/AVOutputFormatWrapperImpl.inl | 14 +- .../impl/avformat/AVStreamWrapperImpl.inl | 26 +- .../impl/avutil/AVFrameWrapperImpl.inl | 66 ++--- .../impl/ffmpeg-3.4.8-single-header.h | 150 +++++------ .../impl/ffmpeg-4.2.4-single-header.h | 144 +++++------ .../impl/ffmpeg-5.0.1-single-header.h | 132 +++++----- .../wrappers/AVCodecWrapper.h | 28 +- .../wrappers/AVDictionaryWrapper.h | 6 +- .../wrappers/AVFifoBufferWrapper.h | 2 +- .../wrappers/AVFormatContextWrapper.h | 84 +++--- .../wrappers/AVFrameWrapper.h | 68 ++--- .../wrappers/AVIOContextWrapper.cpp | 8 +- .../wrappers/AVIOContextWrapper.h | 24 +- .../wrappers/AVInputFormatWrapper.h | 12 +- .../wrappers/AVOutputFormatWrapper.h | 16 +- .../wrappers/AVPacketWrapper.h | 24 +- .../wrappers/AVStreamWrapper.h | 28 +- libraries/lib-files/FileIO.cpp | 10 +- libraries/lib-files/FileIO.h | 2 +- libraries/lib-files/SaucedacityLogger.h | 4 +- libraries/lib-math/Dither.cpp | 18 +- libraries/lib-math/Dither.h | 4 +- libraries/lib-math/FFT.cpp | 10 +- libraries/lib-math/InterpolateAudio.cpp | 2 +- libraries/lib-math/Matrix.cpp | 2 +- libraries/lib-math/Matrix.h | 14 +- libraries/lib-math/RealFFTf.cpp | 6 +- libraries/lib-math/Resample.cpp | 2 +- libraries/lib-math/Resample.h | 4 +- libraries/lib-math/SSEMathFuncs.h | 6 +- libraries/lib-math/SampleCount.h | 12 +- libraries/lib-math/SampleFormat.cpp | 6 +- libraries/lib-math/SampleFormat.h | 8 +- libraries/lib-math/float_cast.h | 2 +- libraries/lib-preferences/FileConfig.cpp | 2 +- libraries/lib-preferences/FileConfig.h | 50 ++-- libraries/lib-preferences/Prefs.cpp | 10 +- libraries/lib-preferences/Prefs.h | 6 +- libraries/lib-registries/ClientData.h | 10 +- libraries/lib-registries/ClientDataHelpers.h | 16 +- libraries/lib-strings/Identifier.h | 10 +- libraries/lib-strings/Internat.cpp | 4 +- libraries/lib-strings/Internat.h | 4 +- libraries/lib-strings/Languages.cpp | 10 +- libraries/lib-strings/TranslatableString.cpp | 2 +- libraries/lib-strings/TranslatableString.h | 26 +- libraries/lib-utility/MemoryStream.cpp | 6 +- libraries/lib-utility/MemoryStream.h | 4 +- libraries/lib-utility/MemoryX.h | 4 +- libraries/lib-utility/Observer.h | 2 +- libraries/lib-xml/XMLFileReader.cpp | 14 +- libraries/lib-xml/XMLFileReader.h | 4 +- libraries/lib-xml/XMLFileWriter.cpp | 8 +- libraries/lib-xml/XMLFileWriter.h | 8 +- libraries/lib-xml/XMLStringWriter.h | 2 +- libraries/lib-xml/XMLTagHandler.h | 6 +- libraries/lib-xml/XMLWriter.cpp | 4 +- libraries/lib-xml/XMLWriter.h | 2 +- modules/mod-null/ModNullCallback.cpp | 6 +- modules/mod-nyq-bench/NyqBench.cpp | 28 +- modules/mod-nyq-bench/NyqBench.h | 12 +- modules/mod-script-pipe/PipeServer.cpp | 20 +- modules/mod-script-pipe/ScripterCallback.cpp | 2 +- src/AColor.cpp | 6 +- src/AboutDialog.cpp | 4 +- src/AboutDialog.h | 12 +- src/AdornedRulerPanel.cpp | 33 ++- src/AdornedRulerPanel.h | 10 +- src/AudioIO.cpp | 64 ++--- src/AudioIO.h | 26 +- src/AudioIOBase.cpp | 24 +- src/AudioIOBase.h | 14 +- src/AutoRecoveryDialog.cpp | 8 +- src/BatchCommandDialog.h | 2 +- src/BatchCommands.cpp | 2 - src/BatchCommands.h | 30 +-- src/BatchProcessDialog.cpp | 5 +- src/BatchProcessDialog.h | 8 +- src/CellularPanel.cpp | 32 +-- src/CellularPanel.h | 6 +- src/Clipboard.h | 12 +- src/CommonCommandFlags.cpp | 2 +- src/DBConnection.cpp | 23 +- src/DBConnection.h | 14 +- src/DeviceManager.cpp | 12 +- src/Diags.cpp | 10 +- src/Diags.h | 6 +- src/Envelope.cpp | 26 +- src/Envelope.h | 10 +- src/FileFormats.cpp | 28 +- src/FreqWindow.cpp | 8 +- src/FreqWindow.h | 4 +- src/HitTestResult.h | 7 +- src/ImageManipulation.cpp | 4 +- src/JournalEvents.cpp | 14 +- src/JournalEvents.h | 5 +- src/JournalOutput.cpp | 2 +- src/JournalRegistry.cpp | 4 +- src/JournalRegistry.h | 2 +- src/JournalWindowPaths.cpp | 6 +- src/JournalWindowPaths.h | 5 +- src/KeyboardCapture.cpp | 8 +- src/LabelDialog.cpp | 36 +-- src/LabelDialog.h | 8 +- src/LabelTrack.cpp | 4 +- src/LabelTrack.h | 6 +- src/LogWindow.cpp | 2 +- src/Lyrics.cpp | 14 +- src/Lyrics.h | 12 +- src/MacroMagic.h | 4 +- src/Menus.cpp | 26 +- src/Menus.h | 6 +- src/Mix.cpp | 8 +- src/Mix.h | 6 +- src/MixerBoard.cpp | 56 ++-- src/MixerBoard.h | 26 +- src/ModuleManager.cpp | 14 +- src/ModuleManager.h | 10 +- src/NoteTrack.cpp | 12 +- src/NumberScale.h | 8 +- src/PitchName.h | 20 +- src/PlaybackSchedule.h | 38 +-- src/PluginManager.cpp | 36 ++- src/PluginManager.h | 56 ++-- src/PluginRegistrationDialog.cpp | 38 +-- src/PluginRegistrationDialog.h | 2 +- src/Printing.cpp | 10 +- src/Profiler.cpp | 18 +- src/Profiler.h | 4 +- src/Project.cpp | 2 +- src/Project.h | 16 +- src/ProjectAudioIO.h | 6 +- src/ProjectAudioManager.cpp | 6 +- src/ProjectAudioManager.h | 2 +- src/ProjectFileIO.cpp | 32 ++- src/ProjectFileIO.h | 16 +- src/ProjectFileIORegistry.cpp | 2 +- src/ProjectFileManager.cpp | 10 +- src/ProjectFileManager.h | 6 +- src/ProjectHistory.h | 6 +- src/ProjectManager.cpp | 10 +- src/ProjectManager.h | 4 +- src/ProjectSelectionManager.h | 2 +- src/ProjectSerializer.cpp | 30 +-- src/ProjectSerializer.h | 4 +- src/ProjectSettings.h | 30 +-- src/ProjectStatus.h | 2 +- src/ProjectWindow.cpp | 10 +- src/ProjectWindow.h | 22 +- src/ProjectWindowBase.h | 2 +- src/RingBuffer.cpp | 2 +- src/RingBuffer.h | 2 +- src/SampleBlock.h | 10 +- src/SaucedacityApp.cpp | 243 +++++++++--------- src/SaucedacityApp.h | 22 +- src/Screenshot.cpp | 18 +- src/SelectedRegion.cpp | 2 +- src/SelectedRegion.h | 14 +- src/SelectionState.cpp | 2 +- src/Sequence.cpp | 8 +- src/Sequence.h | 35 +-- src/Snap.h | 2 +- src/SoundActivatedRecord.h | 4 +- src/SpectrumAnalyst.cpp | 8 +- src/SpectrumAnalyst.h | 14 +- src/SplashDialog.cpp | 8 +- src/SplashDialog.h | 4 +- src/SqliteSampleBlock.cpp | 41 +-- src/Tags.cpp | 27 +- src/Tags.h | 14 +- src/TimeDialog.cpp | 14 +- src/TimeDialog.h | 6 +- src/TimeTrack.cpp | 2 +- src/TimeTrack.h | 2 +- src/TimerRecordDialog.cpp | 10 +- src/TimerRecordDialog.h | 8 +- src/Track.cpp | 8 +- src/Track.h | 37 +-- src/TrackArtist.h | 8 +- src/TrackInfo.cpp | 2 +- src/TrackPanel.cpp | 51 ++-- src/TrackPanel.h | 16 +- src/TrackPanelAx.h | 2 +- src/TrackPanelCell.h | 6 +- src/TrackPanelMouseEvent.h | 9 +- src/TrackPanelResizeHandle.h | 4 +- src/UIHandle.h | 8 +- src/UndoManager.h | 19 +- src/ViewInfo.h | 30 +-- src/VoiceKey.cpp | 10 +- src/VoiceKey.h | 12 +- src/WaveClip.cpp | 12 +- src/WaveClip.h | 20 +- src/WaveTrack.cpp | 27 +- src/WrappedType.cpp | 18 +- src/WrappedType.h | 18 +- src/ZoomInfo.cpp | 4 +- src/ZoomInfo.h | 36 +-- src/commands/AppCommandEvent.h | 6 +- src/commands/AudacityCommand.cpp | 8 +- src/commands/AudacityCommand.h | 6 +- src/commands/BatchEvalCommand.h | 2 +- src/commands/Command.cpp | 10 +- src/commands/Command.h | 12 +- src/commands/CommandBuilder.cpp | 8 +- src/commands/CommandBuilder.h | 2 +- src/commands/CommandContext.cpp | 3 +- src/commands/CommandContext.h | 16 +- src/commands/CommandDirectory.cpp | 7 +- src/commands/CommandDirectory.h | 4 +- src/commands/CommandHandler.cpp | 6 +- src/commands/CommandHandler.h | 2 +- src/commands/CommandManager.cpp | 56 ++-- src/commands/CommandManager.h | 48 ++-- src/commands/CommandSignature.cpp | 3 +- src/commands/CommandSignature.h | 2 +- src/commands/CommandTargets.cpp | 18 +- src/commands/CommandTargets.h | 90 ++++--- src/commands/CommandType.cpp | 3 +- src/commands/CommandType.h | 2 +- src/commands/CompareAudioCommand.cpp | 4 +- src/commands/CompareAudioCommand.h | 2 +- src/commands/DragCommand.cpp | 3 +- src/commands/GetInfoCommand.cpp | 25 +- src/commands/HelpCommand.cpp | 6 +- src/commands/HelpCommand.h | 2 +- src/commands/Keyboard.h | 2 +- src/commands/LoadCommands.cpp | 9 +- src/commands/LoadCommands.h | 2 +- src/commands/ResponseQueue.cpp | 4 +- src/commands/ResponseQueue.h | 2 +- src/commands/ScreenshotCommand.cpp | 16 +- src/commands/ScreenshotCommand.h | 16 +- src/commands/ScriptCommandRelay.cpp | 2 +- src/commands/SetClipCommand.cpp | 3 +- src/commands/SetEnvelopeCommand.cpp | 3 +- src/commands/SetLabelCommand.cpp | 3 +- src/commands/SetProjectCommand.cpp | 3 +- src/commands/SetTrackInfoCommand.h | 4 +- src/commands/Validators.h | 40 +-- src/effects/Amplify.cpp | 5 +- src/effects/Amplify.h | 2 +- src/effects/AutoDuck.cpp | 30 +-- src/effects/AutoDuck.h | 8 +- src/effects/BassTreble.cpp | 5 +- src/effects/BassTreble.h | 10 +- src/effects/ChangePitch.cpp | 22 +- src/effects/ChangePitch.h | 2 +- src/effects/ChangeSpeed.cpp | 11 +- src/effects/ChangeSpeed.h | 2 +- src/effects/ChangeTempo.cpp | 5 +- src/effects/ChangeTempo.h | 2 +- src/effects/ClickRemoval.cpp | 5 +- src/effects/ClickRemoval.h | 2 +- src/effects/Compressor.cpp | 17 +- src/effects/Compressor.h | 2 +- src/effects/Compressor2.cpp | 68 ++--- src/effects/Compressor2.h | 66 ++--- src/effects/Contrast.cpp | 11 +- src/effects/Distortion.cpp | 63 +++-- src/effects/Distortion.h | 12 +- src/effects/DtmfGen.cpp | 9 +- src/effects/DtmfGen.h | 4 +- src/effects/EBUR128.h | 2 +- src/effects/Echo.cpp | 5 +- src/effects/Echo.h | 4 +- src/effects/Effect.cpp | 41 ++- src/effects/Effect.h | 38 +-- src/effects/EffectManager.cpp | 46 ++-- src/effects/EffectManager.h | 8 +- src/effects/EffectUI.cpp | 53 ++-- src/effects/EffectUI.h | 4 +- src/effects/Equalization.cpp | 134 +++++----- src/effects/Equalization.h | 32 +-- src/effects/Fade.cpp | 3 +- src/effects/Fade.h | 6 +- src/effects/FindClipping.cpp | 3 +- src/effects/FindClipping.h | 2 +- src/effects/Generator.h | 4 +- src/effects/Invert.cpp | 6 +- src/effects/Invert.h | 2 +- src/effects/LoadEffects.cpp | 9 +- src/effects/LoadEffects.h | 4 +- src/effects/Loudness.cpp | 14 +- src/effects/Loudness.h | 10 +- src/effects/Noise.cpp | 3 +- src/effects/Noise.h | 2 +- src/effects/NoiseReduction.cpp | 67 +++-- src/effects/NoiseReduction.h | 2 +- src/effects/Normalize.cpp | 7 +- src/effects/Normalize.h | 6 +- src/effects/Paulstretch.cpp | 18 +- src/effects/Paulstretch.h | 4 +- src/effects/Phaser.cpp | 9 +- src/effects/Phaser.h | 8 +- src/effects/RealtimeEffectManager.cpp | 9 +- src/effects/RealtimeEffectManager.h | 2 +- src/effects/Repair.cpp | 6 +- src/effects/Repair.h | 2 +- src/effects/Repeat.cpp | 3 +- src/effects/Repeat.h | 2 +- src/effects/Reverb.cpp | 13 +- src/effects/Reverb.h | 4 +- src/effects/Reverb_libSoX.h | 12 +- src/effects/Reverse.cpp | 10 +- src/effects/Reverse.h | 2 +- src/effects/ScienFilter.cpp | 10 +- src/effects/ScienFilter.h | 10 +- src/effects/Silence.cpp | 5 +- src/effects/Silence.h | 2 +- src/effects/SoundTouchEffect.cpp | 11 +- src/effects/SoundTouchEffect.h | 6 +- src/effects/StereoToMono.cpp | 6 +- src/effects/StereoToMono.h | 2 +- src/effects/TimeWarper.h | 28 +- src/effects/ToneGen.cpp | 5 +- src/effects/ToneGen.h | 6 +- src/effects/TruncSilence.cpp | 11 +- src/effects/TruncSilence.h | 8 +- src/effects/TwoPassSimpleMono.cpp | 8 +- src/effects/TwoPassSimpleMono.h | 4 +- src/effects/VST/VSTControl.h | 6 +- src/effects/VST/VSTControlGTK.cpp | 4 +- src/effects/VST/VSTControlGTK.h | 4 +- src/effects/VST/VSTEffect.cpp | 193 +++++++------- src/effects/VST/VSTEffect.h | 18 +- src/effects/VST/aeffectx.h | 10 +- src/effects/Wahwah.cpp | 7 +- src/effects/Wahwah.h | 8 +- src/effects/ladspa/LadspaEffect.cpp | 55 ++-- src/effects/ladspa/LadspaEffect.h | 10 +- src/effects/lv2/LV2Effect.cpp | 214 ++++++++------- src/effects/lv2/LV2Effect.h | 20 +- src/effects/lv2/LoadLV2.cpp | 12 +- src/effects/lv2/LoadLV2.h | 4 +- src/effects/lv2/NativeWindow.h | 2 +- src/effects/lv2/zix/ring.cpp | 8 +- src/effects/lv2/zix/ring.h | 2 +- src/effects/nyquist/LoadNyquist.cpp | 8 +- src/effects/nyquist/LoadNyquist.h | 2 +- src/effects/nyquist/Nyquist.cpp | 95 ++++--- src/effects/nyquist/Nyquist.h | 18 +- src/effects/vamp/LoadVamp.cpp | 13 +- src/effects/vamp/LoadVamp.h | 4 +- src/effects/vamp/VampEffect.cpp | 94 +++---- src/effects/vamp/VampEffect.h | 4 +- src/export/Export.cpp | 42 +-- src/export/Export.h | 28 +- src/export/ExportCL.cpp | 30 +-- src/export/ExportFFmpeg.cpp | 34 +-- src/export/ExportFFmpegDialogs.cpp | 95 ++++--- src/export/ExportFFmpegDialogs.h | 30 +-- src/export/ExportFLAC.cpp | 12 +- src/export/ExportMP2.cpp | 16 +- src/export/ExportMP3.cpp | 64 +++-- src/export/ExportMultiple.cpp | 10 +- src/export/ExportMultiple.h | 6 +- src/export/ExportOGG.cpp | 16 +- src/export/ExportPCM.cpp | 32 +-- src/ffmpeg/FFmpeg.cpp | 4 +- src/ffmpeg/FFmpegNotFoundDialog.cpp | 2 - src/import/FormatClassifier.cpp | 12 +- src/import/FormatClassifier.h | 16 +- src/import/Import.cpp | 26 +- src/import/Import.h | 8 +- src/import/ImportAUP.cpp | 28 +- src/import/ImportFFmpeg.cpp | 6 +- src/import/ImportFLAC.cpp | 6 +- src/import/ImportLOF.cpp | 6 +- src/import/ImportMIDI.h | 32 +-- src/import/ImportMP3.cpp | 17 +- src/import/ImportOGG.cpp | 6 +- src/import/ImportPCM.cpp | 12 +- src/import/ImportPlugin.h | 7 +- src/import/ImportRaw.cpp | 4 +- src/import/MultiFormatReader.cpp | 12 +- src/import/RawAudioGuess.cpp | 38 +-- src/import/SpecPowerMeter.cpp | 6 +- src/import/SpecPowerMeter.h | 4 +- src/menus/TransportMenus.cpp | 2 +- src/prefs/BatchPrefs.cpp | 1 - src/prefs/BatchPrefs.h | 2 +- src/prefs/DevicePrefs.cpp | 18 +- src/prefs/DevicePrefs.h | 2 +- src/prefs/DirectoriesPrefs.cpp | 18 +- src/prefs/DirectoriesPrefs.h | 2 +- src/prefs/EffectsPrefs.cpp | 2 +- src/prefs/EffectsPrefs.h | 2 +- src/prefs/ExtImportPrefs.cpp | 40 +-- src/prefs/ExtImportPrefs.h | 14 +- src/prefs/GUIPrefs.h | 2 +- src/prefs/GUISettings.h | 2 +- src/prefs/ImportExportPrefs.h | 2 +- src/prefs/KeyConfigPrefs.cpp | 31 ++- src/prefs/KeyConfigPrefs.h | 2 +- src/prefs/LibraryPrefs.h | 2 +- src/prefs/ModulePrefs.cpp | 2 +- src/prefs/ModulePrefs.h | 2 +- src/prefs/MousePrefs.h | 2 +- src/prefs/PlaybackPrefs.h | 2 +- src/prefs/PrefsDialog.cpp | 38 +-- src/prefs/PrefsDialog.h | 8 +- src/prefs/PrefsPanel.cpp | 7 +- src/prefs/PrefsPanel.h | 13 +- src/prefs/QualityPrefs.h | 2 +- src/prefs/RecordingPrefs.h | 2 +- src/prefs/SpectrogramSettings.cpp | 6 +- src/prefs/SpectrogramSettings.h | 6 +- src/prefs/SpectrumPrefs.cpp | 10 +- src/prefs/SpectrumPrefs.h | 4 +- src/prefs/ThemePrefs.cpp | 2 +- src/prefs/ThemePrefs.h | 2 +- src/prefs/TracksBehaviorsPrefs.h | 2 +- src/prefs/TracksPrefs.h | 2 +- src/prefs/WarningsPrefs.h | 2 +- src/prefs/WaveformPrefs.cpp | 2 +- src/prefs/WaveformPrefs.h | 2 +- src/prefs/WaveformSettings.h | 6 +- src/shuttle/Shuttle.cpp | 4 +- src/shuttle/Shuttle.h | 62 ++--- src/shuttle/ShuttleGetDefinition.cpp | 4 +- src/shuttle/ShuttleGetDefinition.h | 16 +- src/shuttle/ShuttleGui.cpp | 64 ++--- src/shuttle/ShuttleGui.h | 62 ++--- src/shuttle/ShuttlePrefs.h | 2 +- src/theme/FlowPacker.cpp | 6 +- src/theme/FlowPacker.h | 6 +- src/theme/SourceOutputStream.h | 2 +- src/theme/Theme.cpp | 12 +- src/theme/Theme.h | 18 +- src/toolbars/ControlToolBar.cpp | 18 +- src/toolbars/ControlToolBar.h | 2 +- src/toolbars/DeviceToolBar.cpp | 48 ++-- src/toolbars/DeviceToolBar.h | 4 +- src/toolbars/EditToolBar.h | 2 +- src/toolbars/MeterToolBar.cpp | 10 +- src/toolbars/MeterToolBar.h | 4 +- src/toolbars/ScrubbingToolBar.cpp | 2 +- src/toolbars/ScrubbingToolBar.h | 2 +- src/toolbars/SelectionBar.cpp | 26 +- src/toolbars/SelectionBar.h | 2 +- src/toolbars/SpectralSelectionBar.cpp | 14 +- src/toolbars/SpectralSelectionBar.h | 2 +- src/toolbars/SpectralSelectionBarListener.h | 2 +- src/toolbars/TimeToolBar.cpp | 6 +- src/toolbars/TimeToolBar.h | 2 +- src/toolbars/ToolBar.cpp | 27 +- src/toolbars/ToolBar.h | 24 +- src/toolbars/ToolDock.cpp | 2 +- src/toolbars/ToolDock.h | 14 +- src/toolbars/ToolManager.cpp | 53 ++-- src/toolbars/ToolManager.h | 10 +- src/toolbars/ToolsToolBar.cpp | 9 +- src/toolbars/ToolsToolBar.h | 8 +- src/toolbars/TranscriptionToolBar.cpp | 6 +- src/toolbars/TranscriptionToolBar.h | 6 +- .../labeltrack/ui/LabelDefaultClickHandle.cpp | 4 +- .../labeltrack/ui/LabelDefaultClickHandle.h | 2 +- src/tracks/labeltrack/ui/LabelGlyphHandle.cpp | 12 +- src/tracks/labeltrack/ui/LabelGlyphHandle.h | 6 +- src/tracks/labeltrack/ui/LabelTextHandle.cpp | 3 +- src/tracks/labeltrack/ui/LabelTextHandle.h | 6 +- src/tracks/labeltrack/ui/LabelTrackControls.h | 6 +- .../labeltrack/ui/LabelTrackShifter.cpp | 8 +- .../labeltrack/ui/LabelTrackVRulerControls.h | 2 +- src/tracks/labeltrack/ui/LabelTrackView.cpp | 20 +- src/tracks/labeltrack/ui/LabelTrackView.h | 6 +- .../ui/NoteTrackAffordanceControls.h | 2 +- .../notetrack/ui/NoteTrackButtonHandle.h | 6 +- .../notetrack/ui/NoteTrackControls.cpp | 10 +- .../notetrack/ui/NoteTrackControls.h | 6 +- .../notetrack/ui/NoteTrackShifter.cpp | 4 +- .../notetrack/ui/NoteTrackVRulerControls.cpp | 2 +- .../notetrack/ui/NoteTrackVRulerControls.h | 2 +- .../notetrack/ui/NoteTrackVZoomHandle.cpp | 4 +- .../notetrack/ui/NoteTrackVZoomHandle.h | 2 +- .../notetrack/ui/NoteTrackView.cpp | 16 +- .../notetrack/ui/StretchHandle.cpp | 15 +- .../notetrack/ui/StretchHandle.h | 6 +- .../ui/PlayableTrackButtonHandles.h | 4 +- .../ui/PlayableTrackControls.cpp | 2 +- .../wavetrack/ui/CutlineHandle.cpp | 6 +- .../wavetrack/ui/CutlineHandle.h | 4 +- .../wavetrack/ui/SampleHandle.cpp | 5 +- .../playabletrack/wavetrack/ui/SampleHandle.h | 6 +- .../wavetrack/ui/SpectrumVRulerControls.cpp | 2 +- .../wavetrack/ui/SpectrumVZoomHandle.cpp | 2 +- .../wavetrack/ui/SpectrumVZoomHandle.h | 4 +- .../wavetrack/ui/SpectrumView.cpp | 18 +- .../wavetrack/ui/WaveClipTrimHandle.cpp | 8 +- .../wavetrack/ui/WaveClipTrimHandle.h | 10 +- .../ui/WaveTrackAffordanceControls.cpp | 14 +- .../ui/WaveTrackAffordanceHandle.cpp | 6 +- .../wavetrack/ui/WaveTrackAffordanceHandle.h | 2 +- .../wavetrack/ui/WaveTrackControls.cpp | 64 ++--- .../wavetrack/ui/WaveTrackControls.h | 8 +- .../wavetrack/ui/WaveTrackShifter.cpp | 14 +- .../wavetrack/ui/WaveTrackSliderHandles.cpp | 4 +- .../wavetrack/ui/WaveTrackSliderHandles.h | 8 +- .../wavetrack/ui/WaveTrackView.cpp | 18 +- .../wavetrack/ui/WaveformVRulerControls.cpp | 2 +- .../wavetrack/ui/WaveformVZoomHandle.cpp | 2 +- .../wavetrack/ui/WaveformVZoomHandle.h | 4 +- .../wavetrack/ui/WaveformView.cpp | 35 ++- src/tracks/timetrack/ui/TimeTrackControls.cpp | 12 +- src/tracks/timetrack/ui/TimeTrackControls.h | 6 +- .../timetrack/ui/TimeTrackVRulerControls.h | 2 +- src/tracks/ui/AffordanceHandle.h | 2 +- src/tracks/ui/BackgroundCell.cpp | 2 +- src/tracks/ui/BackgroundCell.h | 2 +- src/tracks/ui/ButtonHandle.h | 18 +- src/tracks/ui/CommonTrackControls.cpp | 12 +- src/tracks/ui/CommonTrackControls.h | 2 +- src/tracks/ui/CommonTrackPanelCell.h | 6 +- src/tracks/ui/CommonTrackView.h | 4 +- src/tracks/ui/EditCursorOverlay.h | 2 +- src/tracks/ui/EnvelopeHandle.h | 4 +- src/tracks/ui/PlayIndicatorOverlay.h | 4 +- src/tracks/ui/ScrubUI.cpp | 6 +- src/tracks/ui/Scrubbing.cpp | 8 +- src/tracks/ui/Scrubbing.h | 4 +- src/tracks/ui/SelectHandle.cpp | 32 +-- src/tracks/ui/SelectHandle.h | 10 +- src/tracks/ui/SliderHandle.h | 16 +- src/tracks/ui/TextEditHelper.cpp | 18 +- src/tracks/ui/TextEditHelper.h | 10 +- src/tracks/ui/TimeShiftHandle.cpp | 8 +- src/tracks/ui/TimeShiftHandle.h | 18 +- src/tracks/ui/TrackButtonHandles.cpp | 10 +- src/tracks/ui/TrackButtonHandles.h | 8 +- src/tracks/ui/TrackControls.cpp | 2 +- src/tracks/ui/TrackControls.h | 4 +- src/tracks/ui/TrackSelectHandle.cpp | 6 +- src/tracks/ui/TrackSelectHandle.h | 4 +- src/tracks/ui/TrackVRulerControls.h | 2 +- src/tracks/ui/TrackView.cpp | 2 +- src/tracks/ui/TrackView.h | 2 +- src/tracks/ui/ZoomHandle.h | 4 +- src/ui/AccessibleLinksFormatter.cpp | 10 +- src/ui/AccessibleLinksFormatter.h | 8 +- src/widgets/AButton.cpp | 50 ++-- src/widgets/AButton.h | 58 ++--- src/widgets/ASlider.cpp | 16 +- src/widgets/ASlider.h | 26 +- src/widgets/AttachableScrollBar.cpp | 9 +- src/widgets/AttachableScrollBar.h | 2 +- src/widgets/AuStaticText.cpp | 4 +- src/widgets/AuStaticText.h | 4 +- src/widgets/AudacityMessageBox.h | 2 +- src/widgets/BackedPanel.h | 2 +- src/widgets/ErrorDialog.h | 4 +- src/widgets/ExpandingToolBar.cpp | 36 +-- src/widgets/ExpandingToolBar.h | 12 +- src/widgets/FileDialog/FileDialog.cpp | 4 +- src/widgets/FileDialog/FileDialog.h | 10 +- .../FileDialog/gtk/FileDialogPrivate.cpp | 20 +- .../FileDialog/gtk/FileDialogPrivate.h | 8 +- src/widgets/FileHistory.cpp | 8 +- src/widgets/FileHistory.h | 6 +- src/widgets/Grabber.h | 10 +- src/widgets/Grid.cpp | 12 +- src/widgets/Grid.h | 35 ++- src/widgets/HelpSystem.cpp | 8 +- src/widgets/HelpSystem.h | 2 +- src/widgets/HtmlWindow.h | 2 +- src/widgets/ImageRoll.cpp | 22 +- src/widgets/ImageRoll.h | 16 +- src/widgets/KeyView.cpp | 8 +- src/widgets/KeyView.h | 28 +- src/widgets/Meter.cpp | 12 +- src/widgets/Meter.h | 4 +- src/widgets/MeterPanelBase.h | 12 +- src/widgets/MultiDialog.cpp | 6 +- src/widgets/NumericTextCtrl.cpp | 50 ++-- src/widgets/NumericTextCtrl.h | 17 +- src/widgets/Overlay.h | 2 +- src/widgets/OverlayPanel.cpp | 6 +- src/widgets/Plot.cpp | 16 +- src/widgets/Plot.h | 4 +- src/widgets/PopupMenuTable.cpp | 4 +- src/widgets/ProgressDialog.cpp | 2 +- src/widgets/ProgressDialog.h | 2 +- src/widgets/ReadOnlyText.h | 4 +- src/widgets/Ruler.h | 6 +- src/widgets/SliderTextCtrl.h | 6 +- src/widgets/UnwritableLocationErrorDialog.h | 2 +- src/widgets/numformatter.cpp | 2 +- src/widgets/valnum.cpp | 8 +- src/widgets/valnum.h | 34 +-- src/widgets/wxTextCtrlWrapper.h | 6 +- 709 files changed, 4722 insertions(+), 4925 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index b3337aaaa1..85126a20e6 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -5,7 +5,7 @@ ### Linux Most distributions do not package all of Saucedacity's dependencies (yet). -wxWidgets 3.1 is required for building Saucedacity but many distributions only +wxWidgets 3.1 or later is required for building Saucedacity but many distributions only package wxWidgets 3.0. [PortMidi](https://github.com/mixxxdj/portmidi) and [PortSMF](https://github.com/tenacityteam/portsmf) are required for MIDI support but some distributions do not package PortSMF (Saucedacity can still build without @@ -15,6 +15,9 @@ distribution package managers either. Optionally, [vcpkg can be used](#vcpkg-on-Linux) to build dependencies from source which may be helpful if your distribution is missing some packages. +**Note**: Building wxWidgets as a static library does **NOT** work! You will need to build +it as a shared library. + Installing ccache and ninja-build is highly recommended for faster builds but not required. CMake will automatically use ccache if it is installed. @@ -26,7 +29,7 @@ To install Saucedacity's dependencies, run: sudo apt-get install build-essential libavcodec-dev libavformat-dev libavutil-dev libflac++-dev libglib2.0-dev libgtk-3-dev libid3tag0-dev libjack-dev liblilv-dev libmad0-dev libmp3lame-dev libogg-dev libpng-dev portaudio19-dev libportmidi-dev libportsmf-dev libserd-dev libsndfile1-dev libsord-dev libsoundtouch-dev libsoxr-dev libsuil-dev libtwolame-dev vamp-plugin-sdk libvorbis-dev lv2-dev zlib1g-dev cmake ninja-build libjpeg-dev libtiff-dev liblzma-dev libsqlite3-dev ``` -wxWidgets 3.1 is required but not packaged in Debian or Ubuntu. Refer +wxWidgets 3.1 or later is required but not packaged in Debian or Ubuntu. Refer to the [wxWidgets documentation](https://docs.wxwidgets.org/3.1/overview_cmake.html) for how to install it from source code. The above package list diff --git a/lib-src/libnyquist/nyquist/cmt/cext.c b/lib-src/libnyquist/nyquist/cmt/cext.c index 452e18f2d4..c52dafd535 100644 --- a/lib-src/libnyquist/nyquist/cmt/cext.c +++ b/lib-src/libnyquist/nyquist/cmt/cext.c @@ -18,11 +18,11 @@ #include "cext.h" #include "userio.h" -#define calc_middle(top, bot) (((top - bot) / 2 ) + bottom ) +#define calc_middle(top, bot) ((((top) - (bot)) / 2 ) + bottom ) #define kbyte 1000 -#define outof_mem(blocksize) (blocksize == 0 ) -#define done_search(top, bot, middle) ( (( (top - bot) < kbyte ) && \ +#define outof_mem(blocksize) ((blocksize) == 0 ) +#define done_search(top, bot, middle) ( (( ((top) - (bot)) < kbyte ) && \ ( !toomuch_mem(middle)) ) || \ ( outof_mem( middle )) ) diff --git a/lib-src/libnyquist/nyquist/cmt/cmtio.h b/lib-src/libnyquist/nyquist/cmt/cmtio.h index 232862b507..2ca48ade43 100644 --- a/lib-src/libnyquist/nyquist/cmt/cmtio.h +++ b/lib-src/libnyquist/nyquist/cmt/cmtio.h @@ -1,4 +1,4 @@ -#define NOCHAR -2 +#define NOCHAR (-2) extern int IOinputfd; extern int IOnochar; diff --git a/lib-src/libnyquist/nyquist/cmt/midifile.c b/lib-src/libnyquist/nyquist/cmt/midifile.c index 878441a598..f94c6d8f78 100644 --- a/lib-src/libnyquist/nyquist/cmt/midifile.c +++ b/lib-src/libnyquist/nyquist/cmt/midifile.c @@ -22,7 +22,7 @@ #include "userio.h" #include "string.h" -#define MIDIFILE_ERROR -1 +#define MIDIFILE_ERROR (-1) #ifdef PROTOTYPES #define NOARGS void @@ -365,7 +365,6 @@ readtrack() /* read a track chunk */ } if ( Mf_endtrack ) (*Mf_endtrack)(); - return; } static void diff --git a/lib-src/libnyquist/nyquist/cmt/midifns.c b/lib-src/libnyquist/nyquist/cmt/midifns.c index a524f723ee..a84c911d13 100644 --- a/lib-src/libnyquist/nyquist/cmt/midifns.c +++ b/lib-src/libnyquist/nyquist/cmt/midifns.c @@ -440,8 +440,7 @@ void eventwait(long timeout) int c = getc(stdin); ungetc(c, stdin); } - return; -} + } #else void eventwait(long timeout) { @@ -955,7 +954,7 @@ void midi_bend(int channel, int value) * ****************************************************************************/ -boolean midi_buffer(byte huge *buffer, ulong size) +boolean midi_buffer(const byte huge *buffer, ulong size) { if (!buffer) return FALSE; #ifdef AMIGA diff --git a/lib-src/libnyquist/nyquist/cmt/midifns.h b/lib-src/libnyquist/nyquist/cmt/midifns.h index 1bac6bf966..47a5378d7f 100644 --- a/lib-src/libnyquist/nyquist/cmt/midifns.h +++ b/lib-src/libnyquist/nyquist/cmt/midifns.h @@ -101,7 +101,7 @@ void l_rest(long time); void l_restuntil(long time); void metronome(boolean onflag); void midi_bend(int channel, int value); -boolean midi_buffer(byte *buffer, ulong size); +boolean midi_buffer(const byte *buffer, ulong size); void midi_clock(void); void midi_cont(boolean onflag); void midi_ctrl(int channel, int control, int value); diff --git a/lib-src/libnyquist/nyquist/cmt/musiprog.h b/lib-src/libnyquist/nyquist/cmt/musiprog.h index ddd9f95c12..25a93e9654 100644 --- a/lib-src/libnyquist/nyquist/cmt/musiprog.h +++ b/lib-src/libnyquist/nyquist/cmt/musiprog.h @@ -23,9 +23,9 @@ * make a nested call to rest(), the original rest will be locked out * until the nested one returns. It's better to use cause(). */ -#define rest(x) l_rest( (long) x ) -#define restuntil(x) l_restuntil( (long) x) +#define rest(x) l_rest( (long) (x) ) +#define restuntil(x) l_restuntil( (long) (x)) -#define repeat(var, count) {int var; for (var=1; var <= count; var++) { +#define repeat(var, count) {int (var); for ((var)=1; (var) <= (count); (var)++) { #define endrep ;}} diff --git a/lib-src/libnyquist/nyquist/cmt/seq.c b/lib-src/libnyquist/nyquist/cmt/seq.c index bb04a5b384..542389b601 100644 --- a/lib-src/libnyquist/nyquist/cmt/seq.c +++ b/lib-src/libnyquist/nyquist/cmt/seq.c @@ -42,7 +42,7 @@ private char *chunk_alloc(seq_type seq, int size); private void clock_tick(call_args_type args); private void ramp_event(call_args_type args); /*private*/ void send_macro(register unsigned char *ptr, int voice, - short parameter[], int parm_num, int value, int nline); + const short parameter[], int parm_num, int value, int nline); /* chunk_alloc -- allocate data for a sequence */ /* @@ -776,7 +776,7 @@ void report_enabled_channels(seq) void send_macro(ptr, voice, parameter, parm_num, value, nline) register unsigned char *ptr; int voice; - short parameter[]; + const short parameter[]; int parm_num; int value; int nline; diff --git a/lib-src/libnyquist/nyquist/cmt/seq.h b/lib-src/libnyquist/nyquist/cmt/seq.h index 4cba974144..b1f9072ce5 100644 --- a/lib-src/libnyquist/nyquist/cmt/seq.h +++ b/lib-src/libnyquist/nyquist/cmt/seq.h @@ -211,23 +211,23 @@ extern seq_type sequence; chunk_type chunk_create(boolean first_flag); #define seq_cause_noteoff(seq, delay, voice, pitch) \ - (*(((seq_type) seq)->cause_noteoff_fn))(seq, delay, voice, pitch) + (*(((seq_type) (seq))->cause_noteoff_fn))(seq, delay, voice, pitch) #define seq_midi_bend(seq, voice, value) \ - (*(((seq_type) seq)->midi_bend_fn))(seq, voice, value) + (*(((seq_type) (seq))->midi_bend_fn))(seq, voice, value) #define seq_midi_ctrl(seq, voice, ctrl, value) \ - (*(((seq_type) seq)->midi_ctrl_fn))(seq, voice, ctrl, value) + (*(((seq_type) (seq))->midi_ctrl_fn))(seq, voice, ctrl, value) #define seq_midi_program(seq, voice, prog) \ - (*(((seq_type) seq)->midi_program_fn))(seq, voice, prog) + (*(((seq_type) (seq))->midi_program_fn))(seq, voice, prog) #define seq_midi_touch(seq, voice, value) \ - (*(((seq_type) seq)->midi_touch_fn))(seq, voice, value) + (*(((seq_type) (seq))->midi_touch_fn))(seq, voice, value) #define seq_noteoff(seq, args) \ - (*(((seq_type) seq)->noteoff_fn))(args) + (*(((seq_type) (seq))->noteoff_fn))(args) #define seq_noteon(seq, voice, pitch, vel) \ - (*(((seq_type) seq)->noteon_fn))(seq, voice, pitch, vel) -#define seq_free(seq) (*(((seq_type) seq)->free_fn))(seq) + (*(((seq_type) (seq))->noteon_fn))(seq, voice, pitch, vel) +#define seq_free(seq) (*(((seq_type) (seq))->free_fn))(seq) #define seq_register(seq) \ - cu_register((cu_fn_type) (((seq_type) seq)->free_fn), seq) -#define seq_reset(seq) (*(((seq_type) seq)->reset_fn))(seq) + cu_register((cu_fn_type) (((seq_type) (seq))->free_fn), seq) +#define seq_reset(seq) (*(((seq_type) (seq))->reset_fn))(seq) /* LISP: void (SEQ-RESET SEQ) */ extern boolean seq_print; /* debugging switch */ @@ -266,10 +266,10 @@ void seq_cause_noteoff_meth(seq_type seq, time_type delay, int voice, int pitch) seq_type seq_copy(seq_type from_seq); /* LISP: (SEQ-COPY SEQ) */ seq_type seq_create(void); /* LISP: (SEQ-CREATE) */ void seq_cycle(seq_type seq, boolean flag, time_type dur); -#define seq_duration(seq) (((seq_type) seq)->chunklist->u.info.duration) +#define seq_duration(seq) (((seq_type) (seq))->chunklist->u.info.duration) void seq_end_event(call_args_type args); -#define seq_events(seq) (((seq_type) seq)->chunklist ? \ - (((seq_type) seq)->chunklist->u.info.eventlist) : NULL) +#define seq_events(seq) (((seq_type) (seq))->chunklist ? \ + (((seq_type) (seq))->chunklist->u.info.eventlist) : NULL) #define seq_dictionary(seq) (seq)->chunklist->u.info.dictionary #define seq_eventlist(seq) (seq)->chunklist->u.info.eventlist #define seq_ctrlcount(seq) (seq)->chunklist->u.info.ctrlcount @@ -277,7 +277,7 @@ void seq_end_event(call_args_type args); #define seq_used_mask(seq) (seq)->chunklist->u.info.used_mask void seq_free_chunks(seq_type seq); seq_type seq_init(seq_type seq, int create_chunk); -#define seq_loudness(seq) (((seq_type) seq)->loudness) +#define seq_loudness(seq) (((seq_type) (seq))->loudness) void seq_midi_bend_meth(seq_type seq, int voice, int value); void seq_midi_ctrl_meth(seq_type seq, int voice, int ctrl, int value); void seq_midi_program_meth(seq_type seq, int voice, int prog); @@ -286,15 +286,15 @@ void seq_noteon_meth(seq_type seq, int voice, int pitch, int vel); void seq_noteoff_meth(call_args_type args); time_type seq_pause(seq_type seq, boolean flag); void seq_play(seq_type seq); -#define seq_rate(seq) ((seq_type) seq)->rate +#define seq_rate(seq) ((seq_type) (seq))->rate void seq_reset_meth(seq_type seq); -#define seq_runflag(seq) ((seq_type) seq)->runflag +#define seq_runflag(seq) ((seq_type) (seq))->runflag #define seq_set_channel_mask(seq, cm) ((seq)->channel_mask) = (cm) void seq_set_loudness(seq_type seq, int offset); void seq_set_rate(seq_type seq, time_type rate); -#define seq_set_timebase(seq, tb) ((seq_type) seq)->timebase = (tb) +#define seq_set_timebase(seq, tb) ((seq_type) (seq))->timebase = (tb) void seq_set_transpose(seq_type seq, int trans); void seq_start_time(seq_type seq, time_type start_time); void seq_stop(seq_type seq); -#define seq_timebase(seq) ((seq_type) seq)->timebase -#define seq_transpose(seq) ((seq_type) seq)->transpose +#define seq_timebase(seq) ((seq_type) (seq))->timebase +#define seq_transpose(seq) ((seq_type) (seq))->transpose diff --git a/lib-src/libnyquist/nyquist/cmt/seqmwrite.c b/lib-src/libnyquist/nyquist/cmt/seqmwrite.c index f7bc4bde9e..06b3e07c16 100644 --- a/lib-src/libnyquist/nyquist/cmt/seqmwrite.c +++ b/lib-src/libnyquist/nyquist/cmt/seqmwrite.c @@ -54,7 +54,7 @@ private void smfw_noteoff(call_args_type args); private void smfw_noteon(seq_type seq, int voice, int pitch, int vel); private void smfw_process_event(call_args_type args); private void smfw_ramp_event(call_args_type args); -private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[], +private void smfw_send_macro(unsigned char *ptr, int voice, const short parameter[], int parm_num, int value); private void smfw_touch(seq_type seq, int voice, int value); private void writevarlen(long value); @@ -520,7 +520,7 @@ private void smfw_ramp_event(call_args_type args) /* smfw_send_macro -- write msg to midi file from a seq "macro" event */ /**/ -private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[], +private void smfw_send_macro(unsigned char *ptr, int voice, const short parameter[], int parm_num, int value) { unsigned char code, *loc; diff --git a/lib-src/libnyquist/nyquist/cmt/seqread.c b/lib-src/libnyquist/nyquist/cmt/seqread.c index 7d4d1e960d..4812f031ec 100644 --- a/lib-src/libnyquist/nyquist/cmt/seqread.c +++ b/lib-src/libnyquist/nyquist/cmt/seqread.c @@ -106,11 +106,11 @@ extern int abort_flag; 8 bits from the right: ****************************************************************************/ -#define precise(x) (((time_type) x) << 8) -#define seqround(x) ((((time_type) x) + 128) >> 8) -#define trunc(x) (((time_type) x) >> 8) +#define precise(x) (((time_type) (x)) << 8) +#define seqround(x) ((((time_type) (x)) + 128) >> 8) +#define trunc(x) (((time_type) (x)) >> 8) -#define nullstring(s) (s[0] == EOS) +#define nullstring(s) ((s)[0] == EOS) /**************************************************************************** @@ -146,7 +146,7 @@ private void parsefield(void); private boolean parsenote(void); private boolean parseparm(long *valptr); private int scan(void); -private int scan1(char *start); +private int scan1(const char *start); private long scanint(void); private void scansymb(char *); private long scansgnint(void); @@ -1744,7 +1744,7 @@ private int scan(void) * copies one char from start into token, converting to upper case ****************************************************************************/ -private int scan1(char *start) +private int scan1(const char *start) { int i = 0; diff --git a/lib-src/libnyquist/nyquist/cmt/timebase.h b/lib-src/libnyquist/nyquist/cmt/timebase.h index cd67b379c9..c4d191200a 100644 --- a/lib-src/libnyquist/nyquist/cmt/timebase.h +++ b/lib-src/libnyquist/nyquist/cmt/timebase.h @@ -59,9 +59,9 @@ void timebase_use(timebase_type base); ((base)->virt_base + (((rtime) - (base)->real_base) << 8) / (base)->rate)) #define virt_to_real(base, vtime) ((base)->rate >= STOPRATE ? \ - ((base)->virt_base > vtime ? (base)->real_base : MAXTIME) : \ + ((base)->virt_base > (vtime) ? (base)->real_base : MAXTIME) : \ (base)->real_base + ((((vtime) - (base)->virt_base) * (base)->rate) >> 8)) #define virt_to_real_256(base, vtime) ((base)->rate >= STOPRATE ? \ - ((base)->virt_base > vtime ? (base)->real_base << 8 : MAXTIME) : \ + ((base)->virt_base > (vtime) ? (base)->real_base << 8 : MAXTIME) : \ ((base)->real_base << 8) + ((((vtime) - (base)->virt_base) * (base)->rate))) diff --git a/lib-src/libnyquist/nyquist/cmt/userio.c b/lib-src/libnyquist/nyquist/cmt/userio.c index 0ffea9fabc..e70885399d 100644 --- a/lib-src/libnyquist/nyquist/cmt/userio.c +++ b/lib-src/libnyquist/nyquist/cmt/userio.c @@ -448,7 +448,7 @@ int askbool(prompt, deflt) char *prompt; int deflt; { -#define undefined -1 +#define undefined (-1) char defchar; /* the default answer */ char c; /* user input */ char in_string[100]; diff --git a/lib-src/libnyquist/nyquist/cmt/userio.h b/lib-src/libnyquist/nyquist/cmt/userio.h index 86850b19e5..8aeb71dec9 100644 --- a/lib-src/libnyquist/nyquist/cmt/userio.h +++ b/lib-src/libnyquist/nyquist/cmt/userio.h @@ -43,7 +43,7 @@ #define BREAK_LEVEL 1 #define ABORT_LEVEL 2 -#define read_to_eol(ch) if (ch != CR) { char temp[100]; ggets(temp); } +#define read_to_eol(ch) if ((ch) != CR) { char temp[100]; ggets(temp); } extern char fileopen_name[]; extern int abort_flag; diff --git a/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c b/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c index 43c4e336cf..2a99430c9c 100644 --- a/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c +++ b/lib-src/libnyquist/nyquist/cmupv/src/cmupv.c @@ -909,7 +909,7 @@ void compute_one_frame(PV *pv, int ana_hopsize) } -void update_position_queue(PV *pv, float *ana_center) +void update_position_queue(PV *pv, const float *ana_center) { int fftsize = pv->fftsize; float *frame_next = pv->frame_next; diff --git a/lib-src/libnyquist/nyquist/ffts/src/fftlib.c b/lib-src/libnyquist/nyquist/ffts/src/fftlib.c index 5a4c0e8c76..910e51934d 100644 --- a/lib-src/libnyquist/nyquist/ffts/src/fftlib.c +++ b/lib-src/libnyquist/nyquist/ffts/src/fftlib.c @@ -66,7 +66,7 @@ parts of ffts1 *************************************************/ //inline void bitrevR2(float *ioptr, long M, short *BRLow); -static inline void bitrevR2(float *ioptr, long M, short *BRLow){ +static inline void bitrevR2(float *ioptr, long M, const short *BRLow){ /*** bit reverse and first radix 2 stage of forward or inverse fft ***/ float f0r; float f0i; @@ -1130,7 +1130,7 @@ parts of iffts1 *************************************************/ // inline void scbitrevR2(float *ioptr, long M, short *BRLow, float scale); -static inline void scbitrevR2(float *ioptr, long M, short *BRLow, float scale){ +static inline void scbitrevR2(float *ioptr, long M, const short *BRLow, float scale){ /*** scaled bit reverse and first radix 2 stage forward or inverse fft ***/ float f0r; float f0i; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp b/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp index e46d81ac6d..653e5e27ac 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp +++ b/lib-src/libnyquist/nyquist/nyqsrc/f0.cpp @@ -1,6 +1,6 @@ // f0 -- frequency estimation -#include +#include @@ -38,7 +38,7 @@ float parabolic_interp(float x1, float x2, float x3, float y1, float y2, float y -float f0_estimate(float *samples, int n, int m, float threshold, float *results, float *min) +float f0_estimate(const float *samples, int n, int m, float threshold, float *results, float *min) // samples is a buffer of samples // n is the number of samples, equals twice longest period, must be even // m is the shortest period in samples @@ -121,7 +121,7 @@ float best_f0(float *samples, int n, int m, float threshold, int Tmax) // results is an array of size n/2 - m + 1, the number of different lags // Tmax is the length of the search { - float* results=new float[n/2-m+1]; + auto* results=new float[n/2-m+1]; float min=10000000.0; float temp; float best_f0; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.c b/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.c index d78d5c545a..fc83762307 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.c @@ -25,7 +25,7 @@ fast_float FilterUp(float Imp[], float ImpD[], int Nwing, boolean Interp, - float *Xp, double Ph, int Inc) + const float *Xp, double Ph, int Inc) { float *Hp, *Hdp = NULL, *End; fast_float a = 0; @@ -77,7 +77,7 @@ fast_float FilterUp(float Imp[], float ImpD[], fast_float FilterUD( float Imp[], float ImpD[], int Nwing, boolean Interp, - float *Xp, double Ph, int Inc, double dhb) + const float *Xp, double Ph, int Inc, double dhb) { double a; float *Hp, *Hdp, *End; diff --git a/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.h b/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.h index d277e7d871..4b25814da6 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.h @@ -7,9 +7,9 @@ */ fast_float FilterUp(mem_float Imp[], mem_float ImpD[], int Nwing, - boolean Interp, mem_float *Xp, double Ph, int Inc); + boolean Interp, const mem_float *Xp, double Ph, int Inc); fast_float FilterUD(mem_float Imp[], mem_float ImpD[], int Nwing, - boolean Interp, mem_float *Xp, double Ph, int Inc, + boolean Interp, const mem_float *Xp, double Ph, int Inc, double dhb); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/lpanal.c b/lib-src/libnyquist/nyquist/nyqsrc/lpanal.c index 92e6c1a17f..d7582f44c9 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/lpanal.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/lpanal.c @@ -28,7 +28,7 @@ void abs_max(double *x, long desde, long hasta, double *x_maxptr, long *indptr) } -void xcorr(double *s, double *rxx, long N) +void xcorr(const double *s, double *rxx, long N) { /* use: xcorr(s,rxx,N); diff --git a/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c b/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c index d86d2b5c75..0cdcb0cdaf 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/multiseq.c @@ -142,11 +142,11 @@ sample_block_type multiseq_get_next(sound_type snd, long * cnt); void multiseq_print_tree(snd_susp_type a_susp, int n); -#define susp_cnt_time(ssp, ms, cnt) (ssp->susp.t0 - ms->t0 + (cnt)/ssp->s1->sr) +#define susp_cnt_time(ssp, ms, cnt) ((ssp)->susp.t0 - (ms)->t0 + (cnt)/(ssp)->s1->sr) #define susp_time(ssp, ms) susp_cnt_time(ssp, ms, \ - (ssp->susp.current + ssp->s1_cnt)) -#define susp_low_water(ssp, ms) susp_cnt_time(ssp, ms, ssp->susp.current) -#define susp_log_stop_time(ssp, ms) susp_cnt_time(ssp, ms, ssp->susp.log_stop_cnt) + ((ssp)->susp.current + (ssp)->s1_cnt)) +#define susp_low_water(ssp, ms) susp_cnt_time(ssp, ms, (ssp)->susp.current) +#define susp_log_stop_time(ssp, ms) susp_cnt_time(ssp, ms, (ssp)->susp.log_stop_cnt) /* multiseq_advance fetches from each channel to advance to target time */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndread.c b/lib-src/libnyquist/nyquist/nyqsrc/sndread.c index 251f9e0528..2ad9734615 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndread.c +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndread.c @@ -108,7 +108,7 @@ LVAL snd_make_read( long *channels, /* number of channels */ long *mode, /* sample format: PCM, ALAW, etc. */ long *bits, /* BPS: bits per sample */ - long *swap, /* swap bytes */ + const long *swap, /* swap bytes */ double *srate, /* srate: sample rate */ double *dur, /* duration (in seconds) to read */ long *flags) /* which parameters have been set */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sndread.h b/lib-src/libnyquist/nyquist/nyqsrc/sndread.h index db580cc33a..e8997e6174 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sndread.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sndread.h @@ -13,7 +13,7 @@ typedef struct read_susp_struct { LVAL snd_make_read(unsigned char *filename, time_type offset, time_type t0, - long *format, long *channels, long *mode, long *bits, long *swap, + long *format, long *channels, long *mode, long *bits, const long *swap, double *srate, double *dur, long *flags); /* LISP: (SND-READ STRING ANYNUM ANYNUM LONG* LONG* LONG* LONG* LONG* ANYNUM* ANYNUM* LONG^) */ diff --git a/lib-src/libnyquist/nyquist/nyqsrc/sound.h b/lib-src/libnyquist/nyquist/nyqsrc/sound.h index 328a8af92c..42ec96568e 100644 --- a/lib-src/libnyquist/nyquist/nyqsrc/sound.h +++ b/lib-src/libnyquist/nyquist/nyqsrc/sound.h @@ -30,7 +30,7 @@ extern int nosc_enabled; /* enable polling for OSC messages */ /* default stop time (for clipping) */ #define MAX_STOP_TIME 10E20 /* LISP-SRC: (SETF MAX-STOP-TIME 10E20) */ -#define MIN_START_TIME -10E20 +#define MIN_START_TIME (-10E20) /* LISP-SRC: (SETF MIN-START-TIME -10E20) */ /* conversion from float to integer */ @@ -463,7 +463,7 @@ void table_unref(table_type table); sound_type sound_zero(time_type t0, rate_type sr); /* LISP: (SND-ZERO ANYNUM ANYNUM) */ -#define sound_get_next(s, n) ((*(s->get_next))(s, n)) +#define sound_get_next(s, n) ((*((s)->get_next))(s, n)) #define susp_print_tree(s, n) (*((s)->print_tree))(s, n) @@ -486,7 +486,7 @@ double step_to_hz(double); #define susp_check_samples_break(sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ - x2_sample = susp_current_sample(sound, sample_ptr); } + (x2_sample) = susp_current_sample(sound, sample_ptr); } /* susp_get_samples always gets next block (useful only in initialization code) */ @@ -550,15 +550,15 @@ double step_to_hz(double); susp_get_block_samples(sound, sample_block_ptr, \ sample_ptr, sample_cnt); \ if (susp->sound->logical_stop_cnt != UNKNOWN && \ - !(susp->logical_stop_bits & bit)) { \ - susp->logical_stop_bits |= bit; \ + !(susp->logical_stop_bits & (bit))) { \ + susp->logical_stop_bits |= (bit); \ susp->susp.log_stop_cnt = (int64_t) max(susp->susp.log_stop_cnt, \ (((susp->sound->logical_stop_cnt / \ susp->sound->sr + susp->sound->t0) - \ susp->susp.t0) * susp->susp.sr + 0.5)); } \ if (susp->sample_ptr == zero_block->samples) { \ - susp->terminate_bits |= bit; \ - if (susp->terminate_bits == all) { \ + susp->terminate_bits |= (bit); \ + if (susp->terminate_bits == (all)) { \ susp->terminate_cnt = ROUNDBIG( \ (((susp->sound->current - susp->sample_cnt) / \ susp->sound->sr + susp->sound->t0) - \ @@ -575,8 +575,8 @@ double step_to_hz(double); * start times - maybe it should. */ #define logical_stop_cnt_cvt(sound) \ - (sound->logical_stop_cnt == UNKNOWN ? UNKNOWN : \ - ROUNDBIG((sound->logical_stop_cnt / sound->sr) * susp->susp.sr)) + ((sound)->logical_stop_cnt == UNKNOWN ? UNKNOWN : \ + ROUNDBIG(((sound)->logical_stop_cnt / (sound)->sr) * susp->susp.sr)) /* logical_stop_test tests to see if sound has logically stopped; if so, @@ -611,11 +611,11 @@ double step_to_hz(double); sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ - x2_sample = susp_current_sample(sound, sample_ptr); \ + (x2_sample) = susp_current_sample(sound, sample_ptr); \ terminate_test(sample_ptr, sound, susp->sample_cnt); \ if (susp->terminate_cnt < susp->susp.current + cnt + togo) { \ break; }} \ - else x2_sample = susp_current_sample(sound, sample_ptr); + else (x2_sample) = susp_current_sample(sound, sample_ptr); /* susp_check_log_samples_break checks for new samples then checks for * logical stop conditions; breaks from inner loop @@ -624,12 +624,12 @@ double step_to_hz(double); sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ - x2_sample = susp_current_sample(sound, sample_ptr); \ + (x2_sample) = susp_current_sample(sound, sample_ptr); \ logical_stop_test(sound, susp->sample_cnt); \ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN && \ (susp->susp.log_stop_cnt < susp->susp.current + cnt + togo)) { \ break; }} \ - else x2_sample = susp_current_sample(sound, sample_ptr); + else (x2_sample) = susp_current_sample(sound, sample_ptr); /* susp_check_term_log_samples_break checks for new samples then checks for @@ -639,7 +639,7 @@ double step_to_hz(double); sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ - x2_sample = susp_current_sample(sound, sample_ptr); \ + (x2_sample) = susp_current_sample(sound, sample_ptr); \ terminate_test(sample_ptr, sound, susp->sample_cnt); \ logical_stop_test(sound, susp->sample_cnt); \ if ((susp->terminate_cnt != UNKNOWN && \ @@ -647,6 +647,6 @@ double step_to_hz(double); (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN && \ susp->susp.log_stop_cnt < susp->susp.current + cnt + togo)) { \ break; }} \ - else x2_sample = susp_current_sample(sound, sample_ptr); + else (x2_sample) = susp_current_sample(sound, sample_ptr); diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/ADSR.h b/lib-src/libnyquist/nyquist/nyqstk/include/ADSR.h index 521514dc94..f046b84efa 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/ADSR.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/ADSR.h @@ -31,16 +31,16 @@ class ADSR : public Envelope enum { ATTACK, DECAY, SUSTAIN, RELEASE, DONE }; //! Default constructor. - ADSR(void); + ADSR(); //! Class destructor. - ~ADSR(void); + ~ADSR() override; //! Set target = 1, state = \e ADSR::ATTACK. - void keyOn(void); + void keyOn() override; //! Set target = 0, state = \e ADSR::RELEASE. - void keyOff(void); + void keyOff() override; //! Set the attack rate. void setAttackRate(StkFloat rate); @@ -67,17 +67,17 @@ class ADSR : public Envelope void setAllTimes(StkFloat aTime, StkFloat dTime, StkFloat sLevel, StkFloat rTime); //! Set the target value. - void setTarget(StkFloat target); + void setTarget(StkFloat target) override; //! Return the current envelope \e state (ATTACK, DECAY, SUSTAIN, RELEASE, DONE). - int getState(void) const; + int getState() const override; //! Set to state = ADSR::SUSTAIN with current and target values of \e aValue. - void setValue(StkFloat value); + void setValue(StkFloat value) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; StkFloat attackRate_; StkFloat decayRate_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/BandedWG.h b/lib-src/libnyquist/nyquist/nyqstk/include/BandedWG.h index 9323a3efc1..b5092276f8 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/BandedWG.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/BandedWG.h @@ -55,7 +55,7 @@ class BandedWG : public Instrmnt BandedWG(); //! Class destructor. - ~BandedWG(); + ~BandedWG() override; //! Reset and clear all internal state. void clear(); @@ -67,7 +67,7 @@ class BandedWG : public Instrmnt void setPreset(int preset); //! Set instrument parameters for a particular frequency. - void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Apply bow velocity/pressure to instrument with given amplitude and rate of increase. void startBowing(StkFloat amplitude, StkFloat rate); @@ -79,17 +79,17 @@ class BandedWG : public Instrmnt void pluck(StkFloat amp); //! Start a note with the given frequency and amplitude. - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Stop a note with the given amplitude (speed of decay). - void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - void controlChange(int number, StkFloat value); + void controlChange(int number, StkFloat value) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; bool doPluck_; bool trackVelocity_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/BiQuad.h b/lib-src/libnyquist/nyquist/nyqstk/include/BiQuad.h index d4e6cc85f1..994bbc5eea 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/BiQuad.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/BiQuad.h @@ -28,10 +28,10 @@ class BiQuad : protected Filter BiQuad(); //! Class destructor. - virtual ~BiQuad(); + ~BiQuad() override; //! Clears all internal states of the filter. - void clear(void); + void clear(); //! Set the b[0] coefficient value. void setB0(StkFloat b0); @@ -85,16 +85,16 @@ class BiQuad : protected Filter The gain is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0. */ - void setGain(StkFloat gain); + void setGain(StkFloat gain) override; //! Return the current filter gain. - StkFloat getGain(void) const; + StkFloat getGain() const override; //! Return the last computed output value. - StkFloat lastOut(void) const; + StkFloat lastOut() const override; //! Input one sample to the filter and return one output. - virtual StkFloat tick(StkFloat sample); + StkFloat tick(StkFloat sample) override; //! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs. /*! @@ -103,7 +103,7 @@ class BiQuad : protected Filter channel argument is equal to or greater than the number of channels in the StkFrames object. */ - virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); + StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) override; protected: diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/BowTable.h b/lib-src/libnyquist/nyquist/nyqstk/include/BowTable.h index 6604176112..ad3e46262c 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/BowTable.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/BowTable.h @@ -24,7 +24,7 @@ class BowTable : public Function BowTable(); //! Class destructor. - ~BowTable(); + ~BowTable() override; //! Set the table offset value. /*! @@ -44,7 +44,7 @@ class BowTable : public Function protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; StkFloat offset_; StkFloat slope_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Bowed.h b/lib-src/libnyquist/nyquist/nyqstk/include/Bowed.h index a4551f7e0b..c17e46fb9e 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Bowed.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Bowed.h @@ -39,16 +39,16 @@ class Bowed : public Instrmnt { public: //! Class constructor, taking the lowest desired playing frequency. - Bowed(StkFloat lowestFrequency); + explicit Bowed(StkFloat lowestFrequency); //! Class destructor. - ~Bowed(); + ~Bowed() override; //! Reset and clear all internal state. void clear(); //! Set instrument parameters for a particular frequency. - void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Set vibrato gain. void setVibrato(StkFloat gain); @@ -60,17 +60,17 @@ class Bowed : public Instrmnt void stopBowing(StkFloat rate); //! Start a note with the given frequency and amplitude. - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Stop a note with the given amplitude (speed of decay). - void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - void controlChange(int number, StkFloat value); + void controlChange(int number, StkFloat value) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; DelayL neckDelay_; DelayL bridgeDelay_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Chorus.h b/lib-src/libnyquist/nyquist/nyqstk/include/Chorus.h index 5da10e1efd..04ae00595a 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Chorus.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Chorus.h @@ -25,13 +25,13 @@ class Chorus : public Effect /*! An StkError can be thrown if the rawwave path is incorrect. */ - Chorus( StkFloat baseDelay = 6000 ); + explicit Chorus( StkFloat baseDelay = 6000 ); //! Class destructor. - ~Chorus(); + ~Chorus() override; //! Reset and clear all internal state. - void clear(); + void clear() override; //! Set modulation depth. void setModDepth(StkFloat depth); @@ -41,7 +41,7 @@ class Chorus : public Effect protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; DelayL delayLine_[2]; SineWave mods_[2]; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Clarinet.h b/lib-src/libnyquist/nyquist/nyqstk/include/Clarinet.h index fb7d43dc18..480b32def1 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Clarinet.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Clarinet.h @@ -43,16 +43,16 @@ class Clarinet : public Instrmnt /*! An StkError will be thrown if the rawwave path is incorrectly set. */ - Clarinet(StkFloat lowestFrequency); + explicit Clarinet(StkFloat lowestFrequency); //! Class destructor. - ~Clarinet(); + ~Clarinet() override; //! Reset and clear all internal state. void clear(); //! Set instrument parameters for a particular frequency. - void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Apply breath pressure to instrument with given amplitude and rate of increase. void startBlowing(StkFloat amplitude, StkFloat rate); @@ -61,17 +61,17 @@ class Clarinet : public Instrmnt void stopBlowing(StkFloat rate); //! Start a note with the given frequency and amplitude. - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Stop a note with the given amplitude (speed of decay). - void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - void controlChange(int number, StkFloat value); + void controlChange(int number, StkFloat value) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; DelayL delayLine_; ReedTable reedTable_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Delay.h b/lib-src/libnyquist/nyquist/nyqstk/include/Delay.h index 413944c232..8ca55d9fe4 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Delay.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Delay.h @@ -42,7 +42,7 @@ class Delay : protected Filter Delay(unsigned long delay, unsigned long maxDelay); //! Class destructor. - virtual ~Delay(); + ~Delay() override; //! Clears the internal state of the delay line. void clear(); @@ -64,10 +64,10 @@ class Delay : protected Filter void setDelay(unsigned long delay); //! Return the current delay-line length. - unsigned long getDelay(void) const; + unsigned long getDelay() const; //! Calculate and return the signal energy in the delay-line. - StkFloat energy(void) const; + StkFloat energy() const; //! Return the value at \e tapDelay samples from the delay-line input. /*! @@ -78,16 +78,16 @@ class Delay : protected Filter StkFloat contentsAt(unsigned long tapDelay); //! Return the last computed output value. - StkFloat lastOut(void) const; + StkFloat lastOut() const override; //! Return the value which will be output by the next call to tick(). /*! This method is valid only for delay settings greater than zero! */ - virtual StkFloat nextOut(void); + virtual StkFloat nextOut(); //! Input one sample to the filter and return one output. - virtual StkFloat tick(StkFloat sample); + StkFloat tick(StkFloat sample) override; //! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs. /*! @@ -96,7 +96,7 @@ class Delay : protected Filter channel argument is equal to or greater than the number of channels in the StkFrames object. */ - virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); + StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) override; protected: diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/DelayA.h b/lib-src/libnyquist/nyquist/nyqstk/include/DelayA.h index 4f17527e81..1d513d1730 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/DelayA.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/DelayA.h @@ -43,7 +43,7 @@ class DelayA : public Delay DelayA(StkFloat delay, unsigned long maxDelay); //! Class destructor. - ~DelayA(); + ~DelayA() override; //! Clears the internal state of the delay line. void clear(); @@ -55,17 +55,17 @@ class DelayA : public Delay void setDelay(StkFloat delay); //! Return the current delay-line length. - StkFloat getDelay(void) const; + StkFloat getDelay() const; //! Return the value which will be output by the next call to tick(). /*! This method is valid only for delay settings greater than zero! */ - StkFloat nextOut(void); + StkFloat nextOut() override; protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; StkFloat alpha_; StkFloat coeff_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/DelayL.h b/lib-src/libnyquist/nyquist/nyqstk/include/DelayL.h index fa97581579..bbc5e977ef 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/DelayL.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/DelayL.h @@ -46,7 +46,7 @@ class DelayL : public Delay DelayL(StkFloat delay, unsigned long maxDelay); //! Class destructor. - ~DelayL(); + ~DelayL() override; //! Set the delay-line length. /*! @@ -55,17 +55,17 @@ class DelayL : public Delay void setDelay(StkFloat delay); //! Return the current delay-line length. - StkFloat getDelay(void) const; + StkFloat getDelay() const; //! Return the value which will be output by the next call to tick(). /*! This method is valid only for delay settings greater than zero! */ - StkFloat nextOut(void); + StkFloat nextOut() override; protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; StkFloat alpha_; StkFloat omAlpha_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Effect.h b/lib-src/libnyquist/nyquist/nyqstk/include/Effect.h index 812e50a42d..cbae6e08de 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Effect.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Effect.h @@ -24,7 +24,7 @@ class Effect : public Stk Effect(); //! Class destructor. - virtual ~Effect(); + ~Effect() override; //! Reset and clear all internal state. virtual void clear() = 0; @@ -61,7 +61,7 @@ class Effect : public Stk virtual StkFloat computeSample( StkFloat input ) = 0; // Returns true if argument value is prime. - bool isPrime( int number ); + static bool isPrime( int number ); StkFloat lastOutput_[2]; StkFloat effectMix_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Envelope.h b/lib-src/libnyquist/nyquist/nyqstk/include/Envelope.h index a005768014..afe44511e4 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Envelope.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Envelope.h @@ -26,22 +26,22 @@ class Envelope : public Generator public: //! Default constructor. - Envelope(void); + Envelope(); //! Copy constructor. Envelope( const Envelope& e ); //! Class destructor. - virtual ~Envelope(void); + ~Envelope() override; //! Assignment operator. Envelope& operator= ( const Envelope& e ); //! Set target = 1. - virtual void keyOn(void); + virtual void keyOn(); //! Set target = 0. - virtual void keyOff(void); + virtual void keyOff(); //! Set the \e rate. void setRate(StkFloat rate); @@ -56,11 +56,11 @@ class Envelope : public Generator virtual void setValue(StkFloat value); //! Return the current envelope \e state (0 = at target, 1 otherwise). - virtual int getState(void) const; + virtual int getState() const; protected: - virtual StkFloat computeSample( void ); + StkFloat computeSample( ) override; StkFloat value_; StkFloat target_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/FileRead.h b/lib-src/libnyquist/nyquist/nyqstk/include/FileRead.h index 6ecc7ae56b..7f36a586c0 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/FileRead.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/FileRead.h @@ -51,7 +51,7 @@ class FileRead : public Stk FileRead( std::string fileName, bool typeRaw = false ); //! Class destructor. - ~FileRead(); + ~FileRead() override; //! Open the specified file and determine its formatting. /*! @@ -60,19 +60,19 @@ class FileRead : public Stk provided to specify whether the input file is of type STK RAW (default = false). */ - void open( std::string fileName, bool typeRaw = false ); + void open( const std::string& fileName, bool typeRaw = false ); //! If a file is open, close it. - void close( void ); + void close( ); //! Returns \e true if a file is currently open. - bool isOpen( void ); + bool isOpen( ); //! Return the file size in sample frames. - unsigned long fileSize( void ) const { return fileSize_; }; + unsigned long fileSize( ) const { return fileSize_; }; //! Return the number of audio channels in the file. - unsigned int channels( void ) const { return channels_; }; + unsigned int channels( ) const { return channels_; }; //! Return the file sample rate in Hz. /*! @@ -80,7 +80,7 @@ class FileRead : public Stk their headers. By definition, STK RAW files have a sample rate of 22050 Hz. MAT-files are assumed to have a rate of 44100 Hz. */ - StkFloat fileRate( void ) const { return fileRate_; }; + StkFloat fileRate( ) const { return fileRate_; }; //! Read sample frames from the file into an StkFrames object. /*! diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/FileWvIn.h b/lib-src/libnyquist/nyquist/nyqstk/include/FileWvIn.h index 31e0b41e6e..b691305c7a 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/FileWvIn.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/FileWvIn.h @@ -55,7 +55,7 @@ class FileWvIn : public WvIn unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 ); //! Class destructor. - virtual ~FileWvIn(); + ~FileWvIn() override; //! Open the specified file and load its data. /*! @@ -70,17 +70,17 @@ class FileWvIn : public WvIn void openFile( std::string fileName, bool raw = false, bool doNormalize = true ); //! Close a file if one is open. - void closeFile( void ); + void closeFile( ); //! Clear outputs and reset time (file) pointer to zero. - void reset( void ); + void reset( ); //! Normalize data to a maximum of +-1.0. /*! This function has no effect when data is incrementally loaded from disk. */ - void normalize( void ); + void normalize( ); //! Normalize data to a maximum of \e +-peak. /*! @@ -90,7 +90,7 @@ class FileWvIn : public WvIn void normalize( StkFloat peak ); //! Return the file size in sample frames. - unsigned long getSize( void ) const { return data_.frames(); }; + unsigned long getSize( ) const { return data_.frames(); }; //! Return the input file sample rate in Hz (not the data read rate). /*! @@ -98,10 +98,10 @@ class FileWvIn : public WvIn their headers. STK RAW files have a sample rate of 22050 Hz by definition. MAT-files are assumed to have a rate of 44100 Hz. */ - StkFloat getFileRate( void ) const { return data_.dataRate(); }; + StkFloat getFileRate( ) const { return data_.dataRate(); }; //! Query whether reading is complete. - bool isFinished( void ) const { return finished_; }; + bool isFinished( ) const { return finished_; }; //! Set the data read rate in samples. The rate can be negative. /*! @@ -124,11 +124,11 @@ class FileWvIn : public WvIn */ void setInterpolate( bool doInterpolate ) { interpolate_ = doInterpolate; }; - StkFloat lastOut( void ) const; + StkFloat lastOut( ) const; protected: - virtual void computeFrame( void ); + void computeFrame( ) override; FileRead file_; bool finished_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Filter.h b/lib-src/libnyquist/nyquist/nyqstk/include/Filter.h index b7c8abda34..eab74b397b 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Filter.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Filter.h @@ -40,7 +40,7 @@ class Filter : public Stk { public: //! Default constructor creates a zero-order pass-through "filter". - Filter(void); + Filter(); //! Overloaded constructor which takes filter coefficients. /*! @@ -50,10 +50,10 @@ class Filter : public Stk Filter( std::vector &bCoefficients, std::vector &aCoefficients ); //! Class destructor. - virtual ~Filter(void); + ~Filter() override; //! Sets all internal states of the filter to zero. - void clear(void); + void clear(); //! Set filter coefficients. /*! @@ -95,10 +95,10 @@ class Filter : public Stk virtual void setGain(StkFloat gain); //! Return the current filter gain. - virtual StkFloat getGain(void) const; + virtual StkFloat getGain() const; //! Return the last computed output value. - virtual StkFloat lastOut(void) const; + virtual StkFloat lastOut() const; //! Input one sample to the filter and return one output. virtual StkFloat tick( StkFloat input ); diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Flute.h b/lib-src/libnyquist/nyquist/nyqstk/include/Flute.h index 5b6f3bd2a2..e98817810d 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Flute.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Flute.h @@ -47,13 +47,13 @@ class Flute : public Instrmnt Flute(StkFloat lowestFrequency); //! Class destructor. - ~Flute(); + ~Flute() override; //! Reset and clear all internal state. void clear(); //! Set instrument parameters for a particular frequency. - void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Set the reflection coefficient for the jet delay (-1.0 - 1.0). void setJetReflection(StkFloat coefficient); @@ -71,17 +71,17 @@ class Flute : public Instrmnt void stopBlowing(StkFloat rate); //! Start a note with the given frequency and amplitude. - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Stop a note with the given amplitude (speed of decay). - void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - void controlChange(int number, StkFloat value); + void controlChange(int number, StkFloat value) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; DelayL jetDelay_; DelayL boreDelay_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Function.h b/lib-src/libnyquist/nyquist/nyqstk/include/Function.h index 2b773c60e5..42a3c8397c 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Function.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Function.h @@ -25,7 +25,7 @@ class Function : public Stk Function(); //! Class destructor. - virtual ~Function(); + ~Function() override; //! Return the last output value. virtual StkFloat lastOut() const { return lastOutput_; }; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Generator.h b/lib-src/libnyquist/nyquist/nyqstk/include/Generator.h index 9b91ea6577..f44ae21d46 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Generator.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Generator.h @@ -21,16 +21,16 @@ class Generator : public Stk { public: //! Class constructor. - Generator( void ); + Generator( ); //! Class destructor. - virtual ~Generator( void ); + ~Generator( ) override; //! Return the last output value. - virtual StkFloat lastOut( void ) const { return lastOutput_; }; + virtual StkFloat lastOut( ) const { return lastOutput_; }; //! Compute one sample and output. - StkFloat tick( void ); + StkFloat tick( ); //! Fill a channel of the StkFrames object with computed outputs. /*! @@ -46,7 +46,7 @@ class Generator : public Stk // This abstract function must be implemented in all subclasses. // It is used to get around a C++ problem with overloaded virtual // functions. - virtual StkFloat computeSample( void ) = 0; + virtual StkFloat computeSample( ) = 0; StkFloat lastOutput_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Instrmnt.h b/lib-src/libnyquist/nyquist/nyqstk/include/Instrmnt.h index 0bc9585b17..06645b0b90 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Instrmnt.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Instrmnt.h @@ -24,7 +24,7 @@ class Instrmnt : public Stk Instrmnt(); //! Class destructor. - virtual ~Instrmnt(); + ~Instrmnt() override; //! Start a note with the given frequency and amplitude. virtual void noteOn(StkFloat frequency, StkFloat amplitude) = 0; @@ -45,7 +45,7 @@ class Instrmnt : public Stk StkFloat lastOutRight() const; //! Compute one sample and output. - StkFloat tick( void ); + StkFloat tick( ); //! Fill a channel of the StkFrames object with computed outputs. /*! @@ -64,7 +64,7 @@ class Instrmnt : public Stk // This abstract function must be implemented in all subclasses. // It is used to get around a C++ problem with overloaded virtual // functions. - virtual StkFloat computeSample( void ) = 0; + virtual StkFloat computeSample( ) = 0; StkFloat lastOutput_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/JCRev.h b/lib-src/libnyquist/nyquist/nyqstk/include/JCRev.h index 92848cfcc9..c47fb7af46 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/JCRev.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/JCRev.h @@ -30,17 +30,17 @@ class JCRev : public Effect JCRev( StkFloat T60 = 1.0 ); //! Class destructor. - ~JCRev(); + ~JCRev() override; //! Reset and clear all internal state. - void clear(); + void clear() override; //! Set the reverberation T60 decay time. void setT60( StkFloat T60 ); protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; Delay allpassDelays_[3]; Delay combDelays_[4]; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/JetTable.h b/lib-src/libnyquist/nyquist/nyqstk/include/JetTable.h index 003a758c36..401e194d47 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/JetTable.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/JetTable.h @@ -28,11 +28,11 @@ class JetTable : public Function JetTable(); //! Class destructor. - ~JetTable(); + ~JetTable() override; protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; }; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Mandolin.h b/lib-src/libnyquist/nyquist/nyqstk/include/Mandolin.h index e619cf9eff..d22d7b3941 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Mandolin.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Mandolin.h @@ -43,7 +43,7 @@ class Mandolin : public PluckTwo Mandolin(StkFloat lowestFrequency); //! Class destructor. - ~Mandolin(); + ~Mandolin() override; //! Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency. void pluck(StkFloat amplitude); @@ -52,17 +52,17 @@ class Mandolin : public PluckTwo void pluck(StkFloat amplitude,StkFloat position); //! Start a note with the given frequency and amplitude (0.0 - 1.0). - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Set the body size (a value of 1.0 produces the "default" size). void setBodySize(StkFloat size); //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - void controlChange(int number, StkFloat value); + void controlChange(int number, StkFloat value) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; FileWvIn *soundfile_[12]; int mic_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Modal.h b/lib-src/libnyquist/nyquist/nyqstk/include/Modal.h index 1b5443a0f8..76b309f3a9 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Modal.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Modal.h @@ -34,13 +34,13 @@ class Modal : public Instrmnt Modal( unsigned int modes = 4 ); //! Class destructor. - virtual ~Modal(); + ~Modal() override; //! Reset and clear all internal state. void clear(); //! Set instrument parameters for a particular frequency. - virtual void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Set the ratio and radius for a specified mode filter. void setRatioAndRadius(unsigned int modeIndex, StkFloat ratio, StkFloat radius); @@ -61,17 +61,17 @@ class Modal : public Instrmnt void damp(StkFloat amplitude); //! Start a note with the given frequency and amplitude. - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Stop a note with the given amplitude (speed of decay). - void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - virtual void controlChange(int number, StkFloat value) = 0; + void controlChange(int number, StkFloat value) override = 0; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; Envelope envelope_; FileWvIn *wave_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/ModalBar.h b/lib-src/libnyquist/nyquist/nyqstk/include/ModalBar.h index 2336b2939b..86ae675d5c 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/ModalBar.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/ModalBar.h @@ -43,7 +43,7 @@ class ModalBar : public Modal ModalBar(); //! Class destructor. - ~ModalBar(); + ~ModalBar() override; //! Set stick hardness (0.0 - 1.0). void setStickHardness(StkFloat hardness); @@ -58,7 +58,7 @@ class ModalBar : public Modal void setModulationDepth(StkFloat mDepth); //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - void controlChange(int number, StkFloat value); + void controlChange(int number, StkFloat value) override; }; } // namespace Nyq diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/NRev.h b/lib-src/libnyquist/nyquist/nyqstk/include/NRev.h index 28031cf968..e23b8c0b91 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/NRev.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/NRev.h @@ -32,17 +32,17 @@ class NRev : public Effect NRev( StkFloat T60 = 1.0 ); //! Class destructor. - ~NRev(); + ~NRev() override; //! Reset and clear all internal state. - void clear(); + void clear() override; //! Set the reverberation T60 decay time. void setT60( StkFloat T60 ); protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; Delay allpassDelays_[8]; Delay combDelays_[6]; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Noise.h b/lib-src/libnyquist/nyquist/nyqstk/include/Noise.h index 0cbd409d18..ed3e7c53ad 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Noise.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Noise.h @@ -33,18 +33,18 @@ class Noise : public Generator Noise( unsigned int seed ); //! Class destructor. - virtual ~Noise(); + ~Noise() override; //! Seed the random number generator with a specific seed value. /*! If no seed is provided or the seed value is zero, the random number generator is seeded with the current system time. */ - void setSeed( unsigned int seed = 0 ); + static void setSeed( unsigned int seed = 0 ); protected: - virtual StkFloat computeSample( void ); + StkFloat computeSample( ) override; }; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/OnePole.h b/lib-src/libnyquist/nyquist/nyqstk/include/OnePole.h index a141452ab4..9d05cafd3d 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/OnePole.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/OnePole.h @@ -31,10 +31,10 @@ class OnePole : protected Filter OnePole( StkFloat thePole ); //! Class destructor. - ~OnePole(); + ~OnePole() override; //! Clears the internal state of the filter. - void clear(void); + void clear(); //! Set the b[0] coefficient value. void setB0(StkFloat b0); @@ -57,16 +57,16 @@ class OnePole : protected Filter The gain is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0. */ - void setGain(StkFloat gain); + void setGain(StkFloat gain) override; //! Return the current filter gain. - StkFloat getGain(void) const; + StkFloat getGain() const override; //! Return the last computed output value. - StkFloat lastOut(void) const; + StkFloat lastOut() const override; //! Input one sample to the filter and return one output. - StkFloat tick(StkFloat sample); + StkFloat tick(StkFloat sample) override; //! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs. /*! @@ -75,7 +75,7 @@ class OnePole : protected Filter channel argument is equal to or greater than the number of channels in the StkFrames object. */ - StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); + StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) override; }; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/OneZero.h b/lib-src/libnyquist/nyquist/nyqstk/include/OneZero.h index 19da1716b5..5e8ef24091 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/OneZero.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/OneZero.h @@ -31,10 +31,10 @@ class OneZero : protected Filter OneZero(StkFloat theZero); //! Class destructor. - ~OneZero(); + ~OneZero() override; //! Clears the internal state of the filter. - void clear(void); + void clear(); //! Set the b[0] coefficient value. void setB0(StkFloat b0); @@ -57,16 +57,16 @@ class OneZero : protected Filter The gain is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0. */ - void setGain(StkFloat gain); + void setGain(StkFloat gain) override; //! Return the current filter gain. - StkFloat getGain(void) const; + StkFloat getGain() const override; //! Return the last computed output value. - StkFloat lastOut(void) const; + StkFloat lastOut() const override; //! Input one sample to the filter and return one output. - StkFloat tick(StkFloat sample); + StkFloat tick(StkFloat sample) override; //! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs. /*! @@ -75,7 +75,7 @@ class OneZero : protected Filter channel argument is equal to or greater than the number of channels in the StkFrames object. */ - StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); + StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) override; }; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/PRCRev.h b/lib-src/libnyquist/nyquist/nyqstk/include/PRCRev.h index 5ee5c767ab..1cfd68aa76 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/PRCRev.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/PRCRev.h @@ -30,17 +30,17 @@ class PRCRev : public Effect PRCRev( StkFloat T60 = 1.0 ); //! Class destructor. - ~PRCRev(); + ~PRCRev() override; //! Reset and clear all internal state. - void clear(); + void clear() override; //! Set the reverberation T60 decay time. void setT60( StkFloat T60 ); protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; Delay allpassDelays_[2]; Delay combDelays_[2]; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/PitShift.h b/lib-src/libnyquist/nyquist/nyqstk/include/PitShift.h index 775b8e2336..82f6b83ba6 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/PitShift.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/PitShift.h @@ -25,17 +25,17 @@ class PitShift : public Effect PitShift(); //! Class destructor. - ~PitShift(); + ~PitShift() override; //! Reset and clear all internal state. - void clear(); + void clear() override; //! Set the pitch shift factor (1.0 produces no shift). void setShift(StkFloat shift); protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; DelayL delayLine_[2]; StkFloat delay_[2]; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/PluckTwo.h b/lib-src/libnyquist/nyquist/nyqstk/include/PluckTwo.h index eabb74d22a..0fdb343eb1 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/PluckTwo.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/PluckTwo.h @@ -36,13 +36,13 @@ class PluckTwo : public Instrmnt PluckTwo(StkFloat lowestFrequency); //! Class destructor. - virtual ~PluckTwo(); + ~PluckTwo() override; //! Reset and clear all internal state. void clear(); //! Set instrument parameters for a particular frequency. - virtual void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Detune the two strings by the given factor. A value of 1.0 produces unison strings. void setDetune(StkFloat detune); @@ -62,11 +62,11 @@ class PluckTwo : public Instrmnt void setBaseLoopGain(StkFloat aGain); //! Stop a note with the given amplitude (speed of decay). - virtual void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; protected: - virtual StkFloat computeSample( void ) = 0; + StkFloat computeSample( ) override = 0; DelayA delayLine_; DelayA delayLine2_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/PoleZero.h b/lib-src/libnyquist/nyquist/nyqstk/include/PoleZero.h index 5ee5d1028e..b32a23e395 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/PoleZero.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/PoleZero.h @@ -28,10 +28,10 @@ class PoleZero : protected Filter PoleZero(); //! Class destructor. - ~PoleZero(); + ~PoleZero() override; //! Clears the internal states of the filter. - void clear(void); + void clear(); //! Set the b[0] coefficient value. void setB0(StkFloat b0); @@ -64,16 +64,16 @@ class PoleZero : protected Filter The gain is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0. */ - void setGain( StkFloat gain ); + void setGain( StkFloat gain ) override; //! Return the current filter gain. - StkFloat getGain( void ) const; + StkFloat getGain( ) const override; //! Return the last computed output value. - StkFloat lastOut( void ) const; + StkFloat lastOut( ) const override; //! Input one sample to the filter and return one output. - StkFloat tick( StkFloat sample ); + StkFloat tick( StkFloat sample ) override; //! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs. /*! @@ -82,7 +82,7 @@ class PoleZero : protected Filter channel argument is equal to or greater than the number of channels in the StkFrames object. */ - StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); + StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) override; }; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/ReedTable.h b/lib-src/libnyquist/nyquist/nyqstk/include/ReedTable.h index c7e87445df..b00fec63ec 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/ReedTable.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/ReedTable.h @@ -32,7 +32,7 @@ class ReedTable : public Function ReedTable(); //! Class destructor. - ~ReedTable(); + ~ReedTable() override; //! Set the table offset value. /*! @@ -52,7 +52,7 @@ class ReedTable : public Function protected: - StkFloat computeSample( StkFloat input ); + StkFloat computeSample( StkFloat input ) override; StkFloat offset_; StkFloat slope_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Saxofony.h b/lib-src/libnyquist/nyquist/nyqstk/include/Saxofony.h index 7609d4a135..914c4753d4 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Saxofony.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Saxofony.h @@ -59,13 +59,13 @@ class Saxofony : public Instrmnt Saxofony(StkFloat lowestFrequency); //! Class destructor. - ~Saxofony(); + ~Saxofony() override; //! Reset and clear all internal state. void clear(); //! Set instrument parameters for a particular frequency. - void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Set the "blowing" position between the air column terminations (0.0 - 1.0). void setBlowPosition(StkFloat aPosition); @@ -77,17 +77,17 @@ class Saxofony : public Instrmnt void stopBlowing(StkFloat rate); //! Start a note with the given frequency and amplitude. - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Stop a note with the given amplitude (speed of decay). - void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; //! Perform the control change specified by \e number and \e value (0.0 - 128.0). - void controlChange(int number, StkFloat value); + void controlChange(int number, StkFloat value) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; DelayL delays_[2]; ReedTable reedTable_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/SineWave.h b/lib-src/libnyquist/nyquist/nyqstk/include/SineWave.h index 756570d2db..462d8551f6 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/SineWave.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/SineWave.h @@ -32,13 +32,13 @@ class SineWave : public Generator { public: //! Default constructor. - SineWave( void ); + SineWave( ); //! Class destructor. - virtual ~SineWave( void ); + ~SineWave( ) override; //! Clear output and reset time pointer to zero. - void reset( void ); + void reset( ); //! Set the data read rate in samples. The rate can be negative. /*! @@ -76,7 +76,7 @@ class SineWave : public Generator protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; static StkFrames table_; StkFloat time_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Sitar.h b/lib-src/libnyquist/nyquist/nyqstk/include/Sitar.h index d2b0bcd323..ee41368c0f 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Sitar.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Sitar.h @@ -36,26 +36,26 @@ class Sitar : public Instrmnt Sitar( StkFloat lowestFrequency = 20 ); //! Class destructor. - ~Sitar(); + ~Sitar() override; //! Reset and clear all internal state. void clear(); //! Set instrument parameters for a particular frequency. - void setFrequency(StkFloat frequency); + void setFrequency(StkFloat frequency) override; //! Pluck the string with the given amplitude using the current frequency. void pluck(StkFloat amplitude); //! Start a note with the given frequency and amplitude. - void noteOn(StkFloat frequency, StkFloat amplitude); + void noteOn(StkFloat frequency, StkFloat amplitude) override; //! Stop a note with the given amplitude (speed of decay). - void noteOff(StkFloat amplitude); + void noteOff(StkFloat amplitude) override; protected: - StkFloat computeSample( void ); + StkFloat computeSample( ) override; DelayA delayLine_; OneZero loopFilter_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/Stk.h b/lib-src/libnyquist/nyquist/nyqstk/include/Stk.h index 4d04f26038..ba4d620bb9 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/Stk.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/Stk.h @@ -46,10 +46,11 @@ typedef uint64_t uintmax_t; */ #endif -#include +#include #include #include #include +#include using namespace std; @@ -108,23 +109,23 @@ class StkError public: //! The constructor. - StkError(const std::string& message, Type type = StkError::UNSPECIFIED) - : message_(message), type_(type) {} + StkError(std::string message, Type type = StkError::UNSPECIFIED) + : message_(std::move(message)), type_(type) {} //! The destructor. - virtual ~StkError(void) {}; + virtual ~StkError() {}; //! Prints thrown error message to stderr. - virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; } + virtual void printMessage() { std::cerr << '\n' << message_ << "\n\n"; } //! Returns the thrown error message type. - virtual const Type& getType(void) { return type_; } + virtual const Type& getType() { return type_; } //! Returns the thrown error message string. - virtual const std::string& getMessage(void) { return message_; } + virtual const std::string& getMessage() { return message_; } //! Returns the thrown error message as a C string. - virtual const char *getMessageCString(void) { return message_.c_str(); } + virtual const char *getMessageCString() { return message_.c_str(); } }; @@ -141,7 +142,7 @@ class Stk static const StkFormat STK_FLOAT64; /*!< Normalized between plus/minus 1.0. */ //! Static method which returns the current STK sample rate. - static StkFloat sampleRate(void) { return srate_; } + static StkFloat sampleRate() { return srate_; } //! Static method which sets the STK sample rate. /*! @@ -155,10 +156,10 @@ class Stk static void setSampleRate(StkFloat rate) { if (rate > 0.0) srate_ = rate; } //! Static method which returns the current rawwave path. - static std::string rawwavePath(void) { return rawwavepath_; } + static std::string rawwavePath() { return rawwavepath_; } //! Static method which sets the STK rawwave path. - static void setRawwavePath(std::string path); + static void setRawwavePath(const std::string& path); //! Static method which byte-swaps a 16-bit data type. static void swap16(unsigned char *ptr); @@ -176,7 +177,7 @@ class Stk static void handleError( const char *message, StkError::Type type ); //! Static function for error reporting and handling using c++ strings. - static void handleError( std::string message, StkError::Type type ); + static void handleError( const std::string& message, StkError::Type type ); //! Toggle display of WARNING and STATUS messages. static void showWarnings( bool status ) { showWarnings_ = status; } @@ -195,10 +196,10 @@ class Stk std::ostringstream errorString_; //! Default constructor. - Stk(void); + Stk(); //! Class destructor. - virtual ~Stk(void); + virtual ~Stk(); //! Internal function for error reporting which assumes message in \c errorString_ variable. void handleError( StkError::Type type ); @@ -276,13 +277,13 @@ class StkFrames must be between 0 and channels() - 1. No range checking is performed unless _STK_DEBUG_ is defined. */ - StkFloat interpolate( StkFloat frame, unsigned int channel = 0 ) const; + [[nodiscard]] StkFloat interpolate( StkFloat frame, unsigned int channel = 0 ) const; //! Returns the total number of audio samples represented by the object. - size_t size() const { return size_; }; + [[nodiscard]] size_t size() const { return size_; }; //! Returns \e true if the object size is zero and \e false otherwise. - bool empty() const; + [[nodiscard]] bool empty() const; //! Resize self to represent the specified number of channels and frames. /*! @@ -305,10 +306,10 @@ class StkFrames void resize( size_t nFrames, unsigned int nChannels, StkFloat value ); //! Return the number of channels represented by the data. - unsigned int channels( void ) const { return nChannels_; }; + [[nodiscard]] unsigned int channels( ) const { return nChannels_; }; //! Return the number of sample frames represented by the data. - size_t frames( void ) const { return nFrames_; }; + [[nodiscard]] size_t frames( ) const { return nFrames_; }; //! Set the sample rate associated with the StkFrames data. /*! @@ -322,10 +323,10 @@ class StkFrames By default, this value is set equal to the current STK sample rate at the time of instantiation. */ - StkFloat dataRate( void ) const { return dataRate_; }; + [[nodiscard]] StkFloat dataRate( ) const { return dataRate_; }; //! Returns \c true if the data is in interleaved format, \c false if the data is non-interleaved. - bool interleaved( void ) const { return interleaved_; }; + [[nodiscard]] bool interleaved( ) const { return interleaved_; }; //! Set the flag to indicate whether the internal data is in interleaved (\c true) or non-interleaved (\c false) format. /*! diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/WaveLoop.h b/lib-src/libnyquist/nyquist/nyqstk/include/WaveLoop.h index 67d345a51f..70806d0f17 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/WaveLoop.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/WaveLoop.h @@ -35,7 +35,7 @@ class WaveLoop : public FileWvIn unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 ); //! Class destructor. - virtual ~WaveLoop(); + ~WaveLoop() override; //! Open the specified file and load its data. /*! @@ -65,7 +65,7 @@ class WaveLoop : public FileWvIn void setFrequency( StkFloat frequency ); //! Increment the read pointer by \e time samples, modulo file size. - void addTime( StkFloat time ); + void addTime( StkFloat time ) override; //! Increment current read pointer by \e angle, relative to a looping frequency. /*! @@ -85,7 +85,7 @@ class WaveLoop : public FileWvIn protected: - virtual void computeFrame( void ); + void computeFrame( ) override; StkFrames firstFrame_; StkFloat phaseOffset_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/include/WvIn.h b/lib-src/libnyquist/nyquist/nyqstk/include/WvIn.h index a4ee60b906..17a891d469 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/include/WvIn.h +++ b/lib-src/libnyquist/nyquist/nyqstk/include/WvIn.h @@ -33,28 +33,28 @@ class WvIn : public Stk WvIn(); //! Class destructor. - virtual ~WvIn(); + ~WvIn() override; //! Return the number of audio channels in the data. - unsigned int getChannels( void ) const { return data_.channels(); }; + unsigned int getChannels( ) const { return data_.channels(); }; //! Return the average across the last output sample frame. /*! If no file data is loaded, the returned value is 0.0. */ - StkFloat lastOut( void ) const; + StkFloat lastOut( ) const; //! Return an StkFrames reference to the last output sample frame. /*! If no file data is loaded, an empty container is returned. */ - const StkFrames& lastFrame( void ) const { return lastOutputs_; }; + const StkFrames& lastFrame( ) const { return lastOutputs_; }; //! Read out the average across one sample frame of data. /*! If no file data is loaded, the returned value is 0.0. */ - StkFloat tick( void ); + StkFloat tick( ); //! Fill a channel of the StkFrames object with averaged sample frames. /*! @@ -80,7 +80,7 @@ class WvIn : public Stk // This abstract function must be implemented in all subclasses. // It is used to get around a C++ problem with overloaded virtual // functions. - virtual void computeFrame( void ) = 0; + virtual void computeFrame( ) = 0; StkFrames data_; StkFrames lastOutputs_; diff --git a/lib-src/libnyquist/nyquist/nyqstk/instr.cpp b/lib-src/libnyquist/nyquist/nyqstk/instr.cpp index e39567a887..7a94f6a101 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/instr.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/instr.cpp @@ -8,8 +8,8 @@ #include "Sitar.h" #include "ModalBar.h" #include "Flute.h" -#include "stdlib.h" -#include "string.h" +#include +#include using namespace Nyq; @@ -22,7 +22,7 @@ struct instr { struct instr *initInstrument(int instr_type, int sample_rate) { - struct instr *in = (struct instr *) malloc(sizeof(struct instr)); + auto *in = (struct instr *) malloc(sizeof(struct instr)); Stk::setSampleRate(sample_rate); switch(instr_type) { case CLARINET: @@ -50,7 +50,7 @@ struct instr *initInstrument(int instr_type, int sample_rate) { in->instrObjPtr = new Flute(10.0); break; default: - return NULL; + return nullptr; } return in; } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/ADSR.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/ADSR.cpp index 2b7dd9287b..b0003985ba 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/ADSR.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/ADSR.cpp @@ -31,8 +31,7 @@ ADSR :: ADSR() : Envelope() } ADSR :: ~ADSR() -{ -} += default; void ADSR :: keyOn() { @@ -150,7 +149,7 @@ void ADSR :: setValue(StkFloat value) rate_ = (StkFloat) 0.0; } -int ADSR :: getState(void) const +int ADSR :: getState() const { return state_; } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/BiQuad.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/BiQuad.cpp index 7434f4b130..b2c9abd3a5 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/BiQuad.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/BiQuad.cpp @@ -30,7 +30,7 @@ BiQuad :: ~BiQuad() { } -void BiQuad :: clear(void) +void BiQuad :: clear() { Filter::clear(); } @@ -92,12 +92,12 @@ void BiQuad :: setGain(StkFloat gain) Filter::setGain(gain); } -StkFloat BiQuad :: getGain(void) const +StkFloat BiQuad :: getGain() const { return Filter::getGain(); } -StkFloat BiQuad :: lastOut(void) const +StkFloat BiQuad :: lastOut() const { return Filter::lastOut(); } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/BowTable.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/BowTable.cpp index 69069a4b13..1277478e3d 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/BowTable.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/BowTable.cpp @@ -10,7 +10,7 @@ /***************************************************/ #include "BowTable.h" -#include +#include using namespace Nyq; diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp index 3749868a23..6acf3d0ed8 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Delay.cpp @@ -61,10 +61,10 @@ Delay :: ~Delay() { } -void Delay :: clear(void) +void Delay :: clear() { - for (unsigned int i=0; i +#include using namespace Nyq; diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Envelope.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Envelope.cpp index 6fe66986d2..3354d06696 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Envelope.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Envelope.cpp @@ -17,7 +17,7 @@ using namespace Nyq; -Envelope :: Envelope(void) : Generator() +Envelope :: Envelope() : Generator() { target_ = 0.0; value_ = 0.0; @@ -33,7 +33,7 @@ Envelope :: Envelope ( const Envelope& e ) state_ = 0; } -Envelope :: ~Envelope(void) +Envelope :: ~Envelope() { } @@ -49,13 +49,13 @@ Envelope& Envelope :: operator= ( const Envelope& e ) return *this; } -void Envelope :: keyOn(void) +void Envelope :: keyOn() { target_ = 1.0; if (value_ != target_) state_ = 1; } -void Envelope :: keyOff(void) +void Envelope :: keyOff() { target_ = 0.0; if (value_ != target_) state_ = 1; @@ -96,12 +96,12 @@ void Envelope :: setValue(StkFloat value) value_ = value; } -int Envelope :: getState(void) const +int Envelope :: getState() const { return state_; } -StkFloat Envelope :: computeSample(void ) +StkFloat Envelope :: computeSample( ) { if (state_) { if (target_ > value_) { diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/FileRead.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/FileRead.cpp index 37027fd07e..d9f22e12e6 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/FileRead.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/FileRead.cpp @@ -29,14 +29,15 @@ */ /***************************************************/ -#include "string.h" +#include #include "FileRead.h" -#include +#include #include #include -#include +#include #include #include +#include /* this is defined in xlisp.h, but it seems a bad idea * to create an stk dependency on xlisp, or to add a new @@ -49,14 +50,14 @@ extern "C" { using namespace Nyq; FileRead :: FileRead() - : fd_(0) + : fd_(nullptr) { } FileRead :: FileRead( std::string fileName, bool typeRaw ) - : fd_(0) + : fd_(nullptr) { - open( fileName, typeRaw ); + open( std::move(fileName), typeRaw ); } FileRead :: ~FileRead() @@ -65,26 +66,26 @@ FileRead :: ~FileRead() fclose( fd_ ); } -void FileRead :: close( void ) +void FileRead :: close( ) { if ( fd_ ) fclose( fd_ ); - fd_ = 0; + fd_ = nullptr; wavFile_ = false; } -bool FileRead :: isOpen( void ) +bool FileRead :: isOpen( ) { if ( fd_ ) return true; else return false; } -void FileRead :: open( std::string fileName, bool typeRaw ) +void FileRead :: open( const std::string& fileName, bool typeRaw ) { // If another file is open, close it. close(); // Try to open the file. - fd_ = NULL; + fd_ = nullptr; if (ok_to_open(fileName.c_str(), "rb")) fd_ = fopen( fileName.c_str(), "rb" ); if ( !fd_ ) { @@ -590,7 +591,7 @@ bool FileRead :: getMatInfo( const char *fileName ) void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNormalize ) { // Make sure we have an open file. - if ( fd_ == 0 ) { + if ( fd_ == nullptr ) { errorString_ << "FileRead::read: a file is not open!"; Stk::handleError( StkError::WARNING ); return; @@ -618,7 +619,7 @@ void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNorma // Read samples into StkFrames data buffer. if ( dataType_ == STK_SINT16 ) { - SINT16 *buf = (SINT16 *) &buffer[0]; + auto *buf = (SINT16 *) &buffer[0]; if ( fseek( fd_, dataOffset_+(offset*2), SEEK_SET ) == -1 ) goto error; if ( fread( buf, nSamples * 2, 1, fd_ ) != 1 ) goto error; if ( byteswap_ ) { @@ -637,7 +638,7 @@ void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNorma } } else if ( dataType_ == STK_SINT32 ) { - SINT32 *buf = (SINT32 *) &buffer[0]; + auto *buf = (SINT32 *) &buffer[0]; if ( fseek( fd_, dataOffset_+(offset*4 ), SEEK_SET ) == -1 ) goto error; if ( fread( buf, nSamples * 4, 1, fd_ ) != 1 ) goto error; if ( byteswap_ ) { @@ -656,7 +657,7 @@ void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNorma } } else if ( dataType_ == STK_FLOAT32 ) { - FLOAT32 *buf = (FLOAT32 *) &buffer[0]; + auto *buf = (FLOAT32 *) &buffer[0]; if ( fseek( fd_, dataOffset_+(offset*4), SEEK_SET ) == -1 ) goto error; if ( fread( buf, nSamples * 4, 1, fd_ ) != 1 ) goto error; if ( byteswap_ ) { @@ -668,7 +669,7 @@ void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNorma buffer[i] = buf[i]; } else if ( dataType_ == STK_FLOAT64 ) { - FLOAT64 *buf = (FLOAT64 *) &buffer[0]; + auto *buf = (FLOAT64 *) &buffer[0]; if ( fseek( fd_, dataOffset_+(offset*8), SEEK_SET ) == -1 ) goto error; if ( fread( buf, nSamples * 8, 1, fd_ ) != 1 ) goto error; if ( byteswap_ ) { @@ -680,7 +681,7 @@ void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNorma buffer[i] = buf[i]; } else if ( dataType_ == STK_SINT8 && wavFile_ ) { // 8-bit WAV data is unsigned! - unsigned char *buf = (unsigned char *) &buffer[0]; + auto *buf = (unsigned char *) &buffer[0]; if ( fseek( fd_, dataOffset_+offset, SEEK_SET ) == -1 ) goto error; if ( fread( buf, nSamples, 1, fd_) != 1 ) goto error; if ( doNormalize ) { diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/FileWvIn.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/FileWvIn.cpp index 57a5f099b7..7b1e643620 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/FileWvIn.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/FileWvIn.cpp @@ -32,6 +32,7 @@ #include "FileWvIn.h" #include +#include using namespace Nyq; @@ -46,7 +47,7 @@ FileWvIn :: FileWvIn( std::string fileName, bool raw, bool doNormalize, : finished_(true), interpolate_(false), time_(0.0), chunkThreshold_(chunkThreshold), chunkSize_(chunkSize) { - openFile( fileName, raw, doNormalize ); + openFile( std::move(fileName), raw, doNormalize ); } FileWvIn :: ~FileWvIn() @@ -54,7 +55,7 @@ FileWvIn :: ~FileWvIn() this->closeFile(); } -void FileWvIn :: closeFile( void ) +void FileWvIn :: closeFile( ) { if ( file_.isOpen() ) file_.close(); finished_ = true; @@ -66,7 +67,7 @@ void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize ) this->closeFile(); // Attempt to open the file ... an error might be thrown here. - file_.open( fileName, raw ); + file_.open( std::move(fileName), raw ); // Determine whether chunking or not. if ( file_.fileSize() > chunkThreshold_ ) { @@ -95,7 +96,7 @@ void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize ) this->reset(); } -void FileWvIn :: reset(void) +void FileWvIn :: reset() { time_ = (StkFloat) 0.0; for ( unsigned int i=0; inormalize( 1.0 ); } @@ -156,13 +157,13 @@ void FileWvIn :: addTime( StkFloat time ) } } -StkFloat FileWvIn :: lastOut( void ) const +StkFloat FileWvIn :: lastOut( ) const { if ( finished_ ) return 0.0; return WvIn :: lastOut(); } -void FileWvIn :: computeFrame( void ) +void FileWvIn :: computeFrame( ) { if ( finished_ ) return; diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Filter.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Filter.cpp index 59cabbe77f..6fd664eb96 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Filter.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Filter.cpp @@ -28,7 +28,7 @@ /***************************************************/ #include "Filter.h" -#include +#include using namespace Nyq; @@ -46,7 +46,7 @@ Filter :: Filter() Filter :: Filter( std::vector &bCoefficients, std::vector &aCoefficients ) { // Check the arguments. - if ( bCoefficients.size() == 0 || aCoefficients.size() == 0 ) { + if ( bCoefficients.empty() || aCoefficients.empty() ) { errorString_ << "Filter: a and b coefficient vectors must both have size > 0!"; handleError( StkError::FUNCTION_ARGUMENT ); } @@ -69,7 +69,7 @@ Filter :: ~Filter() { } -void Filter :: clear(void) +void Filter :: clear() { unsigned int i; for (i=0; i &bCoefficients, std::vector &aCoefficients, bool clearState ) { // Check the arguments. - if ( bCoefficients.size() == 0 || aCoefficients.size() == 0 ) { + if ( bCoefficients.empty() || aCoefficients.empty() ) { errorString_ << "Filter::setCoefficients: a and b coefficient vectors must both have size > 0!"; handleError( StkError::FUNCTION_ARGUMENT ); } @@ -122,7 +122,7 @@ void Filter :: setCoefficients( std::vector &bCoefficients, std::vecto void Filter :: setNumerator( std::vector &bCoefficients, bool clearState ) { // Check the argument. - if ( bCoefficients.size() == 0 ) { + if ( bCoefficients.empty() ) { errorString_ << "Filter::setNumerator: coefficient vector must have size > 0!"; handleError( StkError::FUNCTION_ARGUMENT ); } @@ -142,7 +142,7 @@ void Filter :: setNumerator( std::vector &bCoefficients, bool clearSta void Filter :: setDenominator( std::vector &aCoefficients, bool clearState ) { // Check the argument. - if ( aCoefficients.size() == 0 ) { + if ( aCoefficients.empty() ) { errorString_ << "Filter::setDenominator: coefficient vector must have size > 0!"; handleError( StkError::FUNCTION_ARGUMENT ); } @@ -176,12 +176,12 @@ void Filter :: setGain(StkFloat gain) gain_ = gain; } -StkFloat Filter :: getGain(void) const +StkFloat Filter :: getGain() const { return gain_; } -StkFloat Filter :: lastOut(void) const +StkFloat Filter :: lastOut() const { return outputs_[0]; } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Generator.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Generator.cpp index 9b703d651e..e46a6c3a66 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Generator.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Generator.cpp @@ -22,7 +22,7 @@ Generator :: ~Generator() { } -StkFloat Generator :: tick( void ) +StkFloat Generator :: tick( ) { return computeSample(); } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Instrmnt.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Instrmnt.cpp index 35127a70f1..1a0bebde96 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Instrmnt.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Instrmnt.cpp @@ -33,17 +33,17 @@ StkFloat Instrmnt :: lastOut() const } // Support for stereo output: -StkFloat Instrmnt :: lastOutLeft(void) const +StkFloat Instrmnt :: lastOutLeft() const { return 0.5 * lastOutput_; } -StkFloat Instrmnt :: lastOutRight(void) const +StkFloat Instrmnt :: lastOutRight() const { return 0.5 * lastOutput_; } -StkFloat Instrmnt :: tick( void ) +StkFloat Instrmnt :: tick( ) { return computeSample(); } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/JCRev.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/JCRev.cpp index 10dffc6689..ce09d0205b 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/JCRev.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/JCRev.cpp @@ -15,7 +15,7 @@ /***************************************************/ #include "JCRev.h" -#include +#include using namespace Nyq; diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Mandolin.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Mandolin.cpp index a1d5cf2032..dfbe6718c6 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Mandolin.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Mandolin.cpp @@ -36,18 +36,18 @@ Mandolin :: Mandolin(StkFloat lowestFrequency) : PluckTwo(lowestFrequency) { // Concatenate the STK rawwave path to the rawwave files - soundfile_[0] = new FileWvIn( (Stk::rawwavePath() + "mand1.raw").c_str(), true ); - soundfile_[1] = new FileWvIn( (Stk::rawwavePath() + "mand2.raw").c_str(), true ); - soundfile_[2] = new FileWvIn( (Stk::rawwavePath() + "mand3.raw").c_str(), true ); - soundfile_[3] = new FileWvIn( (Stk::rawwavePath() + "mand4.raw").c_str(), true ); - soundfile_[4] = new FileWvIn( (Stk::rawwavePath() + "mand5.raw").c_str(), true ); - soundfile_[5] = new FileWvIn( (Stk::rawwavePath() + "mand6.raw").c_str(), true ); - soundfile_[6] = new FileWvIn( (Stk::rawwavePath() + "mand7.raw").c_str(), true ); - soundfile_[7] = new FileWvIn( (Stk::rawwavePath() + "mand8.raw").c_str(), true ); - soundfile_[8] = new FileWvIn( (Stk::rawwavePath() + "mand9.raw").c_str(), true ); - soundfile_[9] = new FileWvIn( (Stk::rawwavePath() + "mand10.raw").c_str(), true ); - soundfile_[10] = new FileWvIn( (Stk::rawwavePath() + "mand11.raw").c_str(), true ); - soundfile_[11] = new FileWvIn( (Stk::rawwavePath() + "mand12.raw").c_str(), true ); + soundfile_[0] = new FileWvIn( Stk::rawwavePath() + "mand1.raw", true ); + soundfile_[1] = new FileWvIn( Stk::rawwavePath() + "mand2.raw", true ); + soundfile_[2] = new FileWvIn( Stk::rawwavePath() + "mand3.raw", true ); + soundfile_[3] = new FileWvIn( Stk::rawwavePath() + "mand4.raw", true ); + soundfile_[4] = new FileWvIn( Stk::rawwavePath() + "mand5.raw", true ); + soundfile_[5] = new FileWvIn( Stk::rawwavePath() + "mand6.raw", true ); + soundfile_[6] = new FileWvIn( Stk::rawwavePath() + "mand7.raw", true ); + soundfile_[7] = new FileWvIn( Stk::rawwavePath() + "mand8.raw", true ); + soundfile_[8] = new FileWvIn( Stk::rawwavePath() + "mand9.raw", true ); + soundfile_[9] = new FileWvIn( Stk::rawwavePath() + "mand10.raw", true ); + soundfile_[10] = new FileWvIn( Stk::rawwavePath() + "mand11.raw", true ); + soundfile_[11] = new FileWvIn( Stk::rawwavePath() + "mand12.raw", true ); mic_ = 0; dampTime_ = 0; @@ -56,8 +56,8 @@ Mandolin :: Mandolin(StkFloat lowestFrequency) Mandolin :: ~Mandolin() { - for ( int i=0; i<12; i++ ) - delete soundfile_[i]; + for (auto & i : soundfile_) + delete i; } void Mandolin :: pluck(StkFloat amplitude) @@ -118,8 +118,8 @@ void Mandolin :: setBodySize(StkFloat size) { // Scale the commuted body response by its sample rate (22050). StkFloat rate = size * 22050.0 / Stk::sampleRate(); - for ( int i=0; i<12; i++ ) - soundfile_[i]->setRate( rate ); + for (auto & i : soundfile_) + i->setRate( rate ); } StkFloat Mandolin :: computeSample() diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Modal.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Modal.cpp index da00f2512f..2000599bb3 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Modal.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Modal.cpp @@ -12,7 +12,7 @@ /***************************************************/ #include "Modal.h" -#include +#include using namespace Nyq; diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/ModalBar.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/ModalBar.cpp index 38e2165149..61085630e1 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/ModalBar.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/ModalBar.cpp @@ -38,7 +38,7 @@ ModalBar :: ModalBar() : Modal() { // Concatenate the STK rawwave path to the rawwave file - wave_ = new FileWvIn( (Stk::rawwavePath() + "marmstk1.raw").c_str(), true ); + wave_ = new FileWvIn( Stk::rawwavePath() + "marmstk1.raw", true ); wave_->setRate( 0.5 * 22050.0 / Stk::sampleRate() ); // Set the resonances for preset 0 (marimba). diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/NRev.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/NRev.cpp index 55f2b96374..7709b1f402 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/NRev.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/NRev.cpp @@ -17,7 +17,7 @@ /***************************************************/ #include "NRev.h" -#include +#include using namespace Nyq; diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Noise.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Noise.cpp index d982e02ea6..30bc0baa70 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Noise.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Noise.cpp @@ -11,8 +11,8 @@ /***************************************************/ #include "Noise.h" -#include -#include +#include +#include using namespace Nyq; @@ -37,7 +37,7 @@ Noise :: ~Noise() void Noise :: setSeed( unsigned int seed ) { if ( seed == 0 ) - srand( (unsigned int) time(NULL) ); + srand( (unsigned int) time(nullptr) ); else srand( seed ); } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/OnePole.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/OnePole.cpp index 97eee7b42e..e068e2a899 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/OnePole.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/OnePole.cpp @@ -43,7 +43,7 @@ OnePole :: ~OnePole() { } -void OnePole :: clear(void) +void OnePole :: clear() { Filter::clear(); } @@ -74,12 +74,12 @@ void OnePole :: setGain(StkFloat gain) Filter::setGain(gain); } -StkFloat OnePole :: getGain(void) const +StkFloat OnePole :: getGain() const { return Filter::getGain(); } -StkFloat OnePole :: lastOut(void) const +StkFloat OnePole :: lastOut() const { return Filter::lastOut(); } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/OneZero.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/OneZero.cpp index 2aed1c1849..cd4225e9c7 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/OneZero.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/OneZero.cpp @@ -38,11 +38,11 @@ OneZero :: OneZero(StkFloat theZero) : Filter() Filter::setCoefficients( b, a ); } -OneZero :: ~OneZero(void) +OneZero :: ~OneZero() { } -void OneZero :: clear(void) +void OneZero :: clear() { Filter::clear(); } @@ -73,12 +73,12 @@ void OneZero :: setGain(StkFloat gain) Filter::setGain(gain); } -StkFloat OneZero :: getGain(void) const +StkFloat OneZero :: getGain() const { return Filter::getGain(); } -StkFloat OneZero :: lastOut(void) const +StkFloat OneZero :: lastOut() const { return Filter::lastOut(); } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/PRCRev.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/PRCRev.cpp index c357b38fb5..f468600dd4 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/PRCRev.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/PRCRev.cpp @@ -15,7 +15,7 @@ /***************************************************/ #include "PRCRev.h" -#include +#include using namespace Nyq; diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/PoleZero.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/PoleZero.cpp index 66ed574b9d..9d27bad6d1 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/PoleZero.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/PoleZero.cpp @@ -30,7 +30,7 @@ PoleZero :: ~PoleZero() { } -void PoleZero :: clear(void) +void PoleZero :: clear() { Filter::clear(); } @@ -71,12 +71,12 @@ void PoleZero :: setGain(StkFloat gain) Filter::setGain(gain); } -StkFloat PoleZero :: getGain(void) const +StkFloat PoleZero :: getGain() const { return Filter::getGain(); } -StkFloat PoleZero :: lastOut(void) const +StkFloat PoleZero :: lastOut() const { return Filter::lastOut(); } diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/SineWave.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/SineWave.cpp index 0a823c2384..f2cb637123 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/SineWave.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/SineWave.cpp @@ -20,7 +20,7 @@ using namespace Nyq; StkFrames SineWave :: table_; -SineWave :: SineWave( void ) +SineWave :: SineWave( ) : time_(0.0), rate_(1.0), phaseOffset_(0.0) { if ( table_.empty() ) { @@ -35,7 +35,7 @@ SineWave :: ~SineWave() { } -void SineWave :: reset(void) +void SineWave :: reset() { time_ = 0.0; lastOutput_ = 0; @@ -75,7 +75,7 @@ void SineWave :: addPhaseOffset( StkFloat angle ) phaseOffset_ = TABLE_SIZE * angle; } -StkFloat SineWave :: computeSample( void ) +StkFloat SineWave :: computeSample( ) { // Check limits of time address ... if necessary, recalculate modulo // TABLE_SIZE. diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Sitar.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Sitar.cpp index 4ba0acb71f..1aad09a4c5 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Sitar.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Sitar.cpp @@ -18,13 +18,13 @@ /***************************************************/ #include "Sitar.h" -#include +#include using namespace Nyq; Sitar :: Sitar(StkFloat lowestFrequency) { - unsigned long length = (unsigned long) (Stk::sampleRate() / lowestFrequency + 1); + auto length = (unsigned long) (Stk::sampleRate() / lowestFrequency + 1); delayLine_.setMaximumDelay( length ); delay_ = 0.5 * length; delayLine_.setDelay( delay_ ); diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/Stk.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/Stk.cpp index 7e21bfae9b..75ada2ba86 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/Stk.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/Stk.cpp @@ -13,7 +13,7 @@ /***************************************************/ #include "Stk.h" -#include +#include using namespace Nyq; @@ -28,15 +28,15 @@ const Stk::StkFormat Stk :: STK_FLOAT64 = 0x20; bool Stk :: showWarnings_ = false; bool Stk :: printErrors_ = true; -Stk :: Stk(void) +Stk :: Stk() { } -Stk :: ~Stk(void) +Stk :: ~Stk() { } -void Stk :: setRawwavePath( std::string path ) +void Stk :: setRawwavePath( const std::string& path ) { if ( !path.empty() ) rawwavepath_ = path; @@ -127,7 +127,7 @@ void Stk :: handleError( const char *message, StkError::Type type ) handleError( msg, type ); } -void Stk :: handleError( std::string message, StkError::Type type ) +void Stk :: handleError( const std::string& message, StkError::Type type ) { if ( type == StkError::WARNING || type == StkError::STATUS ) { if ( !showWarnings_ ) return; @@ -166,7 +166,7 @@ StkFrames :: StkFrames( unsigned int nFrames, unsigned int nChannels, bool inter } #endif } - else data_ = 0; + else data_ = nullptr; dataRate_ = Stk::sampleRate(); } @@ -186,7 +186,7 @@ StkFrames :: StkFrames( const StkFloat& value, unsigned int nFrames, unsigned in #endif for ( long i=0; i<(long)size_; i++ ) data_[i] = value; } - else data_ = 0; + else data_ = nullptr; dataRate_ = Stk::sampleRate(); } @@ -296,7 +296,7 @@ StkFloat StkFrames :: interpolate( StkFloat frame, unsigned int channel ) const } #endif - size_t iIndex = ( size_t ) frame; // integer part of index + auto iIndex = ( size_t ) frame; // integer part of index StkFloat output, alpha = frame - (StkFloat) iIndex; // fractional part of index if ( interleaved_ ) { diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/WaveLoop.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/WaveLoop.cpp index 80dc5aa7b2..4ecfb26ed6 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/WaveLoop.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/WaveLoop.cpp @@ -18,6 +18,7 @@ #include "WaveLoop.h" #include +#include using namespace Nyq; @@ -30,7 +31,7 @@ WaveLoop :: WaveLoop( std::string fileName, bool raw, bool doNormalize, unsigned long chunkThreshold, unsigned long chunkSize ) : FileWvIn( chunkThreshold, chunkSize ), phaseOffset_(0.0) { - this->openFile( fileName, raw, doNormalize ); + this->openFile( std::move(fileName), raw, doNormalize ); } WaveLoop :: ~WaveLoop() @@ -43,7 +44,7 @@ void WaveLoop :: openFile( std::string fileName, bool raw, bool doNormalize ) this->closeFile(); // Attempt to open the file ... an error might be thrown here. - file_.open( fileName, raw ); + file_.open( std::move(fileName), raw ); // Determine whether chunking or not. if ( file_.fileSize() > chunkThreshold_ ) { @@ -126,7 +127,7 @@ void WaveLoop :: addPhaseOffset( StkFloat angle ) phaseOffset_ = file_.fileSize() * angle; } -void WaveLoop :: computeFrame( void ) +void WaveLoop :: computeFrame( ) { // Check limits of time address ... if necessary, recalculate modulo // fileSize. diff --git a/lib-src/libnyquist/nyquist/nyqstk/src/WvIn.cpp b/lib-src/libnyquist/nyquist/nyqstk/src/WvIn.cpp index ecb24dbe36..236fbcc9f5 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/src/WvIn.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/src/WvIn.cpp @@ -30,7 +30,7 @@ WvIn :: ~WvIn() { } -StkFloat WvIn :: lastOut( void ) const +StkFloat WvIn :: lastOut( ) const { if ( lastOutputs_.empty() ) return 0.0; @@ -44,7 +44,7 @@ StkFloat WvIn :: lastOut( void ) const return output / lastOutputs_.size(); } -StkFloat WvIn :: tick( void ) +StkFloat WvIn :: tick( ) { computeFrame(); return lastOut(); diff --git a/lib-src/libnyquist/nyquist/nyqstk/stkinit.cpp b/lib-src/libnyquist/nyquist/nyqstk/stkinit.cpp index adb5e06f2e..efbd6bdd03 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/stkinit.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/stkinit.cpp @@ -1,7 +1,7 @@ /* stk path initialization */ -#include "stdlib.h" -#include "string.h" +#include +#include // #include "instr.h" #include "Stk.h" #include "stkinit.h" @@ -18,7 +18,7 @@ extern "C" { using namespace Nyq; -const char *rawwave_path = NULL; +const char *rawwave_path = nullptr; extern "C" void stk_init() { diff --git a/lib-src/libnyquist/nyquist/nyqstk/stkint.cpp b/lib-src/libnyquist/nyquist/nyqstk/stkint.cpp index c2a1e94346..747cd407bf 100644 --- a/lib-src/libnyquist/nyquist/nyqstk/stkint.cpp +++ b/lib-src/libnyquist/nyquist/nyqstk/stkint.cpp @@ -1,6 +1,6 @@ // interface for STK Effects -#include +#include #include "stkint.h" @@ -17,7 +17,7 @@ struct stkEffect { }; struct stkEffect *initStkEffect(int eff_type, ::StkFloat trev, int sample_rate) { - struct stkEffect * eff = (struct stkEffect *) malloc(sizeof(struct stkEffect)); + auto * eff = (struct stkEffect *) malloc(sizeof(struct stkEffect)); Stk::setSampleRate(sample_rate); switch(eff_type) { case NREV: @@ -30,7 +30,7 @@ struct stkEffect *initStkEffect(int eff_type, ::StkFloat trev, int sample_rate) eff->effectPtr = new PRCRev(trev); break; default: - return NULL; + return nullptr; } return eff; } @@ -57,7 +57,7 @@ struct stkEffect *initStkPitShift(::StkFloat shift, int sample_rate) { PitShift * ps; ps = new PitShift(); ps->setShift(shift); - struct stkEffect * eff = (struct stkEffect *) malloc(sizeof(struct stkEffect)); + auto * eff = (struct stkEffect *) malloc(sizeof(struct stkEffect)); Stk::setSampleRate(sample_rate); eff->effectPtr = ps; return eff; @@ -72,7 +72,7 @@ struct stkEffect *initStkChorus(::StkFloat baseDelay, ::StkFloat depth, ::StkFlo ch = new Chorus(baseDelay); ch->setModDepth(depth); ch->setModFrequency(freq); - struct stkEffect * eff = (struct stkEffect *) malloc(sizeof(struct stkEffect)); + auto * eff = (struct stkEffect *) malloc(sizeof(struct stkEffect)); Stk::setSampleRate(sample_rate); eff->effectPtr = ch; return eff; diff --git a/lib-src/libnyquist/nyquist/xlisp/security.c b/lib-src/libnyquist/nyquist/xlisp/security.c index d819e34e61..e4472e7e80 100644 --- a/lib-src/libnyquist/nyquist/xlisp/security.c +++ b/lib-src/libnyquist/nyquist/xlisp/security.c @@ -124,7 +124,6 @@ void find_full_path(const char *filename, char *fullname) return; error: strcpy(fullname, "//////"); - return; } diff --git a/lib-src/libnyquist/nyquist/xlisp/xlcont.c b/lib-src/libnyquist/nyquist/xlisp/xlcont.c index 03326a5b16..4da34d98b7 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlcont.c +++ b/lib-src/libnyquist/nyquist/xlisp/xlcont.c @@ -38,7 +38,7 @@ FORWARD LOCAL void doupdates(LVAL list, int pflag); /* dummy node type for a list */ -#define LIST -1 +#define LIST (-1) /* xquote - special form 'quote' */ LVAL xquote(void) diff --git a/lib-src/libnyquist/nyquist/xlisp/xldmem.h b/lib-src/libnyquist/nyquist/xlisp/xldmem.h index 60cbcaa91f..cfd3beaafb 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xldmem.h +++ b/lib-src/libnyquist/nyquist/xlisp/xldmem.h @@ -66,8 +66,8 @@ /* object access macros */ #define getclass(x) ((x)->n_vdata[0]) -#define getivar(x,i) ((x)->n_vdata[i+1]) -#define setivar(x,i,v) ((x)->n_vdata[i+1] = (v)) +#define getivar(x,i) ((x)->n_vdata[(i)+1]) +#define setivar(x,i,v) ((x)->n_vdata[(i)+1] = (v)) /* subr/fsubr access macros */ #define getsubr(x) ((x)->n_subr) @@ -171,7 +171,7 @@ typedef struct node { char n_flags; /* flag bits */ union ninfo { /* value */ struct xsubr { /* subr/fsubr node */ - struct node *(*xs_subr)(void); /* function pointer */ + struct node *(*xs_subr)(); /* function pointer */ int xs_offset; /* offset into funtab */ } n_xsubr; struct xcons { /* cons node */ diff --git a/lib-src/libnyquist/nyquist/xlisp/xlisp.h b/lib-src/libnyquist/nyquist/xlisp/xlisp.h index 44d52c358a..1d3ca209b6 100644 --- a/lib-src/libnyquist/nyquist/xlisp/xlisp.h +++ b/lib-src/libnyquist/nyquist/xlisp/xlisp.h @@ -311,14 +311,14 @@ void dbg_gc_xlsave(LVAL *n); #else #define xlstkcheck(n) {if (xlstack - (n) < xlstkbase) xlstkoverflow();} -#define xlsave(n) {*--xlstack = &n; n = NIL;} -#define xlprotect(n) {*--xlstack = &n;} +#define xlsave(n) {*--xlstack = &(n); (n) = NIL;} +#define xlprotect(n) {*--xlstack = &(n);} /* check the stack and protect a single pointer */ #define xlsave1(n) {if (xlstack <= xlstkbase) xlstkoverflow();\ - *--xlstack = &n; n = NIL;} + *--xlstack = &(n); (n) = NIL;} #define xlprot1(n) {if (xlstack <= xlstkbase) xlstkoverflow();\ - *--xlstack = &n;} + *--xlstack = &(n);} /* macros to pop pointers off the stack */ #define xlpop() {++xlstack;} @@ -387,7 +387,7 @@ void dbg_gc_xlsave(LVAL *n); typedef struct { const char *fd_name; /* function name */ int fd_type; /* function type */ - LVAL (*fd_subr)(void); /* function entry point */ + LVAL (*fd_subr)(); /* function entry point */ } FUNDEF; /* execution context flags */ @@ -608,7 +608,7 @@ LVAL cons(LVAL x, LVAL y); LVAL cvstring(const char *str); LVAL new_string(int size); LVAL cvsymbol(const char *pname); -LVAL cvsubr(LVAL (*fcn)(void), int type, int offset); +LVAL cvsubr(LVAL (*fcn)(), int type, int offset); LVAL cvfile(FILE *fp); LVAL cvfixnum(FIXTYPE n); LVAL cvflonum(FLOTYPE n); @@ -959,7 +959,7 @@ LVAL xinfo(void); /* xlsubr.c */ -LVAL xlsubr(const char *sname, int type, LVAL (*fcn)(void), int offset); +LVAL xlsubr(const char *sname, int type, LVAL (*fcn)(), int offset); int xlgetkeyarg(LVAL key, LVAL *pval); void xltest(LVAL *pfcn, int *ptresult); int xlgkfixnum(LVAL key, LVAL *pval); diff --git a/libraries/lib-basic-ui/GenericUIAssert.cpp b/libraries/lib-basic-ui/GenericUIAssert.cpp index 0f032d58f6..4c887851f7 100644 --- a/libraries/lib-basic-ui/GenericUIAssert.cpp +++ b/libraries/lib-basic-ui/GenericUIAssert.cpp @@ -11,6 +11,8 @@ Avery King #include "GenericUIAssert.h" +#include + namespace { @@ -23,7 +25,7 @@ namespace GenericUI void SetAssertFn(AssertFn fn) { - __AssertFn = fn; + __AssertFn = std::move(fn); } void Assert(bool condition) diff --git a/libraries/lib-components/ComponentInterfaceSymbol.h b/libraries/lib-components/ComponentInterfaceSymbol.h index e9e58503a8..211c029f53 100644 --- a/libraries/lib-components/ComponentInterfaceSymbol.h +++ b/libraries/lib-components/ComponentInterfaceSymbol.h @@ -52,14 +52,14 @@ class ComponentInterfaceSymbol , mMsgid{ internal.empty() ? TranslatableString{} : msgid } {} - const wxString &Internal() const { return mInternal; } - const TranslatableString &Msgid() const { return mMsgid; } - const TranslatableString Stripped() const { return mMsgid.Stripped(); } - const wxString Translation() const { return mMsgid.Translation(); } - const wxString StrippedTranslation() const + [[nodiscard]] const wxString &Internal() const { return mInternal; } + [[nodiscard]] const TranslatableString &Msgid() const { return mMsgid; } + [[nodiscard]] const TranslatableString Stripped() const { return mMsgid.Stripped(); } + [[nodiscard]] const wxString Translation() const { return mMsgid.Translation(); } + [[nodiscard]] const wxString StrippedTranslation() const { return Stripped().Translation(); } - bool empty() const { return mInternal.empty(); } + [[nodiscard]] bool empty() const { return mInternal.empty(); } friend inline bool operator == ( const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b ) diff --git a/libraries/lib-components/EffectAutomationParameters.h b/libraries/lib-components/EffectAutomationParameters.h index 32528b2a6d..45456c80fa 100644 --- a/libraries/lib-components/EffectAutomationParameters.h +++ b/libraries/lib-components/EffectAutomationParameters.h @@ -43,7 +43,7 @@ #ifndef __AUDACITY_COMMAND_PARAMETERS_H__ #define __AUDACITY_COMMAND_PARAMETERS_H__ -#include +#include #include // for wxCmdLineParser::ConvertStringToArgs #include // to inherit @@ -77,29 +77,29 @@ class COMPONENTS_API CommandParameters final : public wxFileConfig SetParameters(parms); } - virtual ~CommandParameters(); + ~CommandParameters() override; - virtual bool HasGroup(const wxString & strName) const override + [[nodiscard]] bool HasGroup(const wxString & strName) const override { return wxFileConfig::HasGroup(NormalizeName(strName)); } - virtual bool HasEntry(const wxString& strName) const override + [[nodiscard]] bool HasEntry(const wxString& strName) const override { return wxFileConfig::HasEntry(NormalizeName(strName)); } - virtual bool DoReadString(const wxString & key, wxString *pStr) const override + bool DoReadString(const wxString & key, wxString *pStr) const override { return wxFileConfig::DoReadString(NormalizeName(key), pStr); } - virtual bool DoReadLong(const wxString & key, long *pl) const override + bool DoReadLong(const wxString & key, long *pl) const override { return wxFileConfig::DoReadLong(NormalizeName(key), pl); } - virtual bool DoReadDouble(const wxString & key, double *pd) const override + bool DoReadDouble(const wxString & key, double *pd) const override { wxString str; if (Read(key, &str)) @@ -117,17 +117,17 @@ class COMPONENTS_API CommandParameters final : public wxFileConfig return false; } - virtual bool DoWriteString(const wxString & key, const wxString & szValue) override + bool DoWriteString(const wxString & key, const wxString & szValue) override { return wxFileConfig::DoWriteString(NormalizeName(key), szValue); } - virtual bool DoWriteLong(const wxString & key, long lValue) override + bool DoWriteLong(const wxString & key, long lValue) override { return wxFileConfig::DoWriteLong(NormalizeName(key), lValue); } - virtual bool DoWriteDouble(const wxString & key, double value) override + bool DoWriteDouble(const wxString & key, double value) override { return DoWriteString(key, wxString::Format(wxT("%.8g"), value)); } @@ -289,10 +289,10 @@ class COMPONENTS_API CommandParameters final : public wxFileConfig auto parsed = wxCmdLineParser::ConvertStringToArgs(parms); - for (size_t i = 0, cnt = parsed.size(); i < cnt; i++) + for (const auto & i : parsed) { - wxString key = parsed[i].BeforeFirst(wxT('=')).Trim(false).Trim(true); - wxString val = parsed[i].AfterFirst(wxT('=')).Trim(false).Trim(true); + wxString key = i.BeforeFirst(wxT('=')).Trim(false).Trim(true); + wxString val = i.AfterFirst(wxT('=')).Trim(false).Trim(true); if (!wxFileConfig::Write(key, Unescape(val))) { @@ -303,7 +303,7 @@ class COMPONENTS_API CommandParameters final : public wxFileConfig return true; } - wxString NormalizeName(const wxString & name) const + static wxString NormalizeName(const wxString & name) { wxString cleaned = name; @@ -317,7 +317,7 @@ class COMPONENTS_API CommandParameters final : public wxFileConfig return cleaned; } - wxString Escape(wxString val) + static wxString Escape(wxString val) { val.Replace(wxT("\\"), wxT("\\\\"), true); val.Replace(wxT("\""), wxT("\\\""), true); @@ -326,7 +326,7 @@ class COMPONENTS_API CommandParameters final : public wxFileConfig return val; } - wxString Unescape(wxString val) + static wxString Unescape(wxString val) { val.Replace(wxT("\\n"), wxT("\n"), true); val.Replace(wxT("\\\""), wxT("\""), true); diff --git a/libraries/lib-components/EffectInterface.h b/libraries/lib-components/EffectInterface.h index 6dae4512dc..e7c51d9808 100644 --- a/libraries/lib-components/EffectInterface.h +++ b/libraries/lib-components/EffectInterface.h @@ -75,7 +75,7 @@ flag-functions for interactivity, play-preview and whether the effect can run wi class COMPONENTS_API EffectDefinitionInterface /* not final */ : public ComponentInterface { public: - virtual ~EffectDefinitionInterface(); + ~EffectDefinitionInterface() override; // Type determines how it behaves. virtual EffectType GetType() = 0; @@ -120,7 +120,7 @@ ConfigClientInterface to add Getters/setters for private and shared configs. class COMPONENTS_API EffectHostInterface /* not final */ : public ConfigClientInterface { public: - virtual ~EffectHostInterface(); + ~EffectHostInterface() override; virtual double GetDefaultDuration() = 0; virtual double GetDuration() = 0; @@ -189,7 +189,7 @@ class COMPONENTS_API EffectClientInterface /* not final */ : public EffectDefin EffectHostInterface*, EffectUIClientInterface* ) >; - virtual ~EffectClientInterface(); + ~EffectClientInterface() override; virtual bool SetHost(EffectHostInterface *host) = 0; @@ -202,13 +202,13 @@ class COMPONENTS_API EffectClientInterface /* not final */ : public EffectDefin virtual void SetSampleRate(double rate) = 0; // Suggest a block size, but the return is the size that was really set: virtual size_t SetBlockSize(size_t maxBlockSize) = 0; - virtual size_t GetBlockSize() const = 0; + [[nodiscard]] virtual size_t GetBlockSize() const = 0; virtual sampleCount GetLatency() = 0; virtual size_t GetTailSize() = 0; virtual bool IsReady() = 0; - virtual bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) = 0; + virtual bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) = 0; // This may be called during stack unwinding: virtual bool ProcessFinalize() /* noexcept */ = 0; virtual size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) = 0; diff --git a/libraries/lib-components/ModuleInterface.h b/libraries/lib-components/ModuleInterface.h index da59e47b05..b79a5dfb84 100644 --- a/libraries/lib-components/ModuleInterface.h +++ b/libraries/lib-components/ModuleInterface.h @@ -69,7 +69,7 @@ class COMPONENTS_API ModuleInterface /* not final */ : public ComponentInterface { public: - virtual ~ModuleInterface(); + ~ModuleInterface() override; // Called immediately after creation to give the instance a chance to // initialize. Return "true" if initialziation was successful. diff --git a/libraries/lib-exceptions/InconsistencyException.h b/libraries/lib-exceptions/InconsistencyException.h index 56f5ce67d2..91e8354a38 100644 --- a/libraries/lib-exceptions/InconsistencyException.h +++ b/libraries/lib-exceptions/InconsistencyException.h @@ -38,7 +38,7 @@ class EXCEPTIONS_API InconsistencyException final : public MessageBoxException {} InconsistencyException(InconsistencyException&& that) - : MessageBoxException(std::move(that)) + : MessageBoxException(that) , func{ that.func } , file{ that.file } , line{ that.line } diff --git a/libraries/lib-exceptions/SaucedacityException.cpp b/libraries/lib-exceptions/SaucedacityException.cpp index b4c08430e8..63a451fd5e 100644 --- a/libraries/lib-exceptions/SaucedacityException.cpp +++ b/libraries/lib-exceptions/SaucedacityException.cpp @@ -13,6 +13,7 @@ #include "SaucedacityException.h" #include +#include #include "BasicUI.h" SaucedacityException::SaucedacityException() @@ -51,8 +52,8 @@ void SaucedacityException::EnqueueAction( std::atomic sOutstandingMessages {}; MessageBoxException::MessageBoxException( - ExceptionType exceptionType_, const TranslatableString& caption_) - : caption { caption_ } + ExceptionType exceptionType_, TranslatableString caption_) + : caption {std::move( caption_ )} , exceptionType { exceptionType_ } { if (!caption.empty()) diff --git a/libraries/lib-exceptions/SaucedacityException.h b/libraries/lib-exceptions/SaucedacityException.h index 019486e1e0..be90df9159 100644 --- a/libraries/lib-exceptions/SaucedacityException.h +++ b/libraries/lib-exceptions/SaucedacityException.h @@ -16,6 +16,7 @@ #include "../lib-strings/Internat.h" #include #include +#include #include "Internat.h" @@ -41,7 +42,7 @@ class EXCEPTIONS_API SaucedacityException : public std::exception public: SaucedacityException(); SaucedacityException(const char* what_arg); - virtual ~SaucedacityException(); + ~SaucedacityException() override; //! Don't allow moves of this class or subclasses // see https://bugzilla.audacityteam.org/show_bug.cgi?id=2442 @@ -81,7 +82,7 @@ class EXCEPTIONS_API MessageBoxException /* not final */ //! If default-constructed with empty caption, it makes no message box. explicit MessageBoxException( ExceptionType exceptionType, //!< Exception type - const TranslatableString &caption //!< Shown in message box's frame; not the actual message + TranslatableString caption //!< Shown in message box's frame; not the actual message ); ~MessageBoxException() override; @@ -109,12 +110,12 @@ class EXCEPTIONS_API SimpleMessageBoxException /* not final */ public: explicit SimpleMessageBoxException( ExceptionType exceptionType, //!< Exception type - const TranslatableString &message_, // GetSearchPaths(); - std::unique_ptr CreateAVIOContext() const; - std::unique_ptr CreateAVFormatContext() const; + [[nodiscard]] std::unique_ptr CreateAVIOContext() const; + [[nodiscard]] std::unique_ptr CreateAVFormatContext() const; std::unique_ptr CreateAVStreamWrapper(AVStream* stream, bool forEncoding) const; //! @post return value is not null - std::unique_ptr CreateAVPacketWrapper() const; + [[nodiscard]] std::unique_ptr CreateAVPacketWrapper() const; //! @post return value is not null - std::unique_ptr CreateAVFrameWrapper() const; + [[nodiscard]] std::unique_ptr CreateAVFrameWrapper() const; std::unique_ptr CreateAVInputFormatWrapper(AVInputFormat* inputFormat) const; std::unique_ptr CreateAVOutputFormatWrapper(const AVOutputFormat* outputFormat) const; - std::unique_ptr CreateDecoder(AVCodecIDFwd codecID) const; - std::unique_ptr CreateEncoder(AVCodecIDFwd codecID) const; + [[nodiscard]] std::unique_ptr CreateDecoder(AVCodecIDFwd codecID) const; + [[nodiscard]] std::unique_ptr CreateEncoder(AVCodecIDFwd codecID) const; std::unique_ptr CreateEncoder(const char* codecName) const; std::unique_ptr CreateAVCodecContextWrapper(AVCodecContext* context) const; - std::unique_ptr CreateAVCodecContextWrapperFromCodec(std::unique_ptr codec) const; + [[nodiscard]] std::unique_ptr CreateAVCodecContextWrapperFromCodec(std::unique_ptr codec) const; std::unique_ptr GuessOutputFormat(const char* short_name, const char* filename, const char* mime_type); - const std::vector& GetOutputFormats() const; - const std::vector& GetCodecs() const; + [[nodiscard]] const std::vector& GetOutputFormats() const; + [[nodiscard]] const std::vector& GetCodecs() const; - std::unique_ptr CreateFifoBuffer(int size) const; + [[nodiscard]] std::unique_ptr CreateFifoBuffer(int size) const; template AVDataBuffer CreateMemoryBuffer(int preallocatedSize) const diff --git a/libraries/lib-ffmpeg-support/FFmpegTypes.h b/libraries/lib-ffmpeg-support/FFmpegTypes.h index ccd6fb4069..d5a9f26e59 100644 --- a/libraries/lib-ffmpeg-support/FFmpegTypes.h +++ b/libraries/lib-ffmpeg-support/FFmpegTypes.h @@ -11,7 +11,7 @@ #pragma once #include -#include +#include #define AUDACITY_MKTAG(a, b, c, d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) #define AUDACITY_FFERRTAG(a, b, c, d) (-(int)AUDACITY_MKTAG(a, b, c, d)) @@ -74,7 +74,7 @@ #define AUDACITY_AV_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000)) #ifndef AV_VERSION_INT -#define AV_VERSION_INT(a, b, c) (a << 16 | b << 8 | c) +#define AV_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c)) #endif #define AUDACITY_AV_TIME_BASE (1000 * 1000) @@ -95,7 +95,7 @@ #define FF_COMPLIANCE_NORMAL 0 #define FF_COMPLIANCE_UNOFFICIAL -1 */ -#define AUDACITY_FF_COMPLIANCE_EXPERIMENTAL -2 +#define AUDACITY_FF_COMPLIANCE_EXPERIMENTAL (-2) /* #define FF_PROFILE_AAC_MAIN 0 @@ -170,7 +170,7 @@ struct FFMPegVersion final unsigned Minor { 0 }; unsigned Micro { 0 }; - unsigned GetIntVersion() const noexcept + [[nodiscard]] unsigned GetIntVersion() const noexcept { return AV_VERSION_INT(Major, Minor, Micro); } diff --git a/libraries/lib-ffmpeg-support/impl/FFmpegAPIResolver.h b/libraries/lib-ffmpeg-support/impl/FFmpegAPIResolver.h index e46de67b1e..3fa197a053 100644 --- a/libraries/lib-ffmpeg-support/impl/FFmpegAPIResolver.h +++ b/libraries/lib-ffmpeg-support/impl/FFmpegAPIResolver.h @@ -82,7 +82,7 @@ class FFmpegAPIResolver final //! Compatible library versions to be sought at load time, ordered by //! decreasing preference (that is, newest version first) - std::vector GetSuportedAVFormatVersions() const; + [[nodiscard]] std::vector GetSuportedAVFormatVersions() const; private: std::map mAVCodecIDResolvers; diff --git a/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecContextWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecContextWrapperImpl.inl index ed67448921..328133b074 100644 --- a/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecContextWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecContextWrapperImpl.inl @@ -101,7 +101,7 @@ std::vector Convert(const void* rawData, const size_t dataSize) std::vector output; output.reserve(samplesCount); - const InputType* currentSample = static_cast(rawData); + const auto* currentSample = static_cast(rawData); for (int sample = 0; sample < samplesCount; ++sample) { @@ -132,7 +132,7 @@ public: mAVCodec = mFFmpeg.CreateDecoder(mAVCodecContext->codec_id); } - int GetBitRate() const noexcept override + [[nodiscard]] int GetBitRate() const noexcept override { if (mAVCodecContext != nullptr) // May truncate int64_t to int. But who uses such high rates, really? @@ -147,7 +147,7 @@ public: mAVCodecContext->bit_rate = value; } - uint64_t GetChannelLayout() const noexcept override + [[nodiscard]] uint64_t GetChannelLayout() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->channel_layout; @@ -161,7 +161,7 @@ public: mAVCodecContext->channel_layout = value; } - int GetChannels() const noexcept override + [[nodiscard]] int GetChannels() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->channels; @@ -175,7 +175,7 @@ public: mAVCodecContext->channels = value; } - const AVCodecWrapper* GetCodec() const noexcept override + [[nodiscard]] const AVCodecWrapper* GetCodec() const noexcept override { if (!mAVCodec && mAVCodecContext && mAVCodecContext->codec) { @@ -188,7 +188,7 @@ public: return mAVCodec.get(); } - AVCodecIDFwd GetCodecId() const noexcept override + [[nodiscard]] AVCodecIDFwd GetCodecId() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->codec_id; @@ -202,7 +202,7 @@ public: mAVCodecContext->codec_tag = tag; } - unsigned int GetCodecTag() const noexcept override + [[nodiscard]] unsigned int GetCodecTag() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->codec_tag; @@ -210,7 +210,7 @@ public: return {}; } - AVMediaTypeFwd GetCodecType() const noexcept override + [[nodiscard]] AVMediaTypeFwd GetCodecType() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->codec_type; @@ -218,7 +218,7 @@ public: return {}; } - int GetCompressionLevel() const noexcept override + [[nodiscard]] int GetCompressionLevel() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->compression_level; @@ -232,7 +232,7 @@ public: mAVCodecContext->compression_level = value; } - int GetCutoff() const noexcept override + [[nodiscard]] int GetCutoff() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->cutoff; @@ -246,7 +246,7 @@ public: mAVCodecContext->cutoff = value; } - int GetFlags() const noexcept override + [[nodiscard]] int GetFlags() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->flags; @@ -260,7 +260,7 @@ public: mAVCodecContext->flags = value; } - int GetFlags2() const noexcept override + [[nodiscard]] int GetFlags2() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->flags2; @@ -274,7 +274,7 @@ public: mAVCodecContext->flags2 = value; } - int GetFrameNumber() const noexcept override + [[nodiscard]] int GetFrameNumber() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->frame_number; @@ -288,7 +288,7 @@ public: mAVCodecContext->frame_number = value; } - int GetFrameSize() const noexcept override + [[nodiscard]] int GetFrameSize() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->frame_size; @@ -302,7 +302,7 @@ public: mAVCodecContext->frame_size = value; } - int GetGlobalQuality() const noexcept override + [[nodiscard]] int GetGlobalQuality() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->global_quality; @@ -316,7 +316,7 @@ public: mAVCodecContext->global_quality = value; } - int GetProfile() const noexcept override + [[nodiscard]] int GetProfile() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->profile; @@ -330,7 +330,7 @@ public: mAVCodecContext->profile = value; } - AVSampleFormatFwd GetSampleFmt() const noexcept override + [[nodiscard]] AVSampleFormatFwd GetSampleFmt() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->sample_fmt; @@ -344,7 +344,7 @@ public: mAVCodecContext->sample_fmt = static_cast(value); } - int GetSampleRate() const noexcept override + [[nodiscard]] int GetSampleRate() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->sample_rate; @@ -358,7 +358,7 @@ public: mAVCodecContext->sample_rate = value; } - int GetStrictStdCompliance() const noexcept override + [[nodiscard]] int GetStrictStdCompliance() const noexcept override { if (mAVCodecContext != nullptr) return mAVCodecContext->strict_std_compliance; @@ -372,7 +372,7 @@ public: mAVCodecContext->strict_std_compliance = value; } - struct AudacityAVRational GetTimeBase() const noexcept override + [[nodiscard]] struct AudacityAVRational GetTimeBase() const noexcept override { if (mAVCodecContext != nullptr) { @@ -392,7 +392,7 @@ public: }; } - sampleFormat GetPreferredAudacitySampleFormat() const noexcept override + [[nodiscard]] sampleFormat GetPreferredAudacitySampleFormat() const noexcept override { if (mAVCodecContext == nullptr) return int16Sample; diff --git a/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecWrapperImpl.inl index 945ec17275..ed2823aaa6 100644 --- a/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avcodec/AVCodecWrapperImpl.inl @@ -16,7 +16,7 @@ public: { } - const char* GetName() const noexcept override + [[nodiscard]] const char* GetName() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->name; @@ -24,7 +24,7 @@ public: return {}; } - const char* GetLongName() const noexcept override + [[nodiscard]] const char* GetLongName() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->long_name; @@ -32,7 +32,7 @@ public: return {}; } - AVMediaTypeFwd GetType() const noexcept override + [[nodiscard]] AVMediaTypeFwd GetType() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->type; @@ -40,7 +40,7 @@ public: return {}; } - AVCodecIDFwd GetId() const noexcept override + [[nodiscard]] AVCodecIDFwd GetId() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->id; @@ -48,7 +48,7 @@ public: return {}; } - int GetCapabilities() const noexcept override + [[nodiscard]] int GetCapabilities() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->capabilities; @@ -56,7 +56,7 @@ public: return {}; } - const AVRational* GetSupportedFramerates() const noexcept override + [[nodiscard]] const AVRational* GetSupportedFramerates() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->supported_framerates; @@ -64,7 +64,7 @@ public: return {}; } - const AVPixelFormatFwd* GetPixFmts() const noexcept override + [[nodiscard]] const AVPixelFormatFwd* GetPixFmts() const noexcept override { static_assert(sizeof(AVPixelFormat) == sizeof(AVPixelFormatFwd)); if (mAVCodec != nullptr) @@ -73,7 +73,7 @@ public: return {}; } - const int* GetSupportedSamplerates() const noexcept override + [[nodiscard]] const int* GetSupportedSamplerates() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->supported_samplerates; @@ -81,7 +81,7 @@ public: return {}; } - const AVSampleFormatFwd* GetSampleFmts() const noexcept override + [[nodiscard]] const AVSampleFormatFwd* GetSampleFmts() const noexcept override { static_assert(sizeof(AVSampleFormat) == sizeof(AVSampleFormatFwd)); @@ -91,7 +91,7 @@ public: return {}; } - const uint64_t* GetChannelLayouts() const noexcept override + [[nodiscard]] const uint64_t* GetChannelLayouts() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->channel_layouts; @@ -99,7 +99,7 @@ public: return {}; } - uint8_t GetMaxLowres() const noexcept override + [[nodiscard]] uint8_t GetMaxLowres() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->max_lowres; @@ -107,7 +107,7 @@ public: return {}; } - bool IsAudio() const noexcept override + [[nodiscard]] bool IsAudio() const noexcept override { if (mAVCodec != nullptr) return mAVCodec->type == AVMEDIA_TYPE_AUDIO; diff --git a/libraries/lib-ffmpeg-support/impl/avcodec/AVPacketWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avcodec/AVPacketWrapperImpl.inl index 60efe22ad1..035a30d74d 100644 --- a/libraries/lib-ffmpeg-support/impl/avcodec/AVPacketWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avcodec/AVPacketWrapperImpl.inl @@ -32,7 +32,7 @@ public: mFFmpeg.av_init_packet(mAVPacket); } - AudacityAVBufferRef* GetBuf() const noexcept override + [[nodiscard]] AudacityAVBufferRef* GetBuf() const noexcept override { if (mAVPacket != nullptr) return reinterpret_cast(mAVPacket->buf); @@ -40,7 +40,7 @@ public: return {}; } - int64_t GetPresentationTimestamp() const noexcept override + [[nodiscard]] int64_t GetPresentationTimestamp() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->pts; @@ -48,7 +48,7 @@ public: return {}; } - int64_t GetDecompressionTimestamp() const noexcept override + [[nodiscard]] int64_t GetDecompressionTimestamp() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->dts; @@ -56,7 +56,7 @@ public: return {}; } - uint8_t* GetData() const noexcept override + [[nodiscard]] uint8_t* GetData() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->data; @@ -64,7 +64,7 @@ public: return {}; } - int GetSize() const noexcept override + [[nodiscard]] int GetSize() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->size; @@ -111,7 +111,7 @@ public: mAVPacket->pts = AV_NOPTS_VALUE; } - int GetStreamIndex() const noexcept override + [[nodiscard]] int GetStreamIndex() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->stream_index; @@ -125,7 +125,7 @@ public: mAVPacket->stream_index = index; } - int GetFlags() const noexcept override + [[nodiscard]] int GetFlags() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->flags; @@ -133,7 +133,7 @@ public: return {}; } - int GetDuration() const noexcept override + [[nodiscard]] int GetDuration() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->duration; @@ -141,7 +141,7 @@ public: return {}; } - int64_t GetPos() const noexcept override + [[nodiscard]] int64_t GetPos() const noexcept override { if (mAVPacket != nullptr) return mAVPacket->pos; @@ -149,7 +149,7 @@ public: return {}; } - int64_t GetConvergenceDuration() const noexcept override + [[nodiscard]] int64_t GetConvergenceDuration() const noexcept override { if (mAVPacket != nullptr) #if LIBAVFORMAT_VERSION_MAJOR <= 58 @@ -163,7 +163,7 @@ public: return {}; } - std::unique_ptr Clone() const noexcept override + [[nodiscard]] std::unique_ptr Clone() const noexcept override { // Guarantee non-null return, which is assumed elsewhere auto copy = std::make_unique(mFFmpeg); diff --git a/libraries/lib-ffmpeg-support/impl/avformat/AVFormatContextWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avformat/AVFormatContextWrapperImpl.inl index 2bf4670f98..65893de7ff 100644 --- a/libraries/lib-ffmpeg-support/impl/avformat/AVFormatContextWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avformat/AVFormatContextWrapperImpl.inl @@ -44,13 +44,13 @@ static_assert( class AVFormatContextWrapperImpl : public AVFormatContextWrapper { public: - AVFormatContextWrapperImpl(const FFmpegFunctions& ffmpeg) + explicit AVFormatContextWrapperImpl(const FFmpegFunctions& ffmpeg) : AVFormatContextWrapper(ffmpeg) { mAVFormatContext = mFFmpeg.avformat_alloc_context(); } - AVInputFormat* GetIFormat() const noexcept override + [[nodiscard]] AVInputFormat* GetIFormat() const noexcept override { if (mAVFormatContext != nullptr) #if LIBAVFORMAT_VERSION_MAJOR <= 58 @@ -62,7 +62,7 @@ public: return {}; } - AVOutputFormat* GetOFormat() const noexcept override + [[nodiscard]] AVOutputFormat* GetOFormat() const noexcept override { if (mAVFormatContext != nullptr) #if LIBAVFORMAT_VERSION_MAJOR <= 58 @@ -83,7 +83,7 @@ public: } } - AVIOContextWrapper* GetAVIOContext() const noexcept override + [[nodiscard]] AVIOContextWrapper* GetAVIOContext() const noexcept override { return mAVIOContext.get(); } @@ -97,7 +97,7 @@ public: } } - int GetCtxFlags() const noexcept override + [[nodiscard]] int GetCtxFlags() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->ctx_flags; @@ -105,7 +105,7 @@ public: return {}; } - unsigned int GetStreamsCount() const noexcept override + [[nodiscard]] unsigned int GetStreamsCount() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->nb_streams; @@ -113,12 +113,12 @@ public: return {}; } - const AVFormatContextWrapper::StreamsList& GetStreams() const noexcept override + [[nodiscard]] const AVFormatContextWrapper::StreamsList& GetStreams() const noexcept override { return mStreams; } - const char* GetFilename() const noexcept override + [[nodiscard]] const char* GetFilename() const noexcept override { if (mAVFormatContext != nullptr) #if LIBAVFORMAT_VERSION_MAJOR <= 58 @@ -146,7 +146,7 @@ public: #endif } - int64_t GetStartTime() const noexcept override + [[nodiscard]] int64_t GetStartTime() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->start_time; @@ -154,7 +154,7 @@ public: return {}; } - int64_t GetDuration() const noexcept override + [[nodiscard]] int64_t GetDuration() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->duration; @@ -162,7 +162,7 @@ public: return {}; } - int GetBitRate() const noexcept override + [[nodiscard]] int GetBitRate() const noexcept override { if (mAVFormatContext != nullptr) // May truncate int64_t to int. But who uses such high rates, really? @@ -177,7 +177,7 @@ public: mAVFormatContext->bit_rate = bit_rate; } - unsigned int GetPacketSize() const noexcept override + [[nodiscard]] unsigned int GetPacketSize() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->packet_size; @@ -191,7 +191,7 @@ public: mAVFormatContext->packet_size = packet_size; } - int GetMaxDelay() const noexcept override + [[nodiscard]] int GetMaxDelay() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->max_delay; @@ -205,7 +205,7 @@ public: mAVFormatContext->max_delay = max_delay; } - int GetFlags() const noexcept override + [[nodiscard]] int GetFlags() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->flags; @@ -219,7 +219,7 @@ public: mAVFormatContext->flags = flags; } - unsigned int GetProbeSize() const noexcept override + [[nodiscard]] unsigned int GetProbeSize() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->probesize; @@ -233,7 +233,7 @@ public: mAVFormatContext->probesize = probesize; } - int GetMaxAnalyzeDuration() const noexcept override + [[nodiscard]] int GetMaxAnalyzeDuration() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->max_analyze_duration; @@ -247,7 +247,7 @@ public: mAVFormatContext->max_analyze_duration = max_analyze_duration; } - AVCodecIDFwd GetAudioCodecId() const noexcept override + [[nodiscard]] AVCodecIDFwd GetAudioCodecId() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->audio_codec_id; @@ -261,7 +261,7 @@ public: mAVFormatContext->audio_codec_id = static_cast(audio_codec_id); } - unsigned int GetMaxIndexSize() const noexcept override + [[nodiscard]] unsigned int GetMaxIndexSize() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->max_index_size; @@ -275,7 +275,7 @@ public: mAVFormatContext->max_index_size = max_index_size; } - AVDictionaryWrapper GetMetadata() const noexcept override + [[nodiscard]] AVDictionaryWrapper GetMetadata() const noexcept override { if (mAVFormatContext != nullptr) return AVDictionaryWrapper(mFFmpeg, mAVFormatContext->metadata); @@ -296,7 +296,7 @@ public: mAVFormatContext->metadata = metadata.Release(); } - int64_t GetStartTimeRealtime() const noexcept override + [[nodiscard]] int64_t GetStartTimeRealtime() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->start_time_realtime; @@ -310,7 +310,7 @@ public: mAVFormatContext->start_time_realtime = start_time_realtime; } - int GetFpsProbeSize() const noexcept override + [[nodiscard]] int GetFpsProbeSize() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->fps_probe_size; @@ -324,7 +324,7 @@ public: mAVFormatContext->fps_probe_size = fps_probe_size; } - int GetErrorRecognition() const noexcept override + [[nodiscard]] int GetErrorRecognition() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->error_recognition; @@ -338,7 +338,7 @@ public: mAVFormatContext->error_recognition = error_recognition; } - int64_t GetMaxInterleaveDelta() const noexcept override + [[nodiscard]] int64_t GetMaxInterleaveDelta() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->max_interleave_delta; @@ -352,7 +352,7 @@ public: mAVFormatContext->max_interleave_delta = max_interleave_delta; } - int GetStrictStdCompliance() const noexcept override + [[nodiscard]] int GetStrictStdCompliance() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->strict_std_compliance; @@ -366,7 +366,7 @@ public: mAVFormatContext->strict_std_compliance = strict_std_compliance; } - int GetAudioPreload() const noexcept override + [[nodiscard]] int GetAudioPreload() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->audio_preload; @@ -380,7 +380,7 @@ public: mAVFormatContext->audio_preload = audio_preload; } - int GetMaxChunkDuration() const noexcept override + [[nodiscard]] int GetMaxChunkDuration() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->max_chunk_duration; @@ -394,7 +394,7 @@ public: mAVFormatContext->max_chunk_duration = max_chunk_duration; } - int GetMaxChunkSize() const noexcept override + [[nodiscard]] int GetMaxChunkSize() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->max_chunk_size; @@ -408,7 +408,7 @@ public: mAVFormatContext->max_chunk_size = max_chunk_size; } - int GetUseWallclockAsTimestamps() const noexcept override + [[nodiscard]] int GetUseWallclockAsTimestamps() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->use_wallclock_as_timestamps; @@ -423,7 +423,7 @@ public: mAVFormatContext->use_wallclock_as_timestamps = use_wallclock_as_timestamps; } - int GetAvoidNegativeTs() const noexcept override + [[nodiscard]] int GetAvoidNegativeTs() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->avoid_negative_ts; @@ -437,7 +437,7 @@ public: mAVFormatContext->avoid_negative_ts = avoid_negative_ts; } - int GetAvioFlags() const noexcept override + [[nodiscard]] int GetAvioFlags() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->avio_flags; @@ -451,7 +451,7 @@ public: mAVFormatContext->avio_flags = avio_flags; } - int64_t GetSkipInitialBytes() const noexcept override + [[nodiscard]] int64_t GetSkipInitialBytes() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->skip_initial_bytes; @@ -465,7 +465,7 @@ public: mAVFormatContext->skip_initial_bytes = skip_initial_bytes; } - unsigned int GetCorrectTsOverflow() const noexcept override + [[nodiscard]] unsigned int GetCorrectTsOverflow() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->correct_ts_overflow; @@ -479,7 +479,7 @@ public: mAVFormatContext->correct_ts_overflow = correct_ts_overflow; } - int GetSeek2any() const noexcept override + [[nodiscard]] int GetSeek2any() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->seek2any; @@ -493,7 +493,7 @@ public: mAVFormatContext->seek2any = seek2any; } - int GetFlushPackets() const noexcept override + [[nodiscard]] int GetFlushPackets() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->flush_packets; @@ -507,7 +507,7 @@ public: mAVFormatContext->flush_packets = flush_packets; } - int GetProbeScore() const noexcept override + [[nodiscard]] int GetProbeScore() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->probe_score; @@ -515,7 +515,7 @@ public: return {}; } - int GetFormatProbeSize() const noexcept override + [[nodiscard]] int GetFormatProbeSize() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->format_probesize; @@ -529,7 +529,7 @@ public: mAVFormatContext->format_probesize = format_probesize; } - AVCodecWrapper* GetAudioCodec() const noexcept override + [[nodiscard]] AVCodecWrapper* GetAudioCodec() const noexcept override { return mForcedAudioCodec.get(); } @@ -543,7 +543,7 @@ public: mForcedAudioCodec = move(audio_codec); } - void* GetOpaque() const noexcept override + [[nodiscard]] void* GetOpaque() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->opaque; @@ -557,7 +557,7 @@ public: mAVFormatContext->opaque = opaque; } - int64_t GetOutputTsOffset() const noexcept override + [[nodiscard]] int64_t GetOutputTsOffset() const noexcept override { if (mAVFormatContext != nullptr) return mAVFormatContext->output_ts_offset; diff --git a/libraries/lib-ffmpeg-support/impl/avformat/AVIOContextWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avformat/AVIOContextWrapperImpl.inl index 7a4990285c..6fcb0a7d5c 100644 --- a/libraries/lib-ffmpeg-support/impl/avformat/AVIOContextWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avformat/AVIOContextWrapperImpl.inl @@ -21,7 +21,7 @@ public: mFFmpeg.av_free(mAVIOContext->buffer); } - unsigned char* GetBuffer() const noexcept override + [[nodiscard]] unsigned char* GetBuffer() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->buffer; @@ -29,7 +29,7 @@ public: return {}; } - int GetBufferSize() const noexcept override + [[nodiscard]] int GetBufferSize() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->buffer_size; @@ -37,7 +37,7 @@ public: return {}; } - unsigned char* GetBufPtr() const noexcept override + [[nodiscard]] unsigned char* GetBufPtr() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->buf_ptr; @@ -45,7 +45,7 @@ public: return {}; } - unsigned char* GetBufEnd() const noexcept override + [[nodiscard]] unsigned char* GetBufEnd() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->buf_end; @@ -53,7 +53,7 @@ public: return {}; } - void* GetOpaque() const noexcept override + [[nodiscard]] void* GetOpaque() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->opaque; @@ -67,7 +67,7 @@ public: mAVIOContext->opaque = opaque; } - int64_t GetPos() const noexcept override + [[nodiscard]] int64_t GetPos() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->pos; @@ -75,7 +75,7 @@ public: return {}; } - int GetEofReached() const noexcept override + [[nodiscard]] int GetEofReached() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->eof_reached; @@ -83,7 +83,7 @@ public: return {}; } - int GetWriteFlag() const noexcept override + [[nodiscard]] int GetWriteFlag() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->write_flag; @@ -97,7 +97,7 @@ public: mAVIOContext->write_flag = write_flag; } - int GetError() const noexcept override + [[nodiscard]] int GetError() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->error; @@ -111,7 +111,7 @@ public: mAVIOContext->error = error; } - int GetSeekable() const noexcept override + [[nodiscard]] int GetSeekable() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->seekable; @@ -125,7 +125,7 @@ public: mAVIOContext->seekable = seekable; } - int GetDirect() const noexcept override + [[nodiscard]] int GetDirect() const noexcept override { if (mAVIOContext != nullptr) return mAVIOContext->direct; diff --git a/libraries/lib-ffmpeg-support/impl/avformat/AVInputFormatWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avformat/AVInputFormatWrapperImpl.inl index 77d595d45f..89ea5dda0d 100644 --- a/libraries/lib-ffmpeg-support/impl/avformat/AVInputFormatWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avformat/AVInputFormatWrapperImpl.inl @@ -11,11 +11,11 @@ class AVInputFormatWrapperImpl : public AVInputFormatWrapper { public: - AVInputFormatWrapperImpl(AVInputFormat* wrapped) + explicit AVInputFormatWrapperImpl(AVInputFormat* wrapped) : AVInputFormatWrapper(wrapped) {} - const char* GetName() const noexcept override + [[nodiscard]] const char* GetName() const noexcept override { if (mAVInputFormat != nullptr) return mAVInputFormat->name; @@ -23,7 +23,7 @@ public: return {}; } - const char* GetLongName() const noexcept override + [[nodiscard]] const char* GetLongName() const noexcept override { if (mAVInputFormat != nullptr) return mAVInputFormat->long_name; @@ -31,7 +31,7 @@ public: return {}; } - int GetFlags() const noexcept override + [[nodiscard]] int GetFlags() const noexcept override { if (mAVInputFormat != nullptr) return mAVInputFormat->flags; @@ -39,7 +39,7 @@ public: return {}; } - const char* GetExtensions() const noexcept override + [[nodiscard]] const char* GetExtensions() const noexcept override { if (mAVInputFormat != nullptr) return mAVInputFormat->extensions; @@ -47,7 +47,7 @@ public: return {}; } - const struct AVCodecTag* const* GetCodecTag() const noexcept override + [[nodiscard]] const struct AVCodecTag* const* GetCodecTag() const noexcept override { if (mAVInputFormat != nullptr) return mAVInputFormat->codec_tag; diff --git a/libraries/lib-ffmpeg-support/impl/avformat/AVOutputFormatWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avformat/AVOutputFormatWrapperImpl.inl index 4f6276d20d..64305b9345 100644 --- a/libraries/lib-ffmpeg-support/impl/avformat/AVOutputFormatWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avformat/AVOutputFormatWrapperImpl.inl @@ -16,7 +16,7 @@ public: { } - const char* GetName() const noexcept override + [[nodiscard]] const char* GetName() const noexcept override { if (mAVOutputFormat != nullptr) return mAVOutputFormat->name; @@ -24,7 +24,7 @@ public: return {}; } - const char* GetLongName() const noexcept override + [[nodiscard]] const char* GetLongName() const noexcept override { if (mAVOutputFormat != nullptr) return mAVOutputFormat->long_name; @@ -32,7 +32,7 @@ public: return {}; } - const char* GetMimeType() const noexcept override + [[nodiscard]] const char* GetMimeType() const noexcept override { if (mAVOutputFormat != nullptr) return mAVOutputFormat->mime_type; @@ -40,7 +40,7 @@ public: return {}; } - const char* GetExtensions() const noexcept override + [[nodiscard]] const char* GetExtensions() const noexcept override { if (mAVOutputFormat != nullptr) return mAVOutputFormat->extensions; @@ -48,7 +48,7 @@ public: return {}; } - AVCodecIDFwd GetAudioCodec() const noexcept override + [[nodiscard]] AVCodecIDFwd GetAudioCodec() const noexcept override { if (mAVOutputFormat != nullptr) return mAVOutputFormat->audio_codec; @@ -56,7 +56,7 @@ public: return {}; } - int GetFlags() const noexcept override + [[nodiscard]] int GetFlags() const noexcept override { if (mAVOutputFormat != nullptr) return mAVOutputFormat->flags; @@ -64,7 +64,7 @@ public: return {}; } - const struct AVCodecTag* const* GetCodecTag() const noexcept override + [[nodiscard]] const struct AVCodecTag* const* GetCodecTag() const noexcept override { if (mAVOutputFormat != nullptr) return mAVOutputFormat->codec_tag; diff --git a/libraries/lib-ffmpeg-support/impl/avformat/AVStreamWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avformat/AVStreamWrapperImpl.inl index 3ca66480c3..28e6db54f6 100644 --- a/libraries/lib-ffmpeg-support/impl/avformat/AVStreamWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avformat/AVStreamWrapperImpl.inl @@ -18,7 +18,7 @@ public: { } - int GetIndex() const noexcept override + [[nodiscard]] int GetIndex() const noexcept override { if (mAVStream != nullptr) return mAVStream->index; @@ -26,7 +26,7 @@ public: return {}; } - int GetId() const noexcept override + [[nodiscard]] int GetId() const noexcept override { if (mAVStream != nullptr) return mAVStream->id; @@ -40,7 +40,7 @@ public: mAVStream->id = id; } - AudacityAVRational GetTimeBase() const noexcept override + [[nodiscard]] AudacityAVRational GetTimeBase() const noexcept override { if (mAVStream != nullptr) return { mAVStream->time_base.num, mAVStream->time_base.den }; @@ -57,7 +57,7 @@ public: mAVStream->time_base.den = time_base.den; } - int64_t GetStartTime() const noexcept override + [[nodiscard]] int64_t GetStartTime() const noexcept override { if (mAVStream != nullptr) return mAVStream->start_time; @@ -71,7 +71,7 @@ public: mAVStream->start_time = start_time; } - int64_t GetDuration() const noexcept override + [[nodiscard]] int64_t GetDuration() const noexcept override { if (mAVStream != nullptr) return mAVStream->duration; @@ -85,7 +85,7 @@ public: mAVStream->duration = duration; } - int64_t GetFramesCount() const noexcept override + [[nodiscard]] int64_t GetFramesCount() const noexcept override { if (mAVStream != nullptr) return mAVStream->nb_frames; @@ -99,7 +99,7 @@ public: mAVStream->nb_frames = nb_frames; } - int GetDisposition() const noexcept override + [[nodiscard]] int GetDisposition() const noexcept override { if (mAVStream != nullptr) return mAVStream->disposition; @@ -113,7 +113,7 @@ public: mAVStream->disposition = disposition; } - AVSampleFormatFwd GetDiscard() const noexcept override + [[nodiscard]] AVSampleFormatFwd GetDiscard() const noexcept override { if (mAVStream != nullptr) return mAVStream->discard; @@ -127,7 +127,7 @@ public: mAVStream->discard = static_cast(discard); } - AudacityAVRational GetSampleAspectRatio() const noexcept override + [[nodiscard]] AudacityAVRational GetSampleAspectRatio() const noexcept override { if (mAVStream != nullptr) return { mAVStream->sample_aspect_ratio.num, @@ -146,7 +146,7 @@ public: mAVStream->sample_aspect_ratio.den = sample_aspect_ratio.den; } - AVDictionaryWrapper GetMetadata() const noexcept override + [[nodiscard]] AVDictionaryWrapper GetMetadata() const noexcept override { if (mAVStream != nullptr) return AVDictionaryWrapper(mFFmpeg, mAVStream->metadata); @@ -172,7 +172,7 @@ public: } } - bool IsAudio() const noexcept override + [[nodiscard]] bool IsAudio() const noexcept override { if (mAVStream != nullptr) #if LIBAVFORMAT_VERSION_MAJOR <= 58 @@ -184,7 +184,7 @@ public: return {}; } - AVCodecIDFwd GetAVCodecID() const noexcept override + [[nodiscard]] AVCodecIDFwd GetAVCodecID() const noexcept override { if (mAVStream != nullptr) #if LIBAVFORMAT_VERSION_MAJOR <= 58 @@ -196,7 +196,7 @@ public: return AV_CODEC_ID_NONE; } - std::unique_ptr + [[nodiscard]] std::unique_ptr GetAVCodecContext() const noexcept override { if (mAVStream == nullptr) diff --git a/libraries/lib-ffmpeg-support/impl/avutil/AVFrameWrapperImpl.inl b/libraries/lib-ffmpeg-support/impl/avutil/AVFrameWrapperImpl.inl index 8f6370894b..56dbc9504b 100644 --- a/libraries/lib-ffmpeg-support/impl/avutil/AVFrameWrapperImpl.inl +++ b/libraries/lib-ffmpeg-support/impl/avutil/AVFrameWrapperImpl.inl @@ -17,12 +17,12 @@ public: { } - int GetNumDataPointers() const noexcept override + [[nodiscard]] int GetNumDataPointers() const noexcept override { return AV_NUM_DATA_POINTERS; } - uint8_t* GetData(int index) const noexcept override + [[nodiscard]] uint8_t* GetData(int index) const noexcept override { if (mAVFrame == nullptr) return {}; @@ -33,7 +33,7 @@ public: return mAVFrame->data[index]; } - int GetLineSize(int index) const noexcept override + [[nodiscard]] int GetLineSize(int index) const noexcept override { if (mAVFrame == nullptr) return {}; @@ -44,7 +44,7 @@ public: return mAVFrame->linesize[index]; } - uint8_t* GetExtendedData(int index) const noexcept override + [[nodiscard]] uint8_t* GetExtendedData(int index) const noexcept override { if (mAVFrame != nullptr) return mAVFrame->extended_data[index]; @@ -52,7 +52,7 @@ public: return {}; } - int GetWidth() const noexcept override + [[nodiscard]] int GetWidth() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->width; @@ -60,7 +60,7 @@ public: return {}; } - int GetHeight() const noexcept override + [[nodiscard]] int GetHeight() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->height; @@ -68,7 +68,7 @@ public: return {}; } - int GetSamplesCount() const noexcept override + [[nodiscard]] int GetSamplesCount() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->nb_samples; @@ -82,7 +82,7 @@ public: mAVFrame->nb_samples = count; } - AVSampleFormatFwd GetFormat() const noexcept override + [[nodiscard]] AVSampleFormatFwd GetFormat() const noexcept override { if (mAVFrame != nullptr) return static_cast(mAVFrame->format); @@ -96,7 +96,7 @@ public: mAVFrame->format = format; } - int GetKeyFrame() const noexcept override + [[nodiscard]] int GetKeyFrame() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->key_frame; @@ -104,7 +104,7 @@ public: return {}; } - AudacityAVRational GetSampleAspectRatio() const noexcept override + [[nodiscard]] AudacityAVRational GetSampleAspectRatio() const noexcept override { if (mAVFrame != nullptr) return { mAVFrame->sample_aspect_ratio.num, @@ -113,7 +113,7 @@ public: return {}; } - int64_t GetPresentationTimestamp() const noexcept override + [[nodiscard]] int64_t GetPresentationTimestamp() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->pts; @@ -121,7 +121,7 @@ public: return {}; } - int64_t GetPacketPresentationTimestamp() const noexcept override + [[nodiscard]] int64_t GetPacketPresentationTimestamp() const noexcept override { if (mAVFrame != nullptr) #if LIBAVUTIL_VERSION_MAJOR <= 56 @@ -133,7 +133,7 @@ public: return {}; } - int64_t GetPacketDecompressionTimestamp() const noexcept override + [[nodiscard]] int64_t GetPacketDecompressionTimestamp() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->pkt_dts; @@ -141,7 +141,7 @@ public: return {}; } - int GetCodedPictureNumber() const noexcept override + [[nodiscard]] int GetCodedPictureNumber() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->coded_picture_number; @@ -149,7 +149,7 @@ public: return {}; } - int GetDisplayPictureNumber() const noexcept override + [[nodiscard]] int GetDisplayPictureNumber() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->display_picture_number; @@ -157,7 +157,7 @@ public: return {}; } - int GetQuality() const noexcept override + [[nodiscard]] int GetQuality() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->quality; @@ -165,7 +165,7 @@ public: return {}; } - void* GetOpaque() const noexcept override + [[nodiscard]] void* GetOpaque() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->opaque; @@ -179,7 +179,7 @@ public: mAVFrame->opaque = opaque; } - int GetRepeatPict() const noexcept override + [[nodiscard]] int GetRepeatPict() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->repeat_pict; @@ -187,7 +187,7 @@ public: return {}; } - int GetInterlacedFrame() const noexcept override + [[nodiscard]] int GetInterlacedFrame() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->interlaced_frame; @@ -195,7 +195,7 @@ public: return {}; } - int GetTopFieldFirst() const noexcept override + [[nodiscard]] int GetTopFieldFirst() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->top_field_first; @@ -203,7 +203,7 @@ public: return {}; } - int GetPaletteHasChanged() const noexcept override + [[nodiscard]] int GetPaletteHasChanged() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->palette_has_changed; @@ -211,7 +211,7 @@ public: return {}; } - int64_t GetReorderedOpaque() const noexcept override + [[nodiscard]] int64_t GetReorderedOpaque() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->reordered_opaque; @@ -219,7 +219,7 @@ public: return {}; } - int GetSampleRate() const noexcept override + [[nodiscard]] int GetSampleRate() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->sample_rate; @@ -227,7 +227,7 @@ public: return {}; } - uint64_t GetChannelLayout() const noexcept override + [[nodiscard]] uint64_t GetChannelLayout() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->channel_layout; @@ -247,7 +247,7 @@ public: } } - int GetSideDataCount() const noexcept override + [[nodiscard]] int GetSideDataCount() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->nb_side_data; @@ -255,7 +255,7 @@ public: return {}; } - int GetFlags() const noexcept override + [[nodiscard]] int GetFlags() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->flags; @@ -263,7 +263,7 @@ public: return {}; } - int64_t GetBestEffortTimestamp() const noexcept override + [[nodiscard]] int64_t GetBestEffortTimestamp() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->best_effort_timestamp; @@ -271,7 +271,7 @@ public: return {}; } - int64_t GetPacketPos() const noexcept override + [[nodiscard]] int64_t GetPacketPos() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->pkt_pos; @@ -279,7 +279,7 @@ public: return {}; } - int64_t GetPacketDuration() const noexcept override + [[nodiscard]] int64_t GetPacketDuration() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->pkt_duration; @@ -287,7 +287,7 @@ public: return {}; } - AVDictionaryWrapper GetMetadata() const noexcept override + [[nodiscard]] AVDictionaryWrapper GetMetadata() const noexcept override { if (mAVFrame != nullptr) return AVDictionaryWrapper(mFFmpeg, mAVFrame->metadata); @@ -295,7 +295,7 @@ public: return AVDictionaryWrapper(mFFmpeg); } - int GetDecodeErrorFlags() const noexcept override + [[nodiscard]] int GetDecodeErrorFlags() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->decode_error_flags; @@ -303,7 +303,7 @@ public: return {}; } - int GetChannels() const noexcept override + [[nodiscard]] int GetChannels() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->channels; @@ -311,7 +311,7 @@ public: return {}; } - int GetPacketSize() const noexcept override + [[nodiscard]] int GetPacketSize() const noexcept override { if (mAVFrame != nullptr) return mAVFrame->pkt_size; diff --git a/libraries/lib-ffmpeg-support/impl/ffmpeg-3.4.8-single-header.h b/libraries/lib-ffmpeg-support/impl/ffmpeg-3.4.8-single-header.h index e078a3c2ae..fccc5ef17c 100644 --- a/libraries/lib-ffmpeg-support/impl/ffmpeg-3.4.8-single-header.h +++ b/libraries/lib-ffmpeg-support/impl/ffmpeg-3.4.8-single-header.h @@ -1,17 +1,17 @@ // This header was generated from the FFMPEG headers #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define AVCODEC_AVCODEC_H @@ -19,13 +19,13 @@ #define AVUTIL_AVUTIL_H -unsigned avutil_version(void); +unsigned avutil_version(); -const char *av_version_info(void); +const char *av_version_info(); -const char *avutil_configuration(void); +const char *avutil_configuration(); -const char *avutil_license(void); +const char *avutil_license(); enum AVMediaType { AVMEDIA_TYPE_UNKNOWN = -1, @@ -179,7 +179,7 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; (b)= a; (a)= SWAP_tmp;}while(0) #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) # define av_ceil_log2 av_ceil_log2_c @@ -322,26 +322,26 @@ static av_always_inline av_const int av_parity_c(uint32_t v) #define GET_UTF8(val, GET_BYTE, ERROR)\ val= (GET_BYTE);\ {\ - uint32_t top = (val & 128) >> 1;\ - if ((val & 0xc0) == 0x80 || val >= 0xFE)\ - ERROR\ - while (val & top) {\ + uint32_t top = ((val) & 128) >> 1;\ + if (((val) & 0xc0) == 0x80 || (val) >= 0xFE)\ + (ERROR)\ + while ((val) & top) {\ int tmp= (GET_BYTE) - 128;\ if(tmp>>6)\ ERROR\ - val= (val<<6) + tmp;\ + val= ((val)<<6) + tmp;\ top <<= 5;\ }\ - val &= (top << 1) - 1;\ + (val) &= (top << 1) - 1;\ } #define GET_UTF16(val, GET_16BIT, ERROR)\ val = GET_16BIT;\ {\ - unsigned int hi = val - 0xD800;\ + unsigned int hi = (val) - 0xD800;\ if (hi < 0x800) {\ - val = GET_16BIT - 0xDC00;\ - if (val > 0x3FFU || hi > 0x3FFU)\ + (val) = (GET_16BIT) - 0xDC00;\ + if ((val) > 0x3FFU || hi > 0x3FFU)\ ERROR\ val += (hi<<10) + 0x10000;\ }\ @@ -352,16 +352,16 @@ static av_always_inline av_const int av_parity_c(uint32_t v) int bytes, shift;\ uint32_t in = val;\ if (in < 0x80) {\ - tmp = in;\ + (tmp) = in;\ PUT_BYTE\ } else {\ bytes = (av_log2(in) + 4) / 5;\ shift = (bytes - 1) * 6;\ - tmp = (256 - (256 >> bytes)) | (in >> shift);\ - PUT_BYTE\ + (tmp) = (256 - (256 >> bytes)) | (in >> shift);\ + (PUT_BYTE)\ while (shift >= 6) {\ shift -= 6;\ - tmp = 0x80 | ((in >> shift) & 0x3f);\ + (tmp) = 0x80 | ((in >> shift) & 0x3f);\ PUT_BYTE\ }\ }\ @@ -371,10 +371,10 @@ static av_always_inline av_const int av_parity_c(uint32_t v) {\ uint32_t in = val;\ if (in < 0x10000) {\ - tmp = in;\ + (tmp) = in;\ PUT_16BIT\ } else {\ - tmp = 0xD800 | ((in - 0x10000) >> 10);\ + (tmp) = 0xD800 | ((in - 0x10000) >> 10);\ PUT_16BIT\ tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ PUT_16BIT\ @@ -448,14 +448,14 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) { if (!size || nmemb >= INT_MAX / size) - return NULL; + return nullptr; return av_malloc(nmemb * size); } av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) { if (!size || nmemb >= INT_MAX / size) - return NULL; + return nullptr; return av_mallocz(nmemb * size); } @@ -703,7 +703,7 @@ typedef struct AVClass { int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); } AVClass; -#define AV_LOG_QUIET -8 +#define AV_LOG_QUIET (-8) #define AV_LOG_PANIC 0 @@ -729,7 +729,7 @@ void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); void av_vlog(void *avcl, int level, const char *fmt, va_list vl); -int av_log_get_level(void); +int av_log_get_level(); void av_log_set_level(int level); @@ -754,7 +754,7 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, #define AV_LOG_PRINT_LEVEL 2 void av_log_set_flags(int arg); -int av_log_get_flags(void); +int av_log_get_flags(); #define AVUTIL_PIXFMT_H @@ -1171,7 +1171,7 @@ unsigned av_int_list_length_for_size(unsigned elsize, FILE *av_fopen_utf8(const char *path, const char *mode); -AVRational av_get_time_base_q(void); +AVRational av_get_time_base_q(); #define AV_FOURCC_MAX_STRING_SIZE 32 @@ -1331,7 +1331,7 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); #define AV_CPU_FLAG_VFP_VM (1 << 7) #define AV_CPU_FLAG_SETEND (1 <<16) -int av_get_cpu_flags(void); +int av_get_cpu_flags(); void av_force_cpu_flags(int flags); @@ -1342,9 +1342,9 @@ int av_parse_cpu_flags(const char *s); int av_parse_cpu_caps(unsigned *flags, const char *s); -int av_cpu_count(void); +int av_cpu_count(); -size_t av_cpu_max_align(void); +size_t av_cpu_max_align(); #define AVUTIL_CHANNEL_LAYOUT_H @@ -1481,7 +1481,7 @@ int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags); void av_dict_free(AVDictionary **m); int av_dict_get_string(const AVDictionary *m, char **buffer, - const char key_val_sep, const char pairs_sep); + char key_val_sep, char pairs_sep); #define AVUTIL_FRAME_H @@ -1682,7 +1682,7 @@ void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val); const char *av_get_colorspace_name(enum AVColorSpace val); -AVFrame *av_frame_alloc(void); +AVFrame *av_frame_alloc(); void av_frame_free(AVFrame **frame); @@ -2707,7 +2707,7 @@ typedef struct AVCodecContext { int global_quality; int compression_level; -#define FF_COMPRESSION_DEFAULT -1 +#define FF_COMPRESSION_DEFAULT (-1) int flags; @@ -3075,8 +3075,8 @@ typedef struct AVCodecContext { #define FF_COMPLIANCE_VERY_STRICT 2 #define FF_COMPLIANCE_STRICT 1 #define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_UNOFFICIAL -1 -#define FF_COMPLIANCE_EXPERIMENTAL -2 +#define FF_COMPLIANCE_UNOFFICIAL (-1) +#define FF_COMPLIANCE_EXPERIMENTAL (-2) int error_concealment; #define FF_EC_GUESS_MVS 1 @@ -3184,8 +3184,8 @@ typedef struct AVCodecContext { int nsse_weight; int profile; -#define FF_PROFILE_UNKNOWN -99 -#define FF_PROFILE_RESERVED -100 +#define FF_PROFILE_UNKNOWN (-99) +#define FF_PROFILE_RESERVED (-100) #define FF_PROFILE_AAC_MAIN 0 #define FF_PROFILE_AAC_LOW 1 @@ -3277,7 +3277,7 @@ typedef struct AVCodecContext { #define FF_PROFILE_HEVC_REXT 4 int level; -#define FF_LEVEL_UNKNOWN -99 +#define FF_LEVEL_UNKNOWN (-99) enum AVDiscard skip_loop_filter; @@ -3315,7 +3315,7 @@ typedef struct AVCodecContext { char *sub_charenc; int sub_charenc_mode; -#define FF_SUB_CHARENC_MODE_DO_NOTHING -1 +#define FF_SUB_CHARENC_MODE_DO_NOTHING (-1) #define FF_SUB_CHARENC_MODE_AUTOMATIC 0 #define FF_SUB_CHARENC_MODE_PRE_DECODER 1 @@ -3583,15 +3583,15 @@ typedef struct AVCodecParameters { AVCodec *av_codec_next(const AVCodec *c); -unsigned avcodec_version(void); +unsigned avcodec_version(); -const char *avcodec_configuration(void); +const char *avcodec_configuration(); -const char *avcodec_license(void); +const char *avcodec_license(); void avcodec_register(AVCodec *codec); -void avcodec_register_all(void); +void avcodec_register_all(); AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); @@ -3599,16 +3599,16 @@ void avcodec_free_context(AVCodecContext **avctx); int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); -const AVClass *avcodec_get_class(void); +const AVClass *avcodec_get_class(); -const AVClass *avcodec_get_frame_class(void); +const AVClass *avcodec_get_frame_class(); -const AVClass *avcodec_get_subtitle_rect_class(void); +const AVClass *avcodec_get_subtitle_rect_class(); attribute_deprecated int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); -AVCodecParameters *avcodec_parameters_alloc(void); +AVCodecParameters *avcodec_parameters_alloc(); void avcodec_parameters_free(AVCodecParameters **par); @@ -3626,7 +3626,7 @@ int avcodec_close(AVCodecContext *avctx); void avsubtitle_free(AVSubtitle *sub); -AVPacket *av_packet_alloc(void); +AVPacket *av_packet_alloc(); AVPacket *av_packet_clone(const AVPacket *src); @@ -3697,7 +3697,7 @@ AVCodec *avcodec_find_decoder_by_name(const char *name); int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags); attribute_deprecated -unsigned avcodec_get_edge_width(void); +unsigned avcodec_get_edge_width(); void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); @@ -4038,11 +4038,11 @@ int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt); void av_bsf_free(AVBSFContext **ctx); -const AVClass *av_bsf_get_class(void); +const AVClass *av_bsf_get_class(); typedef struct AVBSFList AVBSFList; -AVBSFList *av_bsf_list_alloc(void); +AVBSFList *av_bsf_list_alloc(); void av_bsf_list_free(AVBSFList **lst); @@ -4590,7 +4590,7 @@ typedef struct AVStreamInternal AVStreamInternal; #define AV_PTS_WRAP_IGNORE 0 #define AV_PTS_WRAP_ADD_OFFSET 1 -#define AV_PTS_WRAP_SUB_OFFSET -1 +#define AV_PTS_WRAP_SUB_OFFSET (-1) typedef struct AVStream { int index; @@ -4873,7 +4873,7 @@ typedef struct AVFormatContext { int max_ts_probe; int avoid_negative_ts; -#define AVFMT_AVOID_NEG_TS_AUTO -1 +#define AVFMT_AVOID_NEG_TS_AUTO (-1) #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 @@ -4973,30 +4973,30 @@ typedef struct AVPacketList { struct AVPacketList *next; } AVPacketList; -unsigned avformat_version(void); +unsigned avformat_version(); -const char *avformat_configuration(void); +const char *avformat_configuration(); -const char *avformat_license(void); +const char *avformat_license(); -void av_register_all(void); +void av_register_all(); void av_register_input_format(AVInputFormat *format); void av_register_output_format(AVOutputFormat *format); -int avformat_network_init(void); +int avformat_network_init(); -int avformat_network_deinit(void); +int avformat_network_deinit(); AVInputFormat *av_iformat_next(const AVInputFormat *f); AVOutputFormat *av_oformat_next(const AVOutputFormat *f); -AVFormatContext *avformat_alloc_context(void); +AVFormatContext *avformat_alloc_context(); void avformat_free_context(AVFormatContext *s); -const AVClass *avformat_get_class(void); +const AVClass *avformat_get_class(); AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c); @@ -5154,13 +5154,13 @@ int av_match_ext(const char *filename, const char *extensions); int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance); -const struct AVCodecTag *avformat_get_riff_video_tags(void); +const struct AVCodecTag *avformat_get_riff_video_tags(); -const struct AVCodecTag *avformat_get_riff_audio_tags(void); +const struct AVCodecTag *avformat_get_riff_audio_tags(); -const struct AVCodecTag *avformat_get_mov_video_tags(void); +const struct AVCodecTag *avformat_get_mov_video_tags(); -const struct AVCodecTag *avformat_get_mov_audio_tags(void); +const struct AVCodecTag *avformat_get_mov_audio_tags(); AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame); diff --git a/libraries/lib-ffmpeg-support/impl/ffmpeg-4.2.4-single-header.h b/libraries/lib-ffmpeg-support/impl/ffmpeg-4.2.4-single-header.h index 76674204b0..0cf9a1d34a 100644 --- a/libraries/lib-ffmpeg-support/impl/ffmpeg-4.2.4-single-header.h +++ b/libraries/lib-ffmpeg-support/impl/ffmpeg-4.2.4-single-header.h @@ -1,17 +1,17 @@ // This header was generated from the FFMPEG headers #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define AVCODEC_AVCODEC_H @@ -19,13 +19,13 @@ #define AVUTIL_AVUTIL_H -unsigned avutil_version(void); +unsigned avutil_version(); -const char *av_version_info(void); +const char *av_version_info(); -const char *avutil_configuration(void); +const char *avutil_configuration(); -const char *avutil_license(void); +const char *avutil_license(); enum AVMediaType { AVMEDIA_TYPE_UNKNOWN = -1, @@ -176,7 +176,7 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; (b)= a; (a)= SWAP_tmp;}while(0) #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) # define av_ceil_log2 av_ceil_log2_c @@ -331,26 +331,26 @@ static av_always_inline av_const int av_parity_c(uint32_t v) #define GET_UTF8(val, GET_BYTE, ERROR)\ val= (GET_BYTE);\ {\ - uint32_t top = (val & 128) >> 1;\ - if ((val & 0xc0) == 0x80 || val >= 0xFE)\ - ERROR\ - while (val & top) {\ + uint32_t top = ((val) & 128) >> 1;\ + if (((val) & 0xc0) == 0x80 || (val) >= 0xFE)\ + (ERROR)\ + while ((val) & top) {\ int tmp= (GET_BYTE) - 128;\ if(tmp>>6)\ ERROR\ - val= (val<<6) + tmp;\ + val= ((val)<<6) + tmp;\ top <<= 5;\ }\ - val &= (top << 1) - 1;\ + (val) &= (top << 1) - 1;\ } #define GET_UTF16(val, GET_16BIT, ERROR)\ val = GET_16BIT;\ {\ - unsigned int hi = val - 0xD800;\ + unsigned int hi = (val) - 0xD800;\ if (hi < 0x800) {\ - val = GET_16BIT - 0xDC00;\ - if (val > 0x3FFU || hi > 0x3FFU)\ + (val) = (GET_16BIT) - 0xDC00;\ + if ((val) > 0x3FFU || hi > 0x3FFU)\ ERROR\ val += (hi<<10) + 0x10000;\ }\ @@ -361,16 +361,16 @@ static av_always_inline av_const int av_parity_c(uint32_t v) int bytes, shift;\ uint32_t in = val;\ if (in < 0x80) {\ - tmp = in;\ + (tmp) = in;\ PUT_BYTE\ } else {\ bytes = (av_log2(in) + 4) / 5;\ shift = (bytes - 1) * 6;\ - tmp = (256 - (256 >> bytes)) | (in >> shift);\ - PUT_BYTE\ + (tmp) = (256 - (256 >> bytes)) | (in >> shift);\ + (PUT_BYTE)\ while (shift >= 6) {\ shift -= 6;\ - tmp = 0x80 | ((in >> shift) & 0x3f);\ + (tmp) = 0x80 | ((in >> shift) & 0x3f);\ PUT_BYTE\ }\ }\ @@ -380,10 +380,10 @@ static av_always_inline av_const int av_parity_c(uint32_t v) {\ uint32_t in = val;\ if (in < 0x10000) {\ - tmp = in;\ + (tmp) = in;\ PUT_16BIT\ } else {\ - tmp = 0xD800 | ((in - 0x10000) >> 10);\ + (tmp) = 0xD800 | ((in - 0x10000) >> 10);\ PUT_16BIT\ tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ PUT_16BIT\ @@ -703,7 +703,7 @@ typedef struct AVClass { int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); } AVClass; -#define AV_LOG_QUIET -8 +#define AV_LOG_QUIET (-8) #define AV_LOG_PANIC 0 @@ -729,7 +729,7 @@ void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); void av_vlog(void *avcl, int level, const char *fmt, va_list vl); -int av_log_get_level(void); +int av_log_get_level(); void av_log_set_level(int level); @@ -752,7 +752,7 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, #define AV_LOG_PRINT_LEVEL 2 void av_log_set_flags(int arg); -int av_log_get_flags(void); +int av_log_get_flags(); #define AVUTIL_PIXFMT_H @@ -1181,7 +1181,7 @@ unsigned av_int_list_length_for_size(unsigned elsize, FILE *av_fopen_utf8(const char *path, const char *mode); -AVRational av_get_time_base_q(void); +AVRational av_get_time_base_q(); #define AV_FOURCC_MAX_STRING_SIZE 32 @@ -1342,7 +1342,7 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); #define AV_CPU_FLAG_VFP_VM (1 << 7) #define AV_CPU_FLAG_SETEND (1 <<16) -int av_get_cpu_flags(void); +int av_get_cpu_flags(); void av_force_cpu_flags(int flags); @@ -1353,9 +1353,9 @@ int av_parse_cpu_flags(const char *s); int av_parse_cpu_caps(unsigned *flags, const char *s); -int av_cpu_count(void); +int av_cpu_count(); -size_t av_cpu_max_align(void); +size_t av_cpu_max_align(); #define AVUTIL_CHANNEL_LAYOUT_H @@ -1492,7 +1492,7 @@ int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags); void av_dict_free(AVDictionary **m); int av_dict_get_string(const AVDictionary *m, char **buffer, - const char key_val_sep, const char pairs_sep); + char key_val_sep, char pairs_sep); #define AVUTIL_FRAME_H @@ -1742,7 +1742,7 @@ void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val); const char *av_get_colorspace_name(enum AVColorSpace val); -AVFrame *av_frame_alloc(void); +AVFrame *av_frame_alloc(); void av_frame_free(AVFrame **frame); @@ -2778,7 +2778,7 @@ typedef struct AVCodecContext { int global_quality; int compression_level; -#define FF_COMPRESSION_DEFAULT -1 +#define FF_COMPRESSION_DEFAULT (-1) int flags; @@ -3086,8 +3086,8 @@ typedef struct AVCodecContext { #define FF_COMPLIANCE_VERY_STRICT 2 #define FF_COMPLIANCE_STRICT 1 #define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_UNOFFICIAL -1 -#define FF_COMPLIANCE_EXPERIMENTAL -2 +#define FF_COMPLIANCE_UNOFFICIAL (-1) +#define FF_COMPLIANCE_EXPERIMENTAL (-2) int error_concealment; #define FF_EC_GUESS_MVS 1 @@ -3189,8 +3189,8 @@ typedef struct AVCodecContext { int nsse_weight; int profile; -#define FF_PROFILE_UNKNOWN -99 -#define FF_PROFILE_RESERVED -100 +#define FF_PROFILE_UNKNOWN (-99) +#define FF_PROFILE_RESERVED (-100) #define FF_PROFILE_AAC_MAIN 0 #define FF_PROFILE_AAC_LOW 1 @@ -3304,7 +3304,7 @@ typedef struct AVCodecContext { #define FF_PROFILE_ARIB_PROFILE_C 1 int level; -#define FF_LEVEL_UNKNOWN -99 +#define FF_LEVEL_UNKNOWN (-99) enum AVDiscard skip_loop_filter; @@ -3339,7 +3339,7 @@ typedef struct AVCodecContext { char *sub_charenc; int sub_charenc_mode; -#define FF_SUB_CHARENC_MODE_DO_NOTHING -1 +#define FF_SUB_CHARENC_MODE_DO_NOTHING (-1) #define FF_SUB_CHARENC_MODE_AUTOMATIC 0 #define FF_SUB_CHARENC_MODE_PRE_DECODER 1 #define FF_SUB_CHARENC_MODE_IGNORE 2 @@ -3655,17 +3655,17 @@ const AVCodec *av_codec_iterate(void **opaque); attribute_deprecated AVCodec *av_codec_next(const AVCodec *c); -unsigned avcodec_version(void); +unsigned avcodec_version(); -const char *avcodec_configuration(void); +const char *avcodec_configuration(); -const char *avcodec_license(void); +const char *avcodec_license(); attribute_deprecated void avcodec_register(AVCodec *codec); attribute_deprecated -void avcodec_register_all(void); +void avcodec_register_all(); AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); @@ -3673,16 +3673,16 @@ void avcodec_free_context(AVCodecContext **avctx); int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); -const AVClass *avcodec_get_class(void); +const AVClass *avcodec_get_class(); -const AVClass *avcodec_get_frame_class(void); +const AVClass *avcodec_get_frame_class(); -const AVClass *avcodec_get_subtitle_rect_class(void); +const AVClass *avcodec_get_subtitle_rect_class(); attribute_deprecated int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); -AVCodecParameters *avcodec_parameters_alloc(void); +AVCodecParameters *avcodec_parameters_alloc(); void avcodec_parameters_free(AVCodecParameters **par); @@ -3700,7 +3700,7 @@ int avcodec_close(AVCodecContext *avctx); void avsubtitle_free(AVSubtitle *sub); -AVPacket *av_packet_alloc(void); +AVPacket *av_packet_alloc(); AVPacket *av_packet_clone(const AVPacket *src); @@ -4094,11 +4094,11 @@ void av_bsf_flush(AVBSFContext *ctx); void av_bsf_free(AVBSFContext **ctx); -const AVClass *av_bsf_get_class(void); +const AVClass *av_bsf_get_class(); typedef struct AVBSFList AVBSFList; -AVBSFList *av_bsf_list_alloc(void); +AVBSFList *av_bsf_list_alloc(); void av_bsf_list_free(AVBSFList **lst); @@ -4638,7 +4638,7 @@ typedef struct AVStreamInternal AVStreamInternal; #define AV_PTS_WRAP_IGNORE 0 #define AV_PTS_WRAP_ADD_OFFSET 1 -#define AV_PTS_WRAP_SUB_OFFSET -1 +#define AV_PTS_WRAP_SUB_OFFSET (-1) typedef struct AVStream { int index; @@ -4934,7 +4934,7 @@ typedef struct AVFormatContext { int max_ts_probe; int avoid_negative_ts; -#define AVFMT_AVOID_NEG_TS_AUTO -1 +#define AVFMT_AVOID_NEG_TS_AUTO (-1) #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 @@ -5051,23 +5051,23 @@ typedef struct AVPacketList { struct AVPacketList *next; } AVPacketList; -unsigned avformat_version(void); +unsigned avformat_version(); -const char *avformat_configuration(void); +const char *avformat_configuration(); -const char *avformat_license(void); +const char *avformat_license(); attribute_deprecated -void av_register_all(void); +void av_register_all(); attribute_deprecated void av_register_input_format(AVInputFormat *format); attribute_deprecated void av_register_output_format(AVOutputFormat *format); -int avformat_network_init(void); +int avformat_network_init(); -int avformat_network_deinit(void); +int avformat_network_deinit(); attribute_deprecated AVInputFormat *av_iformat_next(const AVInputFormat *f); @@ -5079,11 +5079,11 @@ const AVOutputFormat *av_muxer_iterate(void **opaque); const AVInputFormat *av_demuxer_iterate(void **opaque); -AVFormatContext *avformat_alloc_context(void); +AVFormatContext *avformat_alloc_context(); void avformat_free_context(AVFormatContext *s); -const AVClass *avformat_get_class(void); +const AVClass *avformat_get_class(); AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c); @@ -5241,13 +5241,13 @@ int av_match_ext(const char *filename, const char *extensions); int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance); -const struct AVCodecTag *avformat_get_riff_video_tags(void); +const struct AVCodecTag *avformat_get_riff_video_tags(); -const struct AVCodecTag *avformat_get_riff_audio_tags(void); +const struct AVCodecTag *avformat_get_riff_audio_tags(); -const struct AVCodecTag *avformat_get_mov_video_tags(void); +const struct AVCodecTag *avformat_get_mov_video_tags(); -const struct AVCodecTag *avformat_get_mov_audio_tags(void); +const struct AVCodecTag *avformat_get_mov_audio_tags(); AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame); diff --git a/libraries/lib-ffmpeg-support/impl/ffmpeg-5.0.1-single-header.h b/libraries/lib-ffmpeg-support/impl/ffmpeg-5.0.1-single-header.h index a25b78c4a7..ed98ccd3d1 100644 --- a/libraries/lib-ffmpeg-support/impl/ffmpeg-5.0.1-single-header.h +++ b/libraries/lib-ffmpeg-support/impl/ffmpeg-5.0.1-single-header.h @@ -1,17 +1,17 @@ // This header was generated from the FFMPEG headers #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define AVCODEC_AVCODEC_H @@ -19,13 +19,13 @@ #define AVUTIL_AVUTIL_H -unsigned avutil_version(void); +unsigned avutil_version(); -const char *av_version_info(void); +const char *av_version_info(); -const char *avutil_configuration(void); +const char *avutil_configuration(); -const char *avutil_license(void); +const char *avutil_license(); enum AVMediaType { AVMEDIA_TYPE_UNKNOWN = -1, @@ -118,7 +118,7 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; (b)= a; (a)= SWAP_tmp;}while(0) #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) @@ -345,28 +345,28 @@ static av_always_inline av_const int av_parity_c(uint32_t v) #define GET_UTF8(val, GET_BYTE, ERROR)\ val= (GET_BYTE);\ {\ - uint32_t top = (val & 128) >> 1;\ - if ((val & 0xc0) == 0x80 || val >= 0xFE)\ + uint32_t top = ((val) & 128) >> 1;\ + if (((val) & 0xc0) == 0x80 || (val) >= 0xFE)\ {ERROR}\ - while (val & top) {\ + while ((val) & top) {\ unsigned int tmp = (GET_BYTE) - 128;\ if(tmp>>6)\ {ERROR}\ - val= (val<<6) + tmp;\ + (val)= ((val)<<6) + tmp;\ top <<= 5;\ }\ - val &= (top << 1) - 1;\ + (val) &= (top << 1) - 1;\ } #define GET_UTF16(val, GET_16BIT, ERROR)\ val = (GET_16BIT);\ {\ - unsigned int hi = val - 0xD800;\ + unsigned int hi = (val) - 0xD800;\ if (hi < 0x800) {\ - val = (GET_16BIT) - 0xDC00;\ - if (val > 0x3FFU || hi > 0x3FFU)\ + (val) = (GET_16BIT) - 0xDC00;\ + if ((val) > 0x3FFU || hi > 0x3FFU)\ {ERROR}\ - val += (hi<<10) + 0x10000;\ + (val) += (hi<<10) + 0x10000;\ }\ }\ @@ -375,16 +375,16 @@ static av_always_inline av_const int av_parity_c(uint32_t v) int bytes, shift;\ uint32_t in = val;\ if (in < 0x80) {\ - tmp = in;\ + (tmp) = in;\ PUT_BYTE\ } else {\ bytes = (av_log2(in) + 4) / 5;\ shift = (bytes - 1) * 6;\ - tmp = (256 - (256 >> bytes)) | (in >> shift);\ - PUT_BYTE\ + (tmp) = (256 - (256 >> bytes)) | (in >> shift);\ + (PUT_BYTE)\ while (shift >= 6) {\ shift -= 6;\ - tmp = 0x80 | ((in >> shift) & 0x3f);\ + (tmp) = 0x80 | ((in >> shift) & 0x3f);\ PUT_BYTE\ }\ }\ @@ -394,10 +394,10 @@ static av_always_inline av_const int av_parity_c(uint32_t v) {\ uint32_t in = val;\ if (in < 0x10000) {\ - tmp = in;\ + (tmp) = in;\ PUT_16BIT\ } else {\ - tmp = 0xD800 | ((in - 0x10000) >> 10);\ + (tmp) = 0xD800 | ((in - 0x10000) >> 10);\ PUT_16BIT\ tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ PUT_16BIT\ @@ -712,7 +712,7 @@ typedef struct AVClass { const struct AVClass* (*child_class_iterate)(void **iter); } AVClass; -#define AV_LOG_QUIET -8 +#define AV_LOG_QUIET (-8) #define AV_LOG_PANIC 0 @@ -740,7 +740,7 @@ void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state void av_vlog(void *avcl, int level, const char *fmt, va_list vl); -int av_log_get_level(void); +int av_log_get_level(); void av_log_set_level(int level); @@ -763,7 +763,7 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, #define AV_LOG_PRINT_LEVEL 2 void av_log_set_flags(int arg); -int av_log_get_flags(void); +int av_log_get_flags(); #define AVUTIL_PIXFMT_H @@ -1222,7 +1222,7 @@ unsigned av_int_list_length_for_size(unsigned elsize, FILE *av_fopen_utf8(const char *path, const char *mode); -AVRational av_get_time_base_q(void); +AVRational av_get_time_base_q(); #define AV_FOURCC_MAX_STRING_SIZE 32 @@ -1379,7 +1379,7 @@ int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags); void av_dict_free(AVDictionary **m); int av_dict_get_string(const AVDictionary *m, char **buffer, - const char key_val_sep, const char pairs_sep); + char key_val_sep, char pairs_sep); #define AVUTIL_FRAME_H @@ -1573,7 +1573,7 @@ typedef struct AVFrame { attribute_deprecated const char *av_get_colorspace_name(enum AVColorSpace val); -AVFrame *av_frame_alloc(void); +AVFrame *av_frame_alloc(); void av_frame_free(AVFrame **frame); @@ -2572,7 +2572,7 @@ typedef struct AVCodecParameters { int seek_preroll; } AVCodecParameters; -AVCodecParameters *avcodec_parameters_alloc(void); +AVCodecParameters *avcodec_parameters_alloc(); void avcodec_parameters_free(AVCodecParameters **par); @@ -2769,7 +2769,7 @@ enum AVSideDataParamChangeFlags { AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, }; -AVPacket *av_packet_alloc(void); +AVPacket *av_packet_alloc(); AVPacket *av_packet_clone(const AVPacket *src); @@ -2925,7 +2925,7 @@ typedef struct AVCodecContext { int global_quality; int compression_level; -#define FF_COMPRESSION_DEFAULT -1 +#define FF_COMPRESSION_DEFAULT (-1) int flags; @@ -3139,8 +3139,8 @@ typedef struct AVCodecContext { #define FF_COMPLIANCE_VERY_STRICT 2 #define FF_COMPLIANCE_STRICT 1 #define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_UNOFFICIAL -1 -#define FF_COMPLIANCE_EXPERIMENTAL -2 +#define FF_COMPLIANCE_UNOFFICIAL (-1) +#define FF_COMPLIANCE_EXPERIMENTAL (-2) int error_concealment; #define FF_EC_GUESS_MVS 1 @@ -3232,8 +3232,8 @@ typedef struct AVCodecContext { int nsse_weight; int profile; -#define FF_PROFILE_UNKNOWN -99 -#define FF_PROFILE_RESERVED -100 +#define FF_PROFILE_UNKNOWN (-99) +#define FF_PROFILE_RESERVED (-100) #define FF_PROFILE_AAC_MAIN 0 #define FF_PROFILE_AAC_LOW 1 @@ -3353,7 +3353,7 @@ typedef struct AVCodecContext { #define FF_PROFILE_KLVA_ASYNC 1 int level; -#define FF_LEVEL_UNKNOWN -99 +#define FF_LEVEL_UNKNOWN (-99) enum AVDiscard skip_loop_filter; @@ -3382,7 +3382,7 @@ typedef struct AVCodecContext { char *sub_charenc; int sub_charenc_mode; -#define FF_SUB_CHARENC_MODE_DO_NOTHING -1 +#define FF_SUB_CHARENC_MODE_DO_NOTHING (-1) #define FF_SUB_CHARENC_MODE_AUTOMATIC 0 #define FF_SUB_CHARENC_MODE_PRE_DECODER 1 #define FF_SUB_CHARENC_MODE_IGNORE 2 @@ -3525,22 +3525,22 @@ typedef struct AVSubtitle { int64_t pts; } AVSubtitle; -unsigned avcodec_version(void); +unsigned avcodec_version(); -const char *avcodec_configuration(void); +const char *avcodec_configuration(); -const char *avcodec_license(void); +const char *avcodec_license(); AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); void avcodec_free_context(AVCodecContext **avctx); -const AVClass *avcodec_get_class(void); +const AVClass *avcodec_get_class(); attribute_deprecated -const AVClass *avcodec_get_frame_class(void); +const AVClass *avcodec_get_frame_class(); -const AVClass *avcodec_get_subtitle_rect_class(void); +const AVClass *avcodec_get_subtitle_rect_class(); int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec); @@ -4189,7 +4189,7 @@ const char *av_disposition_to_string(int disposition); #define AV_PTS_WRAP_IGNORE 0 #define AV_PTS_WRAP_ADD_OFFSET 1 -#define AV_PTS_WRAP_SUB_OFFSET -1 +#define AV_PTS_WRAP_SUB_OFFSET (-1) typedef struct AVStream { int index; @@ -4379,7 +4379,7 @@ typedef struct AVFormatContext { int max_ts_probe; int avoid_negative_ts; -#define AVFMT_AVOID_NEG_TS_AUTO -1 +#define AVFMT_AVOID_NEG_TS_AUTO (-1) #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 @@ -4457,27 +4457,27 @@ void av_format_inject_global_side_data(AVFormatContext *s); enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx); -unsigned avformat_version(void); +unsigned avformat_version(); -const char *avformat_configuration(void); +const char *avformat_configuration(); -const char *avformat_license(void); +const char *avformat_license(); -int avformat_network_init(void); +int avformat_network_init(); -int avformat_network_deinit(void); +int avformat_network_deinit(); const AVOutputFormat *av_muxer_iterate(void **opaque); const AVInputFormat *av_demuxer_iterate(void **opaque); -AVFormatContext *avformat_alloc_context(void); +AVFormatContext *avformat_alloc_context(); void avformat_free_context(AVFormatContext *s); -const AVClass *avformat_get_class(void); +const AVClass *avformat_get_class(); -const AVClass *av_stream_get_class(void); +const AVClass *av_stream_get_class(); AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c); @@ -4643,13 +4643,13 @@ int av_match_ext(const char *filename, const char *extensions); int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance); -const struct AVCodecTag *avformat_get_riff_video_tags(void); +const struct AVCodecTag *avformat_get_riff_video_tags(); -const struct AVCodecTag *avformat_get_riff_audio_tags(void); +const struct AVCodecTag *avformat_get_riff_audio_tags(); -const struct AVCodecTag *avformat_get_mov_video_tags(void); +const struct AVCodecTag *avformat_get_mov_video_tags(); -const struct AVCodecTag *avformat_get_mov_audio_tags(void); +const struct AVCodecTag *avformat_get_mov_audio_tags(); AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame); diff --git a/libraries/lib-ffmpeg-support/wrappers/AVCodecWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVCodecWrapper.h index 85e4d7b4b3..722ccaab04 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVCodecWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVCodecWrapper.h @@ -28,23 +28,23 @@ class FFMPEG_SUPPORT_API AVCodecWrapper explicit AVCodecWrapper(const AVCodec* wrapped) noexcept; - const AVCodec* GetWrappedValue() const noexcept; + [[nodiscard]] const AVCodec* GetWrappedValue() const noexcept; virtual ~AVCodecWrapper() = default; - virtual const char* GetName() const noexcept = 0; - virtual const char* GetLongName() const noexcept = 0; - virtual AVMediaTypeFwd GetType() const noexcept = 0; - virtual AVCodecIDFwd GetId() const noexcept = 0; - virtual int GetCapabilities() const noexcept = 0; - virtual const AVRational* GetSupportedFramerates() const noexcept = 0; - virtual const AVMediaTypeFwd* GetPixFmts() const noexcept = 0; - virtual const int* GetSupportedSamplerates() const noexcept = 0; - virtual const AVSampleFormatFwd* GetSampleFmts() const noexcept = 0; - virtual const uint64_t* GetChannelLayouts() const noexcept = 0; - virtual uint8_t GetMaxLowres() const noexcept = 0; - - virtual bool IsAudio() const noexcept = 0; + [[nodiscard]] virtual const char* GetName() const noexcept = 0; + [[nodiscard]] virtual const char* GetLongName() const noexcept = 0; + [[nodiscard]] virtual AVMediaTypeFwd GetType() const noexcept = 0; + [[nodiscard]] virtual AVCodecIDFwd GetId() const noexcept = 0; + [[nodiscard]] virtual int GetCapabilities() const noexcept = 0; + [[nodiscard]] virtual const AVRational* GetSupportedFramerates() const noexcept = 0; + [[nodiscard]] virtual const AVMediaTypeFwd* GetPixFmts() const noexcept = 0; + [[nodiscard]] virtual const int* GetSupportedSamplerates() const noexcept = 0; + [[nodiscard]] virtual const AVSampleFormatFwd* GetSampleFmts() const noexcept = 0; + [[nodiscard]] virtual const uint64_t* GetChannelLayouts() const noexcept = 0; + [[nodiscard]] virtual uint8_t GetMaxLowres() const noexcept = 0; + + [[nodiscard]] virtual bool IsAudio() const noexcept = 0; protected: const AVCodec* mAVCodec { nullptr }; diff --git a/libraries/lib-ffmpeg-support/wrappers/AVDictionaryWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVDictionaryWrapper.h index 746d6f58a7..59470d496b 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVDictionaryWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVDictionaryWrapper.h @@ -35,7 +35,7 @@ class FFMPEG_SUPPORT_API AVDictionaryWrapper explicit AVDictionaryWrapper(const FFmpegFunctions& ffmpeg, AVDictionary* rhs) noexcept; AVDictionary* GetWrappedValue() noexcept; - const AVDictionary* GetWrappedValue() const noexcept; + [[nodiscard]] const AVDictionary* GetWrappedValue() const noexcept; virtual ~AVDictionaryWrapper(); @@ -49,8 +49,8 @@ class FFMPEG_SUPPORT_API AVDictionaryWrapper Set(key, std::to_string(value), flags); } - std::string_view Get(const std::string_view& key, const std::string_view& defaultValue, int flags = 0) const; - bool HasValue(const std::string_view& key, int flags = 0) const noexcept; + [[nodiscard]] std::string_view Get(const std::string_view& key, const std::string_view& defaultValue, int flags = 0) const; + [[nodiscard]] bool HasValue(const std::string_view& key, int flags = 0) const noexcept; AVDictionary* Release() noexcept; protected: diff --git a/libraries/lib-ffmpeg-support/wrappers/AVFifoBufferWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVFifoBufferWrapper.h index 7e768ccff0..49395cd8ab 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVFifoBufferWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVFifoBufferWrapper.h @@ -26,7 +26,7 @@ class FFMPEG_SUPPORT_API AVFifoBufferWrapper const FFmpegFunctions& ffmpeg, int size) noexcept; AVFifoBuffer* GetWrappedValue() noexcept; - const AVFifoBuffer* GetWrappedValue() const noexcept; + [[nodiscard]] const AVFifoBuffer* GetWrappedValue() const noexcept; virtual ~AVFifoBufferWrapper(); diff --git a/libraries/lib-ffmpeg-support/wrappers/AVFormatContextWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVFormatContextWrapper.h index 8a4a2774dc..76d8dce9f8 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVFormatContextWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVFormatContextWrapper.h @@ -45,7 +45,7 @@ class FFMPEG_SUPPORT_API AVFormatContextWrapper //! @return null if OpenInputContext or OpenOutputContext has not been called AVFormatContext* GetWrappedValue() noexcept; //! @return null if OpenInputContext or OpenOutputContext has not been called - const AVFormatContext* GetWrappedValue() const noexcept; + [[nodiscard]] const AVFormatContext* GetWrappedValue() const noexcept; virtual ~AVFormatContextWrapper(); @@ -58,117 +58,117 @@ class FFMPEG_SUPPORT_API AVFormatContextWrapper std::unique_ptr CreateStream(); - const AVInputFormatWrapper* GetInputFormat() const noexcept; - const AVOutputFormatWrapper* GetOutputFormat() const noexcept; + [[nodiscard]] const AVInputFormatWrapper* GetInputFormat() const noexcept; + [[nodiscard]] const AVOutputFormatWrapper* GetOutputFormat() const noexcept; virtual void SetOutputFormat(std::unique_ptr oformat) noexcept = 0; - virtual AVIOContextWrapper* GetAVIOContext() const noexcept = 0; + [[nodiscard]] virtual AVIOContextWrapper* GetAVIOContext() const noexcept = 0; virtual void SetAVIOContext(std::unique_ptr pb) noexcept = 0; - virtual int GetCtxFlags() const noexcept = 0; + [[nodiscard]] virtual int GetCtxFlags() const noexcept = 0; - virtual unsigned int GetStreamsCount() const noexcept = 0; + [[nodiscard]] virtual unsigned int GetStreamsCount() const noexcept = 0; - virtual const StreamsList& GetStreams() const noexcept = 0; - virtual const AVStreamWrapper* GetStream(int index) const noexcept; + [[nodiscard]] virtual const StreamsList& GetStreams() const noexcept = 0; + [[nodiscard]] virtual const AVStreamWrapper* GetStream(int index) const noexcept; - virtual const char* GetFilename() const noexcept = 0; + [[nodiscard]] virtual const char* GetFilename() const noexcept = 0; virtual void SetFilename(const char* filename) noexcept = 0; - virtual int64_t GetStartTime() const noexcept = 0; + [[nodiscard]] virtual int64_t GetStartTime() const noexcept = 0; - virtual int64_t GetDuration() const noexcept = 0; + [[nodiscard]] virtual int64_t GetDuration() const noexcept = 0; - virtual int GetBitRate() const noexcept = 0; + [[nodiscard]] virtual int GetBitRate() const noexcept = 0; virtual void SetBitRate(int bit_rate) noexcept = 0; - virtual unsigned int GetPacketSize() const noexcept = 0; + [[nodiscard]] virtual unsigned int GetPacketSize() const noexcept = 0; virtual void SetPacketSize(unsigned int packet_size) noexcept = 0; - virtual int GetMaxDelay() const noexcept = 0; + [[nodiscard]] virtual int GetMaxDelay() const noexcept = 0; virtual void SetMaxDelay(int max_delay) noexcept = 0; - virtual int GetFlags() const noexcept = 0; + [[nodiscard]] virtual int GetFlags() const noexcept = 0; virtual void SetFlags(int flags) noexcept = 0; - virtual unsigned int GetProbeSize() const noexcept = 0; + [[nodiscard]] virtual unsigned int GetProbeSize() const noexcept = 0; virtual void SetProbeSize(unsigned int probesize) noexcept = 0; - virtual int GetMaxAnalyzeDuration() const noexcept = 0; + [[nodiscard]] virtual int GetMaxAnalyzeDuration() const noexcept = 0; virtual void SetMaxAnalyzeDuration(int max_analyze_duration) noexcept = 0; - virtual AVCodecIDFwd GetAudioCodecId() const noexcept = 0; + [[nodiscard]] virtual AVCodecIDFwd GetAudioCodecId() const noexcept = 0; virtual void SetAudioCodecId(AVCodecIDFwd audio_codec_id) noexcept = 0; - virtual unsigned int GetMaxIndexSize() const noexcept = 0; + [[nodiscard]] virtual unsigned int GetMaxIndexSize() const noexcept = 0; virtual void SetMaxIndexSize(unsigned int max_index_size) noexcept = 0; - virtual AVDictionaryWrapper GetMetadata() const noexcept = 0; + [[nodiscard]] virtual AVDictionaryWrapper GetMetadata() const noexcept = 0; virtual void SetMetadata(AVDictionaryWrapper metadata) noexcept = 0; - virtual int64_t GetStartTimeRealtime() const noexcept = 0; + [[nodiscard]] virtual int64_t GetStartTimeRealtime() const noexcept = 0; virtual void SetStartTimeRealtime(int64_t start_time_realtime) noexcept = 0; - virtual int GetFpsProbeSize() const noexcept = 0; + [[nodiscard]] virtual int GetFpsProbeSize() const noexcept = 0; virtual void SetFpsProbeSize(int fps_probe_size) noexcept = 0; - virtual int GetErrorRecognition() const noexcept = 0; + [[nodiscard]] virtual int GetErrorRecognition() const noexcept = 0; virtual void SetErrorRecognition(int error_recognition) noexcept = 0; - virtual int64_t GetMaxInterleaveDelta() const noexcept = 0; + [[nodiscard]] virtual int64_t GetMaxInterleaveDelta() const noexcept = 0; virtual void SetMaxInterleaveDelta(int64_t max_interleave_delta) noexcept = 0; - virtual int GetStrictStdCompliance() const noexcept = 0; + [[nodiscard]] virtual int GetStrictStdCompliance() const noexcept = 0; virtual void SetStrictStdCompliance(int strict_std_compliance) noexcept = 0; - virtual int GetAudioPreload() const noexcept = 0; + [[nodiscard]] virtual int GetAudioPreload() const noexcept = 0; virtual void SetAudioPreload(int audio_preload) noexcept = 0; - virtual int GetMaxChunkDuration() const noexcept = 0; + [[nodiscard]] virtual int GetMaxChunkDuration() const noexcept = 0; virtual void SetMaxChunkDuration(int max_chunk_duration) noexcept = 0; - virtual int GetMaxChunkSize() const noexcept = 0; + [[nodiscard]] virtual int GetMaxChunkSize() const noexcept = 0; virtual void SetMaxChunkSize(int max_chunk_size) noexcept = 0; - virtual int GetUseWallclockAsTimestamps() const noexcept = 0; + [[nodiscard]] virtual int GetUseWallclockAsTimestamps() const noexcept = 0; virtual void SetUseWallclockAsTimestamps(int use_wallclock_as_timestamps) noexcept = 0; - virtual int GetAvoidNegativeTs() const noexcept = 0; + [[nodiscard]] virtual int GetAvoidNegativeTs() const noexcept = 0; virtual void SetAvoidNegativeTs(int avoid_negative_ts) noexcept = 0; - virtual int GetAvioFlags() const noexcept = 0; + [[nodiscard]] virtual int GetAvioFlags() const noexcept = 0; virtual void SetAvioFlags(int avio_flags) noexcept = 0; - virtual int64_t GetSkipInitialBytes() const noexcept = 0; + [[nodiscard]] virtual int64_t GetSkipInitialBytes() const noexcept = 0; virtual void SetSkipInitialBytes(int64_t skip_initial_bytes) noexcept = 0; - virtual unsigned int GetCorrectTsOverflow() const noexcept = 0; + [[nodiscard]] virtual unsigned int GetCorrectTsOverflow() const noexcept = 0; virtual void SetCorrectTsOverflow(unsigned int correct_ts_overflow) noexcept = 0; - virtual int GetSeek2any() const noexcept = 0; + [[nodiscard]] virtual int GetSeek2any() const noexcept = 0; virtual void SetSeek2any(int seek2any) noexcept = 0; - virtual int GetFlushPackets() const noexcept = 0; + [[nodiscard]] virtual int GetFlushPackets() const noexcept = 0; virtual void SetFlushPackets(int flush_packets) noexcept = 0; - virtual int GetProbeScore() const noexcept = 0; + [[nodiscard]] virtual int GetProbeScore() const noexcept = 0; - virtual int GetFormatProbeSize() const noexcept = 0; + [[nodiscard]] virtual int GetFormatProbeSize() const noexcept = 0; virtual void SetFormatProbeSize(int format_probesize) noexcept = 0; - virtual AVCodecWrapper* GetAudioCodec() const noexcept = 0; + [[nodiscard]] virtual AVCodecWrapper* GetAudioCodec() const noexcept = 0; virtual void SetAudioCodec( std::unique_ptr audio_codec) noexcept = 0; - virtual void* GetOpaque() const noexcept = 0; + [[nodiscard]] virtual void* GetOpaque() const noexcept = 0; virtual void SetOpaque(void* opaque) noexcept = 0; - virtual int64_t GetOutputTsOffset() const noexcept = 0; + [[nodiscard]] virtual int64_t GetOutputTsOffset() const noexcept = 0; virtual void SetOutputTsOffset(int64_t output_ts_offset) noexcept = 0; protected: - virtual AVInputFormat* GetIFormat() const noexcept = 0; - virtual AVOutputFormat* GetOFormat() const noexcept = 0; + [[nodiscard]] virtual AVInputFormat* GetIFormat() const noexcept = 0; + [[nodiscard]] virtual AVOutputFormat* GetOFormat() const noexcept = 0; virtual void UpdateStreamList() noexcept = 0; diff --git a/libraries/lib-ffmpeg-support/wrappers/AVFrameWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVFrameWrapper.h index 6024e5bbcf..13b690ae3b 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVFrameWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVFrameWrapper.h @@ -33,56 +33,56 @@ class FFMPEG_SUPPORT_API AVFrameWrapper explicit AVFrameWrapper(const FFmpegFunctions& ffmpeg) noexcept; AVFrame* GetWrappedValue() noexcept; - const AVFrame* GetWrappedValue() const noexcept; + [[nodiscard]] const AVFrame* GetWrappedValue() const noexcept; virtual ~AVFrameWrapper(); - virtual int GetNumDataPointers() const noexcept = 0; - virtual uint8_t* GetData(int index) const noexcept = 0; - virtual int GetLineSize(int index) const noexcept = 0; - virtual uint8_t* GetExtendedData(int index) const noexcept = 0; + [[nodiscard]] virtual int GetNumDataPointers() const noexcept = 0; + [[nodiscard]] virtual uint8_t* GetData(int index) const noexcept = 0; + [[nodiscard]] virtual int GetLineSize(int index) const noexcept = 0; + [[nodiscard]] virtual uint8_t* GetExtendedData(int index) const noexcept = 0; - virtual int GetWidth() const noexcept = 0; - virtual int GetHeight() const noexcept = 0; + [[nodiscard]] virtual int GetWidth() const noexcept = 0; + [[nodiscard]] virtual int GetHeight() const noexcept = 0; - virtual int GetSamplesCount() const noexcept = 0; + [[nodiscard]] virtual int GetSamplesCount() const noexcept = 0; virtual void SetSamplesCount(int count) noexcept = 0; - virtual AVSampleFormatFwd GetFormat() const noexcept = 0; + [[nodiscard]] virtual AVSampleFormatFwd GetFormat() const noexcept = 0; virtual void SetFormat(AVSampleFormatFwd format) noexcept = 0; - virtual int GetKeyFrame() const noexcept = 0; + [[nodiscard]] virtual int GetKeyFrame() const noexcept = 0; - virtual AudacityAVRational GetSampleAspectRatio() const noexcept = 0; - virtual int64_t GetPresentationTimestamp() const noexcept = 0; - virtual int64_t GetPacketPresentationTimestamp() const noexcept = 0; - virtual int64_t GetPacketDecompressionTimestamp() const noexcept = 0; - virtual int GetCodedPictureNumber() const noexcept = 0; - virtual int GetDisplayPictureNumber() const noexcept = 0; - virtual int GetQuality() const noexcept = 0; + [[nodiscard]] virtual AudacityAVRational GetSampleAspectRatio() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPresentationTimestamp() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPacketPresentationTimestamp() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPacketDecompressionTimestamp() const noexcept = 0; + [[nodiscard]] virtual int GetCodedPictureNumber() const noexcept = 0; + [[nodiscard]] virtual int GetDisplayPictureNumber() const noexcept = 0; + [[nodiscard]] virtual int GetQuality() const noexcept = 0; - virtual void* GetOpaque() const noexcept = 0; + [[nodiscard]] virtual void* GetOpaque() const noexcept = 0; virtual void SetOpaque(void *opaque) noexcept = 0; - virtual int GetRepeatPict() const noexcept = 0; - virtual int GetInterlacedFrame() const noexcept = 0; - virtual int GetTopFieldFirst() const noexcept = 0; - virtual int GetPaletteHasChanged() const noexcept = 0; - virtual int64_t GetReorderedOpaque() const noexcept = 0; - virtual int GetSampleRate() const noexcept = 0; + [[nodiscard]] virtual int GetRepeatPict() const noexcept = 0; + [[nodiscard]] virtual int GetInterlacedFrame() const noexcept = 0; + [[nodiscard]] virtual int GetTopFieldFirst() const noexcept = 0; + [[nodiscard]] virtual int GetPaletteHasChanged() const noexcept = 0; + [[nodiscard]] virtual int64_t GetReorderedOpaque() const noexcept = 0; + [[nodiscard]] virtual int GetSampleRate() const noexcept = 0; - virtual uint64_t GetChannelLayout() const noexcept = 0; + [[nodiscard]] virtual uint64_t GetChannelLayout() const noexcept = 0; virtual void SetChannelLayout(uint64_t layout) noexcept = 0; - virtual int GetSideDataCount() const noexcept = 0; - virtual int GetFlags() const noexcept = 0; - virtual int64_t GetBestEffortTimestamp() const noexcept = 0; - virtual int64_t GetPacketPos() const noexcept = 0; - virtual int64_t GetPacketDuration() const noexcept = 0; - virtual AVDictionaryWrapper GetMetadata() const noexcept = 0; - virtual int GetDecodeErrorFlags() const noexcept = 0; - virtual int GetChannels() const noexcept = 0; - virtual int GetPacketSize() const noexcept = 0; + [[nodiscard]] virtual int GetSideDataCount() const noexcept = 0; + [[nodiscard]] virtual int GetFlags() const noexcept = 0; + [[nodiscard]] virtual int64_t GetBestEffortTimestamp() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPacketPos() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPacketDuration() const noexcept = 0; + [[nodiscard]] virtual AVDictionaryWrapper GetMetadata() const noexcept = 0; + [[nodiscard]] virtual int GetDecodeErrorFlags() const noexcept = 0; + [[nodiscard]] virtual int GetChannels() const noexcept = 0; + [[nodiscard]] virtual int GetPacketSize() const noexcept = 0; protected: const FFmpegFunctions& mFFmpeg; AVFrame* mAVFrame { nullptr }; diff --git a/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.cpp b/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.cpp index f392764e3e..e6a32f478a 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.cpp +++ b/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.cpp @@ -51,7 +51,7 @@ AVIOContextWrapper::Open(const wxString& fileName, bool forWriting) if (!pFile->Open(fileName, forWriting ? wxFile::write : wxFile::read)) return OpenResult::FileOpenFailed; - unsigned char* buffer = + auto* buffer = static_cast(mFFmpeg.av_malloc(BufferSize)); if (buffer == nullptr) @@ -83,7 +83,7 @@ AVIOContextWrapper::Open(const wxString& fileName, bool forWriting) int AVIOContextWrapper::FileRead(void* opaque, uint8_t* buf, int size) { - AVIOContextWrapper* wrapper = static_cast(opaque); + auto* wrapper = static_cast(opaque); if (wrapper == nullptr) return AUDACITY_AVERROR(EINVAL); @@ -93,7 +93,7 @@ int AVIOContextWrapper::FileRead(void* opaque, uint8_t* buf, int size) int AVIOContextWrapper::FileWrite(void* opaque, const uint8_t* buf, int size) { - AVIOContextWrapper* wrapper = static_cast(opaque); + auto* wrapper = static_cast(opaque); if (!(wrapper && wrapper->mpFile)) return {}; return wrapper->mpFile->Write(buf, size); @@ -101,7 +101,7 @@ int AVIOContextWrapper::FileWrite(void* opaque, const uint8_t* buf, int size) int64_t AVIOContextWrapper::FileSeek(void* opaque, int64_t pos, int whence) { - AVIOContextWrapper* wrapper = static_cast(opaque); + auto* wrapper = static_cast(opaque); if (!(wrapper && wrapper->mpFile)) return {}; diff --git a/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.h index d6814bc58b..8c527a3c08 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVIOContextWrapper.h @@ -38,34 +38,34 @@ class FFMPEG_SUPPORT_API AVIOContextWrapper explicit AVIOContextWrapper(const FFmpegFunctions& ffmpeg) noexcept; AVIOContext* GetWrappedValue() noexcept; - const AVIOContext* GetWrappedValue() const noexcept; + [[nodiscard]] const AVIOContext* GetWrappedValue() const noexcept; virtual ~AVIOContextWrapper(); OpenResult Open(const wxString& fileName, bool forWriting); - virtual unsigned char* GetBuffer() const noexcept = 0; - virtual int GetBufferSize() const noexcept = 0; - virtual unsigned char* GetBufPtr() const noexcept = 0; - virtual unsigned char* GetBufEnd() const noexcept = 0; + [[nodiscard]] virtual unsigned char* GetBuffer() const noexcept = 0; + [[nodiscard]] virtual int GetBufferSize() const noexcept = 0; + [[nodiscard]] virtual unsigned char* GetBufPtr() const noexcept = 0; + [[nodiscard]] virtual unsigned char* GetBufEnd() const noexcept = 0; - virtual void* GetOpaque() const noexcept = 0; + [[nodiscard]] virtual void* GetOpaque() const noexcept = 0; virtual void SetOpaque(void* opaque) noexcept = 0; - virtual int64_t GetPos() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPos() const noexcept = 0; - virtual int GetEofReached() const noexcept = 0; + [[nodiscard]] virtual int GetEofReached() const noexcept = 0; - virtual int GetWriteFlag() const noexcept = 0; + [[nodiscard]] virtual int GetWriteFlag() const noexcept = 0; virtual void SetWriteFlag(int write_flag) noexcept = 0; - virtual int GetError() const noexcept = 0; + [[nodiscard]] virtual int GetError() const noexcept = 0; virtual void SetError(int error) noexcept = 0; - virtual int GetSeekable() const noexcept = 0; + [[nodiscard]] virtual int GetSeekable() const noexcept = 0; virtual void SetSeekable(int seekable) noexcept = 0; - virtual int GetDirect() const noexcept = 0; + [[nodiscard]] virtual int GetDirect() const noexcept = 0; virtual void SetDirect(int direct) noexcept = 0; protected: diff --git a/libraries/lib-ffmpeg-support/wrappers/AVInputFormatWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVInputFormatWrapper.h index 60e9d314d3..b49918a5ef 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVInputFormatWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVInputFormatWrapper.h @@ -25,15 +25,15 @@ class FFMPEG_SUPPORT_API AVInputFormatWrapper explicit AVInputFormatWrapper(AVInputFormat* wrapped) noexcept; AVInputFormat* GetWrappedValue() noexcept; - const AVInputFormat* GetWrappedValue() const noexcept; + [[nodiscard]] const AVInputFormat* GetWrappedValue() const noexcept; virtual ~AVInputFormatWrapper() = default; - virtual const char* GetName() const noexcept = 0; - virtual const char* GetLongName() const noexcept = 0; - virtual int GetFlags() const noexcept = 0; - virtual const char* GetExtensions() const noexcept = 0; - virtual const struct AVCodecTag* const* GetCodecTag() const noexcept = 0; + [[nodiscard]] virtual const char* GetName() const noexcept = 0; + [[nodiscard]] virtual const char* GetLongName() const noexcept = 0; + [[nodiscard]] virtual int GetFlags() const noexcept = 0; + [[nodiscard]] virtual const char* GetExtensions() const noexcept = 0; + [[nodiscard]] virtual const struct AVCodecTag* const* GetCodecTag() const noexcept = 0; protected: AVInputFormat* mAVInputFormat { nullptr }; }; diff --git a/libraries/lib-ffmpeg-support/wrappers/AVOutputFormatWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVOutputFormatWrapper.h index c052f328e2..89689272ef 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVOutputFormatWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVOutputFormatWrapper.h @@ -26,18 +26,18 @@ class FFMPEG_SUPPORT_API AVOutputFormatWrapper explicit AVOutputFormatWrapper(const AVOutputFormat* wrapped) noexcept; - const AVOutputFormat* GetWrappedValue() const noexcept; + [[nodiscard]] const AVOutputFormat* GetWrappedValue() const noexcept; //! This class is move-only, although it doesn't manage a resource virtual ~AVOutputFormatWrapper() = default; - virtual const char* GetName() const noexcept = 0; - virtual const char* GetLongName() const noexcept = 0; - virtual const char* GetMimeType() const noexcept = 0; - virtual const char* GetExtensions() const noexcept = 0; - virtual AVCodecIDFwd GetAudioCodec() const noexcept = 0; - virtual int GetFlags() const noexcept = 0; - virtual const struct AVCodecTag* const* GetCodecTag() const noexcept = 0; + [[nodiscard]] virtual const char* GetName() const noexcept = 0; + [[nodiscard]] virtual const char* GetLongName() const noexcept = 0; + [[nodiscard]] virtual const char* GetMimeType() const noexcept = 0; + [[nodiscard]] virtual const char* GetExtensions() const noexcept = 0; + [[nodiscard]] virtual AVCodecIDFwd GetAudioCodec() const noexcept = 0; + [[nodiscard]] virtual int GetFlags() const noexcept = 0; + [[nodiscard]] virtual const struct AVCodecTag* const* GetCodecTag() const noexcept = 0; protected: const AVOutputFormat* mAVOutputFormat { nullptr }; }; diff --git a/libraries/lib-ffmpeg-support/wrappers/AVPacketWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVPacketWrapper.h index 3fa6f0af65..29873a4b9f 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVPacketWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVPacketWrapper.h @@ -29,37 +29,37 @@ class FFMPEG_SUPPORT_API AVPacketWrapper explicit AVPacketWrapper(const FFmpegFunctions& ffmpeg) noexcept; AVPacket* GetWrappedValue() noexcept; - const AVPacket* GetWrappedValue() const noexcept; + [[nodiscard]] const AVPacket* GetWrappedValue() const noexcept; virtual ~AVPacketWrapper(); - virtual AudacityAVBufferRef* GetBuf() const noexcept = 0; + [[nodiscard]] virtual AudacityAVBufferRef* GetBuf() const noexcept = 0; - virtual int64_t GetPresentationTimestamp() const noexcept = 0; - virtual int64_t GetDecompressionTimestamp() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPresentationTimestamp() const noexcept = 0; + [[nodiscard]] virtual int64_t GetDecompressionTimestamp() const noexcept = 0; - virtual int GetDuration() const noexcept = 0; + [[nodiscard]] virtual int GetDuration() const noexcept = 0; virtual void RescalePresentationTimestamp(AudacityAVRational bq, AudacityAVRational cq) noexcept = 0; virtual void RescaleDecompressionTimestamp(AudacityAVRational bq, AudacityAVRational cq) noexcept = 0; virtual void RescaleDuration(AudacityAVRational bq, AudacityAVRational cq) noexcept = 0; - virtual uint8_t* GetData() const noexcept = 0; - virtual int GetSize() const noexcept = 0; + [[nodiscard]] virtual uint8_t* GetData() const noexcept = 0; + [[nodiscard]] virtual int GetSize() const noexcept = 0; virtual bool OffsetPacket(size_t offset) noexcept = 0; virtual void ResetData() noexcept = 0; virtual void ResetTimestamps() noexcept = 0; - virtual int GetStreamIndex() const noexcept = 0; + [[nodiscard]] virtual int GetStreamIndex() const noexcept = 0; virtual void SetStreamIndex(int index) noexcept = 0; - virtual int GetFlags() const noexcept = 0; - virtual int64_t GetPos() const noexcept = 0; - virtual int64_t GetConvergenceDuration() const noexcept = 0; + [[nodiscard]] virtual int GetFlags() const noexcept = 0; + [[nodiscard]] virtual int64_t GetPos() const noexcept = 0; + [[nodiscard]] virtual int64_t GetConvergenceDuration() const noexcept = 0; //! @post return value is not null - virtual std::unique_ptr Clone() const noexcept = 0; + [[nodiscard]] virtual std::unique_ptr Clone() const noexcept = 0; protected: const FFmpegFunctions& mFFmpeg; diff --git a/libraries/lib-ffmpeg-support/wrappers/AVStreamWrapper.h b/libraries/lib-ffmpeg-support/wrappers/AVStreamWrapper.h index 16f13cfbd8..5fff368b24 100644 --- a/libraries/lib-ffmpeg-support/wrappers/AVStreamWrapper.h +++ b/libraries/lib-ffmpeg-support/wrappers/AVStreamWrapper.h @@ -33,44 +33,44 @@ class FFMPEG_SUPPORT_API AVStreamWrapper AVStreamWrapper(const FFmpegFunctions& ffmpeg, AVStream* wrapped) noexcept; AVStream* GetWrappedValue() noexcept; - const AVStream* GetWrappedValue() const noexcept; + [[nodiscard]] const AVStream* GetWrappedValue() const noexcept; virtual ~AVStreamWrapper() = default; - virtual int GetIndex() const noexcept = 0; + [[nodiscard]] virtual int GetIndex() const noexcept = 0; - virtual int GetId() const noexcept = 0; + [[nodiscard]] virtual int GetId() const noexcept = 0; virtual void SetId(int id) noexcept = 0; - virtual AudacityAVRational GetTimeBase() const noexcept = 0; + [[nodiscard]] virtual AudacityAVRational GetTimeBase() const noexcept = 0; virtual void SetTimeBase(AudacityAVRational time_base) noexcept = 0; - virtual int64_t GetStartTime() const noexcept = 0; + [[nodiscard]] virtual int64_t GetStartTime() const noexcept = 0; virtual void SetStartTime(int64_t start_time) noexcept = 0; - virtual int64_t GetDuration() const noexcept = 0; + [[nodiscard]] virtual int64_t GetDuration() const noexcept = 0; virtual void SetDuration(int64_t duration) noexcept = 0; - virtual int64_t GetFramesCount() const noexcept = 0; + [[nodiscard]] virtual int64_t GetFramesCount() const noexcept = 0; virtual void SetFramesCount(int64_t nb_frames) noexcept = 0; - virtual int GetDisposition() const noexcept = 0; + [[nodiscard]] virtual int GetDisposition() const noexcept = 0; virtual void SetDisposition(int disposition) noexcept = 0; - virtual AVSampleFormatFwd GetDiscard() const noexcept = 0; + [[nodiscard]] virtual AVSampleFormatFwd GetDiscard() const noexcept = 0; virtual void SetDiscard(AVDiscardFwd discard) noexcept = 0; - virtual AudacityAVRational GetSampleAspectRatio() const noexcept = 0; + [[nodiscard]] virtual AudacityAVRational GetSampleAspectRatio() const noexcept = 0; virtual void SetSampleAspectRatio(AudacityAVRational sample_aspect_ratio) noexcept = 0; - virtual AVDictionaryWrapper GetMetadata() const noexcept = 0; + [[nodiscard]] virtual AVDictionaryWrapper GetMetadata() const noexcept = 0; virtual void SetMetadata(AVDictionaryWrapper metadata) noexcept = 0; - virtual bool IsAudio() const noexcept = 0; + [[nodiscard]] virtual bool IsAudio() const noexcept = 0; - virtual AVCodecIDFwd GetAVCodecID() const noexcept = 0; + [[nodiscard]] virtual AVCodecIDFwd GetAVCodecID() const noexcept = 0; - virtual std::unique_ptr GetAVCodecContext() const noexcept = 0; + [[nodiscard]] virtual std::unique_ptr GetAVCodecContext() const noexcept = 0; virtual int SetParametersFromContext(AVCodecContextWrapper& context) noexcept = 0; diff --git a/libraries/lib-files/FileIO.cpp b/libraries/lib-files/FileIO.cpp index 2eec6d2ab2..be514bd0df 100644 --- a/libraries/lib-files/FileIO.cpp +++ b/libraries/lib-files/FileIO.cpp @@ -25,14 +25,14 @@ FileIO::FileIO(const wxFileNameWrapper & name, FileIOMode mode) auto path = name.GetFullPath(); if (mMode == FileIO::Input) { mInputStream = std::make_unique(path); - if (mInputStream == NULL || !mInputStream->IsOk()) { + if (mInputStream == nullptr || !mInputStream->IsOk()) { wxPrintf(wxT("Couldn't get input stream: %s\n"), path); return; } } else { mOutputStream = std::make_unique(path); - if (mOutputStream == NULL || !mOutputStream->IsOk()) { + if (mOutputStream == nullptr || !mOutputStream->IsOk()) { wxPrintf(wxT("Couldn't get output stream: %s\n"), path); return; } @@ -46,7 +46,7 @@ FileIO::~FileIO() Close(); } -bool FileIO::IsOpened() +bool FileIO::IsOpened() const { return mOpen; } @@ -67,7 +67,7 @@ bool FileIO::Close() wxInputStream & FileIO::Read(void *buf, size_t size) { - if (mInputStream == NULL) { + if (mInputStream == nullptr) { return *mInputStream; } @@ -76,7 +76,7 @@ wxInputStream & FileIO::Read(void *buf, size_t size) wxOutputStream & FileIO::Write(const void *buf, size_t size) { - if (mOutputStream == NULL) { + if (mOutputStream == nullptr) { return *mOutputStream; } diff --git a/libraries/lib-files/FileIO.h b/libraries/lib-files/FileIO.h index bac55dff49..361efaeecf 100644 --- a/libraries/lib-files/FileIO.h +++ b/libraries/lib-files/FileIO.h @@ -33,7 +33,7 @@ class FILES_API FileIO // Calls Close() ~FileIO(); - bool IsOpened(); + bool IsOpened() const; bool Close(); diff --git a/libraries/lib-files/SaucedacityLogger.h b/libraries/lib-files/SaucedacityLogger.h index 5244bf99a5..76ba6b3da5 100644 --- a/libraries/lib-files/SaucedacityLogger.h +++ b/libraries/lib-files/SaucedacityLogger.h @@ -27,7 +27,7 @@ class FILES_API SaucedacityLogger final : public wxEvtHandler, // Get the singleton instance or null static SaucedacityLogger *Get(); - bool SaveLog(const wxString &fileName) const; + [[nodiscard]] bool SaveLog(const wxString &fileName) const; bool ClearLog(); //! Retrieve all or some of the lines since most recent ClearLog or start of program @@ -35,7 +35,7 @@ class FILES_API SaucedacityLogger final : public wxEvtHandler, wxString GetLog(int count = 0); //! Get all the accumulated text since program start or last ClearLog() - const wxString &GetBuffer() const { return mBuffer; } + [[nodiscard]] const wxString &GetBuffer() const { return mBuffer; } void Flush() override; diff --git a/libraries/lib-math/Dither.cpp b/libraries/lib-math/Dither.cpp index 45e672dad5..aed818e83d 100644 --- a/libraries/lib-math/Dither.cpp +++ b/libraries/lib-math/Dither.cpp @@ -45,9 +45,9 @@ and get deterministic behaviour. // (Note: this file should be included first) #include "float_cast.h" -#include +#include #include -#include +#include //#include //#include //#include @@ -179,10 +179,10 @@ const float Dither::SHAPED_BS[] = { 2.033f, -2.165f, 1.959f, -1.590f, 0.6149f }; char *d, *s; \ unsigned int ii; \ int x; \ - for (d = (char*)dst, s = (char*)src, ii = 0; \ - ii < len; \ - ii++, d += SAMPLE_SIZE(dstFormat) * dstStride, \ - s += SAMPLE_SIZE(srcFormat) * srcStride) \ + for (d = (char*)(dst), s = (char*)(src), ii = 0; \ + ii < (len); \ + ii++, d += SAMPLE_SIZE(dstFormat) * (dstStride), \ + s += SAMPLE_SIZE(srcFormat) * (srcStride)) \ DITHER_STEP(dither, store, load, d, s); \ } while (0) @@ -197,11 +197,11 @@ const float Dither::SHAPED_BS[] = { 2.033f, -2.165f, 1.959f, -1.590f, 0.6149f }; // Implement a dither. There are only 3 cases where we must dither, // in all other cases, no dithering is necessary. #define DITHER(dither, dst, dstFormat, dstStride, src, srcFormat, srcStride, len) \ - do { if (srcFormat == int24Sample && dstFormat == int16Sample) \ + do { if ((srcFormat) == int24Sample && (dstFormat) == int16Sample) \ DITHER_INT24_TO_INT16(dither, dst, dstStride, src, srcStride, len); \ - else if (srcFormat == floatSample && dstFormat == int16Sample) \ + else if ((srcFormat) == floatSample && (dstFormat) == int16Sample) \ DITHER_FLOAT_TO_INT16(dither, dst, dstStride, src, srcStride, len); \ - else if (srcFormat == floatSample && dstFormat == int24Sample) \ + else if ((srcFormat) == floatSample && (dstFormat) == int24Sample) \ DITHER_FLOAT_TO_INT24(dither, dst, dstStride, src, srcStride, len); \ else { wxASSERT(false); } \ } while (0) diff --git a/libraries/lib-math/Dither.h b/libraries/lib-math/Dither.h index 369273b7f7..acfb61132b 100644 --- a/libraries/lib-math/Dither.h +++ b/libraries/lib-math/Dither.h @@ -47,8 +47,8 @@ class MATH_API Dither private: // Dither methods - float NoDither(float sample); - float RectangleDither(float sample); + static float NoDither(float sample); + static float RectangleDither(float sample); float TriangleDither(float sample); float ShapedDither(float sample); diff --git a/libraries/lib-math/FFT.cpp b/libraries/lib-math/FFT.cpp index 53af989b4c..c0d0c10717 100644 --- a/libraries/lib-math/FFT.cpp +++ b/libraries/lib-math/FFT.cpp @@ -47,8 +47,8 @@ #include #include -#include -#include +#include +#include #include #include "RealFFTf.h" @@ -157,7 +157,7 @@ void FFT(size_t NumSamples, for (size_t i = 0; i < NumSamples; i++) { auto j = FastReverseBits(i, NumBits); RealOut[j] = RealIn[i]; - ImagOut[j] = (ImagIn == NULL) ? 0.0 : ImagIn[i]; + ImagOut[j] = (ImagIn == nullptr) ? 0.0 : ImagIn[i]; } /* @@ -212,7 +212,7 @@ void FFT(size_t NumSamples, */ if (InverseTransform) { - float denom = (float) NumSamples; + auto denom = (float) NumSamples; for (size_t i = 0; i < NumSamples; i++) { RealOut[i] /= denom; @@ -273,7 +273,7 @@ void InverseRealFFT(size_t NumSamples, const float *RealIn, const float *ImagIn, // Copy the data into the processing buffer for (size_t i = 0; i < (NumSamples / 2); i++) pFFT[2*i ] = RealIn[i]; - if(ImagIn == NULL) { + if(ImagIn == nullptr) { for (size_t i = 0; i < (NumSamples / 2); i++) pFFT[2*i+1] = 0; } else { diff --git a/libraries/lib-math/InterpolateAudio.cpp b/libraries/lib-math/InterpolateAudio.cpp index 50e01e7d16..85e6c706ba 100644 --- a/libraries/lib-math/InterpolateAudio.cpp +++ b/libraries/lib-math/InterpolateAudio.cpp @@ -11,7 +11,7 @@ #include "InterpolateAudio.h" #include -#include +#include #include diff --git a/libraries/lib-math/Matrix.cpp b/libraries/lib-math/Matrix.cpp index 8ac73a74a9..b1c8da3ef7 100644 --- a/libraries/lib-math/Matrix.cpp +++ b/libraries/lib-math/Matrix.cpp @@ -10,7 +10,7 @@ #include "Matrix.h" -#include +#include #include #include diff --git a/libraries/lib-math/Matrix.h b/libraries/lib-math/Matrix.h index 840cd5d7a2..9adcaedf64 100644 --- a/libraries/lib-math/Matrix.h +++ b/libraries/lib-math/Matrix.h @@ -35,7 +35,7 @@ class Vector public: Vector(); Vector(const Vector& copyFrom); - Vector(unsigned len, double *data=NULL); + Vector(unsigned len, double *data=nullptr); Vector(unsigned len, float *data); Vector& operator=(const Vector &other); ~Vector(); @@ -45,9 +45,9 @@ class Vector inline double& operator[](unsigned i) { return mData[i]; } inline double operator[](unsigned i) const { return mData[i]; } - inline unsigned Len() const { return mN; } + [[nodiscard]] inline unsigned Len() const { return mN; } - double Sum() const; + [[nodiscard]] double Sum() const; private: unsigned mN{ 0 }; @@ -58,15 +58,15 @@ class Matrix { public: Matrix(const Matrix& copyFrom); - Matrix(unsigned rows, unsigned cols, double **data=NULL); + Matrix(unsigned rows, unsigned cols, double **data=nullptr); ~Matrix(); Matrix& operator=(const Matrix& other); inline Vector& operator[](unsigned i) { return mRowVec[i]; } inline Vector& operator[](unsigned i) const { return mRowVec[i]; } - inline unsigned Rows() const { return mRows; } - inline unsigned Cols() const { return mCols; } + [[nodiscard]] inline unsigned Rows() const { return mRows; } + [[nodiscard]] inline unsigned Cols() const { return mCols; } void SwapRows(unsigned i, unsigned j); @@ -96,7 +96,7 @@ Vector operator*(const Vector &left, const Matrix &right); Vector operator*(const Matrix &left, const Vector &right); Matrix operator+(const Matrix &left, const Matrix &right); -Matrix operator*(const Matrix &left, const double right); +Matrix operator*(const Matrix &left, double right); // No operator* on matrices due to ambiguity Matrix ScalarMultiply(const Matrix &left, const Matrix &right); diff --git a/libraries/lib-math/RealFFTf.cpp b/libraries/lib-math/RealFFTf.cpp index d95daf52d7..173a7e8b37 100644 --- a/libraries/lib-math/RealFFTf.cpp +++ b/libraries/lib-math/RealFFTf.cpp @@ -39,8 +39,8 @@ #include "RealFFTf.h" #include -#include -#include +#include +#include #include #include @@ -117,7 +117,7 @@ HFFT GetFFT(size_t fftlen) h++) ; if(h < size) { - if(hFFTArray[h] == NULL) { + if(hFFTArray[h] == nullptr) { hFFTArray[h].reset( InitializeFFT(fftlen).release() ); } return HFFT{ hFFTArray[h].get() }; diff --git a/libraries/lib-math/Resample.cpp b/libraries/lib-math/Resample.cpp index 0c36953c66..f5d11f5947 100644 --- a/libraries/lib-math/Resample.cpp +++ b/libraries/lib-math/Resample.cpp @@ -43,7 +43,7 @@ Resample::Resample(const bool useBestMethod, const double dMinFactor, const doub mbWantConstRateResampling = false; // variable rate resampling q_spec = soxr_quality_spec(SOXR_HQ, SOXR_VR); } - mHandle.reset(soxr_create(1, dMinFactor, 1, 0, 0, &q_spec, 0)); + mHandle.reset(soxr_create(1, dMinFactor, 1, nullptr, nullptr, &q_spec, nullptr)); } Resample::~Resample() diff --git a/libraries/lib-math/Resample.h b/libraries/lib-math/Resample.h index d15ee8fe42..547a8707da 100644 --- a/libraries/lib-math/Resample.h +++ b/libraries/lib-math/Resample.h @@ -36,7 +36,7 @@ class MATH_API Resample final /// the fast method. // dMinFactor and dMaxFactor specify the range of factors for variable-rate resampling. // For constant-rate, pass the same value for both. - Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor); + Resample(bool useBestMethod, double dMinFactor, double dMaxFactor); ~Resample(); static EnumSetting< int > FastMethodSetting; @@ -73,7 +73,7 @@ class MATH_API Resample final size_t outBufferLen); protected: - void SetMethod(const bool useBestMethod); + void SetMethod(bool useBestMethod); protected: int mMethod; // resampler-specific enum for resampling method diff --git a/libraries/lib-math/SSEMathFuncs.h b/libraries/lib-math/SSEMathFuncs.h index 962dffbfd7..3d3aa40357 100644 --- a/libraries/lib-math/SSEMathFuncs.h +++ b/libraries/lib-math/SSEMathFuncs.h @@ -159,12 +159,12 @@ typedef union xmm_mm_union { #define COPY_XMM_TO_MM(xmm_, mm0_, mm1_) { \ xmm_mm_union u; u.xmm = xmm_; \ - mm0_ = u.mm[0]; \ - mm1_ = u.mm[1]; \ + (mm0_) = u.mm[0]; \ + (mm1_) = u.mm[1]; \ } #define COPY_MM_TO_XMM(mm0_, mm1_, xmm_) { \ - xmm_mm_union u; u.mm[0]=mm0_; u.mm[1]=mm1_; xmm_ = u.xmm; \ + xmm_mm_union u; u.mm[0]=mm0_; u.mm[1]=mm1_; (xmm_) = u.xmm; \ } #endif // USE_SSE2 diff --git a/libraries/lib-math/SampleCount.h b/libraries/lib-math/SampleCount.h index 19be036250..482d30be74 100644 --- a/libraries/lib-math/SampleCount.h +++ b/libraries/lib-math/SampleCount.h @@ -41,12 +41,12 @@ class MATH_API sampleCount sampleCount ( const sampleCount& ) = default; sampleCount &operator= ( const sampleCount& ) = default; - float as_float() const { return value; } - double as_double() const { return value; } + [[nodiscard]] float as_float() const { return value; } + [[nodiscard]] double as_double() const { return value; } - long long as_long_long() const { return value; } + [[nodiscard]] long long as_long_long() const { return value; } - size_t as_size_t() const; + [[nodiscard]] size_t as_size_t() const; sampleCount &operator += (sampleCount b) { value += b.value; return *this; } sampleCount &operator -= (sampleCount b) { value -= b.value; return *this; } @@ -57,11 +57,11 @@ class MATH_API sampleCount sampleCount operator - () const { return -value; } sampleCount &operator ++ () { ++value; return *this; } - sampleCount operator ++ (int) + const sampleCount operator ++ (int) { sampleCount result{ *this }; ++value; return result; } sampleCount &operator -- () { --value; return *this; } - sampleCount operator -- (int) + const sampleCount operator -- (int) { sampleCount result{ *this }; --value; return result; } private: diff --git a/libraries/lib-math/SampleFormat.cpp b/libraries/lib-math/SampleFormat.cpp index 6537cb2897..38ae9f56fa 100644 --- a/libraries/lib-math/SampleFormat.cpp +++ b/libraries/lib-math/SampleFormat.cpp @@ -39,9 +39,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "Prefs.h" #include "Internat.h" diff --git a/libraries/lib-math/SampleFormat.h b/libraries/lib-math/SampleFormat.h index d2ca09069b..105b75a3fc 100644 --- a/libraries/lib-math/SampleFormat.h +++ b/libraries/lib-math/SampleFormat.h @@ -41,7 +41,7 @@ enum sampleFormat : unsigned // ---------------------------------------------------------------------------- // Provide the number of bytes a specific sample will take // ---------------------------------------------------------------------------- -#define SAMPLE_SIZE(SampleFormat) (SampleFormat >> 16) +#define SAMPLE_SIZE(SampleFormat) ((SampleFormat) >> 16) // ---------------------------------------------------------------------------- // Generic pointer to sample data @@ -70,7 +70,7 @@ class SampleBuffer { public: SampleBuffer() - : mPtr(0) + : mPtr(nullptr) {} SampleBuffer(size_t count, sampleFormat format) : mPtr((samplePtr)malloc(count * SAMPLE_SIZE(format))) @@ -92,10 +92,10 @@ class SampleBuffer { void Free() { free(mPtr); - mPtr = 0; + mPtr = nullptr; } - samplePtr ptr() const { return mPtr; } + [[nodiscard]] samplePtr ptr() const { return mPtr; } private: diff --git a/libraries/lib-math/float_cast.h b/libraries/lib-math/float_cast.h index 6886e3d93d..9550497288 100644 --- a/libraries/lib-math/float_cast.h +++ b/libraries/lib-math/float_cast.h @@ -153,7 +153,7 @@ #define __USE_ISOC9X 1 #define __USE_ISOC99 1 - #include + #include #else /* dmazzoni: modified these to do a proper rounding, even though diff --git a/libraries/lib-preferences/FileConfig.cpp b/libraries/lib-preferences/FileConfig.cpp index 6a0f7c0fb9..1186fca136 100644 --- a/libraries/lib-preferences/FileConfig.cpp +++ b/libraries/lib-preferences/FileConfig.cpp @@ -8,7 +8,7 @@ **********************************************************************/ -#include +#include #include #include "FileConfig.h" diff --git a/libraries/lib-preferences/FileConfig.h b/libraries/lib-preferences/FileConfig.h index 154dcda9ec..7dd58a236c 100644 --- a/libraries/lib-preferences/FileConfig.h +++ b/libraries/lib-preferences/FileConfig.h @@ -27,24 +27,24 @@ class PREFERENCES_API FileConfig : public wxConfigBase long style = wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_GLOBAL_FILE, const wxMBConv& conv = wxConvAuto()); void Init(); - virtual ~FileConfig(); - - virtual void SetPath(const wxString& strPath) wxOVERRIDE; - virtual const wxString& GetPath() const wxOVERRIDE; - virtual bool GetFirstGroup(wxString& str, long& lIndex) const wxOVERRIDE; - virtual bool GetNextGroup(wxString& str, long& lIndex) const wxOVERRIDE; - virtual bool GetFirstEntry(wxString& str, long& lIndex) const wxOVERRIDE; - virtual bool GetNextEntry(wxString& str, long& lIndex) const wxOVERRIDE; - virtual size_t GetNumberOfEntries(bool bRecursive = false) const wxOVERRIDE; - virtual size_t GetNumberOfGroups(bool bRecursive = false) const wxOVERRIDE; - virtual bool HasGroup(const wxString& strName) const wxOVERRIDE; - virtual bool HasEntry(const wxString& strName) const wxOVERRIDE; - virtual bool Flush(bool bCurrentOnly = false) wxOVERRIDE; - virtual bool RenameEntry(const wxString& oldName, const wxString& newName) wxOVERRIDE; - virtual bool RenameGroup(const wxString& oldName, const wxString& newName) wxOVERRIDE; - virtual bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = true) wxOVERRIDE; - virtual bool DeleteGroup(const wxString& key) wxOVERRIDE; - virtual bool DeleteAll() wxOVERRIDE; + ~FileConfig() override; + + void SetPath(const wxString& strPath) wxOVERRIDE; + [[nodiscard]] const wxString& GetPath() const wxOVERRIDE; + bool GetFirstGroup(wxString& str, long& lIndex) const wxOVERRIDE; + bool GetNextGroup(wxString& str, long& lIndex) const wxOVERRIDE; + bool GetFirstEntry(wxString& str, long& lIndex) const wxOVERRIDE; + bool GetNextEntry(wxString& str, long& lIndex) const wxOVERRIDE; + [[nodiscard]] size_t GetNumberOfEntries(bool bRecursive = false) const wxOVERRIDE; + [[nodiscard]] size_t GetNumberOfGroups(bool bRecursive = false) const wxOVERRIDE; + [[nodiscard]] bool HasGroup(const wxString& strName) const wxOVERRIDE; + [[nodiscard]] bool HasEntry(const wxString& strName) const wxOVERRIDE; + bool Flush(bool bCurrentOnly = false) wxOVERRIDE; + bool RenameEntry(const wxString& oldName, const wxString& newName) wxOVERRIDE; + bool RenameGroup(const wxString& oldName, const wxString& newName) wxOVERRIDE; + bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = true) wxOVERRIDE; + bool DeleteGroup(const wxString& key) wxOVERRIDE; + bool DeleteAll() wxOVERRIDE; // Set and Get values of the version major/minor/micro keys in audacity.cfg when Audacity first opens void SetVersionKeysInit( int major, int minor, int micro) @@ -61,23 +61,23 @@ class PREFERENCES_API FileConfig : public wxConfigBase } protected: - virtual bool DoReadString(const wxString& key, wxString *pStr) const wxOVERRIDE; - virtual bool DoReadLong(const wxString& key, long *pl) const wxOVERRIDE; + bool DoReadString(const wxString& key, wxString *pStr) const wxOVERRIDE; + bool DoReadLong(const wxString& key, long *pl) const wxOVERRIDE; #if wxUSE_BASE64 - virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const wxOVERRIDE; + bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const wxOVERRIDE; #endif // wxUSE_BASE64 - virtual bool DoWriteString(const wxString& key, const wxString& szValue) wxOVERRIDE; - virtual bool DoWriteLong(const wxString& key, long lValue) wxOVERRIDE; + bool DoWriteString(const wxString& key, const wxString& szValue) wxOVERRIDE; + bool DoWriteLong(const wxString& key, long lValue) wxOVERRIDE; #if wxUSE_BASE64 - virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) wxOVERRIDE; + bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) wxOVERRIDE; #endif // wxUSE_BASE64 protected: //! Override to notify the user of error conditions involving writability of config files virtual void Warn() = 0; - const FilePath &GetFilePath() const { return mLocalFilename; } + [[nodiscard]] const FilePath &GetFilePath() const { return mLocalFilename; } private: const wxString mAppName; diff --git a/libraries/lib-preferences/Prefs.cpp b/libraries/lib-preferences/Prefs.cpp index 248bff6c40..ed4763744a 100644 --- a/libraries/lib-preferences/Prefs.cpp +++ b/libraries/lib-preferences/Prefs.cpp @@ -84,7 +84,7 @@ struct Hub : Observer::Publisher using Publisher::Publish; }; -static Hub &hub() +Hub &hub() { static Hub theHub; return theHub; @@ -210,9 +210,9 @@ void ResetPreferences() void FinishPreferences() { if (gPrefs) { - wxConfigBase::Set(NULL); + wxConfigBase::Set(nullptr); ugPrefs.reset(); - gPrefs = NULL; + gPrefs = nullptr; } } @@ -428,12 +428,12 @@ void PreferenceInitializer::ReinitializeAll() (*pInitializer)(); } -wxConfigBase *SettingBase::GetConfig() const +wxConfigBase *SettingBase::GetConfig() { return gPrefs; } -bool SettingBase::Delete() +bool SettingBase::Delete() const { auto config = GetConfig(); return config && config->DeleteEntry( GetPath() ); diff --git a/libraries/lib-preferences/Prefs.h b/libraries/lib-preferences/Prefs.h index d181113484..e245014bb8 100644 --- a/libraries/lib-preferences/Prefs.h +++ b/libraries/lib-preferences/Prefs.h @@ -69,12 +69,12 @@ class PREFERENCES_API SettingBase SettingBase( const wxChar *path ) : mPath{ path } {} SettingBase( const wxString &path ) : mPath{ path } {} - wxConfigBase *GetConfig() const; + [[nodiscard]] static wxConfigBase *GetConfig() ; - const wxString &GetPath() const { return mPath; } + [[nodiscard]] const wxString &GetPath() const { return mPath; } //! Delete the key if present, and return true iff it was. - bool Delete(); + bool Delete() const; protected: SettingBase( const SettingBase& ) = default; diff --git a/libraries/lib-registries/ClientData.h b/libraries/lib-registries/ClientData.h index a9b004c00e..4634d5276d 100644 --- a/libraries/lib-registries/ClientData.h +++ b/libraries/lib-registries/ClientData.h @@ -244,13 +244,13 @@ class Site Site& operator =( const Site & other ) { mData = other.mData; return *this; } Site( Site && other ) - : mData( std::move(other.mData) ) + noexcept : mData( std::move(other.mData) ) { } Site& operator =( Site && other ) - { mData = std::move(other.mData); return *this; } + noexcept { mData = std::move(other.mData); return *this; } //! How many attachment pointers are in the Site - size_t size() const { return mData.size(); } + [[nodiscard]] size_t size() const { return mData.size(); } //! How many static factories have been registered with this specialization of Site /*! @@ -267,7 +267,7 @@ class Site class RegisteredFactory { public: - RegisteredFactory( + explicit RegisteredFactory( DataFactory factory ) { @@ -276,7 +276,7 @@ class Site factories.mObject.emplace_back( std::move( factory ) ); } RegisteredFactory( RegisteredFactory &&other ) - { + noexcept { mIndex = other.mIndex; mOwner = other.mOwner; other.mOwner = false; diff --git a/libraries/lib-registries/ClientDataHelpers.h b/libraries/lib-registries/ClientDataHelpers.h index 5451228c49..cf561f2131 100644 --- a/libraries/lib-registries/ClientDataHelpers.h +++ b/libraries/lib-registries/ClientDataHelpers.h @@ -69,13 +69,13 @@ template< typename Object > struct Lockable< Object, NoLocking > template< typename Object > struct Lockable< Object, NonrecursiveLocking > : Object, std::mutex { using Lock = std::unique_lock< std::mutex >; - Lock lock() const { return Lock{ *this }; } + [[nodiscard]] Lock lock() const { return Lock{ *this }; } }; //! Specialization for real locking with std::recursive_mutex template< typename Object > struct Lockable< Object, RecursiveLocking > : Object, std::recursive_mutex { using Lock = std::unique_lock< std::recursive_mutex >; - Lock lock() const { return Lock{ *this }; } + [[nodiscard]] Lock lock() const { return Lock{ *this }; } }; //! Decorated reference to a ClientData::Lockable, with a current lock on it @@ -98,8 +98,8 @@ template< typename Container > struct Copyable< Container, SkipCopying > Copyable() = default; Copyable( const Copyable & ) {} Copyable &operator=( const Copyable & ) { return *this; } - Copyable( Copyable && ) = default; - Copyable &operator=( Copyable&& ) = default; + Copyable( Copyable && ) noexcept = default; + Copyable &operator=( Copyable&& ) noexcept = default; }; //! Specialization that copies pointers, not sub-objects; [strong guarantee](@ref Strong-guarantee) for assignment template< typename Container > struct Copyable< Container, ShallowCopying > @@ -120,8 +120,8 @@ template< typename Container > struct Copyable< Container, ShallowCopying > } return *this; } - Copyable( Copyable && ) = default; - Copyable &operator=( Copyable&& ) = default; + Copyable( Copyable && ) noexcept = default; + Copyable &operator=( Copyable&& ) noexcept = default; }; //! Specialization that clones sub-objects when copying; [strong guarantee](@ref Strong-guarantee) for assignment template< typename Container > struct Copyable< Container, DeepCopying > @@ -144,8 +144,8 @@ template< typename Container > struct Copyable< Container, DeepCopying > } return *this; } - Copyable( Copyable && ) = default; - Copyable &operator=( Copyable&& ) = default; + Copyable( Copyable && ) noexcept = default; + Copyable &operator=( Copyable&& ) noexcept = default; }; } diff --git a/libraries/lib-strings/Identifier.h b/libraries/lib-strings/Identifier.h index ddb8f6e041..5fc4ac6bbd 100644 --- a/libraries/lib-strings/Identifier.h +++ b/libraries/lib-strings/Identifier.h @@ -58,14 +58,14 @@ class STRINGS_API Identifier explicit Identifier(std::initializer_list components, wxChar separator); - bool empty() const { return value.empty(); } - size_t size() const { return value.size(); } - size_t length() const { return value.length(); } + [[nodiscard]] bool empty() const { return value.empty(); } + [[nodiscard]] size_t size() const { return value.size(); } + [[nodiscard]] size_t length() const { return value.length(); } //! Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct - const wxString &GET() const { return value; } + [[nodiscard]] const wxString &GET() const { return value; } - std::vector< Identifier > split( wxChar separator ) const; + [[nodiscard]] std::vector< Identifier > split( wxChar separator ) const; private: wxString value; diff --git a/libraries/lib-strings/Internat.cpp b/libraries/lib-strings/Internat.cpp index 9f3cb0ad23..84b2fd16fe 100644 --- a/libraries/lib-strings/Internat.cpp +++ b/libraries/lib-strings/Internat.cpp @@ -26,8 +26,8 @@ and on Mac OS X for the filesystem. #include #include -#include -#include // for pow() +#include +#include // for pow() // in order for the static member variables to exist, they must appear here // (_outside_) the class definition, in order to be allocated some storage. diff --git a/libraries/lib-strings/Internat.h b/libraries/lib-strings/Internat.h index d84f56e8fc..498eb3e48e 100644 --- a/libraries/lib-strings/Internat.h +++ b/libraries/lib-strings/Internat.h @@ -44,7 +44,7 @@ inline TranslatableString StringLiteral(const char* str) /// Same as the prior definition, but for wxString. Exactly the same as XO, which /// this function intends to replace over time. -inline TranslatableString StringLiteral(wxString str) +inline TranslatableString StringLiteral(const wxString& str) { return TranslatableString( str, {} ); } @@ -83,7 +83,7 @@ inline TranslatableString StringLiteral(wxString str) #else - #include + #include // Raise a signal because it's even too early to use wxASSERT for this. #define _(s) ((wxTranslations::Get() || raise(SIGTRAP)), \ GetCustomTranslation((s))) diff --git a/libraries/lib-strings/Languages.cpp b/libraries/lib-strings/Languages.cpp index cb7fe88aec..2c3479e1ec 100644 --- a/libraries/lib-strings/Languages.cpp +++ b/libraries/lib-strings/Languages.cpp @@ -61,7 +61,7 @@ static void FindFilesInPathList(const wxString & pattern, } } -static bool TranslationExists(const FilePaths &pathList, wxString code) +static bool TranslationExists(const FilePaths &pathList, const wxString& code) { FilePaths results; FindFilesInPathList(code + L"/audacity.mo", pathList, results); @@ -69,7 +69,7 @@ static bool TranslationExists(const FilePaths &pathList, wxString code) FindFilesInPathList(code + L".lproj/audacity.mo", pathList, results); #endif FindFilesInPathList(code + L"/LC_MESSAGES/audacity.mo", pathList, results); - return (results.size() > 0); + return (!results.empty()); } #ifdef __WXMAC__ @@ -233,7 +233,7 @@ void GetLanguages( FilePaths pathList, const wxLanguageInfo *info = wxLocale::FindLanguageInfo(i->first); if (!info) { - wxASSERT(info != NULL); + wxASSERT(info != nullptr); continue; } @@ -337,7 +337,7 @@ wxString SetLang( const FilePaths &pathList, const wxString & lang ) wxSetEnv(wxT("LANG"), wxT("en_US.UTF-8")); #endif - const wxLanguageInfo *info = NULL; + const wxLanguageInfo *info = nullptr; if (!lang.empty() && lang != wxT("System")) { // Try to find the given language info = wxLocale::FindLanguageInfo(lang); @@ -381,7 +381,7 @@ wxString SetLang( const FilePaths &pathList, const wxString & lang ) 0 ); - sLocaleName = wxSetlocale(LC_ALL, NULL); + sLocaleName = wxSetlocale(LC_ALL, nullptr); return result; } diff --git a/libraries/lib-strings/TranslatableString.cpp b/libraries/lib-strings/TranslatableString.cpp index 188541e2fa..5bc03e8280 100644 --- a/libraries/lib-strings/TranslatableString.cpp +++ b/libraries/lib-strings/TranslatableString.cpp @@ -122,7 +122,7 @@ wxString TranslatableString::DoChooseFormat( } TranslatableString &TranslatableString::Join( - const TranslatableString arg, const wxString &separator ) & + const TranslatableString& arg, const wxString &separator ) & { auto prevFormatter = mFormatter; mFormatter = diff --git a/libraries/lib-strings/TranslatableString.h b/libraries/lib-strings/TranslatableString.h index a39a5d3278..cf1fe3c0cc 100644 --- a/libraries/lib-strings/TranslatableString.h +++ b/libraries/lib-strings/TranslatableString.h @@ -11,7 +11,7 @@ #ifndef __AUDACITY_TRANSLATABLE_STRING__ #define __AUDACITY_TRANSLATABLE_STRING__ -#include // for size_t +#include // for size_t #include #include @@ -76,17 +76,17 @@ class STRINGS_API TranslatableString { return *this; } - bool empty() const { return mMsgid.empty(); } + [[nodiscard]] bool empty() const { return mMsgid.empty(); } //! MSGID is the English lookup key in the catalog, not necessarily for user's eyes if locale is some other. /*! The MSGID might not be all the information TranslatableString holds. This is a deliberately ugly-looking function name. Use with caution. */ - Identifier MSGID() const; + [[nodiscard]] Identifier MSGID() const; - wxString Translation() const { return DoFormat( false ); } + [[nodiscard]] wxString Translation() const { return DoFormat( false ); } //! Format as an English string for debugging logs and developers' eyes, not for end users - wxString Debug() const { return DoFormat( true ); } + [[nodiscard]] wxString Debug() const { return DoFormat( true ); } //! Warning: comparison of msgids only, which is not all of the information! /*! This operator makes it easier to define a std::unordered_map on TranslatableStrings */ @@ -99,7 +99,7 @@ class STRINGS_API TranslatableString { { return !(x == y); } //! Returns true if context is NullContextFormatter - bool IsVerbatim() const; + [[nodiscard]] bool IsVerbatim() const; //! Capture variadic format arguments (by copy) when there is no plural. /*! The substitution is computed later in a call to Translate() after msgid is @@ -167,7 +167,7 @@ class STRINGS_API TranslatableString { this and for the argument are both delayed until Translate() is invoked on this, and then the formatter concatenates the translations */ TranslatableString &Join( - TranslatableString arg, const wxString &separator = {} ) &; + const TranslatableString& arg, const wxString &separator = {} ) &; TranslatableString &&Join( TranslatableString arg, const wxString &separator = {} ) && { return std::move( Join( std::move(arg), separator ) ); } @@ -202,10 +202,10 @@ class STRINGS_API TranslatableString { { return std::move( Strip( options ) ); } //! non-mutating, constructs another TranslatableString object - TranslatableString Stripped( unsigned options = MenuCodes ) const + [[nodiscard]] TranslatableString Stripped( unsigned options = MenuCodes ) const { return TranslatableString{ *this }.Strip( options ); } - wxString StrippedTranslation() const { return Stripped().Translation(); } + [[nodiscard]] wxString StrippedTranslation() const { return Stripped().Translation(); } private: static const Formatter NullContextFormatter; @@ -217,7 +217,7 @@ class STRINGS_API TranslatableString { mMsgid.swap( str ); } - friend TranslatableString Verbatim( wxString str ); + friend TranslatableString Verbatim( const wxString& str ); enum class Request { Context, //!< return a disambiguating context string @@ -232,7 +232,7 @@ class STRINGS_API TranslatableString { static wxString DoSubstitute( const Formatter &formatter, const wxString &format, const wxString &context, bool debug ); - wxString DoFormat( bool debug ) const + [[nodiscard]] wxString DoFormat( bool debug ) const { return DoSubstitute( mFormatter, mMsgid, DoGetContext(mFormatter), debug ); } @@ -325,7 +325,7 @@ inline Sink &operator <<( Sink &sink, const TranslatableString &str ) //! Require calls to the one-argument constructor to go through this distinct global function name. /*! This makes it easier to locate and review the uses of this function, separately from the uses of the type. */ -inline TranslatableString Verbatim( wxString str ) -{ return TranslatableString( std::move( str ) ); } +inline TranslatableString Verbatim( const wxString& str ) +{ return TranslatableString( str ); } #endif diff --git a/libraries/lib-utility/MemoryStream.cpp b/libraries/lib-utility/MemoryStream.cpp index 515ee06257..a132152a76 100644 --- a/libraries/lib-utility/MemoryStream.cpp +++ b/libraries/lib-utility/MemoryStream.cpp @@ -71,7 +71,7 @@ size_t MemoryStream::Chunk::Append(StreamChunk& dataView) const size_t bytesToWrite = std::min(ChunkSize - BytesUsed, dataSize); const size_t bytesLeft = dataSize - bytesToWrite; - const uint8_t* beginData = static_cast(dataView.first); + const auto* beginData = static_cast(dataView.first); const uint8_t* endData = beginData + bytesToWrite; // Some extreme micro optimization for MSVC (at least) @@ -115,7 +115,7 @@ MemoryStream::Iterator MemoryStream::end() const MemoryStream::Iterator::Iterator(const MemoryStream* stream, bool isBegin) : mStream(stream) , mListIterator(isBegin ? mStream->mChunks.cbegin() : mStream->mChunks.cend()) - , mShowLinearPart(isBegin && mStream->mLinearData.size() > 0) + , mShowLinearPart(isBegin && !mStream->mLinearData.empty()) { } @@ -129,7 +129,7 @@ MemoryStream::Iterator& MemoryStream::Iterator::operator++() return *this; } -MemoryStream::Iterator MemoryStream::Iterator::operator++(int) +const MemoryStream::Iterator MemoryStream::Iterator::operator++(int) { Iterator result { *this }; this->operator++(); diff --git a/libraries/lib-utility/MemoryStream.h b/libraries/lib-utility/MemoryStream.h index 655d2763b4..0aef2031b6 100644 --- a/libraries/lib-utility/MemoryStream.h +++ b/libraries/lib-utility/MemoryStream.h @@ -59,7 +59,7 @@ class UTILITY_API MemoryStream final void Clear(); void AppendByte(char data); - void AppendData(const void* data, const size_t length); + void AppendData(const void* data, size_t length); // This function possibly has O(size) complexity as it may // require copying bytes to a linear chunk @@ -75,7 +75,7 @@ class UTILITY_API MemoryStream final Iterator& operator++(); - Iterator operator++(int); + const Iterator operator++(int); StreamChunk operator*() const; StreamChunk operator->() const; diff --git a/libraries/lib-utility/MemoryX.h b/libraries/lib-utility/MemoryX.h index a5cab5c348..1a54956707 100644 --- a/libraries/lib-utility/MemoryX.h +++ b/libraries/lib-utility/MemoryX.h @@ -363,9 +363,9 @@ struct IteratorRange : public std::pair { reverse_iterator rbegin() const { return reverse_iterator{ this->second }; } reverse_iterator rend() const { return reverse_iterator{ this->first }; } - bool empty() const { return this->begin() == this->end(); } + [[nodiscard]] bool empty() const { return this->begin() == this->end(); } explicit operator bool () const { return !this->empty(); } - size_t size() const { return std::distance(this->begin(), this->end()); } + [[nodiscard]] size_t size() const { return std::distance(this->begin(), this->end()); } template iterator find(const T &t) const { return std::find(this->begin(), this->end(), t); } diff --git a/libraries/lib-utility/Observer.h b/libraries/lib-utility/Observer.h index e989953378..167635ee74 100644 --- a/libraries/lib-utility/Observer.h +++ b/libraries/lib-utility/Observer.h @@ -84,7 +84,7 @@ class UTILITY_API Subscription { (Publisher was destroyed, or this was not reassigned since it was last Reset(), default-constructed, or moved from) */ - bool Expired() const { return m_wRecord.expired(); } + [[nodiscard]] bool Expired() const { return m_wRecord.expired(); } //! @return not expired explicit operator bool() const { return !Expired(); } diff --git a/libraries/lib-xml/XMLFileReader.cpp b/libraries/lib-xml/XMLFileReader.cpp index 484d2fabe0..034732c471 100644 --- a/libraries/lib-xml/XMLFileReader.cpp +++ b/libraries/lib-xml/XMLFileReader.cpp @@ -20,17 +20,17 @@ #include #include -#include +#include #include "expat.h" XMLFileReader::XMLFileReader() { - mParser = XML_ParserCreate(NULL); + mParser = XML_ParserCreate(nullptr); XML_SetUserData(mParser, (void *)this); XML_SetElementHandler(mParser, startElement, endElement); XML_SetCharacterDataHandler(mParser, charHandler); - mBaseHandler = NULL; + mBaseHandler = nullptr; mHandler.reserve(128); } @@ -189,7 +189,7 @@ const TranslatableString &XMLFileReader::GetLibraryErrorStr() const void XMLFileReader::startElement(void *userData, const char *name, const char **atts) { - XMLFileReader *This = (XMLFileReader *)userData; + auto *This = (XMLFileReader *)userData; Handlers &handlers = This->mHandler; if (handlers.empty()) { @@ -199,7 +199,7 @@ void XMLFileReader::startElement(void *userData, const char *name, if (XMLTagHandler *const handler = handlers.back()) handlers.push_back(handler->ReadXMLChild(name)); else - handlers.push_back(NULL); + handlers.push_back(nullptr); } if (XMLTagHandler *& handler = handlers.back()) { @@ -214,7 +214,7 @@ void XMLFileReader::startElement(void *userData, const char *name, // static void XMLFileReader::endElement(void *userData, const char *name) { - XMLFileReader *This = (XMLFileReader *)userData; + auto *This = (XMLFileReader *)userData; Handlers &handlers = This->mHandler; if (XMLTagHandler *const handler = handlers.back()) @@ -226,7 +226,7 @@ void XMLFileReader::endElement(void *userData, const char *name) // static void XMLFileReader::charHandler(void *userData, const char *s, int len) { - XMLFileReader *This = (XMLFileReader *)userData; + auto *This = (XMLFileReader *)userData; Handlers &handlers = This->mHandler; if (XMLTagHandler *const handler = handlers.back()) diff --git a/libraries/lib-xml/XMLFileReader.h b/libraries/lib-xml/XMLFileReader.h index 185d11d612..7c0edc760b 100644 --- a/libraries/lib-xml/XMLFileReader.h +++ b/libraries/lib-xml/XMLFileReader.h @@ -27,8 +27,8 @@ class XML_API XMLFileReader final { bool ParseString(XMLTagHandler *baseHandler, const wxString &xmldata); - const TranslatableString &GetErrorStr() const; - const TranslatableString &GetLibraryErrorStr() const; + [[nodiscard]] const TranslatableString &GetErrorStr() const; + [[nodiscard]] const TranslatableString &GetLibraryErrorStr() const; // Callback functions for expat diff --git a/libraries/lib-xml/XMLFileWriter.cpp b/libraries/lib-xml/XMLFileWriter.cpp index 914b3883c3..5bfd823112 100644 --- a/libraries/lib-xml/XMLFileWriter.cpp +++ b/libraries/lib-xml/XMLFileWriter.cpp @@ -9,10 +9,12 @@ **********************************************************************/ #include "XMLFileWriter.h" +#include + XMLFileWriter::XMLFileWriter( - const FilePath &outputPath, const TranslatableString &caption, bool keepBackup ) + const FilePath &outputPath, TranslatableString caption, bool keepBackup ) : mOutputPath{ outputPath } - , mCaption{ caption } + , mCaption{std::move( caption )} , mKeepBackup{ keepBackup } // may throw { @@ -65,7 +67,7 @@ void XMLFileWriter::Commit() void XMLFileWriter::PreCommit() // may throw { - while (mTagstack.size()) { + while (!mTagstack.empty()) { EndTag(mTagstack[0]); } diff --git a/libraries/lib-xml/XMLFileWriter.h b/libraries/lib-xml/XMLFileWriter.h index b4a3f9c85f..72dadaf871 100644 --- a/libraries/lib-xml/XMLFileWriter.h +++ b/libraries/lib-xml/XMLFileWriter.h @@ -29,10 +29,10 @@ class XML_API XMLFileWriter final : private wxFFile, public XMLWriter /// The caption is for message boxes to show in case of errors. /// Might throw. XMLFileWriter( - const FilePath &outputPath, const TranslatableString &caption, + const FilePath &outputPath, TranslatableString caption, bool keepBackup = false ); - virtual ~XMLFileWriter(); + ~XMLFileWriter() override; /// Close all tags and then close the file. /// Might throw. If not, then create @@ -50,10 +50,10 @@ class XML_API XMLFileWriter final : private wxFFile, public XMLWriter /// Write to file. Might throw. void Write(const wxString &data) override; - FilePath GetBackupName() const { return mBackupName; } + [[nodiscard]] FilePath GetBackupName() const { return mBackupName; } private: - void ThrowException( + static void ThrowException( const wxFileName &fileName, const TranslatableString &caption) { throw FileException{ FileException::Cause::Write, fileName, caption }; diff --git a/libraries/lib-xml/XMLStringWriter.h b/libraries/lib-xml/XMLStringWriter.h index 1034ec23bd..30a871d111 100644 --- a/libraries/lib-xml/XMLStringWriter.h +++ b/libraries/lib-xml/XMLStringWriter.h @@ -18,7 +18,7 @@ class XML_API XMLStringWriter final : public wxString, public XMLWriter { public: XMLStringWriter(size_t initialSize = 0); - virtual ~XMLStringWriter(); + ~XMLStringWriter() override; void Write(const wxString &data) override; }; diff --git a/libraries/lib-xml/XMLTagHandler.h b/libraries/lib-xml/XMLTagHandler.h index b84dd5d9f7..03dcdb1e53 100644 --- a/libraries/lib-xml/XMLTagHandler.h +++ b/libraries/lib-xml/XMLTagHandler.h @@ -20,7 +20,7 @@ -#include +#include #include "Identifier.h" @@ -69,11 +69,11 @@ class XML_API XMLValueChecker RightChannel = 1, MonoChannel = 2 }; - static bool IsValidChannel(const int nValue); + static bool IsValidChannel(int nValue); #ifdef USE_MIDI static bool IsValidVisibleChannels(const int nValue); #endif - static bool IsValidSampleFormat(const int nValue); // true if nValue is one sampleFormat enum values + static bool IsValidSampleFormat(int nValue); // true if nValue is one sampleFormat enum values }; diff --git a/libraries/lib-xml/XMLWriter.cpp b/libraries/lib-xml/XMLWriter.cpp index 9d9cc63c16..b1418a41db 100644 --- a/libraries/lib-xml/XMLWriter.cpp +++ b/libraries/lib-xml/XMLWriter.cpp @@ -20,7 +20,7 @@ the general functionality for creating XML in UTF8 encoding. #include #include -#include +#include //table for xml encoding compatibility with expat decoding //see wxWidgets-2.8.12/src/expat/lib/xmltok_impl.h @@ -91,7 +91,7 @@ void XMLWriter::EndTag(const wxString &name) { int i; - if (mTagstack.size() > 0) { + if (!mTagstack.empty()) { if (mTagstack[0] == name) { if (mHasKids[1]) { // There will always be at least 2 at this point if (mInTag) { diff --git a/libraries/lib-xml/XMLWriter.h b/libraries/lib-xml/XMLWriter.h index 81340dcc6b..c3d917d43a 100644 --- a/libraries/lib-xml/XMLWriter.h +++ b/libraries/lib-xml/XMLWriter.h @@ -55,7 +55,7 @@ class XML_API XMLWriter /* not final */ { // Escape a string, replacing certain characters with their // XML encoding, i.e. '<' becomes '<' - wxString XMLEsc(const wxString & s); + static wxString XMLEsc(const wxString & s); protected: diff --git a/modules/mod-null/ModNullCallback.cpp b/modules/mod-null/ModNullCallback.cpp index b19e185d52..00b6e4f65e 100644 --- a/modules/mod-null/ModNullCallback.cpp +++ b/modules/mod-null/ModNullCallback.cpp @@ -47,16 +47,16 @@ class ModNullCallback : public wxFrame void OnFuncSecond(const CommandContext &); }; -void ModNullCallback::OnFuncFirst(const CommandContext &) +static void ModNullCallback::OnFuncFirst(const CommandContext &) { int k=32; } -void ModNullCallback::OnFuncSecond(const CommandContext &) +static void ModNullCallback::OnFuncSecond(const CommandContext &) { int k=42; } -ModNullCallback * pModNullCallback=NULL; +ModNullCallback * pModNullCallback=nullptr; #define ModNullFN(X) static_cast((&ModNullCallback:: X)) diff --git a/modules/mod-nyq-bench/NyqBench.cpp b/modules/mod-nyq-bench/NyqBench.cpp index 90085852fd..27294671ac 100644 --- a/modules/mod-nyq-bench/NyqBench.cpp +++ b/modules/mod-nyq-bench/NyqBench.cpp @@ -646,7 +646,7 @@ END_EVENT_TABLE() } NyqBench::NyqBench(wxWindow * parent) -: wxFrame(NULL, +: wxFrame(nullptr, wxID_ANY, wxEmptyString, wxDefaultPosition, @@ -656,12 +656,12 @@ NyqBench::NyqBench(wxWindow * parent) wxMAXIMIZE_BOX | wxRESIZE_BORDER) { - mFindDlg = NULL; + mFindDlg = nullptr; mRunning = false; - mScriptBox = NULL; - mOutputBox = NULL; - mScript = NULL; - mOutput = NULL; + mScriptBox = nullptr; + mOutputBox = nullptr; + mScript = nullptr; + mOutput = nullptr; mPath = gPrefs->Read(wxT("NyqBench/Path"), wxEmptyString); mAutoLoad = (gPrefs->Read(wxT("NyqBench/AutoLoad"), 0L) != 0); @@ -675,9 +675,9 @@ NyqBench::NyqBench(wxWindow * parent) SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); ShuttleGui S(this, eIsCreating); PopulateOrExchange(S); - wxMenuBar *bar = new wxMenuBar(); + auto *bar = new wxMenuBar(); - wxMenu *menu = new wxMenu(); + auto *menu = new wxMenu(); menu->Append(wxID_NEW, wxT("&New\tCtrl+N")); menu->Append(wxID_OPEN, wxT("&Open...\tCtrl+O")); menu->Append(wxID_SAVE, wxT("&Save...\tCtrl+S")); @@ -703,7 +703,7 @@ NyqBench::NyqBench(wxWindow * parent) menu->AppendSeparator(); menu->Append(wxID_FIND, _("&Find...\tCtrl+F")); menu->AppendSeparator(); - wxMenu *sub = new wxMenu(); + auto *sub = new wxMenu(); sub->Append(ID_MATCH, _("&Matching Paren\tF8")); sub->Append(ID_TOP, _("&Top S-expr\tF9")); sub->Append(ID_UP, _("&Higher S-expr\tF10")); @@ -941,8 +941,6 @@ void NyqBench::PopulateOrExchange(ShuttleGui & S) S.EndHorizontalLay(); S.AddSpace(1, 5); - - return; } void NyqBench::OnClose(wxCloseEvent & e) @@ -1129,10 +1127,10 @@ void NyqBench::OnFind(wxCommandEvent & e) { if (mFindDlg ) { delete mFindDlg; - mFindDlg = NULL; + mFindDlg = nullptr; } else { - NyqTextCtrl *w = (NyqTextCtrl *) FindFocus(); + auto *w = (NyqTextCtrl *) FindFocus(); if (w == mScript || w == mOutput) { mFindText = w; @@ -1393,8 +1391,8 @@ void NyqBench::OnFindDialog(wxFindDialogEvent & e) gPrefs->Write(wxT("NyqBench/Find/Word"), (flags & wxFR_WHOLEWORD) != 0); gPrefs->Write(wxT("NyqBench/Find/Case"), (flags & wxFR_MATCHCASE) != 0); - mFindDlg = NULL; - mFindText = NULL; + mFindDlg = nullptr; + mFindText = nullptr; return; } diff --git a/modules/mod-nyq-bench/NyqBench.h b/modules/mod-nyq-bench/NyqBench.h index 30a99c9348..38195c2768 100644 --- a/modules/mod-nyq-bench/NyqBench.h +++ b/modules/mod-nyq-bench/NyqBench.h @@ -80,9 +80,9 @@ class NyqRedirector:wxSTD streambuf { public: NyqRedirector(NyqTextCtrl *text); - virtual ~NyqRedirector(); + ~NyqRedirector() override; - int overflow(int c); + int overflow(int c) override; private: void AppendText(); @@ -100,9 +100,9 @@ class NyqBench:public wxFrame { public: NyqBench(wxWindow *parent); - virtual ~NyqBench(); + ~NyqBench() override; - virtual bool Validate(); + bool Validate() override; void ShowNyqBench(const CommandContext&); @@ -150,11 +150,11 @@ class NyqBench:public wxFrame void OnGo(wxCommandEvent & e); void OnStop(wxCommandEvent & e); - void OnAbout(wxCommandEvent & e); + static void OnAbout(wxCommandEvent & e); void OnFindDialog(wxFindDialogEvent & e); - void OnTextUpdate(wxCommandEvent & e); + static void OnTextUpdate(wxCommandEvent & e); void OnMenuUpdate(wxUpdateUIEvent & e); diff --git a/modules/mod-script-pipe/PipeServer.cpp b/modules/mod-script-pipe/PipeServer.cpp index 4d3066f39d..f46b2f09fa 100644 --- a/modules/mod-script-pipe/PipeServer.cpp +++ b/modules/mod-script-pipe/PipeServer.cpp @@ -110,9 +110,9 @@ void PipeServer() #include #include -#include +#include #include -#include +#include const char fifotmpl[] = "/tmp/audacity_script_pipe.%s.%d"; @@ -123,8 +123,8 @@ extern "C" int DoSrvMore( char * pOut, size_t nMax ); void PipeServer() { - FILE *fromFifo = NULL; - FILE *toFifo = NULL; + FILE *fromFifo = nullptr; + FILE *toFifo = nullptr; int rc; char buf[nBuff]; char toFifoName[nBuff]; @@ -148,23 +148,23 @@ void PipeServer() // open to (incoming) pipe first. toFifo = fopen(toFifoName, "r"); - if (toFifo == NULL) + if (toFifo == nullptr) { perror("Unable to open fifo to server from script"); - if (fromFifo != NULL) + if (fromFifo != nullptr) fclose(fromFifo); return; } // open from (outgoing) pipe second. This could block if there is no reader. fromFifo = fopen(fromFifoName, "w"); - if (fromFifo == NULL) + if (fromFifo == nullptr) { perror("Unable to open fifo from server to script"); return; } - while (fgets(buf, sizeof(buf), toFifo) != NULL) + while (fgets(buf, sizeof(buf), toFifo) != nullptr) { int len = strlen(buf); if (len <= 1) @@ -194,10 +194,10 @@ void PipeServer() printf("Read failed on fifo, quitting\n"); - if (toFifo != NULL) + if (toFifo != nullptr) fclose(toFifo); - if (fromFifo != NULL) + if (fromFifo != nullptr) fclose(fromFifo); unlink(toFifoName); diff --git a/modules/mod-script-pipe/ScripterCallback.cpp b/modules/mod-script-pipe/ScripterCallback.cpp index b6be0a692f..1082f7c75a 100644 --- a/modules/mod-script-pipe/ScripterCallback.cpp +++ b/modules/mod-script-pipe/ScripterCallback.cpp @@ -26,7 +26,7 @@ See the example in this file. It has several cases/options in it. extern void PipeServer(); typedef DLL_IMPORT int (*tpExecScriptServerFunc)( wxString * pIn, wxString * pOut); -static tpExecScriptServerFunc pScriptServerFn=NULL; +static tpExecScriptServerFunc pScriptServerFn=nullptr; extern "C" { diff --git a/src/AColor.cpp b/src/AColor.cpp index e0367dfec3..6a2a1de183 100644 --- a/src/AColor.cpp +++ b/src/AColor.cpp @@ -443,13 +443,13 @@ void AColor::Solo(wxDC * dc, bool on, bool selected) } } -bool AColor::gradient_inited = 0; +bool AColor::gradient_inited = false; void AColor::ReInit() { inited=false; Init(); - gradient_inited=0; + gradient_inited=false; PreComputeGradient(); } @@ -641,7 +641,7 @@ unsigned char AColor::gradient_pre[ColorGradientTotal][colorSchemes][gradientSte void AColor::PreComputeGradient() { if (gradient_inited) return; - gradient_inited = 1; + gradient_inited = true; // Keep in correspondence with enum SpectrogramSettings::ColorScheme diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index 7ec9936d7f..ff0fcca43b 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -327,7 +327,7 @@ AboutDialog::AboutDialog(wxWindow * parent) sActiveInstance = this; SetName(); - icon = NULL; + icon = nullptr; ShuttleGui S( this, eIsCreating ); S.StartNotebook(); { @@ -1132,7 +1132,7 @@ void AboutDialog::AddCredit( const wxString &name, Role role ) } void AboutDialog::AddCredit( - const wxString &name, TranslatableString format, Role role ) + const wxString &name, const TranslatableString& format, Role role ) { auto str = format.empty() ? Verbatim( name ) diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 86cfbb5332..c44f275bda 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -33,8 +33,8 @@ class SAUCEDACITY_DLL_API AboutDialog final : public wxDialogWrapper { DECLARE_DYNAMIC_CLASS(AboutDialog) public: - AboutDialog(wxWindow * parent); - virtual ~ AboutDialog(); + explicit AboutDialog(wxWindow * parent); + ~ AboutDialog() override; static AboutDialog *ActiveInstance(); @@ -70,17 +70,17 @@ class SAUCEDACITY_DLL_API AboutDialog final : public wxDialogWrapper { AboutDialogCreditItemsList creditItems; void PopulateAudacityPage( ShuttleGui & S ); - void PopulateLicensePage( ShuttleGui & S ); + static void PopulateLicensePage( ShuttleGui & S ); void PopulateInformationPage (ShuttleGui & S ); void CreateCreditsList(); void AddCredit( const wxString &name, Role role ); - void AddCredit( const wxString &name, TranslatableString format, Role role ); + void AddCredit( const wxString &name, const TranslatableString& format, Role role ); wxString GetCreditsByRole(AboutDialog::Role role); - void AddBuildinfoRow( wxTextOutputStream *str, const wxChar * libname, + static void AddBuildinfoRow( wxTextOutputStream *str, const wxChar * libname, const TranslatableString &libdesc, const TranslatableString &status); - void AddBuildinfoRow( wxTextOutputStream *str, + static void AddBuildinfoRow( wxTextOutputStream *str, const TranslatableString &description, const wxChar *spec); }; #endif diff --git a/src/AdornedRulerPanel.cpp b/src/AdornedRulerPanel.cpp index 1ebd4d358f..777d270236 100644 --- a/src/AdornedRulerPanel.cpp +++ b/src/AdornedRulerPanel.cpp @@ -125,7 +125,7 @@ class QuickPlayIndicatorOverlay; class AdornedRulerPanel::QuickPlayRulerOverlay final : public Overlay { public: - QuickPlayRulerOverlay(QuickPlayIndicatorOverlay &partner); + explicit QuickPlayRulerOverlay(QuickPlayIndicatorOverlay &partner); // Available to this and to partner @@ -139,9 +139,9 @@ class AdornedRulerPanel::QuickPlayRulerOverlay final : public Overlay void Update(); private: - AdornedRulerPanel *GetRuler() const; + [[nodiscard]] AdornedRulerPanel *GetRuler() const; - unsigned SequenceNumber() const override; + [[nodiscard]] unsigned SequenceNumber() const override; std::pair DoGetRectangle(wxSize size) override; void Draw(OverlayPanel &panel, wxDC &dc) override; @@ -169,10 +169,10 @@ class AdornedRulerPanel::QuickPlayIndicatorOverlay final : public Overlay friend AdornedRulerPanel; public: - QuickPlayIndicatorOverlay(SaucedacityProject *project); + explicit QuickPlayIndicatorOverlay(SaucedacityProject *project); private: - unsigned SequenceNumber() const override; + [[nodiscard]] unsigned SequenceNumber() const override; std::pair DoGetRectangle(wxSize size) override; void Draw(OverlayPanel &panel, wxDC &dc) override; @@ -451,7 +451,7 @@ class AdornedRulerPanel::CommonRulerHandle : public UIHandle , mChoice( menuChoice ) {} - bool Clicked() const { return mClicked != Button::None; } + [[nodiscard]] bool Clicked() const { return mClicked != Button::None; } static UIHandle::Result NeedChangeHighlight (const CommonRulerHandle &oldState, const CommonRulerHandle &newState) @@ -681,8 +681,8 @@ class AdornedRulerPanel::QPCell final : public CommonCell std::shared_ptr ContextMenuDelegate() override { return mParent->mQPCell; } - bool Hit() const { return !mHolder.expired(); } - bool Clicked() const { + [[nodiscard]] bool Hit() const { return !mHolder.expired(); } + [[nodiscard]] bool Clicked() const { if (auto ptr = mHolder.lock()) return ptr->Clicked(); return false; @@ -822,8 +822,8 @@ class AdornedRulerPanel::ScrubbingCell final : public CommonCell std::shared_ptr ContextMenuDelegate() override { return mParent->mScrubbingCell; } - bool Hit() const { return !mHolder.expired(); } - bool Clicked() const { + [[nodiscard]] bool Hit() const { return !mHolder.expired(); } + [[nodiscard]] bool Clicked() const { if (auto ptr = mHolder.lock()) return ptr->Clicked(); return false; @@ -961,8 +961,7 @@ AdornedRulerPanel::AdornedRulerPanel(SaucedacityProject* project, } AdornedRulerPanel::~AdornedRulerPanel() -{ -} += default; void AdornedRulerPanel::Refresh( bool eraseBackground, const wxRect *rect ) { @@ -1020,7 +1019,7 @@ void AdornedRulerPanel::ReCreateButtons() wxPoint position( 1, 0 ); - Grabber * pGrabber = safenew Grabber(this, this->GetId()); + auto * pGrabber = safenew Grabber(this, this->GetId()); pGrabber->SetAsSpacer( true ); //pGrabber->SetSize( 10, 27 ); // default is 10,27 pGrabber->SetPosition( position ); @@ -1794,7 +1793,7 @@ void AdornedRulerPanel::UpdateButtonStates() // The button always reflects the pinned head preference, even though // there is also a Playback preference that may overrule it for scrubbing bool state = TracksPrefs::GetPinnedHeadPreference(); - auto pinButton = static_cast(FindWindow(OnTogglePinnedStateID)); + auto pinButton = dynamic_cast(FindWindow(OnTogglePinnedStateID)); if( !state ) pinButton->PopUp(); else @@ -1811,7 +1810,7 @@ void AdornedRulerPanel::UpdateButtonStates() void AdornedRulerPanel::OnPinnedButton(wxCommandEvent & /*event*/) { - ShowContextMenu(MenuChoice::QuickPlay, NULL); + ShowContextMenu(MenuChoice::QuickPlay, nullptr); } void AdornedRulerPanel::OnTogglePinnedState(wxCommandEvent & /*event*/) @@ -1894,7 +1893,7 @@ void AdornedRulerPanel::OnSyncSelToQuickPlay(wxCommandEvent&) gPrefs->Flush(); } -void AdornedRulerPanel::DragSelection() +void AdornedRulerPanel::DragSelection() const { auto &viewInfo = ViewInfo::Get( *GetProject() ); const auto &playRegion = viewInfo.playRegion; @@ -1912,7 +1911,7 @@ void AdornedRulerPanel::HandleSnapping() pSnapManager = std::make_unique(*mProject, *mTracks, *mViewInfo); - auto results = pSnapManager->Snap(NULL, mQuickPlayPos, false); + auto results = pSnapManager->Snap(nullptr, mQuickPlayPos, false); mQuickPlayPos = results.outTime; mIsSnapped = results.Snapped(); } diff --git a/src/AdornedRulerPanel.h b/src/AdornedRulerPanel.h index a2643107fe..04326aa60d 100644 --- a/src/AdornedRulerPanel.h +++ b/src/AdornedRulerPanel.h @@ -38,12 +38,12 @@ class SAUCEDACITY_DLL_API AdornedRulerPanel final wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - ViewInfo *viewinfo = NULL); + ViewInfo *viewinfo = nullptr); - ~AdornedRulerPanel(); + ~AdornedRulerPanel() override; void Refresh - (bool eraseBackground = true, const wxRect *rect = (const wxRect *) NULL) + (bool eraseBackground = true, const wxRect *rect = (const wxRect *) nullptr) override; bool AcceptsFocus() const override { return s_AcceptsFocus; } @@ -51,7 +51,7 @@ class SAUCEDACITY_DLL_API AdornedRulerPanel final void SetFocusFromKbd() override; public: - int GetRulerHeight() { return GetRulerHeight( ShowingScrubRuler() ); } + int GetRulerHeight() const { return GetRulerHeight( ShowingScrubRuler() ); } static int GetRulerHeight(bool showScrubBar); wxRect GetInnerRect() const { return mInner; } @@ -154,7 +154,7 @@ class SAUCEDACITY_DLL_API AdornedRulerPanel final // void ShowMenu(const wxPoint & pos); void ShowScrubMenu(const wxPoint & pos); - void DragSelection(); + void DragSelection() const; void HandleSnapping(); void OnToggleQuickPlay(wxCommandEvent &evt); void OnSyncSelToQuickPlay(wxCommandEvent &evt); diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 93f896e918..72db9448b8 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -571,10 +571,10 @@ static PaTime util_GetTime( void ) #include -static PaTime util_GetTime( void ) +static PaTime util_GetTime( ) { struct timeval tv; - gettimeofday( &tv, NULL ); + gettimeofday( &tv, nullptr ); return (PaTime) tv.tv_usec * 1e-6 + tv.tv_sec; } @@ -585,7 +585,7 @@ using std::min; AudioIO *AudioIO::Get() { - return static_cast< AudioIO* >( AudioIOBase::Get() ); + return dynamic_cast< AudioIO* >( AudioIOBase::Get() ); } wxDEFINE_EVENT(EVT_AUDIOIO_PLAYBACK, wxCommandEvent); @@ -1048,7 +1048,7 @@ AudioIO::AudioIO() mAudioThreadShouldCallFillBuffersOnce = false; mAudioThreadFillBuffersLoopRunning = false; mAudioThreadFillBuffersLoopActive = false; - mPortStreamV19 = NULL; + mPortStreamV19 = nullptr; #ifdef EXPERIMENTAL_MIDI_OUT mMidiStream = NULL; @@ -1074,7 +1074,7 @@ AudioIO::AudioIO() mUpdateMeters = false; mUpdatingMeters = false; - mOwningProject = NULL; + mOwningProject = nullptr; mOutputMeter.Release(); PaError err = Pa_Initialize(); @@ -1118,7 +1118,7 @@ AudioIO::AudioIO() mLastPlaybackTimeMillis = 0; #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT - mScrubState = NULL; + mScrubState = nullptr; mScrubDuration = 0; mSilentScrub = false; #endif @@ -1238,12 +1238,12 @@ bool AudioIO::StartPortAudioStream(const AudioIOStartStreamOptions &options, const PaDeviceInfo *playbackDeviceInfo; playbackDeviceInfo = Pa_GetDeviceInfo( playbackParameters.device ); - if( playbackDeviceInfo == NULL ) + if( playbackDeviceInfo == nullptr ) return false; // regardless of source formats, we always mix to float playbackParameters.sampleFormat = paFloat32; - playbackParameters.hostApiSpecificStreamInfo = NULL; + playbackParameters.hostApiSpecificStreamInfo = nullptr; playbackParameters.channelCount = mNumPlaybackChannels; if (mSoftwarePlaythrough) @@ -1278,13 +1278,13 @@ bool AudioIO::StartPortAudioStream(const AudioIOStartStreamOptions &options, captureDeviceInfo = Pa_GetDeviceInfo( captureParameters.device ); - if( captureDeviceInfo == NULL ) + if( captureDeviceInfo == nullptr ) return false; captureParameters.sampleFormat = AudacityToPortAudioSampleFormat(mCaptureFormat); - captureParameters.hostApiSpecificStreamInfo = NULL; + captureParameters.hostApiSpecificStreamInfo = nullptr; captureParameters.channelCount = mNumCaptureChannels; if (mSoftwarePlaythrough) @@ -1301,7 +1301,7 @@ bool AudioIO::StartPortAudioStream(const AudioIOStartStreamOptions &options, // July 2016 (Carsten and Uwe) // BUG 193: Possibly tell portAudio to use 24 bit with DirectSound. int userData = 24; - int* lpUserData = (captureFormat_saved == int24Sample) ? &userData : NULL; + int* lpUserData = (captureFormat_saved == int24Sample) ? &userData : nullptr; // (Linux, bug 1885) After scanning devices it takes a little time for the // ALSA device to be available, so allow retries. @@ -1314,8 +1314,8 @@ bool AudioIO::StartPortAudioStream(const AudioIOStartStreamOptions &options, for (unsigned int tries = 0; tries < maxTries; tries++) { mLastPaError = Pa_OpenStream( &mPortStreamV19, - useCapture ? &captureParameters : NULL, - usePlayback ? &playbackParameters : NULL, + useCapture ? &captureParameters : nullptr, + usePlayback ? &playbackParameters : nullptr, mRate, paFramesPerBufferUnspecified, paNoFlag, audacityAudioCallback, lpUserData ); @@ -1520,7 +1520,7 @@ int AudioIO::StartStream(const TransportTracks &tracks, auto pListener = GetListener(); - if (tracks.playbackTracks.size() > 0 + if (!tracks.playbackTracks.empty() #ifdef EXPERIMENTAL_MIDI_OUT || tracks.midiTracks.size() > 0 #endif @@ -1530,7 +1530,7 @@ int AudioIO::StartStream(const TransportTracks &tracks, if (mSoftwarePlaythrough) playbackChannels = 2; - if (tracks.captureTracks.size() > 0) + if (!tracks.captureTracks.empty()) { // For capture, every input channel gets its own track captureChannels = mCaptureTracks.size(); @@ -1768,7 +1768,7 @@ void AudioIO::CallAfterRecording(PostRecordingAction action) // Don't delay it except until idle time. // (Recording might start between now and then, but won't go far before // the action is done. So the system isn't bulletproof yet.) - wxTheApp->CallAfter(std::move(action)); + wxTheApp->CallAfter(action); } bool AudioIO::AllocateBuffers( @@ -1975,7 +1975,7 @@ void AudioIO::StartStreamCleanup(bool bOnlyBuffers) { Pa_AbortStream( mPortStreamV19 ); Pa_CloseStream( mPortStreamV19 ); - mPortStreamV19 = NULL; + mPortStreamV19 = nullptr; mStreamToken = 0; } @@ -2089,7 +2089,7 @@ bool AudioIoCallback::StartPortMidiStream() bool AudioIO::IsAvailable(SaucedacityProject *project) const { - return mOwningProject == NULL || mOwningProject == project; + return mOwningProject == nullptr || mOwningProject == project; } void AudioIO::SetMeters() @@ -2109,7 +2109,7 @@ void AudioIO::StopStream() mRecordingSchedule.mCrossfadeData.clear(); // free arrays } ); - if( mPortStreamV19 == NULL + if( mPortStreamV19 == nullptr #ifdef EXPERIMENTAL_MIDI_OUT && mMidiStream == NULL #endif @@ -2191,7 +2191,7 @@ void AudioIO::StopStream() if (mPortStreamV19) { Pa_AbortStream( mPortStreamV19 ); Pa_CloseStream( mPortStreamV19 ); - mPortStreamV19 = NULL; + mPortStreamV19 = nullptr; } #ifdef EXPERIMENTAL_MIDI_OUT @@ -2264,7 +2264,7 @@ void AudioIO::StopStream() // we allocated in StartStream() // - if (mPlaybackTracks.size() > 0) + if (!mPlaybackTracks.empty()) { mPlaybackBuffers.reset(); mPlaybackMixers.reset(); @@ -2274,7 +2274,7 @@ void AudioIO::StopStream() // // Offset all recorded tracks to account for latency // - if (mCaptureTracks.size() > 0) + if (!mCaptureTracks.empty()) { mCaptureBuffers.reset(); mResample.reset(); @@ -2287,7 +2287,7 @@ void AudioIO::StopStream() // first track in a project. // - for (unsigned int i = 0; i < mCaptureTracks.size(); i++) { + for (auto & mCaptureTrack : mCaptureTracks) { // The calls to Flush // may cause exceptions because of exhaustion of disk space. // Stop those exceptions here, or else they propagate through too @@ -2299,7 +2299,7 @@ void AudioIO::StopStream() // state, though the append buffer may be lost. GuardedCall( [&] { - WaveTrack* track = mCaptureTracks[i].get(); + WaveTrack* track = mCaptureTrack.get(); // use No-fail-guarantee that track is flushed, // Partial-guarantee that some initial length of the recording @@ -2661,7 +2661,7 @@ void AudioIO::FillBuffers() DefaultDelayedHandlerAction{}( pException ); }; - if (mPlaybackTracks.size() > 0) + if (!mPlaybackTracks.empty()) { // Though extremely unlikely, it is possible that some buffers // will have more samples available than others. This could happen @@ -2851,7 +2851,7 @@ void AudioIO::FillBuffers() } // end of playback buffering if (!mRecordingException && - mCaptureTracks.size() > 0) + !mCaptureTracks.empty()) GuardedCall( [&] { // start record buffering const auto avail = GetCommonlyAvailCapture(); // samples @@ -3602,7 +3602,7 @@ bool AudioIoCallback::FillOutputBuffers( if(numPlaybackChannels <= 0) return false; - float *outputFloats = (float *)outputBuffer; + auto *outputFloats = (float *)outputBuffer; #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT // While scrubbing, ignore seek requests @@ -3893,7 +3893,7 @@ void AudioIoCallback::FillInputBuffers( switch(mCaptureFormat) { case floatSample: { - float *inputFloats = (float *)inputBuffer; + auto *inputFloats = (float *)inputBuffer; for(unsigned i = 0; i < len; i++) tempFloats[i] = inputFloats[numCaptureChannels*i+t]; @@ -3906,8 +3906,8 @@ void AudioIoCallback::FillInputBuffers( wxASSERT(false); break; case int16Sample: { - short *inputShorts = (short *)inputBuffer; - short *tempShorts = (short *)tempFloats; + auto *inputShorts = (short *)inputBuffer; + auto *tempShorts = (short *)tempFloats; for( unsigned i = 0; i < len; i++) { float tmp = inputShorts[numCaptureChannels*i+t]; tmp = wxClip( -32768, tmp, 32767 ); @@ -3977,7 +3977,7 @@ void AudioIoCallback::DoPlaythrough( if( numPlaybackChannels <= 0 ) return; - float *outputFloats = (float *)outputBuffer; + auto *outputFloats = (float *)outputBuffer; for(unsigned i = 0; i < framesPerBuffer*numPlaybackChannels; i++) outputFloats[i] = 0.0; @@ -4175,7 +4175,7 @@ int AudioIoCallback::AudioCallback(const void *inputBuffer, void *outputBuffer, new float[framesPerBuffer * std::max(numCaptureChannels, numPlaybackChannels)] ); - float* outputMeterFloats = static_cast(outputBuffer); + auto* outputMeterFloats = static_cast(outputBuffer); // ----- END of MEMORY ALLOCATIONS ------------------------------------------ if (inputBuffer && numCaptureChannels) { diff --git a/src/AudioIO.h b/src/AudioIO.h index ef6fe5a6a3..0521f3aa92 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -132,7 +132,7 @@ class SAUCEDACITY_DLL_API AudioIoCallback /* not final */ { public: AudioIoCallback(); - ~AudioIoCallback(); + ~AudioIoCallback() override; public: // This function executes in a thread spawned by the PortAudio library @@ -140,7 +140,7 @@ class SAUCEDACITY_DLL_API AudioIoCallback /* not final */ const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, - const PaStreamCallbackFlags statusFlags, void *userData); + PaStreamCallbackFlags statusFlags, void *userData); #ifdef EXPERIMENTAL_MIDI_OUT void PrepareMidiIterator(bool send = true, double offset = 0); @@ -178,7 +178,7 @@ class SAUCEDACITY_DLL_API AudioIoCallback /* not final */ bool GetHasSolo() { return mHasSolo; } #endif - std::shared_ptr< AudioIOListener > GetListener() const + [[nodiscard]] std::shared_ptr< AudioIOListener > GetListener() const { return mListener.lock(); } void SetListener( const std::shared_ptr< AudioIOListener > &listener); @@ -220,7 +220,7 @@ class SAUCEDACITY_DLL_API AudioIoCallback /* not final */ void FillInputBuffers( const void *inputBuffer, unsigned long framesPerBuffer, - const PaStreamCallbackFlags statusFlags, + PaStreamCallbackFlags statusFlags, float * tempFloats ); void UpdateTimePosition( @@ -464,7 +464,7 @@ class SAUCEDACITY_DLL_API AudioIO final { AudioIO(); - ~AudioIO(); + ~AudioIO() override; public: // This might return null during application startup or shutdown @@ -507,7 +507,7 @@ class SAUCEDACITY_DLL_API AudioIO final void CallAfterRecording(PostRecordingAction action); #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT - bool IsScrubbing() const { return IsBusy() && mScrubState != 0; } + [[nodiscard]] bool IsScrubbing() const { return IsBusy() && mScrubState != nullptr; } /** \brief Notify scrubbing engine of desired position or speed. * If options.adjustStart is true, then when mouse movement exceeds maximum @@ -520,24 +520,24 @@ class SAUCEDACITY_DLL_API AudioIO final /** \brief return the ending time of the last scrub interval. */ - double GetLastScrubTime() const; + [[nodiscard]] double GetLastScrubTime() const; #endif public: std::string LastPaErrorString(); - wxLongLong GetLastPlaybackTime() const { return mLastPlaybackTimeMillis; } - SaucedacityProject *GetOwningProject() const { return mOwningProject; } + [[nodiscard]] wxLongLong GetLastPlaybackTime() const { return mLastPlaybackTimeMillis; } + [[nodiscard]] SaucedacityProject *GetOwningProject() const { return mOwningProject; } /** \brief Pause and un-pause playback and recording */ void SetPaused(bool state); sampleFormat GetCaptureFormat() { return mCaptureFormat; } - unsigned GetNumPlaybackChannels() const { return mNumPlaybackChannels; } - unsigned GetNumCaptureChannels() const { return mNumCaptureChannels; } + [[nodiscard]] unsigned GetNumPlaybackChannels() const { return mNumPlaybackChannels; } + [[nodiscard]] unsigned GetNumCaptureChannels() const { return mNumCaptureChannels; } // Meaning really capturing, not just pre-rolling - bool IsCapturing() const; + [[nodiscard]] bool IsCapturing() const; /** \brief Ensure selected device names are valid * @@ -585,7 +585,7 @@ class SAUCEDACITY_DLL_API AudioIO final private: - bool DelayingActions() const; + [[nodiscard]] bool DelayingActions() const; /** \brief Set the current VU meters - this should be done once after * each call to StartStream currently */ diff --git a/src/AudioIOBase.cpp b/src/AudioIOBase.cpp index d94789a0ae..56061b2ede 100644 --- a/src/AudioIOBase.cpp +++ b/src/AudioIOBase.cpp @@ -211,7 +211,7 @@ std::vector AudioIOBase::GetSupportedPlaybackRates(int devIndex, double ra std::vector supported; int irate = (int)rate; - const PaDeviceInfo* devInfo = NULL; + const PaDeviceInfo* devInfo = nullptr; int i; devInfo = Pa_GetDeviceInfo(devIndex); @@ -233,7 +233,7 @@ std::vector AudioIOBase::GetSupportedPlaybackRates(int devIndex, double ra pars.channelCount = 1; pars.sampleFormat = paFloat32; pars.suggestedLatency = devInfo->defaultHighOutputLatency; - pars.hostApiSpecificStreamInfo = NULL; + pars.hostApiSpecificStreamInfo = nullptr; // JKC: PortAudio Errors handled OK here. No need to report them for (i = 0; i < NumRatesToTry; i++) @@ -241,7 +241,7 @@ std::vector AudioIOBase::GetSupportedPlaybackRates(int devIndex, double ra // LLL: Remove when a proper method of determining actual supported // DirectSound rate is devised. if (!(isDirectSound && RatesToTry[i] > 200000)){ - if (Pa_IsFormatSupported(NULL, &pars, RatesToTry[i]) == 0) + if (Pa_IsFormatSupported(nullptr, &pars, RatesToTry[i]) == 0) supported.push_back(RatesToTry[i]); Pa_Sleep( 10 );// There are ALSA drivers that don't like being probed // too quickly. @@ -253,7 +253,7 @@ std::vector AudioIOBase::GetSupportedPlaybackRates(int devIndex, double ra // LLL: Remove when a proper method of determining actual supported // DirectSound rate is devised. if (!(isDirectSound && RatesToTry[i] > 200000)) - if (Pa_IsFormatSupported(NULL, &pars, irate) == 0) + if (Pa_IsFormatSupported(nullptr, &pars, irate) == 0) supported.push_back(irate); } @@ -276,7 +276,7 @@ std::vector AudioIOBase::GetSupportedCaptureRates(int devIndex, double rat std::vector supported; int irate = (int)rate; - const PaDeviceInfo* devInfo = NULL; + const PaDeviceInfo* devInfo = nullptr; int i; devInfo = Pa_GetDeviceInfo(devIndex); @@ -302,7 +302,7 @@ std::vector AudioIOBase::GetSupportedCaptureRates(int devIndex, double rat pars.channelCount = recordChannels; pars.sampleFormat = paFloat32; pars.suggestedLatency = latencyDuration / 1000.0; - pars.hostApiSpecificStreamInfo = NULL; + pars.hostApiSpecificStreamInfo = nullptr; for (i = 0; i < NumRatesToTry; i++) { @@ -310,7 +310,7 @@ std::vector AudioIOBase::GetSupportedCaptureRates(int devIndex, double rat // DirectSound rate is devised. if (!(isDirectSound && RatesToTry[i] > 200000)) { - if (Pa_IsFormatSupported(&pars, NULL, RatesToTry[i]) == 0) + if (Pa_IsFormatSupported(&pars, nullptr, RatesToTry[i]) == 0) supported.push_back(RatesToTry[i]); Pa_Sleep( 10 );// There are ALSA drivers that don't like being probed // too quickly. @@ -322,7 +322,7 @@ std::vector AudioIOBase::GetSupportedCaptureRates(int devIndex, double rat // LLL: Remove when a proper method of determining actual supported // DirectSound rate is devised. if (!(isDirectSound && RatesToTry[i] > 200000)) - if (Pa_IsFormatSupported(&pars, NULL, irate) == 0) + if (Pa_IsFormatSupported(&pars, nullptr, irate) == 0) supported.push_back(irate); } @@ -565,8 +565,8 @@ wxString AudioIOBase::GetDeviceInfo() /* i18n-hint: Supported, meaning made available by the system */ s << XO("Supported Rates:\n"); - for (int k = 0; k < (int) rates.size(); k++) { - s << wxT(" ") << (int)rates[k] << wxT("\n"); + for (long rate : rates) { + s << wxT(" ") << (int)rate << wxT("\n"); } if (name == playDevice && info->maxOutputChannels > 0) @@ -605,8 +605,8 @@ wxString AudioIOBase::GetDeviceInfo() supportedSampleRates = GetSupportedSampleRates(playDeviceNum, recDeviceNum); s << XO("Supported Rates:\n"); - for (int k = 0; k < (int) supportedSampleRates.size(); k++) { - s << wxT(" ") << (int)supportedSampleRates[k] << wxT("\n"); + for (long supportedSampleRate : supportedSampleRates) { + s << wxT(" ") << (int)supportedSampleRate << wxT("\n"); } } else { diff --git a/src/AudioIOBase.h b/src/AudioIOBase.h index 6e6630689b..40ea7b44ce 100644 --- a/src/AudioIOBase.h +++ b/src/AudioIOBase.h @@ -82,7 +82,7 @@ struct AudioIOStartStreamOptions , playLooped(false) , cutPreviewGapStart(0.0) , cutPreviewGapLen(0.0) - , pStartTime(NULL) + , pStartTime(nullptr) , preRoll(0.0) {} @@ -213,7 +213,7 @@ class SAUCEDACITY_DLL_API AudioIOBase /* not final */ #endif /** \brief Find out if playback / recording is currently paused */ - bool IsPaused() const; + [[nodiscard]] bool IsPaused() const; virtual void StopStream() = 0; @@ -221,7 +221,7 @@ class SAUCEDACITY_DLL_API AudioIOBase /* not final */ * or recording. * * When this is false, it's safe to start playing or recording */ - bool IsBusy() const; + [[nodiscard]] bool IsBusy() const; /** \brief Returns true if the audio i/o is running at all, but not during * cleanup @@ -229,19 +229,19 @@ class SAUCEDACITY_DLL_API AudioIOBase /* not final */ * Doesn't return true if the device has been closed but some disk i/o or * cleanup is still going on. If you want to know if it's safe to start a * NEW stream, use IsBusy() */ - bool IsStreamActive() const; - bool IsStreamActive(int token) const; + [[nodiscard]] bool IsStreamActive() const; + [[nodiscard]] bool IsStreamActive(int token) const; /** \brief Returns true if the stream is active, or even if audio I/O is * busy cleaning up its data or writing to disk. * * This is used by TrackPanel to determine when a track has been completely * recorded, and it's safe to flush to disk. */ - bool IsAudioTokenActive(int token) const; + [[nodiscard]] bool IsAudioTokenActive(int token) const; /** \brief Returns true if we're monitoring input (but not recording or * playing actual audio) */ - bool IsMonitoring() const; + [[nodiscard]] bool IsMonitoring() const; protected: static std::unique_ptr ugAudioIO; diff --git a/src/AutoRecoveryDialog.cpp b/src/AutoRecoveryDialog.cpp index c0e3f5cb81..fba39e597f 100644 --- a/src/AutoRecoveryDialog.cpp +++ b/src/AutoRecoveryDialog.cpp @@ -38,7 +38,7 @@ class AutoRecoveryDialog final : public wxDialogWrapper public: explicit AutoRecoveryDialog(SaucedacityProject *proj); - bool HasRecoverables() const; + [[nodiscard]] bool HasRecoverables() const; FilePaths GetRecoverables(); private: @@ -79,7 +79,7 @@ AutoRecoveryDialog::AutoRecoveryDialog(SaucedacityProject *project) bool AutoRecoveryDialog::HasRecoverables() const { - return mFiles.size() > 0; + return !mFiles.empty(); } FilePaths AutoRecoveryDialog::GetRecoverables() @@ -154,7 +154,7 @@ void AutoRecoveryDialog::PopulateList() FilePaths active = ActiveProjects::GetAll(); - for (auto file : active) + for (const auto& file : active) { wxFileName fn = file; if (fn.FileExists()) @@ -182,7 +182,7 @@ void AutoRecoveryDialog::PopulateList() mFileList->DeleteAllItems(); wxVector data; - for (auto file : files) + for (const auto& file : files) { wxFileName fn = file; if (fn != activeFile) diff --git a/src/BatchCommandDialog.h b/src/BatchCommandDialog.h index 66ec6c5731..12de37c04d 100644 --- a/src/BatchCommandDialog.h +++ b/src/BatchCommandDialog.h @@ -42,7 +42,7 @@ class MacroCommandDialog final : public wxDialogWrapper { void OnCancel(wxCommandEvent &event); void OnHelp(wxCommandEvent &event); void OnItemSelected(wxListEvent &event); - ManualPageID GetHelpPageName() { return L"Scripting Reference" ; } + static ManualPageID GetHelpPageName() { return L"Scripting Reference" ; } void ValidateChoices(); void PopulateCommandList(); diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 9fe087c7ec..2c3cbd907c 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -956,8 +956,6 @@ void MacroCommands::Split(const wxString & str, wxString & command, wxString & p command = str.Mid(0, splitAt); param = str.Mid(splitAt + 1); - - return; } wxString MacroCommands::Join(const wxString & command, const wxString & param) diff --git a/src/BatchCommands.h b/src/BatchCommands.h index 47fe139682..3d32e7d1bc 100644 --- a/src/BatchCommands.h +++ b/src/BatchCommands.h @@ -36,18 +36,18 @@ class MacroCommandsCatalog { }; using Entries = std::vector; - MacroCommandsCatalog( const SaucedacityProject *project ); + explicit MacroCommandsCatalog( const SaucedacityProject *project ); // binary search - Entries::const_iterator ByFriendlyName( const TranslatableString &friendlyName ) const; + [[nodiscard]] Entries::const_iterator ByFriendlyName( const TranslatableString &friendlyName ) const; // linear search - Entries::const_iterator ByCommandId( const CommandID &commandId ) const; + [[nodiscard]] Entries::const_iterator ByCommandId( const CommandID &commandId ) const; // Lookup by position as sorted by friendly name const Entry &operator[] ( size_t index ) const { return mCommands[index]; } - Entries::const_iterator begin() const { return mCommands.begin(); } - Entries::const_iterator end() const { return mCommands.end(); } + [[nodiscard]] Entries::const_iterator begin() const { return mCommands.begin(); } + [[nodiscard]] Entries::const_iterator end() const { return mCommands.end(); } private: // Sorted by friendly name @@ -61,7 +61,7 @@ class MacroCommands final { const PluginID & ID, const CommandContext & context, unsigned flags ); // constructors and destructors - MacroCommands( SaucedacityProject &project ); + explicit MacroCommands( SaucedacityProject &project ); public: bool ApplyMacro( const MacroCommandsCatalog &catalog, const wxString & filename = {}); @@ -70,15 +70,15 @@ class MacroCommands final { const CommandContext & context, CommandFlag flags, bool alwaysEnabled); bool ApplyCommand( const TranslatableString &friendlyCommand, const CommandID & command, const wxString & params, - CommandContext const * pContext=NULL ); + CommandContext const * pContext=nullptr ); bool ApplyCommandInBatchMode( const TranslatableString &friendlyCommand, const CommandID & command, const wxString ¶ms, - CommandContext const * pContext = NULL); + CommandContext const * pContext = nullptr); bool ApplyEffectCommand( const PluginID & ID, const TranslatableString &friendlyCommand, const CommandID & command, const wxString & params, const CommandContext & Context); - bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params ); + static bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params ); void AbortBatch(); // These commands do not depend on the command list. @@ -97,9 +97,9 @@ class MacroCommands final { void RestoreMacro(const wxString & name); wxString ReadMacro(const wxString & macro, wxWindow *parent = nullptr); wxString WriteMacro(const wxString & macro, wxWindow *parent = nullptr); - bool AddMacro(const wxString & macro); - bool DeleteMacro(const wxString & name); - bool RenameMacro(const wxString & oldmacro, const wxString & newmacro); + static bool AddMacro(const wxString & macro); + static bool DeleteMacro(const wxString & name); + static bool RenameMacro(const wxString & oldmacro, const wxString & newmacro); void AddToMacro(const CommandID & command, int before = -1); void AddToMacro(const CommandID & command, const wxString & params, int before = -1); @@ -111,10 +111,10 @@ class MacroCommands final { wxString GetMessage(){ return mMessage;}; void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;}; - bool IsFixed(const wxString & name); + static bool IsFixed(const wxString & name); - void Split(const wxString & str, wxString & command, wxString & param); - wxString Join(const wxString & command, const wxString & param); + static void Split(const wxString & str, wxString & command, wxString & param); + static wxString Join(const wxString & command, const wxString & param); private: SaucedacityProject &mProject; diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp index 478b6d6465..2a65b896af 100644 --- a/src/BatchProcessDialog.cpp +++ b/src/BatchProcessDialog.cpp @@ -383,7 +383,7 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event)) activityWin.SetName(); ShuttleGui S(&activityWin, eIsCreating); - wxListCtrl * fileList = NULL; + wxListCtrl * fileList = nullptr; S.StartVerticalLay(1); { @@ -712,9 +712,6 @@ void MacrosWindow::PopulateOrExchange(ShuttleGui & S) } S.EndHorizontalLay(); - - - return; } /// This clears and updates the contents of mList, the commands for the current macro. diff --git a/src/BatchProcessDialog.h b/src/BatchProcessDialog.h index 414059fd82..e0fa81e2cf 100644 --- a/src/BatchProcessDialog.h +++ b/src/BatchProcessDialog.h @@ -31,7 +31,7 @@ class ApplyMacroDialog : public wxDialogWrapper { // constructors and destructors ApplyMacroDialog( wxWindow * parent, SaucedacityProject &project, bool bInherited=false); - virtual ~ApplyMacroDialog(); + ~ApplyMacroDialog() override; public: // Populate methods NOT virtual. void Populate(); @@ -75,11 +75,11 @@ class MacrosWindow final : public ApplyMacroDialog, public: MacrosWindow( wxWindow * parent, SaucedacityProject &project, bool bExpanded=true); - ~MacrosWindow(); + ~MacrosWindow() override; void UpdateDisplay( bool bExpanded ); private: - TranslatableString WindowTitle() const; + [[nodiscard]] TranslatableString WindowTitle() const; void Populate(); void PopulateOrExchange(ShuttleGui &S); @@ -87,7 +87,7 @@ class MacrosWindow final : public ApplyMacroDialog, void OnApplyToFiles(wxCommandEvent & event) override; void OnCancel(wxCommandEvent &event) override; - virtual ManualPageID GetHelpPageName() override {return + ManualPageID GetHelpPageName() override {return mbExpanded ? "Manage_Macros" : "Apply_Macro";} diff --git a/src/CellularPanel.cpp b/src/CellularPanel.cpp index 21ce8db85e..9a566a1572 100644 --- a/src/CellularPanel.cpp +++ b/src/CellularPanel.cpp @@ -32,6 +32,8 @@ #include #include // for wxUSE_* macros + +#include #include "KeyboardCapture.h" #include "UIHandle.h" #include "TrackPanelMouseEvent.h" @@ -48,7 +50,7 @@ struct CellularPanel::Filter : wxEventFilter wxEvtHandler::AddFilter( this ); } - ~Filter() + ~Filter() override { wxEvtHandler::RemoveFilter( this ); } @@ -62,7 +64,7 @@ struct CellularPanel::Filter : wxEventFilter { if ( spActivePanel && event.GetEventType() == wxEVT_KEY_DOWN && - static_cast< wxKeyEvent& >( event ).GetKeyCode() == WXK_ESCAPE ) { + dynamic_cast< wxKeyEvent& >( event ).GetKeyCode() == WXK_ESCAPE ) { spActivePanel->HandleEscapeKey( true ); return Event_Processed; } @@ -428,7 +430,7 @@ bool CellularPanel::HasEscape() !Target()->HasEscape()) return false; - return state.mTargets.size() > 0; + return !state.mTargets.empty(); } bool CellularPanel::ChangeTarget(bool forward, bool cycle) @@ -470,7 +472,7 @@ bool CellularPanel::ChangeTarget(bool forward, bool cycle) bool CellularPanel::IsMouseCaptured() { auto &state = *mState; - return state.mUIHandle != NULL; + return state.mUIHandle != nullptr; } void CellularPanel::OnContextMenu(wxContextMenuEvent & WXUNUSED(event)) @@ -529,7 +531,7 @@ void CellularPanel::OnCaptureKey(wxCommandEvent & event) { auto &state = *mState; state.mEnableTab = false; - wxKeyEvent *kevent = static_cast(event.GetEventObject()); + auto *kevent = dynamic_cast(event.GetEventObject()); const auto code = kevent->GetKeyCode(); if ( WXK_ESCAPE != code ) HandleInterruptedDrag(); @@ -830,25 +832,25 @@ class DefaultRightButtonHandler : public UIHandle { ~DefaultRightButtonHandler() override; - virtual Result Click + Result Click (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) override { return RefreshCode::RefreshNone; } - virtual Result Drag + Result Drag (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) override { return RefreshCode::RefreshNone; } - virtual HitTestPreview Preview + HitTestPreview Preview (const TrackPanelMouseState &state, SaucedacityProject *pProject) override { return {}; } - virtual Result Release + Result Release (const TrackPanelMouseEvent &event, SaucedacityProject *pProject, wxWindow *pParent) override { @@ -859,7 +861,7 @@ class DefaultRightButtonHandler : public UIHandle { return RefreshCode::RefreshNone; } - virtual Result Cancel(SaucedacityProject *pProject) override + Result Cancel(SaucedacityProject *pProject) override { return RefreshCode::RefreshNone; } @@ -997,16 +999,16 @@ namespace { using SimpleNodeVisitor = CellularPanel::SimpleNodeVisitor; // Visit cells only - Adaptor( const SimpleCellVisitor& function_ ) + explicit Adaptor( const SimpleCellVisitor& function_ ) : function{ [&](const wxRect &rect, TrackPanelNode &cell) { - return function_( rect, static_cast(cell) ); + return function_( rect, dynamic_cast(cell) ); } } {} // Visit cells and groups, each once only, choosing pre- or post- ordering // for the groups - Adaptor( const SimpleNodeVisitor &function_, bool pre_ ) - : function{ function_ }, pre{ pre_ }, post{ ! pre_ } {} + Adaptor( SimpleNodeVisitor function_, bool pre_ ) + : function{std::move( function_ )}, pre{ pre_ }, post{ ! pre_ } {} void VisitCell( const wxRect &rect, TrackPanelCell &cell ) override { return function( rect, cell ); } @@ -1164,7 +1166,7 @@ wxRect CellularPanel::FindRect( UIHandlePtr CellularPanel::Target() { auto &state = *mState; - if (state.mTargets.size()) + if (!state.mTargets.empty()) return state.mTargets[state.mTarget]; else return {}; diff --git a/src/CellularPanel.h b/src/CellularPanel.h index 656535697e..f28ea944ee 100644 --- a/src/CellularPanel.h +++ b/src/CellularPanel.h @@ -43,7 +43,7 @@ class SAUCEDACITY_DLL_API CellularPanel : public OverlayPanel { // Overridables: - virtual SaucedacityProject *GetProject() const = 0; + [[nodiscard]] virtual SaucedacityProject *GetProject() const = 0; // Get the root object defining a recursive subdivision of the panel's // area into cells @@ -102,11 +102,11 @@ class SAUCEDACITY_DLL_API CellularPanel : public OverlayPanel { UIHandlePtr Target(); - std::shared_ptr LastCell() const; + [[nodiscard]] std::shared_ptr LastCell() const; bool IsMouseCaptured(); - wxCoord MostRecentXCoord() const; + [[nodiscard]] wxCoord MostRecentXCoord() const; void HandleCursorForPresentMouseState(bool doHit = true); diff --git a/src/Clipboard.h b/src/Clipboard.h index c99b6d631e..9ff67b027d 100644 --- a/src/Clipboard.h +++ b/src/Clipboard.h @@ -28,13 +28,13 @@ class SAUCEDACITY_DLL_API Clipboard final public: static Clipboard &Get(); - const TrackList &GetTracks() const; + [[nodiscard]] const TrackList &GetTracks() const; - double T0() const { return mT0; } - double T1() const { return mT1; } - double Duration() const { return mT1 - mT0; } + [[nodiscard]] double T0() const { return mT0; } + [[nodiscard]] double T1() const { return mT1; } + [[nodiscard]] double Duration() const { return mT1 - mT0; } - const std::weak_ptr &Project() const { return mProject; } + [[nodiscard]] const std::weak_ptr &Project() const { return mProject; } void Clear(); @@ -43,7 +43,7 @@ class SAUCEDACITY_DLL_API Clipboard final const std::weak_ptr &pProject ); Clipboard(); - ~Clipboard(); + ~Clipboard() override; void Swap( Clipboard &other ); diff --git a/src/CommonCommandFlags.cpp b/src/CommonCommandFlags.cpp index 13ec097589..0633b208de 100644 --- a/src/CommonCommandFlags.cpp +++ b/src/CommonCommandFlags.cpp @@ -322,7 +322,7 @@ const ReservedCommandFlag& focus = focus->GetParent(); } return (focus && - !static_cast(focus)->IsIconized() + !dynamic_cast(focus)->IsIconized() ); }, CommandFlagOptions{}.QuickTest() diff --git a/src/DBConnection.cpp b/src/DBConnection.cpp index 6c66c48a8f..83cd3c77f6 100644 --- a/src/DBConnection.cpp +++ b/src/DBConnection.cpp @@ -23,6 +23,8 @@ Paul Licameli -- split from ProjectFileIO.cpp #include #include +#include + #include "Project.h" // Configuration to provide "safe" connections @@ -41,11 +43,11 @@ static const char *FastConfig = "PRAGMA .journal_mode = OFF;"; DBConnection::DBConnection( - const std::weak_ptr &pProject, - const std::shared_ptr &pErrors, + std::weak_ptr pProject, + std::shared_ptr pErrors, CheckpointFailureCallback callback) -: mpProject{ pProject } -, mpErrors{ pErrors } +: mpProject{std::move( pProject )} +, mpErrors{std::move( pErrors )} , mCallback{ std::move(callback) } { mDB = nullptr; @@ -68,7 +70,7 @@ void DBConnection::SetBypass( bool bypass ) mBypass = bypass; } -bool DBConnection::ShouldBypass() +bool DBConnection::ShouldBypass() const { return mBypass; } @@ -131,7 +133,7 @@ void DBConnection::SetDBError( } } -int DBConnection::Open(const FilePath fileName) +int DBConnection::Open(const FilePath& fileName) { wxASSERT(mDB == nullptr); int rc; @@ -158,7 +160,7 @@ int DBConnection::Open(const FilePath fileName) return rc; } -int DBConnection::OpenStepByStep(const FilePath fileName) +int DBConnection::OpenStepByStep(const FilePath& fileName) { const char *name = fileName.ToUTF8(); @@ -393,7 +395,7 @@ sqlite3_stmt *DBConnection::Prepare(enum StatementID id, const char *sql) // Prepare the statement sqlite3_stmt *stmt = nullptr; - rc = sqlite3_prepare_v3(mDB, sql, -1, SQLITE_PREPARE_PERSISTENT, &stmt, 0); + rc = sqlite3_prepare_v3(mDB, sql, -1, SQLITE_PREPARE_PERSISTENT, &stmt, nullptr); if (rc != SQLITE_OK) { wxLogMessage("Failed to prepare statement for %s\n" @@ -513,13 +515,12 @@ void DBConnection::CheckpointThread(sqlite3 *db, const FilePath &fileName) } } - return; -} + } int DBConnection::CheckpointHook(void *data, sqlite3 *db, const char *schema, int pages) { // Get access to our object - DBConnection *that = static_cast(data); + auto *that = static_cast(data); // Queue the database pointer for our checkpoint thread to process std::lock_guard guard(that->mCheckpointMutex); diff --git a/src/DBConnection.h b/src/DBConnection.h index 892e0b2757..e188a96a60 100644 --- a/src/DBConnection.h +++ b/src/DBConnection.h @@ -46,12 +46,12 @@ class DBConnection using CheckpointFailureCallback = std::function; DBConnection( - const std::weak_ptr &pProject, - const std::shared_ptr &pErrors, + std::weak_ptr pProject, + std::shared_ptr pErrors, CheckpointFailureCallback callback); ~DBConnection(); - int Open(const FilePath fileName); + int Open(const FilePath& fileName); bool Close(); //! throw and show appropriate message box @@ -67,8 +67,8 @@ class DBConnection sqlite3 *DB(); - int GetLastRC() const ; - const wxString GetLastMessage() const; + [[nodiscard]] int GetLastRC() const ; + [[nodiscard]] const wxString GetLastMessage() const; enum StatementID { @@ -84,7 +84,7 @@ class DBConnection sqlite3_stmt *Prepare(enum StatementID id, const char *sql); void SetBypass( bool bypass ); - bool ShouldBypass(); + bool ShouldBypass() const; //! Just set stored errors void SetError( @@ -99,7 +99,7 @@ class DBConnection int errorCode = -1); private: - int OpenStepByStep(const FilePath fileName); + int OpenStepByStep(const FilePath& fileName); int ModeConfig(sqlite3 *db, const char *schema, const char *config); void CheckpointThread(sqlite3 *db, const FilePath &fileName); diff --git a/src/DeviceManager.cpp b/src/DeviceManager.cpp index 126729e0dd..f434a93c0f 100644 --- a/src/DeviceManager.cpp +++ b/src/DeviceManager.cpp @@ -70,7 +70,7 @@ wxString MakeDeviceSourceString(const DeviceSourceMap *map) DeviceSourceMap* DeviceManager::GetDefaultDevice(int hostIndex, int isInput) { if (hostIndex < 0 || hostIndex >= Pa_GetHostApiCount()) { - return NULL; + return nullptr; } const struct PaHostApiInfo *apiinfo = Pa_GetHostApiInfo(hostIndex); // get info on API @@ -84,7 +84,7 @@ DeviceSourceMap* DeviceManager::GetDefaultDevice(int hostIndex, int isInput) } wxLogDebug(wxT("GetDefaultDevice() no default device")); - return NULL; + return nullptr; } DeviceSourceMap* DeviceManager::GetDefaultOutputDevice(int hostIndex) @@ -166,13 +166,13 @@ static void AddSources(int deviceIndex, int rate, std::vector * // will be the highest available for play and record on the device, or // 44.1kHz if the info cannot be fetched. - PaStream *stream = NULL; + PaStream *stream = nullptr; PaStreamParameters parameters; parameters.device = deviceIndex; parameters.sampleFormat = paFloat32; - parameters.hostApiSpecificStreamInfo = NULL; + parameters.hostApiSpecificStreamInfo = nullptr; parameters.channelCount = 1; // If the device is for input, open a stream so we can use portmixer to query @@ -189,10 +189,10 @@ static void AddSources(int deviceIndex, int rate, std::vector * error = Pa_OpenStream(&stream, ¶meters, - NULL, + nullptr, rate, paFramesPerBufferUnspecified, paClipOff | paDitherOff, - DummyPaStreamCallback, NULL); + DummyPaStreamCallback, nullptr); } if (stream && !error) { diff --git a/src/Diags.cpp b/src/Diags.cpp index f3227141c9..4cd12168d2 100644 --- a/src/Diags.cpp +++ b/src/Diags.cpp @@ -42,13 +42,13 @@ static wxStopWatch MasterWatch; static bool bStopWatchStarted = false; void diagnostics_do_diag( t_diag_struct * pDiag ){ - wxLog * pLog = wxLog::SetActiveTarget(NULL); + wxLog * pLog = wxLog::SetActiveTarget(nullptr); // this macro is empty if wxWidgets is not compiled in debug mode wxLogDebug( wxT("%s"), pDiag->pMessage ); wxLog::SetActiveTarget(pLog); } void diagnostics_do_diag_mem( t_diag_struct * pDiag, long amount ){ - wxLog * pLog = wxLog::SetActiveTarget(NULL); + wxLog * pLog = wxLog::SetActiveTarget(nullptr); wxLogDebug( wxT("%s %l"), pDiag->pMessage, amount ); wxLog::SetActiveTarget(pLog); pDiag->total += amount; @@ -64,7 +64,7 @@ void diagnostics_do_diag_mem( t_diag_struct * pDiag, long amount ){ } void diagnostics_do_perfmon_start( t_diag_struct * pDiag, t_diag_struct ** pRememberMe ){ - if( *pRememberMe == NULL ){ + if( *pRememberMe == nullptr ){ *pRememberMe = pDiag; if( !bStopWatchStarted ){ bStopWatchStarted = true; @@ -76,7 +76,7 @@ void diagnostics_do_perfmon_start( t_diag_struct * pDiag, t_diag_struct ** pReme void diagnostics_do_perfmon_stop( t_diag_struct ** ppDiag ){ t_diag_struct * pDiag = *ppDiag; - *ppDiag = NULL; + *ppDiag = nullptr; long amount = MasterWatch.Time() - pDiag->most_recent; pDiag->total += amount; pDiag->most_recent = amount; @@ -88,7 +88,7 @@ void diagnostics_do_perfmon_stop( t_diag_struct ** ppDiag ){ pDiag->most = amount; else if( amount < pDiag->least ) pDiag->least = amount; - wxLog * pLog = wxLog::SetActiveTarget(NULL); + wxLog * pLog = wxLog::SetActiveTarget(nullptr); wxLogDebug( wxT("%s %f seconds"), pDiag->pMessage, ((float)amount)/1000.0f ); wxLog::SetActiveTarget(pLog); } diff --git a/src/Diags.h b/src/Diags.h index 118e6bc7a8..727743aa24 100644 --- a/src/Diags.h +++ b/src/Diags.h @@ -70,12 +70,12 @@ extern void diagnostics_do_perfmon_stop( t_diag_struct ** ppDiag); MAKE_TIMER( timername ); { \ static t_diag_struct diag = { DEFAULT_LOG_COUNT, DEFAULT_LOG_COUNT, 0,0,0,0,wxT(message)};\ if( --diag.countdown >=0 )\ - diagnostics_do_perfmon_start( &diag, &timername );\ + diagnostics_do_perfmon_start( &diag, &(timername) );\ } #define TIMER_STOP( timername ){ \ - if( timername != NULL )\ - diagnostics_do_perfmon_stop( &timername );\ + if( (timername) != NULL )\ + diagnostics_do_perfmon_stop( &(timername) );\ } diff --git a/src/Envelope.cpp b/src/Envelope.cpp index 806094fe50..d35c609169 100644 --- a/src/Envelope.cpp +++ b/src/Envelope.cpp @@ -120,9 +120,9 @@ void Envelope::RescaleValues(double minValue, double maxValue) mDefaultValue = ClampValue(mMinValue + (mMaxValue - mMinValue) * factor); // rescale all points - for( unsigned int i = 0; i < mEnv.size(); i++ ) { - factor = (mEnv[i].GetVal() - oldMinValue) / (oldMaxValue - oldMinValue); - mEnv[i].SetVal( this, mMinValue + (mMaxValue - mMinValue) * factor ); + for(auto & i : mEnv) { + factor = (i.GetVal() - oldMinValue) / (oldMaxValue - oldMinValue); + i.SetVal( this, mMinValue + (mMaxValue - mMinValue) * factor ); } } @@ -218,8 +218,8 @@ void Envelope::SetRange(double minValue, double maxValue) { mMinValue = minValue; mMaxValue = maxValue; mDefaultValue = ClampValue(mDefaultValue); - for( unsigned int i = 0; i < mEnv.size(); i++ ) - mEnv[i].SetVal( this, mEnv[i].GetVal() ); // this clamps the value to the NEW range + for(auto & i : mEnv) + i.SetVal( this, i.GetVal() ); // this clamps the value to the NEW range } // This is used only during construction of an Envelope by complete or partial @@ -331,7 +331,7 @@ bool Envelope::HandleXMLTag(const wxChar *tag, const wxChar **attrs) XMLTagHandler *Envelope::HandleXMLChild(const wxChar *tag) { if (wxStrcmp(tag, wxT("controlpoint"))) - return NULL; + return nullptr; mEnv.push_back( EnvPoint{} ); return &mEnv.back(); @@ -462,7 +462,7 @@ void Envelope::CollapseRegion( double t0, double t1, double sampleDur ) /*! @excsafety{No-fail} */ void Envelope::PasteEnvelope( double t0, const Envelope *e, double sampleDur ) { - const bool wasEmpty = (this->mEnv.size() == 0); + const bool wasEmpty = (this->mEnv.empty()); auto otherSize = e->mEnv.size(); const double otherDur = e->mTrackLen; const auto otherOffset = e->mOffset; @@ -1208,7 +1208,7 @@ double Envelope::Integral( double t0, double t1 ) const } // loop through the rest of the envelope points until we get to t1 - while (1) + while (true) { if(i >= count) // the requested range extends beyond the last point { @@ -1271,7 +1271,7 @@ double Envelope::IntegralOfInverse( double t0, double t1 ) const } // loop through the rest of the envelope points until we get to t1 - while (1) + while (true) { if(i >= count) // the requested range extends beyond the last point { @@ -1353,7 +1353,7 @@ double Envelope::SolveIntegralOfInverse( double t0, double area ) const if (area < 0) { // loop BACKWARDS through the rest of the envelope points until we get to t1 // (which is less than t0) - while (1) + while (true) { if(i < 0) // the requested range extends beyond the leftmost point { @@ -1374,7 +1374,7 @@ double Envelope::SolveIntegralOfInverse( double t0, double area ) const } else { // loop through the rest of the envelope points until we get to t1 - while (1) + while (true) { if(i >= (int)count) // the requested range extends beyond the last point { @@ -1397,8 +1397,8 @@ double Envelope::SolveIntegralOfInverse( double t0, double area ) const void Envelope::print() const { - for( unsigned int i = 0; i < mEnv.size(); i++ ) - wxPrintf( "(%.2f, %.2f)\n", mEnv[i].GetT(), mEnv[i].GetVal() ); + for(const auto & i : mEnv) + wxPrintf( "(%.2f, %.2f)\n", i.GetT(), i.GetVal() ); } static void checkResult( int n, double a, double b ) diff --git a/src/Envelope.h b/src/Envelope.h index 92ce57d44a..804f59c6cd 100644 --- a/src/Envelope.h +++ b/src/Envelope.h @@ -33,9 +33,9 @@ class EnvPoint final : public XMLTagHandler { EnvPoint() {} inline EnvPoint( double t, double val ) : mT{ t }, mVal{ val } {} - double GetT() const { return mT; } + [[nodiscard]] double GetT() const { return mT; } void SetT(double t) { mT = t; } - double GetVal() const { return mVal; } + [[nodiscard]] double GetVal() const { return mVal; } inline void SetVal( Envelope *pEnvelope, double val ); bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override @@ -57,7 +57,7 @@ class EnvPoint final : public XMLTagHandler { XMLTagHandler *HandleXMLChild(const wxChar * WXUNUSED(tag)) override { - return NULL; + return nullptr; } private: @@ -81,7 +81,7 @@ class SAUCEDACITY_DLL_API Envelope /* not final */ : public XMLTagHandler { void Initialize(int numPoints); - virtual ~Envelope(); + ~Envelope() override; /** \brief Get many envelope points for pixel columns at once, * but don't assume uniform time per pixel. @@ -108,7 +108,7 @@ class SAUCEDACITY_DLL_API Envelope /* not final */ : public XMLTagHandler { double GetMaxValue() const { return mMaxValue; } void SetRange(double minValue, double maxValue); - double ClampValue(double value) { return std::max(mMinValue, std::min(mMaxValue, value)); } + double ClampValue(double value) const { return std::max(mMinValue, std::min(mMaxValue, value)); } // Newfangled XML file I/O bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override; diff --git a/src/FileFormats.cpp b/src/FileFormats.cpp index e4466ad330..5a9c8bb97c 100644 --- a/src/FileFormats.cpp +++ b/src/FileFormats.cpp @@ -39,7 +39,7 @@ int sf_num_headers() { int count; - sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, + sf_command(nullptr, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count)); return count; @@ -51,7 +51,7 @@ wxString sf_header_index_name(int format) memset(&format_info, 0, sizeof(format_info)); format_info.format = format; - sf_command(NULL, SFC_GET_FORMAT_MAJOR, + sf_command(nullptr, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)) ; return LAT1CTOWX(format_info.name); @@ -63,7 +63,7 @@ unsigned int sf_header_index_to_type(int i) memset(&format_info, 0, sizeof(format_info)); format_info.format = i; - sf_command (NULL, SFC_GET_FORMAT_MAJOR, + sf_command (nullptr, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)); return format_info.format & SF_FORMAT_TYPEMASK; @@ -77,7 +77,7 @@ int sf_num_encodings() { int count ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ; + sf_command (nullptr, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ; return count; } @@ -88,7 +88,7 @@ wxString sf_encoding_index_name(int i) memset(&format_info, 0, sizeof(format_info)); format_info.format = i; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, + sf_command (nullptr, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)); return sf_normalize_name(format_info.name); } @@ -99,7 +99,7 @@ unsigned int sf_encoding_index_to_subtype(int i) memset(&format_info, 0, sizeof(format_info)); format_info.format = i; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, + sf_command (nullptr, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)); return format_info.format & SF_FORMAT_SUBMASK; @@ -115,7 +115,7 @@ wxString sf_header_name(int format) memset(&format_info, 0, sizeof(format_info)); format_info.format = (format & SF_FORMAT_TYPEMASK); - sf_command(NULL, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); + sf_command(nullptr, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); return LAT1CTOWX(format_info.name); } @@ -128,7 +128,7 @@ wxString sf_header_shortname(int format) memset(&format_info, 0, sizeof(format_info)); format_info.format = (format & SF_FORMAT_TYPEMASK); - sf_command(NULL, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); + sf_command(nullptr, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); MallocString<> tmp { strdup( format_info.name ) }; i = 0; @@ -150,7 +150,7 @@ wxString sf_header_extension(int format) memset(&format_info, 0, sizeof(format_info)); format_info.format = (format & SF_FORMAT_TYPEMASK); - sf_command(NULL, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); + sf_command(nullptr, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); return LAT1CTOWX(format_info.extension); } @@ -161,7 +161,7 @@ wxString sf_encoding_name(int encoding) memset(&format_info, 0, sizeof(format_info)); format_info.format = (encoding & SF_FORMAT_SUBMASK); - sf_command(NULL, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); + sf_command(nullptr, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)); return sf_normalize_name(format_info.name); } @@ -170,7 +170,7 @@ int sf_num_simple_formats() { int count ; - sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ; + sf_command (nullptr, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ; return count; } @@ -182,7 +182,7 @@ SF_FORMAT_INFO *sf_simple_format(int i) memset(&g_format_info, 0, sizeof(g_format_info)); g_format_info.format = i; - sf_command (NULL, SFC_GET_SIMPLE_FORMAT, + sf_command (nullptr, SFC_GET_SIMPLE_FORMAT, &g_format_info, sizeof(g_format_info)); return &g_format_info; @@ -247,12 +247,12 @@ FileExtensions sf_get_all_extensions() memset(&format_info, 0, sizeof(format_info)); - sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, + sf_command(nullptr, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count)); for(k=0; k(FindWindowById( wxID_CANCEL )); + mCloseButton = dynamic_cast(FindWindowById( wxID_CANCEL )); mCloseButton->SetDefault(); Layout(); @@ -1008,7 +1008,7 @@ void FrequencyPlotDialog::Recalc() return; } - SpectrumAnalyst::Algorithm alg = + auto alg = SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection()); int windowFunc = mFuncChoice->GetSelection(); diff --git a/src/FreqWindow.h b/src/FreqWindow.h index 86822cd695..ba1d678431 100644 --- a/src/FreqWindow.h +++ b/src/FreqWindow.h @@ -42,7 +42,7 @@ class FreqPlot final : public wxWindow FreqPlot(wxWindow *parent, wxWindowID winid); // We don't need or want to accept focus. - bool AcceptsFocus() const; + [[nodiscard]] bool AcceptsFocus() const override; private: void OnPaint(wxPaintEvent & event); @@ -62,7 +62,7 @@ class FrequencyPlotDialog final : public wxDialogWrapper, FrequencyPlotDialog(wxWindow *parent, wxWindowID id, SaucedacityProject &project, const TranslatableString & title, const wxPoint & pos); - virtual ~ FrequencyPlotDialog(); + ~ FrequencyPlotDialog() override; bool Show( bool show = true ) override; diff --git a/src/HitTestResult.h b/src/HitTestResult.h index 8d6f5fb6a7..177f2f7563 100644 --- a/src/HitTestResult.h +++ b/src/HitTestResult.h @@ -12,6 +12,7 @@ Paul Licameli #define __AUDACITY_HIT_TEST_RESULT__ #include +#include // Saucedacity libraries #include // for TranslatableString @@ -23,9 +24,9 @@ struct HitTestPreview HitTestPreview() {} - HitTestPreview(const TranslatableString &message_, wxCursor *cursor_, - const TranslatableString &tooltip_ = {}) - : message{ message_ }, cursor{ cursor_ }, tooltip{ tooltip_ } + HitTestPreview(TranslatableString message_, wxCursor *cursor_, + TranslatableString tooltip_ = {}) + : message{std::move( message_ )}, cursor{ cursor_ }, tooltip{std::move( tooltip_ )} {} TranslatableString message {}; diff --git a/src/ImageManipulation.cpp b/src/ImageManipulation.cpp index 7658215f73..26e711faed 100644 --- a/src/ImageManipulation.cpp +++ b/src/ImageManipulation.cpp @@ -320,8 +320,8 @@ void PasteSubImage( wxImage * background, wxImage * foreground, int xoff, int yo unsigned char *bg = background->GetData(); unsigned char *fg = foreground->GetData(); - unsigned char *bgAlpha = background->HasAlpha() ? background->GetAlpha() : NULL; - unsigned char *fgAlpha = foreground->HasAlpha() ? foreground->GetAlpha() : NULL; + unsigned char *bgAlpha = background->HasAlpha() ? background->GetAlpha() : nullptr; + unsigned char *fgAlpha = foreground->HasAlpha() ? foreground->GetAlpha() : nullptr; // For testing... Set as if no alpha in foreground.... // fgAlpha = NULL; diff --git a/src/JournalEvents.cpp b/src/JournalEvents.cpp index 302618fb25..121d97bf21 100644 --- a/src/JournalEvents.cpp +++ b/src/JournalEvents.cpp @@ -30,9 +30,7 @@ #include #include -namespace Journal { - -namespace Events { +namespace Journal::Events { namespace { @@ -62,7 +60,7 @@ static const ByCodeMap &ByCode(); // This sub-object populates the journal system's dictionary for playback struct RegisteredEventType : RegisteredCommand { static bool DispatchEvent( wxArrayStringEx fields ); - explicit RegisteredEventType( Code code ) + explicit RegisteredEventType( const Code& code ) : RegisteredCommand{ code.GET(), DispatchEvent } {} }; @@ -348,7 +346,7 @@ const Types &TypeCatalog() return result; } -static const ByTypeMap &ByType() +const ByTypeMap &ByType() { static std::once_flag flag; static ByTypeMap result; @@ -359,7 +357,7 @@ static const ByTypeMap &ByType() return result; } -static const ByCodeMap &ByCode() +const ByCodeMap &ByCode() { static std::once_flag flag; static ByCodeMap result; @@ -378,7 +376,7 @@ struct Watcher : public wxEventFilter wxEvtHandler::AddFilter( this ); } - ~Watcher() + ~Watcher() override { wxEvtHandler::RemoveFilter( this ); } @@ -430,5 +428,3 @@ void Watch() } } - -} diff --git a/src/JournalEvents.h b/src/JournalEvents.h index 59d3d47a5d..3b681482ec 100644 --- a/src/JournalEvents.h +++ b/src/JournalEvents.h @@ -12,9 +12,7 @@ #include -namespace Journal -{ -namespace Events +namespace Journal::Events { //\brief Initialization, to be called after wxWidgets has initialized void Initialize(); @@ -22,4 +20,3 @@ namespace Events //! Install the global event filter for recording void Watch(); } -} diff --git a/src/JournalOutput.cpp b/src/JournalOutput.cpp index 49d8db1fed..879cc966a1 100644 --- a/src/JournalOutput.cpp +++ b/src/JournalOutput.cpp @@ -20,7 +20,7 @@ namespace { struct FlushingTextFile : wxTextFile { // Flush output when the program quits, even if that makes an incomplete // journal file without an exit - ~FlushingTextFile() { if ( IsOpened() ) { Write(); Close(); } } + ~FlushingTextFile() override { if ( IsOpened() ) { Write(); Close(); } } } sFileOut; } diff --git a/src/JournalRegistry.cpp b/src/JournalRegistry.cpp index 61e392e964..61c2a491b6 100644 --- a/src/JournalRegistry.cpp +++ b/src/JournalRegistry.cpp @@ -19,7 +19,7 @@ namespace { bool sError = false; -static Dictionary &sDictionary() +Dictionary &sDictionary() { static Dictionary theDictionary; return theDictionary; @@ -38,7 +38,7 @@ void SetError() } RegisteredCommand::RegisteredCommand( - const wxString &name, Dispatcher dispatcher ) + const wxString &name, const Dispatcher& dispatcher ) { if ( !sDictionary().insert( { name, dispatcher } ).second ) { wxLogDebug( wxString::Format ( diff --git a/src/JournalRegistry.h b/src/JournalRegistry.h index 237a51a4a3..30db7b9b9c 100644 --- a/src/JournalRegistry.h +++ b/src/JournalRegistry.h @@ -37,7 +37,7 @@ namespace Journal // struct is meant for static construction struct RegisteredCommand{ explicit RegisteredCommand( - const wxString &name, Dispatcher dispatcher ); + const wxString &name, const Dispatcher& dispatcher ); }; //\brief type of the dictionary of registered commands diff --git a/src/JournalWindowPaths.cpp b/src/JournalWindowPaths.cpp index 4206bf539e..64d82af502 100644 --- a/src/JournalWindowPaths.cpp +++ b/src/JournalWindowPaths.cpp @@ -16,9 +16,7 @@ #include "widgets/AuStaticText.h" #include "wxArrayStringEx.h" -namespace Journal { - -namespace WindowPaths { +namespace Journal::WindowPaths { namespace { @@ -125,5 +123,3 @@ wxWindow *FindByPath( const Path &path ) } } - -} diff --git a/src/JournalWindowPaths.h b/src/JournalWindowPaths.h index 82069bf2ad..89aa3b2d58 100644 --- a/src/JournalWindowPaths.h +++ b/src/JournalWindowPaths.h @@ -17,9 +17,7 @@ class Identifier; class wxWindow; -namespace Journal -{ -namespace WindowPaths +namespace Journal::WindowPaths { using Path = Identifier; @@ -30,6 +28,5 @@ namespace WindowPaths // same path in a previous run wxWindow *FindByPath( const Path &path ); } -} #endif diff --git a/src/KeyboardCapture.cpp b/src/KeyboardCapture.cpp index 2fd9e7e959..d5be703de8 100644 --- a/src/KeyboardCapture.cpp +++ b/src/KeyboardCapture.cpp @@ -191,7 +191,7 @@ static class EventMonitor final : public wxEventFilter return Event_Skip; } - wxKeyEvent key = static_cast( event ); + wxKeyEvent key = dynamic_cast( event ); if ( !( sPreFilter() && sPreFilter()( key ) ) ) return Event_Skip; @@ -311,13 +311,13 @@ static class EventMonitor final : public wxEventFilter if (keyDown) { wxString chars = GetUnicodeString(temp); - for (size_t i = 0, cnt = chars.length(); i < cnt; i++) + for (auto && i : chars) { temp = event; temp.SetEventType(wxEVT_CHAR); temp.WasProcessed(); temp.StopPropagation(); - temp.m_uniChar = chars[i]; + temp.m_uniChar = i; wxEventProcessInHandlerOnly onlyChar(temp, handler); handler->ProcessEvent(temp); } @@ -329,7 +329,7 @@ static class EventMonitor final : public wxEventFilter } // Convert the key down event to a unicode string. - wxString GetUnicodeString(const wxKeyEvent & event) + static wxString GetUnicodeString(const wxKeyEvent & event) { wxString chars; diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index 9a47cff44c..4496971081 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -46,6 +46,7 @@ #include "widgets/HelpSystem.h" #include +#include enum Column { @@ -103,8 +104,8 @@ LabelDialog::LabelDialog(wxWindow *parent, int index, ViewInfo &viewinfo, double rate, - const NumericFormatSymbol & format, - const NumericFormatSymbol &freqFormat) + NumericFormatSymbol format, + NumericFormatSymbol freqFormat) : wxDialogWrapper(parent, wxID_ANY, XO("Edit Labels"), @@ -117,8 +118,8 @@ LabelDialog::LabelDialog(wxWindow *parent, , mIndex(index) , mViewInfo(&viewinfo), mRate(rate), - mFormat(format) - , mFreqFormat(freqFormat) + mFormat(std::move(format)) + , mFreqFormat(std::move(freqFormat)) { SetName(); Populate(); @@ -156,9 +157,9 @@ void LabelDialog::PopulateLabels() // do it for us. (The DecRef() that is needed after GetDefaultEditorForType // becomes the duty of the wxGridCellAttr objects after we set them in the grid.) mChoiceEditor = (ChoiceEditor *) mGrid->GetDefaultEditorForType(GRID_VALUE_CHOICE); - mTimeEditor = static_cast + mTimeEditor = dynamic_cast (mGrid->GetDefaultEditorForType(GRID_VALUE_TIME)); - mFrequencyEditor = static_cast + mFrequencyEditor = dynamic_cast (mGrid->GetDefaultEditorForType(GRID_VALUE_FREQUENCY)); // Initialize and set the track name column attributes @@ -466,7 +467,7 @@ void LabelDialog::FindAllLabels() FindInitialRow(); - if (mData.size() == 0) { + if (mData.empty()) { wxCommandEvent e; OnInsert(e); } @@ -622,7 +623,7 @@ void LabelDialog::OnRemove(wxCommandEvent & WXUNUSED(event)) mGrid->SetGridCursor(row, col); // Make sure focus isn't lost - if (mData.size() == 0 && wxWindow::FindFocus() == mGrid->GetGridWindow()) { + if (mData.empty() && wxWindow::FindFocus() == mGrid->GetGridWindow()) { wxWindow *ok = wxWindow::FindWindowById( wxID_OK, this); if (ok) { ok->SetFocus(); @@ -808,8 +809,6 @@ void LabelDialog::OnCellChange(wxGridEvent &event) // Done...no need for protection anymore guard = false; - - return; } void LabelDialog::OnChangeTrack(wxGridEvent & WXUNUSED(event), int row, RowData *rd) @@ -842,16 +841,12 @@ void LabelDialog::OnChangeTrack(wxGridEvent & WXUNUSED(event), int row, RowData // Repopulate the grid TransferDataToWindow(); - - return; } void LabelDialog::OnChangeLabel(wxGridEvent & WXUNUSED(event), int row, RowData *rd) { // Remember the value...no need to repopulate rd->title = mGrid->GetCellValue(row, Col_Label); - - return; } void LabelDialog::OnChangeStime(wxGridEvent & WXUNUSED(event), int row, RowData *rd) @@ -862,8 +857,6 @@ void LabelDialog::OnChangeStime(wxGridEvent & WXUNUSED(event), int row, RowData rd->selectedRegion.setT0(t, false); mGrid->SetCellValue(row, Col_Etime, wxString::Format(wxT("%g"), rd->selectedRegion.t1())); - - return; } void LabelDialog::OnChangeEtime(wxGridEvent & WXUNUSED(event), int row, RowData *rd) @@ -874,8 +867,6 @@ void LabelDialog::OnChangeEtime(wxGridEvent & WXUNUSED(event), int row, RowData rd->selectedRegion.setT1(t, false); mGrid->SetCellValue(row, Col_Stime, wxString::Format(wxT("%g"), rd->selectedRegion.t0())); - - return; } void LabelDialog::OnChangeLfreq(wxGridEvent & WXUNUSED(event), int row, RowData *rd) @@ -886,8 +877,6 @@ void LabelDialog::OnChangeLfreq(wxGridEvent & WXUNUSED(event), int row, RowData rd->selectedRegion.setF0(f, false); mGrid->SetCellValue(row, Col_Hfreq, wxString::Format(wxT("%g"), rd->selectedRegion.f1())); - - return; } void LabelDialog::OnChangeHfreq(wxGridEvent & WXUNUSED(event), int row, RowData *rd) @@ -898,8 +887,6 @@ void LabelDialog::OnChangeHfreq(wxGridEvent & WXUNUSED(event), int row, RowData rd->selectedRegion.setF1(f, false); mGrid->SetCellValue(row, Col_Lfreq, wxString::Format(wxT("%g"), rd->selectedRegion.f0())); - - return; } void LabelDialog::ReadSize(){ @@ -935,8 +922,7 @@ void LabelDialog::OnOK(wxCommandEvent & WXUNUSED(event)) EndModal(wxID_OK); } - return; -} + } void LabelDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) { @@ -953,6 +939,4 @@ void LabelDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) WriteSize(); // Standard handling EndModal(wxID_CANCEL); - - return; } diff --git a/src/LabelDialog.h b/src/LabelDialog.h index 36e4292a0c..d79b209a06 100644 --- a/src/LabelDialog.h +++ b/src/LabelDialog.h @@ -51,9 +51,9 @@ class LabelDialog final : public wxDialogWrapper ViewInfo &viewinfo, double rate, - const NumericFormatSymbol & format, - const NumericFormatSymbol &freqFormat); - ~LabelDialog(); + NumericFormatSymbol format, + NumericFormatSymbol freqFormat); + ~LabelDialog() override; bool Show(bool show = true) override; @@ -63,7 +63,7 @@ class LabelDialog final : public wxDialogWrapper void PopulateOrExchange( ShuttleGui & S ); void PopulateLabels(); void OnHelp(wxCommandEvent & event); - ManualPageID GetHelpPageName() {return "Labels_Editor";} + static ManualPageID GetHelpPageName() {return "Labels_Editor";} bool TransferDataToWindow() override; bool TransferDataFromWindow() override; diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index f7e066d71c..7d614b8947 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -37,7 +37,7 @@ for drawing different aspects of the label and its text box. #include #include -#include +#include #include #include @@ -645,7 +645,7 @@ XMLTagHandler *LabelTrack::HandleXMLChild(const wxChar *tag) if (!wxStrcmp(tag, wxT("label"))) return this; else - return NULL; + return nullptr; } void LabelTrack::WriteXML(XMLWriter &xmlFile) const diff --git a/src/LabelTrack.h b/src/LabelTrack.h index 8ab50b58dc..8f3628bc51 100644 --- a/src/LabelTrack.h +++ b/src/LabelTrack.h @@ -64,7 +64,7 @@ class SAUCEDACITY_DLL_API LabelStruct /// and end of parent to be within a region that borders them (this makes /// it possible to DELETE capture all labels with a Select All). TimeRelations RegionRelation(double reg_t0, double reg_t1, - const LabelTrack *parent = NULL) const; + const LabelTrack *parent = nullptr) const; public: SelectedRegion selectedRegion; @@ -90,7 +90,7 @@ class SAUCEDACITY_DLL_API LabelTrack final LabelTrack(); LabelTrack(const LabelTrack &orig); - virtual ~ LabelTrack(); + ~ LabelTrack() override; void SetLabel( size_t iLabel, const LabelStruct &newLabel ); @@ -196,7 +196,7 @@ struct LabelTrackEvent : TrackListEvent {} LabelTrackEvent( const LabelTrackEvent& ) = default; - wxEvent *Clone() const override { + [[nodiscard]] wxEvent *Clone() const override { // wxWidgets will own the event object return safenew LabelTrackEvent(*this); } diff --git a/src/LogWindow.cpp b/src/LogWindow.cpp index 1cf73b0e79..fc186a0d09 100644 --- a/src/LogWindow.cpp +++ b/src/LogWindow.cpp @@ -86,7 +86,7 @@ void LogWindow::Show(bool show) // This is the first use, so create the frame Destroy_ptr frame - { safenew wxFrame(NULL, wxID_ANY, _("Saucedacity Log")) }; + { safenew wxFrame(nullptr, wxID_ANY, _("Saucedacity Log")) }; frame->SetName(frame->GetTitle()); frame->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); diff --git a/src/Lyrics.cpp b/src/Lyrics.cpp index da12686978..4c3c67edbe 100644 --- a/src/Lyrics.cpp +++ b/src/Lyrics.cpp @@ -143,9 +143,9 @@ void LyricsPanel::Clear() mText = wxT(""); // Add two dummy syllables at the beginning - mSyllables.push_back(Syllable()); + mSyllables.emplace_back(); mSyllables[0].t = -2.0; - mSyllables.push_back(Syllable()); + mSyllables.emplace_back(); mSyllables[1].t = -1.0; mHighlightTextCtrl->Clear(); @@ -180,7 +180,7 @@ void LyricsPanel::Add(double t, const wxString &syllable, wxString &highlightTex } } - mSyllables.push_back(Syllable()); + mSyllables.emplace_back(); Syllable &thisSyllable = mSyllables[i]; thisSyllable.t = t; thisSyllable.text = syllable; @@ -210,11 +210,11 @@ void LyricsPanel::Finish(double finalT) { // Add 3 dummy syllables at the end int i = mSyllables.size(); - mSyllables.push_back(Syllable()); + mSyllables.emplace_back(); mSyllables[i].t = finalT + 1.0; - mSyllables.push_back(Syllable()); + mSyllables.emplace_back(); mSyllables[i+1].t = finalT + 2.0; - mSyllables.push_back(Syllable()); + mSyllables.emplace_back(); mSyllables[i+2].t = finalT + 3.0; // Mark measurements as invalid @@ -264,7 +264,7 @@ unsigned int LyricsPanel::GetDefaultFontSize() const return (mLyricsStyle == kBouncingBallLyrics) ? 48 : 10; } -void LyricsPanel::SetDrawnFont(wxDC *dc) +void LyricsPanel::SetDrawnFont(wxDC *dc) const { dc->SetFont(wxFont(mKaraokeFontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); } diff --git a/src/Lyrics.h b/src/Lyrics.h index e9dd588695..ee5321f981 100644 --- a/src/Lyrics.h +++ b/src/Lyrics.h @@ -55,7 +55,7 @@ class HighlightTextCtrl final : public wxTextCtrl const wxString& value = {}, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - virtual ~HighlightTextCtrl() {}; + ~HighlightTextCtrl() override {}; void OnMouseEvent(wxMouseEvent &evt); @@ -88,15 +88,15 @@ class LyricsPanel final SaucedacityProject *project, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - virtual ~LyricsPanel(); + ~LyricsPanel() override; int FindSyllable(long startChar); // Find the syllable whose char0 <= startChar <= char1. - int GetCurrentSyllableIndex() { return mCurrentSyllable; }; + int GetCurrentSyllableIndex() const { return mCurrentSyllable; }; Syllable* GetSyllable(int nSyl) { return &(mSyllables[nSyl]); }; void SetCurrentSyllableIndex(int nSyl) { mCurrentSyllable = nSyl; }; LyricsStyle GetLyricsStyle() { return mLyricsStyle; }; - void SetLyricsStyle(const LyricsStyle newLyricsStyle); + void SetLyricsStyle(LyricsStyle newLyricsStyle); void Update(double t); void UpdateLyrics(wxEvent &e); @@ -127,9 +127,9 @@ class LyricsPanel final void Add(double t, const wxString &syllable, wxString &highlightText); - unsigned int GetDefaultFontSize() const; // Depends on mLyricsStyle. Call only after mLyricsStyle is set. + [[nodiscard]] unsigned int GetDefaultFontSize() const; // Depends on mLyricsStyle. Call only after mLyricsStyle is set. - void SetDrawnFont(wxDC *dc); // for kBouncingBallLyrics + void SetDrawnFont(wxDC *dc) const; // for kBouncingBallLyrics void SetHighlightFont(); // for kHighlightLyrics void Measure(wxDC *dc); diff --git a/src/MacroMagic.h b/src/MacroMagic.h index 28bc786df1..b826ebc9e7 100644 --- a/src/MacroMagic.h +++ b/src/MacroMagic.h @@ -62,7 +62,7 @@ using teBmps = int; /// The index of a bitmap resource in Theme Resources. #ifdef THEME_EXTERNS #define DEFINE_IMAGE( name, initialiser, textual_name ) extern SAUCEDACITY_DLL_API teBmps name; -#define DEFINE_COLOUR( name, initialiser, textual_name ) extern SAUCEDACITY_DLL_API int name; -#define DEFINE_FONT( name, initialiser, textual_name ) extern SAUCEDACITY_DLL_API int name; +#define DEFINE_COLOUR( name, initialiser, textual_name ) extern SAUCEDACITY_DLL_API int (name); +#define DEFINE_FONT( name, initialiser, textual_name ) extern SAUCEDACITY_DLL_API int (name); #define SET_THEME_FLAGS( flags ) #endif diff --git a/src/Menus.cpp b/src/Menus.cpp index 6a1f411090..9c2f6d7bbf 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -43,6 +43,8 @@ #include #include +#include +#include #include #include @@ -189,9 +191,9 @@ void MenuVisitor::DoSeparator() namespace MenuTable { MenuItem::MenuItem( const Identifier &internalName, - const TranslatableString &title_, BaseItemPtrs &&items_ ) + TranslatableString title_, BaseItemPtrs &&items_ ) : ConcreteGroupItem< false, ToolbarMenuVisitor >{ - internalName, std::move( items_ ) }, title{ title_ } + internalName, std::move( items_ ) }, title{std::move( title_ )} { wxASSERT( !title.empty() ); } @@ -200,20 +202,20 @@ MenuItem::~MenuItem() {} ConditionalGroupItem::ConditionalGroupItem( const Identifier &internalName, Condition condition_, BaseItemPtrs &&items_ ) : ConcreteGroupItem< false, ToolbarMenuVisitor >{ - internalName, std::move( items_ ) }, condition{ condition_ } + internalName, std::move( items_ ) }, condition{std::move( std::move(condition_) )} { } ConditionalGroupItem::~ConditionalGroupItem() {} CommandItem::CommandItem(const CommandID &name_, - const TranslatableString &label_in_, + TranslatableString label_in_, CommandFunctorPointer callback_, CommandFlag flags_, - const CommandManager::Options &options_, + CommandManager::Options options_, CommandHandlerFinder finder_) -: SingleItem{ name_ }, label_in{ label_in_ } -, finder{ finder_ }, callback{ callback_ } -, flags{ flags_ }, options{ options_ } +: SingleItem{ name_ }, label_in{std::move( label_in_ )} +, finder{std::move( std::move(finder_) )}, callback{ callback_ } +, flags{ flags_ }, options{std::move( options_ )} {} CommandItem::~CommandItem() {} @@ -224,7 +226,7 @@ CommandGroupItem::CommandGroupItem(const Identifier &name_, bool isEffect_, CommandHandlerFinder finder_) : SingleItem{ name_ }, items{ std::move(items_) } -, finder{ finder_ }, callback{ callback_ } +, finder{std::move( std::move(finder_) )}, callback{ callback_ } , flags{ flags_ }, isEffect{ isEffect_ } {} CommandGroupItem::~CommandGroupItem() {} @@ -498,7 +500,7 @@ void MenuCreator::RebuildMenuBar(SaucedacityProject &project) // Delete the menus, since we will soon recreate them. // Rather oddly, the menus don't vanish as a result of doing this. { - auto &window = static_cast( GetProjectFrame( project ) ); + auto &window = dynamic_cast( GetProjectFrame( project ) ); wxWindowPtr menuBar{ window.GetMenuBar() }; window.DetachMenuBar(); // menuBar gets deleted here @@ -582,7 +584,7 @@ CommandFlag MenuManager::GetUpdateFlags( bool checkActive ) const void MenuManager::ModifyAllProjectToolbarMenus() { - for (auto pProject : AllProjects{}) { + for (const auto& pProject : AllProjects{}) { auto &project = *pProject; MenuManager::Get(project).ModifyToolbarMenus(project); } @@ -677,7 +679,7 @@ void MenuManager::UpdateMenus( bool checkActive ) void MenuCreator::RebuildAllMenuBars() { - for( auto p : AllProjects{} ) { + for( const auto& p : AllProjects{} ) { MenuManager::Get(*p).RebuildMenuBar(*p); #if defined(__WXGTK__) // Workaround for: diff --git a/src/Menus.h b/src/Menus.h index b674c8ff87..6fb1435752 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -87,7 +87,7 @@ class SAUCEDACITY_DLL_API MenuManager final MenuManager( SaucedacityProject &project ); MenuManager( const MenuManager & ) = delete; MenuManager &operator=( const MenuManager & ) = delete; - ~MenuManager(); + ~MenuManager() override; static void Visit( ToolbarMenuVisitor &visitor ); @@ -102,7 +102,7 @@ class SAUCEDACITY_DLL_API MenuManager final // If checkActive, do not do complete flags testing on an // inactive project as it is needlessly expensive. - CommandFlag GetUpdateFlags( bool checkActive = false ) const; + [[nodiscard]] CommandFlag GetUpdateFlags( bool checkActive = false ) const; void UpdatePrefs() override; // Command Handling @@ -113,7 +113,7 @@ class SAUCEDACITY_DLL_API MenuManager final private: - void TellUserWhyDisallowed(const TranslatableString & Name, CommandFlag flagsGot, + static void TellUserWhyDisallowed(const TranslatableString & Name, CommandFlag flagsGot, CommandFlag flagsRequired); void OnUndoRedo( wxCommandEvent &evt ); diff --git a/src/Mix.cpp b/src/Mix.cpp index 0015c727cf..ad03054cfd 100644 --- a/src/Mix.cpp +++ b/src/Mix.cpp @@ -283,7 +283,7 @@ Mixer::Mixer(const WaveTrackConstArray &inputTracks, mixerSpec->GetNumTracks() == mNumInputTracks ) mMixerSpec = mixerSpec; else - mMixerSpec = NULL; + mMixerSpec = nullptr; if (mInterleaved) { mNumBuffers = 1; @@ -363,7 +363,7 @@ void Mixer::Clear() } } -void MixBuffers(unsigned numChannels, int *channelFlags, float *gains, +void MixBuffers(unsigned numChannels, const int *channelFlags, const float *gains, samplePtr src, SampleBuffer *dests, int len, bool interleaved) { @@ -383,8 +383,8 @@ void MixBuffers(unsigned numChannels, int *channelFlags, float *gains, } float gain = gains[c]; - float *dest = (float *)destPtr; - float *temp = (float *)src; + auto *dest = (float *)destPtr; + auto *temp = (float *)src; for (int j = 0; j < len; j++) { *dest += temp[j] * gain; // the actual mixing process dest += skip; diff --git a/src/Mix.h b/src/Mix.h index 77b794432b..25a86e837e 100644 --- a/src/Mix.h +++ b/src/Mix.h @@ -70,10 +70,10 @@ class SAUCEDACITY_DLL_API MixerSpec virtual ~MixerSpec(); bool SetNumChannels( unsigned numChannels ); - unsigned GetNumChannels() { return mNumChannels; } + unsigned GetNumChannels() const { return mNumChannels; } - unsigned GetMaxNumChannels() { return mMaxNumChannels; } - unsigned GetNumTracks() { return mNumTracks; } + unsigned GetMaxNumChannels() const { return mMaxNumChannels; } + unsigned GetNumTracks() const { return mNumTracks; } MixerSpec& operator=( const MixerSpec &mixerSpec ); }; diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index c674949d67..efc26690ce 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -90,7 +90,7 @@ void MixerTrackSlider::OnMouseEvent(wxMouseEvent &event) if (event.ButtonUp()) { - MixerTrackCluster* pMixerTrackCluster = (MixerTrackCluster*)(this->GetParent()); + auto* pMixerTrackCluster = (MixerTrackCluster*)(this->GetParent()); switch (mStyle) { case DB_SLIDER: pMixerTrackCluster->HandleSliderGain(true); break; @@ -107,7 +107,7 @@ void MixerTrackSlider::OnFocus(wxFocusEvent &event) void MixerTrackSlider::OnCaptureKey(wxCommandEvent &event) { - wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject(); + auto *kevent = (wxKeyEvent *)event.GetEventObject(); int keyCode = kevent->GetKeyCode(); // Pass LEFT/RIGHT/UP/DOWN/PAGEUP/PAGEDOWN through for input/output sliders @@ -118,8 +118,6 @@ void MixerTrackSlider::OnCaptureKey(wxCommandEvent &event) } event.Skip(); - - return; } @@ -847,7 +845,7 @@ void MixerBoardScrolledWindow::OnMouseEvent(wxMouseEvent& event) #define MIXER_BOARD_MIN_HEIGHT 460 // Min width is one cluster wide, plus margins. -#define MIXER_BOARD_MIN_WIDTH kTripleInset + kMixerTrackClusterWidth*2 + kTripleInset +#define MIXER_BOARD_MIN_WIDTH (kTripleInset + kMixerTrackClusterWidth*2 + kTripleInset) BEGIN_EVENT_TABLE(MixerBoard, wxWindow) @@ -865,15 +863,15 @@ MixerBoard::MixerBoard(SaucedacityProject* pProject, // mute & solo button images // Create once and store on MixerBoard for use in all MixerTrackClusters. - mImageMuteUp = NULL; - mImageMuteOver = NULL; - mImageMuteDown = NULL; - mImageMuteDownWhileSolo = NULL; - mImageMuteDisabled = NULL; - mImageSoloUp = NULL; - mImageSoloOver = NULL; - mImageSoloDown = NULL; - mImageSoloDisabled = NULL; + mImageMuteUp = nullptr; + mImageMuteOver = nullptr; + mImageMuteDown = nullptr; + mImageMuteDownWhileSolo = nullptr; + mImageMuteDisabled = nullptr; + mImageSoloUp = nullptr; + mImageSoloOver = nullptr; + mImageSoloDown = nullptr; + mImageSoloDisabled = nullptr; mMuteSoloWidth = kRightSideStackWidth - kInset; // correct for max width, but really set in MixerBoard::CreateMuteSoloImages @@ -941,7 +939,7 @@ MixerBoard::MixerBoard(SaucedacityProject* pProject, wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, wxCommandEventHandler(MixerBoard::OnStartStop), - NULL, + nullptr, this); } @@ -951,7 +949,7 @@ MixerBoard::MixerBoard(SaucedacityProject* pProject, void MixerBoard::UpdatePrefs() { // Destroys this: - static_cast(GetParent())->Recreate( mProject ); + dynamic_cast(GetParent())->Recreate( mProject ); // Old approach modified things in situ. // However with a theme change there is so much to modify, it is easier @@ -990,7 +988,7 @@ void MixerBoard::UpdateTrackClusters() const int nClusterHeight = mScrolledWindow->GetClientSize().GetHeight() - kDoubleInset; size_t nClusterCount = mMixerTrackClusters.size(); unsigned int nClusterIndex = 0; - MixerTrackCluster* pMixerTrackCluster = NULL; + MixerTrackCluster* pMixerTrackCluster = nullptr; for (auto pPlayableTrack: mTracks->Leaders()) { // TODO: more-than-two-channels @@ -1075,7 +1073,7 @@ void MixerBoard::RemoveTrackCluster(size_t nIndex) wxBitmap* MixerBoard::GetMusicalInstrumentBitmap(const Track* pTrack) { if (mMusicalInstruments.empty()) - return NULL; + return nullptr; // random choice: return mMusicalInstruments[(int)pTrack % mMusicalInstruments.size()].mBitmap; @@ -1123,14 +1121,14 @@ bool MixerBoard::HasSolo() void MixerBoard::RefreshTrackClusters(bool bEraseBackground /*= true*/) { - for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++) - mMixerTrackClusters[i]->Refresh(bEraseBackground); + for (auto & mMixerTrackCluster : mMixerTrackClusters) + mMixerTrackCluster->Refresh(bEraseBackground); } void MixerBoard::ResizeTrackClusters() { - for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.size(); nClusterIndex++) - mMixerTrackClusters[nClusterIndex]->HandleResize(); + for (auto & mMixerTrackCluster : mMixerTrackClusters) + mMixerTrackCluster->HandleResize(); } void MixerBoard::ResetMeters(const bool bResetClipping) @@ -1140,8 +1138,8 @@ void MixerBoard::ResetMeters(const bool bResetClipping) if (!this->IsShown()) return; - for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++) - mMixerTrackClusters[i]->ResetMeter(bResetClipping); + for (auto & mMixerTrackCluster : mMixerTrackClusters) + mMixerTrackCluster->ResetMeter(bResetClipping); } void MixerBoard::UpdateMeters(const double t1, const bool bLoopedPlay) @@ -1165,8 +1163,8 @@ void MixerBoard::UpdateMeters(const double t1, const bool bLoopedPlay) return; } - for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++) - mMixerTrackClusters[i]->UpdateMeter(mPrevT1, t1); + for (auto & mMixerTrackCluster : mMixerTrackClusters) + mMixerTrackCluster->UpdateMeter(mPrevT1, t1); mPrevT1 = t1; } @@ -1200,7 +1198,7 @@ void MixerBoard::MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & WXUNUSED(bitmap), fontSize = 8; #endif wxFont font(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - GetTextExtent(translation, &textWidth, &textHeight, NULL, NULL, &font); + GetTextExtent(translation, &textWidth, &textHeight, nullptr, nullptr, &font); AColor::UseThemeColour( &dc, clrMedium ); dc.DrawRectangle(bev); @@ -1260,7 +1258,7 @@ void MixerBoard::CreateMuteSoloImages() int MixerBoard::FindMixerTrackCluster(const PlayableTrack* pTrack, MixerTrackCluster** hMixerTrackCluster) const { - *hMixerTrackCluster = NULL; + *hMixerTrackCluster = nullptr; for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++) { if (mMixerTrackClusters[i]->mTrack.get() == pTrack) @@ -1486,7 +1484,7 @@ void MixerBoardFrame::Recreate( SaucedacityProject *pProject ) //wxLogDebug("Got rid of board %p", mMixerBoard ); mMixerBoard->Destroy(); - mMixerBoard = NULL; + mMixerBoard = nullptr; mMixerBoard = safenew MixerBoard(pProject, this, pos, siz); //wxLogDebug("Created NEW board %p", mMixerBoard ); mMixerBoard->UpdateTrackClusters(); diff --git a/src/MixerBoard.h b/src/MixerBoard.h index 4f15189f16..cd1999d1a9 100644 --- a/src/MixerBoard.h +++ b/src/MixerBoard.h @@ -42,7 +42,7 @@ class MixerTrackSlider final : public ASlider const wxPoint & pos, const wxSize & size, const ASlider::Options &options = ASlider::Options{}); - virtual ~MixerTrackSlider() {} + ~MixerTrackSlider() override {} void OnMouseEvent(wxMouseEvent & event); @@ -78,10 +78,10 @@ class MixerTrackCluster final : public wxPanelWrapper const std::shared_ptr &pTrack, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - virtual ~MixerTrackCluster() {} + ~MixerTrackCluster() override {} - WaveTrack *GetWave() const; - WaveTrack *GetRight() const; + [[nodiscard]] WaveTrack *GetWave() const; + [[nodiscard]] WaveTrack *GetRight() const; #ifdef EXPERIMENTAL_MIDI_OUT NoteTrack *GetNote() const; #endif @@ -90,19 +90,19 @@ class MixerTrackCluster final : public wxPanelWrapper void HandleResize(); // For wxSizeEvents, update gain slider and meter. - void HandleSliderGain(const bool bWantPushState = false); + void HandleSliderGain(bool bWantPushState = false); #ifdef EXPERIMENTAL_MIDI_OUT void HandleSliderVelocity(const bool bWantPushState = false); #endif - void HandleSliderPan(const bool bWantPushState = false); + void HandleSliderPan(bool bWantPushState = false); - void ResetMeter(const bool bResetClipping); + void ResetMeter(bool bResetClipping); void UpdateForStateChange(); - void UpdateMeter(const double t0, const double t1); + void UpdateMeter(double t0, double t1); private: - wxColour GetTrackColor(); + static wxColour GetTrackColor(); // event handlers void HandleSelect(bool bShiftDown, bool bControlDown); @@ -171,7 +171,7 @@ class MixerBoardScrolledWindow final : public wxScrolledWindow const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxHSCROLL | wxVSCROLL); - virtual ~MixerBoardScrolledWindow(); + ~MixerBoardScrolledWindow() override; private: void OnMouseEvent(wxMouseEvent& event); @@ -214,12 +214,12 @@ class MixerBoard final : public wxWindow, private PrefsListener void RefreshTrackClusters(bool bEraseBackground = true); void ResizeTrackClusters(); - void UpdateMeters(const double t1, const bool bLoopedPlay); + void UpdateMeters(double t1, bool bLoopedPlay); void UpdateWidth(); private: - void ResetMeters(const bool bResetClipping); + void ResetMeters(bool bResetClipping); void RemoveTrackCluster(size_t nIndex); void MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & bitmap, wxRect & bev, const TranslatableString & str, bool up ); @@ -266,7 +266,7 @@ class MixerBoardFrame final { public: MixerBoardFrame(SaucedacityProject* parent); - virtual ~MixerBoardFrame(); + ~MixerBoardFrame() override; void Recreate(SaucedacityProject *pProject); diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index 0638ba37e1..c5873dc4ed 100644 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -54,7 +54,7 @@ Module::Module(const FilePath & name) : mName{ name } { mLib = std::make_unique(); - mDispatch = NULL; + mDispatch = nullptr; } Module::~Module() @@ -94,7 +94,7 @@ bool Module::Load(wxString &deferredErrorMessage) // Check version string matches. (For now, they must match exactly) tVersionFn versionFn = (tVersionFn)(mLib->GetSymbol(wxT(versionFnName))); - if (versionFn == NULL){ + if (versionFn == nullptr){ AudacityMessageBox( XO("The module \"%s\" does not provide a version string.\n\nIt will not be loaded.") .Format( ShortName), @@ -128,7 +128,7 @@ bool Module::Load(wxString &deferredErrorMessage) return true; } - mDispatch = NULL; + mDispatch = nullptr; AudacityMessageBox( XO("The module \"%s\" failed to initialize.\n\nIt will not be loaded.").Format(ShortName), @@ -153,7 +153,7 @@ void Module::Unload() int Module::Dispatch(ModuleDispatchTypes type) { if (mLib->IsLoaded()) - if( mDispatch != NULL ) + if( mDispatch != nullptr ) return mDispatch(type); return 0; @@ -188,8 +188,6 @@ void RegisterProvider(ModuleMain moduleMain) auto &list = builtinModuleList(); if ( moduleMain ) list.push_back(moduleMain); - - return; } void UnregisterProvider(ModuleMain moduleMain) @@ -230,7 +228,7 @@ void ModuleManager::FindModules(FilePaths &files) wxString prefix = path + wxFILE_SEP_PATH; FileNames::AddUniquePathToPathList(prefix + wxT("modules"), pathList); - if (files.size()) { + if (!files.empty()) { break; } } @@ -368,7 +366,7 @@ void ModuleManager::Initialize() errors.clear(); TryLoadModules(files, decided, errors); } - while ( errors.size() && numDecided < decided.size() ); + while ( !errors.empty() && numDecided < decided.size() ); // Only now show accumulated errors of modules that failed to load for ( const auto &pair : errors ) { diff --git a/src/ModuleManager.h b/src/ModuleManager.h index a3be94f13a..fdf88f2374 100644 --- a/src/ModuleManager.h +++ b/src/ModuleManager.h @@ -45,10 +45,10 @@ class Module void ShowLoadFailureError(const wxString &Error); bool Load(wxString &deferredErrorMessage); void Unload(); - bool HasDispatch() { return mDispatch != NULL; }; + bool HasDispatch() { return mDispatch != nullptr; }; int Dispatch(ModuleDispatchTypes type); void * GetSymbol(const wxString &name); - const FilePath &GetName() const { return mName; } + [[nodiscard]] const FilePath &GetName() const { return mName; } private: const FilePath mName; @@ -91,7 +91,7 @@ class SAUCEDACITY_DLL_API ModuleManager final const FilePaths &files, FilePaths &decided, DelayedErrors &errors); public: - void Initialize(); + static void Initialize(); int Dispatch(ModuleDispatchTypes type); // PluginManager use @@ -99,7 +99,7 @@ class SAUCEDACITY_DLL_API ModuleManager final bool DiscoverProviders(); // Supports range-for iteration - auto Providers() const + [[nodiscard]] auto Providers() const { return make_iterator_range(mDynModules.cbegin(), mDynModules.cend()); } bool RegisterEffectPlugin(const PluginID & provider, const PluginPath & path, @@ -110,7 +110,7 @@ class SAUCEDACITY_DLL_API ModuleManager final std::unique_ptr CreateInstance(const PluginID & provider, const PluginPath & path); - bool IsProviderValid(const PluginID & provider, const PluginPath & path); + static bool IsProviderValid(const PluginID & provider, const PluginPath & path); bool IsPluginValid(const PluginID & provider, const PluginPath & path, bool bFast); private: diff --git a/src/NoteTrack.cpp b/src/NoteTrack.cpp index 2e82d61cc7..97b4ef148e 100644 --- a/src/NoteTrack.cpp +++ b/src/NoteTrack.cpp @@ -123,7 +123,7 @@ NoteTrack::NoteTrack() SetDefaultName(_("Note Track")); SetName(GetDefaultName()); - mSeq = NULL; + mSeq = nullptr; mSerializationLength = 0; #ifdef EXPERIMENTAL_MIDI_OUT @@ -149,7 +149,7 @@ Alg_seq &NoteTrack::GetSeq() const { Alg_seq::unserialize ( mSerializationBuffer.get(), mSerializationLength ) }; wxASSERT(alg_track->get_type() == 's'); - mSeq.reset( static_cast(alg_track.release()) ); + mSeq.reset( dynamic_cast(alg_track.release()) ); // Preserve the invariant that at most one of the representations is // valid @@ -233,7 +233,7 @@ void NoteTrack::WarpAndTransposeNotes(double t0, double t1, Alg_iterator iter(mSeq.get(), false); iter.begin(); Alg_event_ptr event; - while (0 != (event = iter.next()) && event->time < t1) { + while (nullptr != (event = iter.next()) && event->time < t1) { if (event->is_note() && event->time >= t0) { event->set_pitch(event->get_pitch() + semitones); } @@ -933,7 +933,7 @@ bool NoteTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs) XMLTagHandler *NoteTrack::HandleXMLChild(const wxChar * WXUNUSED(tag)) { - return NULL; + return nullptr; } void NoteTrack::WriteXML(XMLWriter &xmlFile) const @@ -946,7 +946,7 @@ void NoteTrack::WriteXML(XMLWriter &xmlFile) const // replace saveme with an (unserialized) duplicate, which is // destroyed at end of function. holder = Clone(); - saveme = static_cast(holder.get()); + saveme = dynamic_cast(holder.get()); } saveme->GetSeq().write(data, true); xmlFile.StartTag(wxT("notetrack")); @@ -1074,7 +1074,7 @@ void NoteTrack::ZoomAllNotes() int minPitch = MaxPitch; int maxPitch = MinPitch; - while (NULL != (evt = iterator.next())) { + while (nullptr != (evt = iterator.next())) { if (evt->is_note()) { int pitch = (int) evt->get_pitch(); hasNotes = true; diff --git a/src/NumberScale.h b/src/NumberScale.h index 72fa5e2b79..c3e7cee608 100644 --- a/src/NumberScale.h +++ b/src/NumberScale.h @@ -81,7 +81,7 @@ class NumberScale } } - NumberScale Reversal() const + [[nodiscard]] NumberScale Reversal() const { NumberScale result(*this); std::swap(result.mValue0, result.mValue1); @@ -152,7 +152,7 @@ class NumberScale } // Random access - float PositionToValue(float pp) const + [[nodiscard]] float PositionToValue(float pp) const { switch (mType) { default: @@ -229,7 +229,7 @@ class NumberScale float mValue; }; - Iterator begin(float nPositions) const + [[nodiscard]] Iterator begin(float nPositions) const { switch (mType) { default: @@ -253,7 +253,7 @@ class NumberScale } // Inverse - float ValueToPosition(float val) const + [[nodiscard]] float ValueToPosition(float val) const { switch (mType) { default: diff --git a/src/PitchName.h b/src/PitchName.h index 0d0ca503fa..4eead20ad4 100644 --- a/src/PitchName.h +++ b/src/PitchName.h @@ -26,39 +26,39 @@ class TranslatableString; // Each register starts with C (e.g., for middle C and A440, // it's register 4). // MIDI note number 0 is C-1 in Scientific pitch notation. -SAUCEDACITY_DLL_API double FreqToMIDInote(const double freq); +SAUCEDACITY_DLL_API double FreqToMIDInote(double freq); -SAUCEDACITY_DLL_API double MIDInoteToFreq(const double dMIDInote); +SAUCEDACITY_DLL_API double MIDInoteToFreq(double dMIDInote); // PitchIndex returns the [0,11] index for a double MIDI note number, // per result from FreqToMIDInote, corresponding to modulo 12 // of the integer part of (dMIDInote + 0.5), so 0=C, 1=C#, etc. -SAUCEDACITY_DLL_API unsigned int PitchIndex(const double dMIDInote); +SAUCEDACITY_DLL_API unsigned int PitchIndex(double dMIDInote); // PitchOctave returns the octave index for a double dMIDInote note number, // per result from FreqToMIDInote. // MIDI note number 0 is C-1 in Scientific pitch notation. -SAUCEDACITY_DLL_API int PitchOctave(const double dMIDInote); +SAUCEDACITY_DLL_API int PitchOctave(double dMIDInote); enum class PitchNameChoice { Sharps, Flats, Both }; // PitchName takes dMIDInote (per result from // FreqToMIDInote) and returns a standard pitch/note name [C, C#, etc.). SAUCEDACITY_DLL_API TranslatableString PitchName( - const double dMIDInote, - const PitchNameChoice choice = PitchNameChoice::Sharps ); + double dMIDInote, + PitchNameChoice choice = PitchNameChoice::Sharps ); // PitchName_Absolute does the same thing as PitchName, but appends // the octave number, e.g., instead of "C" it will return "C4" // if the dMIDInote corresponds to middle C, i.e., is 60. SAUCEDACITY_DLL_API TranslatableString PitchName_Absolute( - const double dMIDInote, - const PitchNameChoice choice = PitchNameChoice::Sharps); + double dMIDInote, + PitchNameChoice choice = PitchNameChoice::Sharps); SAUCEDACITY_DLL_API -double PitchToMIDInote(const unsigned int nPitchIndex, const int nPitchOctave); +double PitchToMIDInote(unsigned int nPitchIndex, int nPitchOctave); SAUCEDACITY_DLL_API -double PitchToFreq(const unsigned int nPitchIndex, const int nPitchOctave); +double PitchToFreq(unsigned int nPitchIndex, int nPitchOctave); #endif // __AUDACITY_PITCHNAME__ diff --git a/src/PlaybackSchedule.h b/src/PlaybackSchedule.h index b0f0c6199d..67acd566a4 100644 --- a/src/PlaybackSchedule.h +++ b/src/PlaybackSchedule.h @@ -29,10 +29,10 @@ struct RecordingSchedule { double mPosition{}; bool mLatencyCorrected{}; - double TotalCorrection() const { return mLatencyCorrection - mPreRoll; } - double ToConsume() const; - double Consumed() const; - double ToDiscard() const; + [[nodiscard]] double TotalCorrection() const { return mLatencyCorrection - mPreRoll; } + [[nodiscard]] double ToConsume() const; + [[nodiscard]] double Consumed() const; + [[nodiscard]] double ToDiscard() const; }; struct SAUCEDACITY_DLL_API PlaybackSchedule { @@ -84,7 +84,7 @@ struct SAUCEDACITY_DLL_API PlaybackSchedule { const RecordingSchedule *pRecordingSchedule ); /** \brief True if the end time is before the start time */ - bool ReversedTime() const + [[nodiscard]] bool ReversedTime() const { return mT1 < mT0; } @@ -93,7 +93,7 @@ struct SAUCEDACITY_DLL_API PlaybackSchedule { * * Returns a time in seconds. */ - double GetTrackTime() const + [[nodiscard]] double GetTrackTime() const { return mTime.load(std::memory_order_relaxed); } /** \brief Set current track time value, unadjusted @@ -106,40 +106,40 @@ struct SAUCEDACITY_DLL_API PlaybackSchedule { * Returns the bound if the value is out of bounds; does not wrap. * Returns a time in seconds. */ - double ClampTrackTime( double trackTime ) const; + [[nodiscard]] double ClampTrackTime( double trackTime ) const; /** \brief Clamps mTime to be between mT0 and mT1 * * Returns the bound if the value is out of bounds; does not wrap. * Returns a time in seconds. */ - double LimitTrackTime() const; + [[nodiscard]] double LimitTrackTime() const; /** \brief Normalizes mTime, clamping it and handling gaps from cut preview. * * Clamps the time (unless scrubbing), and skips over the cut section. * Returns a time in seconds. */ - double NormalizeTrackTime() const; + [[nodiscard]] double NormalizeTrackTime() const; void ResetMode() { mPlayMode = PLAY_STRAIGHT; } - bool PlayingStraight() const { return mPlayMode == PLAY_STRAIGHT; } - bool Looping() const { return mPlayMode == PLAY_LOOPED; } - bool Scrubbing() const { return mPlayMode == PLAY_SCRUB || mPlayMode == PLAY_KEYBOARD_SCRUB; } - bool PlayingAtSpeed() const { return mPlayMode == PLAY_AT_SPEED; } - bool Interactive() const { return Scrubbing() || PlayingAtSpeed(); } + [[nodiscard]] bool PlayingStraight() const { return mPlayMode == PLAY_STRAIGHT; } + [[nodiscard]] bool Looping() const { return mPlayMode == PLAY_LOOPED; } + [[nodiscard]] bool Scrubbing() const { return mPlayMode == PLAY_SCRUB || mPlayMode == PLAY_KEYBOARD_SCRUB; } + [[nodiscard]] bool PlayingAtSpeed() const { return mPlayMode == PLAY_AT_SPEED; } + [[nodiscard]] bool Interactive() const { return Scrubbing() || PlayingAtSpeed(); } // Returns true if a loop pass, or the sole pass of straight play, // is completed at the current value of mTime - bool PassIsComplete() const; + [[nodiscard]] bool PassIsComplete() const; // Returns true if time equals t1 or is on opposite side of t1, to t0 - bool Overruns( double trackTime ) const; + [[nodiscard]] bool Overruns( double trackTime ) const; // Compute the NEW track time for the given one and a real duration, // taking into account whether the schedule is for looping - double AdvancedTrackTime( + [[nodiscard]] double AdvancedTrackTime( double trackTime, double realElapsed, double speed) const; // Use the function above in the callback after consuming samples from the @@ -148,10 +148,10 @@ struct SAUCEDACITY_DLL_API PlaybackSchedule { // Convert time between mT0 and argument to real duration, according to // time track if one is given; result is always nonnegative - double RealDuration(double trackTime1) const; + [[nodiscard]] double RealDuration(double trackTime1) const; // How much real time left? - double RealTimeRemaining() const; + [[nodiscard]] double RealTimeRemaining() const; // Advance the real time position void RealTimeAdvance( double increment ); diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 27acac9dbf..86ac4ba770 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -330,10 +330,10 @@ void PluginDescriptor::SetImporterExtensions( FileExtensions extensions ) const PluginID &PluginManagerInterface::DefaultRegistrationCallback( ModuleInterface *provider, ComponentInterface *pInterface ) { - EffectDefinitionInterface * pEInterface = dynamic_cast(pInterface); + auto * pEInterface = dynamic_cast(pInterface); if( pEInterface ) return PluginManager::Get().RegisterPlugin(provider, pEInterface, PluginTypeEffect); - ComponentInterface * pCInterface = dynamic_cast(pInterface); + auto * pCInterface = dynamic_cast(pInterface); if( pCInterface ) return PluginManager::Get().RegisterPlugin(provider, pCInterface); static wxString empty; @@ -343,7 +343,7 @@ const PluginID &PluginManagerInterface::DefaultRegistrationCallback( const PluginID &PluginManagerInterface::AudacityCommandRegistrationCallback( ModuleInterface *provider, ComponentInterface *pInterface ) { - ComponentInterface * pCInterface = dynamic_cast(pInterface); + auto * pCInterface = dynamic_cast(pInterface); if( pCInterface ) return PluginManager::Get().RegisterPlugin(provider, pCInterface); static wxString empty; @@ -491,8 +491,7 @@ void PluginManager::FindFilesInPathList(const wxString & pattern, wxDir::GetAllFiles(ff.GetPath(), &files, ff.GetFullName(), directories ? wxDIR_DEFAULT : wxDIR_FILES); } - return; -} + } bool PluginManager::HasSharedConfigGroup(const PluginID & ID, const RegistryPath & group) { @@ -673,7 +672,7 @@ std::unique_ptr PluginManager::mInstance{}; PluginManager::PluginManager() { - mSettings = NULL; + mSettings = nullptr; } PluginManager::~PluginManager() @@ -731,7 +730,7 @@ void PluginManager::Initialize() void PluginManager::Terminate() { // Get rid of all non-module plugins first - PluginMap::iterator iter = mPlugins.begin(); + auto iter = mPlugins.begin(); while (iter != mPlugins.end()) { PluginDescriptor & plug = iter->second; @@ -929,8 +928,8 @@ void PluginManager::Load() } // Doing the deletion within the search loop risked skipping some items, // hence the delayed delete. - for (unsigned int i = 0; i < groupsToDelete.size(); i++) { - registry.DeleteGroup(groupsToDelete[i]); + for (const auto & i : groupsToDelete) { + registry.DeleteGroup(i); } registry.SetPath(""); registry.Write(REGVERKEY, REGVERCUR); @@ -948,7 +947,6 @@ void PluginManager::Load() LoadGroup(®istry, PluginTypeImporter); LoadGroup(®istry, PluginTypeStub); - return; } void PluginManager::LoadGroup(FileConfig *pRegistry, PluginType type) @@ -1205,8 +1203,7 @@ void PluginManager::LoadGroup(FileConfig *pRegistry, PluginType type) mPlugins[groupName] = std::move(plug); } - return; -} + } void PluginManager::Save() { @@ -1319,8 +1316,7 @@ void PluginManager::SaveGroup(FileConfig *pRegistry, PluginType type) } } - return; -} + } // If bFast is true, do not do a full check. Just check the ones // that are quick to check. Currently (Feb 2017) just Nyquist @@ -1377,9 +1373,9 @@ void PluginManager::CheckForUpdates(bool bFast) PluginPaths paths; if (auto provider = mm.CreateProviderInstance( plugID, plugPath ) ) paths = provider->FindPluginPaths( *this ); - for (size_t i = 0, cnt = paths.size(); i < cnt; i++) + for (auto & i : paths) { - wxString path = paths[i].BeforeFirst(wxT(';'));; + wxString path = i.BeforeFirst(wxT(';'));; if ( ! make_iterator_range( pathIndex ).contains( path ) ) { PluginID ID = plugID + wxT("_") + path; @@ -1405,8 +1401,6 @@ void PluginManager::CheckForUpdates(bool bFast) } Save(); - - return; } // Here solely for the purpose of Nyquist Workbench until @@ -1776,7 +1770,7 @@ bool PluginManager::SetConfig(const RegistryPath & key, const wxString & value) if (!key.empty()) { - wxString wxval = value; + const wxString& wxval = value; result = GetSettings()->Write(key, wxval); if (result) { @@ -1963,7 +1957,7 @@ const static char padc = wxT('='); wxString PluginManager::b64encode(const void *in, int len) { - unsigned char *p = (unsigned char *) in; + auto *p = (unsigned char *) in; wxString out; unsigned long temp; @@ -2004,7 +1998,7 @@ wxString PluginManager::b64encode(const void *in, int len) int PluginManager::b64decode(const wxString &in, void *out) { int len = in.length(); - unsigned char *p = (unsigned char *) out; + auto *p = (unsigned char *) out; if (len % 4) //Sanity check { diff --git a/src/PluginManager.h b/src/PluginManager.h index ef8a224ca0..c0062e725e 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -48,25 +48,25 @@ class SAUCEDACITY_DLL_API PluginDescriptor PluginDescriptor &operator =(PluginDescriptor &&); virtual ~PluginDescriptor(); - bool IsInstantiated() const; + [[nodiscard]] bool IsInstantiated() const; - PluginType GetPluginType() const; + [[nodiscard]] PluginType GetPluginType() const; // All plugins // These return untranslated strings - const wxString & GetID() const; - const wxString & GetProviderID() const; - const PluginPath & GetPath() const; - const ComponentInterfaceSymbol & GetSymbol() const; + [[nodiscard]] const wxString & GetID() const; + [[nodiscard]] const wxString & GetProviderID() const; + [[nodiscard]] const PluginPath & GetPath() const; + [[nodiscard]] const ComponentInterfaceSymbol & GetSymbol() const; - wxString GetUntranslatedVersion() const; + [[nodiscard]] wxString GetUntranslatedVersion() const; // There is no translated version - wxString GetVendor() const; + [[nodiscard]] wxString GetVendor() const; - bool IsEnabled() const; - bool IsValid() const; + [[nodiscard]] bool IsEnabled() const; + [[nodiscard]] bool IsValid() const; void SetEnabled(bool enable); void SetValid(bool valid); @@ -77,20 +77,20 @@ class SAUCEDACITY_DLL_API PluginDescriptor // (Use Effect::GetFamilyName instead) // This string persists in configuration files // So config compatibility will break if it is changed across Audacity versions - wxString GetEffectFamily() const; + [[nodiscard]] wxString GetEffectFamily() const; - EffectType GetEffectType() const; - bool IsEffectDefault() const; - bool IsEffectInteractive() const; - bool IsEffectLegacy() const; - bool IsEffectRealtime() const; - bool IsEffectAutomatable() const; + [[nodiscard]] EffectType GetEffectType() const; + [[nodiscard]] bool IsEffectDefault() const; + [[nodiscard]] bool IsEffectInteractive() const; + [[nodiscard]] bool IsEffectLegacy() const; + [[nodiscard]] bool IsEffectRealtime() const; + [[nodiscard]] bool IsEffectAutomatable() const; // Importer plugins only - const wxString & GetImporterIdentifier() const; - const TranslatableString & GetImporterFilterDescription() const; - const FileExtensions & GetImporterExtensions() const; + [[nodiscard]] const wxString & GetImporterIdentifier() const; + [[nodiscard]] const TranslatableString & GetImporterFilterDescription() const; + [[nodiscard]] const FileExtensions & GetImporterExtensions() const; private: friend class PluginManager; @@ -175,8 +175,8 @@ class SAUCEDACITY_DLL_API PluginManager final : public PluginManagerInterface { public: - RegistryPath GetPluginEnabledSetting( const PluginID &ID ) const; - RegistryPath GetPluginEnabledSetting( const PluginDescriptor &desc ) const; + [[nodiscard]] RegistryPath GetPluginEnabledSetting( const PluginID &ID ) const; + [[nodiscard]] RegistryPath GetPluginEnabledSetting( const PluginDescriptor &desc ) const; // PluginManagerInterface implementation @@ -246,7 +246,7 @@ class SAUCEDACITY_DLL_API PluginManager final : public PluginManagerInterface static wxString GetPluginTypeString(PluginType type); int GetPluginCount(PluginType type); - const PluginDescriptor *GetPlugin(const PluginID & ID) const; + [[nodiscard]] const PluginDescriptor *GetPlugin(const PluginID & ID) const; //! @name iteration over plugins of certain types, supporting range-for syntax //! @{ @@ -274,8 +274,8 @@ class SAUCEDACITY_DLL_API PluginManager final : public PluginManagerInterface }; struct Range { Iterator first; - Iterator begin() const { return first; } - int end() const { return 0; } + [[nodiscard]] Iterator begin() const { return first; } + static int end() { return 0; } }; Range AllPlugins() { return { Iterator{ *this } }; } @@ -304,7 +304,7 @@ class SAUCEDACITY_DLL_API PluginManager final : public PluginManagerInterface private: // private! Use Get() PluginManager(); - ~PluginManager(); + ~PluginManager() override; void LoadGroup(FileConfig *pRegistry, PluginType type); void SaveGroup(FileConfig *pRegistry, PluginType type); @@ -338,8 +338,8 @@ class SAUCEDACITY_DLL_API PluginManager final : public PluginManagerInterface // The PluginID must be kept unique. Since the wxFileConfig class does not preserve // case, we use base64 encoding. wxString ConvertID(const PluginID & ID); - wxString b64encode(const void *in, int len); - int b64decode(const wxString &in, void *out); + static wxString b64encode(const void *in, int len); + static int b64decode(const wxString &in, void *out); private: friend std::default_delete; diff --git a/src/PluginRegistrationDialog.cpp b/src/PluginRegistrationDialog.cpp index 335defb56c..5fe4798521 100644 --- a/src/PluginRegistrationDialog.cpp +++ b/src/PluginRegistrationDialog.cpp @@ -390,7 +390,7 @@ PluginRegistrationDialog::PluginRegistrationDialog(wxWindow *parent, EffectType wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { mType = type; - mEffects = NULL; + mEffects = nullptr; SetName(); mStates.resize(STATE_COUNT); @@ -526,10 +526,10 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S) colWidths.push_back(0); } - for (int i = 0, cnt = mStates.size(); i < cnt; i++) + for (const auto & mState : mStates) { int x; - mEffects->GetTextExtent(mStates[i], &x, NULL); + mEffects->GetTextExtent(mState, &x, nullptr); colWidths[COL_State] = wxMax(colWidths[COL_State], x + 4); // 2 pixel margin on each side } @@ -564,10 +564,10 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S) } int x; - mEffects->GetTextExtent(item.name, &x, NULL); + mEffects->GetTextExtent(item.name, &x, nullptr); colWidths[COL_Name] = wxMax(colWidths[COL_Name], x); - mEffects->GetTextExtent(item.path, &x, NULL); + mEffects->GetTextExtent(item.path, &x, nullptr); if (x > colWidths[COL_Path]) { mLongestPath = item.path; @@ -622,9 +622,9 @@ void PluginRegistrationDialog::RegenerateEffectsList(int filter) mEffects->DeleteAllItems(); int i = 0; - for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) + for (auto & mItem : mItems) { - ItemData & item = iter->second; + ItemData & item = mItem.second; bool add = false; switch (mFilter) @@ -685,7 +685,7 @@ void PluginRegistrationDialog::SetState(int i, bool toggle, bool state) mEffects->GetItem(li); - ItemData *item = (ItemData *) li.m_data; + auto *item = (ItemData *) li.m_data; // If changing the state of a "New" (stub) entry, then we mark it as valid // since it will either be registered if "Enabled" or ignored if "Disabled". @@ -726,9 +726,9 @@ void PluginRegistrationDialog::SetState(int i, bool toggle, bool state) int wxCALLBACK PluginRegistrationDialog::SortCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData) { - PluginRegistrationDialog *dlg = (PluginRegistrationDialog *) sortData; - ItemData *i1 = (ItemData *) item1; - ItemData *i2 = (ItemData *) item2; + auto *dlg = (PluginRegistrationDialog *) sortData; + auto *i1 = (ItemData *) item1; + auto *i2 = (ItemData *) item2; return dlg->SortCompare(i1, i2); } @@ -846,9 +846,9 @@ void PluginRegistrationDialog::OnEnable(wxCommandEvent & WXUNUSED(evt)) } } - for (size_t i = 0, cnt = items.size(); i < cnt; i++) + for (long item : items) { - SetState(items[i], false, STATE_Enabled); + SetState(item, false, STATE_Enabled); } } @@ -865,9 +865,9 @@ void PluginRegistrationDialog::OnDisable(wxCommandEvent & WXUNUSED(evt)) } } - for (size_t i = 0, cnt = items.size(); i < cnt; i++) + for (long item : items) { - SetState(items[i], false, STATE_Disabled); + SetState(item, false, STATE_Disabled); } } @@ -877,9 +877,9 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt)) ModuleManager & mm = ModuleManager::Get(); int enableCount = 0; - for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) + for (auto & mItem : mItems) { - ItemData & item = iter->second; + ItemData & item = mItem.second; wxString path = item.path; if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub) @@ -903,9 +903,9 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt)) progress.CenterOnParent(); int i = 0; - for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) + for (auto & mItem : mItems) { - ItemData & item = iter->second; + ItemData & item = mItem.second; wxString path = item.path; if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub) diff --git a/src/PluginRegistrationDialog.h b/src/PluginRegistrationDialog.h index 4cd657a45e..1f28f52ff9 100644 --- a/src/PluginRegistrationDialog.h +++ b/src/PluginRegistrationDialog.h @@ -8,7 +8,7 @@ **********************************************************************/ #ifndef __AUDACITY_PLUGIN_REGISTRATION_DIALOG__ -#define __AUDACITY_PLUGIN_REGISTRATION_DIALOG__ +#define AUDACITY_PLUGIN_REGISTRATION_DIALOG_ #include "widgets/wxPanelWrapper.h" // to inherit #include diff --git a/src/Printing.cpp b/src/Printing.cpp index e447d21f2b..e8a19afb67 100644 --- a/src/Printing.cpp +++ b/src/Printing.cpp @@ -43,18 +43,18 @@ wxPrintData &gPrintData() class AudacityPrintout final : public wxPrintout { public: - AudacityPrintout(wxString title, + AudacityPrintout(const wxString& title, TrackList *tracks, TrackPanel &panel): wxPrintout(title), mTracks(tracks) , mPanel(panel) { } - bool OnPrintPage(int page); - bool HasPage(int page); - bool OnBeginDocument(int startPage, int endPage); + bool OnPrintPage(int page) override; + bool HasPage(int page) override; + bool OnBeginDocument(int startPage, int endPage) override; void GetPageInfo(int *minPage, int *maxPage, - int *selPageFrom, int *selPageTo); + int *selPageFrom, int *selPageTo) override; private: TrackPanel &mPanel; diff --git a/src/Profiler.cpp b/src/Profiler.cpp index 783d281119..1122260baa 100644 --- a/src/Profiler.cpp +++ b/src/Profiler.cpp @@ -30,7 +30,7 @@ but it will probably work fine if you use it on a high level. ///write to a profile at the end of the test. Profiler::~Profiler() { - if(mTasks.size()) + if(!mTasks.empty()) { //print everything out. append to a log. FILE* log = fopen("AudacityProfilerLog.txt", "a"); @@ -89,10 +89,10 @@ Profiler* Profiler::Instance() ///find a taskProfile for the given task, otherwise create TaskProfile* Profiler::GetOrCreateTaskProfile(const char* fileName, int lineNum) { - for(int i=0;i<(int)mTasks.size();i++) + for(auto & mTask : mTasks) { - if(strcmp(fileName, mTasks[i]->mFileName.get())==0 && lineNum == mTasks[i]->mLine) - return mTasks[i].get(); + if(strcmp(fileName, mTask->mFileName.get())==0 && lineNum == mTask->mLine) + return mTask.get(); } auto tp = std::make_unique(); @@ -102,13 +102,13 @@ TaskProfile* Profiler::GetOrCreateTaskProfile(const char* fileName, int lineNum) TaskProfile* Profiler::GetTaskProfileByDescription(const char* description) { - for(int i=0;i<(int)mTasks.size();i++) + for(auto & mTask : mTasks) { - if(strcmp(description, mTasks[i]->mDescription.get())==0) - return mTasks[i].get(); + if(strcmp(description, mTask->mDescription.get())==0) + return mTask.get(); } - return NULL; + return nullptr; } @@ -147,7 +147,7 @@ void TaskProfile::End(const char* WXUNUSED(fileName), int WXUNUSED(lineNum), con mNumHits++; } -double TaskProfile::ComputeAverageRunTime() +double TaskProfile::ComputeAverageRunTime() const { if(mNumHits) return (double) ((double)mCumTime/CLOCKS_PER_SEC)/mNumHits; diff --git a/src/Profiler.h b/src/Profiler.h index 5635069381..74d2abdd49 100644 --- a/src/Profiler.h +++ b/src/Profiler.h @@ -25,7 +25,7 @@ but it will probably work fine if you use it on a high level. #define __AUDACITY_PROFILER__ #include #include -#include +#include // Saucedacity libraries #include @@ -76,7 +76,7 @@ class Profiler ///end the task timer. void End(const char* fileName, int lineNum, const char* taskDescription); - double ComputeAverageRunTime(); + double ComputeAverageRunTime() const; ArrayOf mFileName; int mLine; diff --git a/src/Project.cpp b/src/Project.cpp index 97f3a79f5e..0db4071871 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -132,7 +132,7 @@ SaucedacityProject::SaucedacityProject() wxLongLong freeSpace = 0; auto path = TempDirectory::TempDir(); - if (wxGetDiskSpace(path, NULL, &freeSpace)) { + if (wxGetDiskSpace(path, nullptr, &freeSpace)) { if (freeSpace < wxLongLong(wxLL(100 * 1048576))) { auto volume = FileNames::AbbreviatePath( path ); /* i18n-hint: %s will be replaced by the drive letter (on Windows) */ diff --git a/src/Project.h b/src/Project.h index 27f7939e9b..e75eb14618 100644 --- a/src/Project.h +++ b/src/Project.h @@ -46,16 +46,16 @@ class SAUCEDACITY_DLL_API AllProjects public: AllProjects() = default; - size_t size() const; - bool empty() const { return size() == 0; } + [[nodiscard]] size_t size() const; + [[nodiscard]] bool empty() const { return size() == 0; } using const_iterator = Container::const_iterator; - const_iterator begin() const; - const_iterator end() const; + [[nodiscard]] const_iterator begin() const; + [[nodiscard]] const_iterator end() const; using const_reverse_iterator = Container::const_reverse_iterator; - const_reverse_iterator rbegin() const; - const_reverse_iterator rend() const; + [[nodiscard]] const_reverse_iterator rbegin() const; + [[nodiscard]] const_reverse_iterator rend() const; using value_type = Container::value_type; @@ -117,7 +117,7 @@ class SAUCEDACITY_DLL_API SaucedacityProject final using AttachedWindows = ::AttachedProjectWindows; SaucedacityProject(); - virtual ~SaucedacityProject(); + ~SaucedacityProject() override; wxFrame *GetFrame() { return mFrame; } const wxFrame *GetFrame() const { return mFrame; } @@ -127,7 +127,7 @@ class SAUCEDACITY_DLL_API SaucedacityProject final const wxWindow *GetPanel() const { return mPanel; } void SetPanel( wxWindow *pPanel ); - int GetProjectNumber(){ return mProjectNo;} + int GetProjectNumber() const{ return mProjectNo;} // Project name can be either empty or have the name of the project. // diff --git a/src/ProjectAudioIO.h b/src/ProjectAudioIO.h index 3916f5924d..c7bfb0fd8c 100644 --- a/src/ProjectAudioIO.h +++ b/src/ProjectAudioIO.h @@ -32,10 +32,10 @@ class SAUCEDACITY_DLL_API ProjectAudioIO final explicit ProjectAudioIO( SaucedacityProject &project ); ProjectAudioIO( const ProjectAudioIO & ) = delete; ProjectAudioIO &operator=( const ProjectAudioIO & ) = delete; - ~ProjectAudioIO(); + ~ProjectAudioIO() override; - int GetAudioIOToken() const; - bool IsAudioActive() const; + [[nodiscard]] int GetAudioIOToken() const; + [[nodiscard]] bool IsAudioActive() const; void SetAudioIOToken(int token); MeterPanelBase *GetPlaybackMeter(); diff --git a/src/ProjectAudioManager.cpp b/src/ProjectAudioManager.cpp index f6b2f7cb58..1858f3a00e 100644 --- a/src/ProjectAudioManager.cpp +++ b/src/ProjectAudioManager.cpp @@ -627,8 +627,8 @@ bool ProjectAudioManager::DoRecord(SaucedacityProject &project, // wave tracks; in case the track recorded to changes scale // type (for instance), during the recording. auto updater = [](Track &d, const Track &s){ - auto &dst = static_cast(d); - auto &src = static_cast(s); + auto &dst = dynamic_cast(d); + auto &src = dynamic_cast(s); dst.Reinit(src); }; @@ -892,7 +892,7 @@ void ProjectAudioManager::OnAudioIOStopRecording() auto &tracks = TrackList::Get( project ); auto gAudioIO = AudioIO::Get(); auto &intervals = gAudioIO->LostCaptureIntervals(); - if (intervals.size()) { + if (!intervals.empty()) { // Make a track with labels for recording errors auto uTrack = std::make_shared(); auto pTrack = uTrack.get(); diff --git a/src/ProjectAudioManager.h b/src/ProjectAudioManager.h index 1042138727..c04354bcdd 100644 --- a/src/ProjectAudioManager.h +++ b/src/ProjectAudioManager.h @@ -63,7 +63,7 @@ class SAUCEDACITY_DLL_API ProjectAudioManager final ProjectAudioManager &operator=( const ProjectAudioManager & ) = delete; ~ProjectAudioManager() override; - bool IsTimerRecordCancelled() { return mTimerRecordCanceled; } + bool IsTimerRecordCancelled() const { return mTimerRecordCanceled; } void SetTimerRecordCancelled() { mTimerRecordCanceled = true; } void ResetTimerRecordCancelled() { mTimerRecordCanceled = false; } diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index bb7f4ca5d8..22453fec1b 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -59,7 +59,7 @@ wxDEFINE_EVENT( EVT_RECONNECTION_FAILURE, wxCommandEvent); // // Note that endianness is not an issue here since SQLite integers are // architecture independent. -#define PACK(b1, b2, b3, b4) ((b1 << 24) | (b2 << 16) | (b3 << 8) | b4) +#define PACK(b1, b2, b3, b4) (((b1) << 24) | ((b2) << 16) | ((b3) << 8) | (b4)) // The ProjectFileID is stored in the SQLite database header to identify the file // as an Audacity project file. It can be used by applications that identify file @@ -222,7 +222,7 @@ bool ProjectFileIO::InitializeSQL() static void RefreshAllTitles(bool bShowProjectNumbers ) { - for ( auto pProject : AllProjects{} ) { + for ( const auto& pProject : AllProjects{} ) { if ( !GetProjectFrame( *pProject ).IsIconized() ) { ProjectFileIO::Get( *pProject ).SetProjectTitle( bShowProjectNumbers ? pProject->GetProjectNumber() : -1 ); @@ -712,7 +712,7 @@ bool ProjectFileIO::UpgradeSchema() // in the set, it will be deleted. void ProjectFileIO::InSet(sqlite3_context *context, int argc, sqlite3_value **argv) { - BlockIDs *blockids = (BlockIDs *) sqlite3_user_data(context); + auto *blockids = (BlockIDs *) sqlite3_user_data(context); SampleBlockID blockid = sqlite3_value_int64(argv[0]); sqlite3_result_int(context, blockids->find(blockid) != blockids->end()); @@ -1107,7 +1107,7 @@ FilePath ProjectFileIO::SafetyFileName(const FilePath &src) }; auto suffixes = AuxiliaryFileSuffixes(); - suffixes.push_back({}); + suffixes.emplace_back(); // Find backup paths not already occupied; check all auxiliary suffixes const auto name = fn.GetName(); @@ -1193,7 +1193,7 @@ bool ProjectFileIO::MoveProject(const FilePath &src, const FilePath &dst) auto dstName = dst + suffix; if (!RenameOrWarn(srcName, dstName)) return false; - pairs.push_back({ srcName, dstName }); + pairs.emplace_back( srcName, dstName ); } } @@ -1241,7 +1241,7 @@ ProjectFileIO::BackupProject::~BackupProject() if (!mSafety.empty()) { // Failed; restore from safety files auto suffixes = AuxiliaryFileSuffixes(); - suffixes.push_back({}); + suffixes.emplace_back(); for (const auto &suffix : suffixes) { auto path = mPath + suffix; if (wxFileExists(path)) @@ -1382,15 +1382,14 @@ void ProjectFileIO::Compact( } } - return; -} + } -bool ProjectFileIO::WasCompacted() +bool ProjectFileIO::WasCompacted() const { return mWasCompacted; } -bool ProjectFileIO::HadUnused() +bool ProjectFileIO::HadUnused() const { return mHadUnused; } @@ -1629,7 +1628,7 @@ void ProjectFileIO::OnCheckpointFailure() mProject.ProcessEvent(evt); } -void ProjectFileIO::WriteXMLHeader(XMLWriter &xmlFile) const +void ProjectFileIO::WriteXMLHeader(XMLWriter &xmlFile) { xmlFile.Write(wxT("GetActiveBlockIDs(); - if (blockids.size() > 0) + if (!blockids.empty()) { success = DeleteBlocks(blockids, true); if (!success) @@ -2226,7 +2225,7 @@ bool ProjectFileIO::IsRecovered() const wxLongLong ProjectFileIO::GetFreeDiskSpace() const { wxLongLong freeSpace; - if (wxGetDiskSpace(wxPathOnly(mFileName), NULL, &freeSpace)) + if (wxGetDiskSpace(wxPathOnly(mFileName), nullptr, &freeSpace)) { if (FileNames::IsOnFATFileSystem(mFileName)) { // 4 GiB per-file maximum @@ -2253,7 +2252,7 @@ wxLongLong ProjectFileIO::GetFreeDiskSpace() const void ProjectFileIO::ShowError(const GenericUI::WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, - const wxString &helpPage) + const wxString &helpPage) const { using namespace Saucedacity; using namespace GenericUI; @@ -2329,8 +2328,7 @@ void ProjectFileIO::SetBypass() } } - return; -} + } int64_t ProjectFileIO::GetBlockUsage(SampleBlockID blockid) { @@ -2341,7 +2339,7 @@ int64_t ProjectFileIO::GetBlockUsage(SampleBlockID blockid) } int64_t ProjectFileIO::GetCurrentUsage( - const std::vector &trackLists) const + const std::vector &trackLists) { unsigned long long current = 0; const auto fn = BlockSpaceUsageAccumulator(current); diff --git a/src/ProjectFileIO.h b/src/ProjectFileIO.h index f34fbea05b..feb6c31ac4 100644 --- a/src/ProjectFileIO.h +++ b/src/ProjectFileIO.h @@ -76,7 +76,7 @@ class SAUCEDACITY_DLL_API ProjectFileIO final ProjectFileIO( const ProjectFileIO & ) = delete; ProjectFileIO &operator=( const ProjectFileIO & ) = delete; - ~ProjectFileIO(); + ~ProjectFileIO() override; // It seems odd to put this method in this class, but the results do depend // on what is discovered while opening the file, such as whether it is a @@ -109,8 +109,8 @@ class SAUCEDACITY_DLL_API ProjectFileIO final int64_t GetBlockUsage(SampleBlockID blockid); // Returns the bytes used for all blocks owned by the given track list - int64_t GetCurrentUsage( - const std::vector &trackLists) const; + static int64_t GetCurrentUsage( + const std::vector &trackLists) ; // Return the bytes used by all sample blocks in the project file, whether // they are attached to the active tracks or held by the Undo manager. @@ -124,7 +124,7 @@ class SAUCEDACITY_DLL_API ProjectFileIO final void ShowError(const GenericUI::WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, - const wxString &helpPage); + const wxString &helpPage) const; const TranslatableString &GetLastError() const; const TranslatableString &GetLibraryError() const; int GetLastErrorCode() const; @@ -183,10 +183,10 @@ class SAUCEDACITY_DLL_API ProjectFileIO final const std::vector &tracks, bool force = false); // The last compact check did actually compact the project file if true - bool WasCompacted(); + bool WasCompacted() const; // The last compact check found unused blocks in the project file - bool HadUnused(); + bool HadUnused() const; // In one SQL command, delete sample blocks with ids in the given set, or // (when complement is true), with ids not in the given set. @@ -208,7 +208,7 @@ class SAUCEDACITY_DLL_API ProjectFileIO final private: void OnCheckpointFailure(); - void WriteXMLHeader(XMLWriter &xmlFile) const; + static void WriteXMLHeader(XMLWriter &xmlFile) ; void WriteXML(XMLWriter &xmlFile, bool recording = false, const TrackList *tracks = nullptr) /* not override */; @@ -248,7 +248,7 @@ class SAUCEDACITY_DLL_API ProjectFileIO final bool CheckVersion(); bool InstallSchema(sqlite3 *db, const char *schema = "main"); - bool UpgradeSchema(); + static bool UpgradeSchema(); // Write project or autosave XML (binary) documents bool WriteDoc(const char *table, const ProjectSerializer &autosave, const char *schema = "main"); diff --git a/src/ProjectFileIORegistry.cpp b/src/ProjectFileIORegistry.cpp index 9908b25a17..20151a66f5 100644 --- a/src/ProjectFileIORegistry.cpp +++ b/src/ProjectFileIORegistry.cpp @@ -21,7 +21,7 @@ namespace ProjectFileIORegistry { namespace { using TagTable = std::unordered_map< wxString, TagHandlerFactory >; - static TagTable &sTagTable() + TagTable &sTagTable() { static TagTable theTable; return theTable; diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index 4180f18c4d..a5c16b8c23 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -305,7 +305,7 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs wxULongLong fileSize = wxFileName::GetSize(projectFileIO.GetFileName()); wxDiskspaceSize_t freeSpace; - if (wxGetDiskSpace(FileNames::AbbreviatePath(fileName), NULL, &freeSpace)) + if (wxGetDiskSpace(FileNames::AbbreviatePath(fileName), nullptr, &freeSpace)) { if (freeSpace.GetValue() <= fileSize.GetValue()) { @@ -499,7 +499,7 @@ For an audio file that will open in other apps, use 'Export'.\n"); // saved to disk, and we then need to check the destination file is not // open in another window. int mayOverwrite = ( projectFileIO.GetFileName() == fName ) ? 2 : 1; - for ( auto p : AllProjects{} ) { + for ( const auto& p : AllProjects{} ) { const wxFileName openProjectName{ ProjectFileIO::Get(*p).GetFileName() }; if (openProjectName.SameAs(fName)) { mayOverwrite -= 1; @@ -646,7 +646,7 @@ bool ProjectFileManager::SaveCopy(const FilePath &fileName /* = wxT("") */) wxULongLong fileSize = wxFileName::GetSize(projectFileIO.GetFileName()); wxDiskspaceSize_t freeSpace; - if (wxGetDiskSpace(FileNames::AbbreviatePath(filename.GetFullPath()), NULL, &freeSpace)) + if (wxGetDiskSpace(FileNames::AbbreviatePath(filename.GetFullPath()), nullptr, &freeSpace)) { if (freeSpace.GetValue() <= fileSize.GetValue()) { @@ -698,7 +698,7 @@ bool ProjectFileManager::SaveCopy(const FilePath &fileName /* = wxT("") */) return true; } -bool ProjectFileManager::SaveFromTimerRecording(wxFileName fnFile) +bool ProjectFileManager::SaveFromTimerRecording(const wxFileName& fnFile) { auto &project = mProject; auto &projectFileIO = ProjectFileIO::Get( project ); @@ -1339,7 +1339,7 @@ namespace { class CompactDialog : public wxDialogWrapper { public: - CompactDialog(TranslatableString text) + CompactDialog(const TranslatableString& text) : wxDialogWrapper(nullptr, wxID_ANY, XO("Compact Project")) { ShuttleGui S(this, eIsCreating); diff --git a/src/ProjectFileManager.h b/src/ProjectFileManager.h index 0f7154e0d2..cc16eb1e52 100644 --- a/src/ProjectFileManager.h +++ b/src/ProjectFileManager.h @@ -44,7 +44,7 @@ class SAUCEDACITY_DLL_API ProjectFileManager final explicit ProjectFileManager( SaucedacityProject &project ); ProjectFileManager( const ProjectFileManager & ) = delete; ProjectFileManager &operator=( const ProjectFileManager & ) = delete; - ~ProjectFileManager(); + ~ProjectFileManager() override; bool OpenProject(); void CloseProject(); @@ -56,7 +56,7 @@ class SAUCEDACITY_DLL_API ProjectFileManager final bool SaveAs(bool allowOverwrite = false); bool SaveAs(const FilePath &newFileName, bool addToHistory = true); // strProjectPathName is full path for aup except extension - bool SaveFromTimerRecording( wxFileName fnFile ); + bool SaveFromTimerRecording( const wxFileName& fnFile ); bool SaveCopy(const FilePath &fileName = wxT("")); /** @brief Show an open dialogue for opening audio files, and possibly other @@ -105,7 +105,7 @@ class SAUCEDACITY_DLL_API ProjectFileManager final void AddImportedTracks(const FilePath &fileName, TrackHolders &&newTracks); - bool GetMenuClose() const { return mMenuClose; } + [[nodiscard]] bool GetMenuClose() const { return mMenuClose; } void SetMenuClose(bool value) { mMenuClose = value; } private: diff --git a/src/ProjectHistory.h b/src/ProjectHistory.h index 714ee954b6..e5197b220d 100644 --- a/src/ProjectHistory.h +++ b/src/ProjectHistory.h @@ -33,8 +33,8 @@ class SAUCEDACITY_DLL_API ProjectHistory final void InitialState(); void SetStateTo(unsigned int n, bool doAutosave = true); - bool UndoAvailable() const; - bool RedoAvailable() const; + [[nodiscard]] bool UndoAvailable() const; + [[nodiscard]] bool RedoAvailable() const; void PushState( const TranslatableString &desc, const TranslatableString &shortDesc); // use UndoPush::AUTOSAVE @@ -48,7 +48,7 @@ class SAUCEDACITY_DLL_API ProjectHistory final // projects void PopState(const UndoState &state, bool doAutosave = true); - bool GetDirty() const { return mDirty; } + [[nodiscard]] bool GetDirty() const { return mDirty; } void SetDirty( bool value ) { mDirty = value; } private: diff --git a/src/ProjectManager.cpp b/src/ProjectManager.cpp index a693708a51..8204dc234f 100644 --- a/src/ProjectManager.cpp +++ b/src/ProjectManager.cpp @@ -112,7 +112,7 @@ void ProjectManager::SaveWindowSize() bool validWindowForSaveWindowSize = FALSE; ProjectWindow * validProject = nullptr; bool foundIconizedProject = FALSE; - for ( auto pProject : AllProjects{} ) + for ( const auto& pProject : AllProjects{} ) { auto &window = ProjectWindow::Get( *pProject ); if (!window.IsIconized()) { @@ -189,7 +189,7 @@ class FileObject final : public wxFileDataObject { } - bool IsSupportedFormat(const wxDataFormat & format, Direction WXUNUSED(dir = Get)) const + [[nodiscard]] bool IsSupportedFormat(const wxDataFormat & format, Direction WXUNUSED(dir = Get)) const override // PRL: This function does NOT override any inherited virtual! What does it do? { if (format.GetType() == wxDF_FILENAME) { @@ -219,7 +219,7 @@ class DropTarget final : public wxFileDropTarget SetDataObject(safenew FileObject()); } - ~DropTarget() + ~DropTarget() override { } @@ -788,7 +788,7 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event) SetActiveProject(AllProjects{}.begin()->get()); } else { - SetActiveProject(NULL); + SetActiveProject(nullptr); } } @@ -848,7 +848,7 @@ void ProjectManager::OpenFiles(SaucedacityProject *proj) { auto selectedFiles = ProjectFileManager::ShowOpenDialog(FileNames::Operation::Open); - if (selectedFiles.size() == 0) { + if (selectedFiles.empty()) { Importer::SetLastOpenType({}); return; } diff --git a/src/ProjectManager.h b/src/ProjectManager.h index a755172f64..7c0d6c050c 100644 --- a/src/ProjectManager.h +++ b/src/ProjectManager.h @@ -106,10 +106,10 @@ class SAUCEDACITY_DLL_API ProjectManager final // Routine to estimate how many minutes of recording time are left on disk int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0); // Converts number of minutes to human readable format - TranslatableString GetHoursMinsString(int iMinutes); + static TranslatableString GetHoursMinsString(int iMinutes); void SetStatusText( const TranslatableString &text, int number ); - void SetSkipSavePrompt(bool bSkip) { sbSkipPromptingForSave = bSkip; }; + static void SetSkipSavePrompt(bool bSkip) { sbSkipPromptingForSave = bSkip; }; private: void OnReconnectionFailure(wxCommandEvent & event); diff --git a/src/ProjectSelectionManager.h b/src/ProjectSelectionManager.h index e00759ca2a..3d262bfc74 100644 --- a/src/ProjectSelectionManager.h +++ b/src/ProjectSelectionManager.h @@ -48,7 +48,7 @@ class SAUCEDACITY_DLL_API ProjectSelectionManager final void AS_ModifySelection(double &start, double &end, bool done) override; // SpectralSelectionBarListener callback methods - double SSBL_GetRate() const override; + [[nodiscard]] double SSBL_GetRate() const override; const NumericFormatSymbol & SSBL_GetFrequencySelectionFormatName() override; void SSBL_SetFrequencySelectionFormatName( const NumericFormatSymbol & formatName) override; diff --git a/src/ProjectSerializer.cpp b/src/ProjectSerializer.cpp index 8581dead74..7bd2df2988 100644 --- a/src/ProjectSerializer.cpp +++ b/src/ProjectSerializer.cpp @@ -166,38 +166,38 @@ namespace { } // Choose between implementations! - static const auto WriteUShort = IsLittleEndian() + const auto WriteUShort = IsLittleEndian() ? &WriteLittleEndian : &WriteBigEndian; - static const auto WriteInt = IsLittleEndian() + const auto WriteInt = IsLittleEndian() ? &WriteLittleEndian : &WriteBigEndian; - static const auto WriteLong = IsLittleEndian() + const auto WriteLong = IsLittleEndian() ? &WriteLittleEndian : &WriteBigEndian; - static const auto WriteULong = IsLittleEndian() + const auto WriteULong = IsLittleEndian() ? &WriteLittleEndian : &WriteBigEndian; - static const auto WriteLongLong = IsLittleEndian() + const auto WriteLongLong = IsLittleEndian() ? &WriteLittleEndian : &WriteBigEndian; - static const auto ReadUShort = IsLittleEndian() + const auto ReadUShort = IsLittleEndian() ? &ReadLittleEndian : &ReadBigEndian; - static const auto ReadInt = IsLittleEndian() + const auto ReadInt = IsLittleEndian() ? &ReadLittleEndian : &ReadBigEndian; - static const auto ReadLong = IsLittleEndian() + const auto ReadLong = IsLittleEndian() ? &ReadLittleEndian : &ReadBigEndian; - static const auto ReadULong = IsLittleEndian() + const auto ReadULong = IsLittleEndian() ? &ReadLittleEndian : &ReadBigEndian; - static const auto ReadLongLong = IsLittleEndian() + const auto ReadLongLong = IsLittleEndian() ? &ReadLittleEndian : &ReadBigEndian; // Functions to read and write certain lengths -- maybe we will change // our choices for widths or signedness? using Length = Int; // Instead, as wide as size_t? - static const auto WriteLength = WriteInt; - static const auto ReadLength = ReadInt; + const auto WriteLength = WriteInt; + const auto ReadLength = ReadInt; using Digits = Int; // Instead, just an unsigned char? - static const auto WriteDigits = WriteInt; - static const auto ReadDigits = ReadInt; + const auto WriteDigits = WriteInt; + const auto ReadDigits = ReadInt; } ProjectSerializer::ProjectSerializer(size_t allocSize) @@ -362,7 +362,7 @@ void ProjectSerializer::WriteName(const wxString & name) WriteUShort( mBuffer, id ); } -const MemoryStream &ProjectSerializer::GetDict() const +const MemoryStream &ProjectSerializer::GetDict() { return mDict; } diff --git a/src/ProjectSerializer.h b/src/ProjectSerializer.h index 3e530b39fe..556af1c879 100644 --- a/src/ProjectSerializer.h +++ b/src/ProjectSerializer.h @@ -38,7 +38,7 @@ class SAUCEDACITY_DLL_API ProjectSerializer final : public XMLWriter static TranslatableString FailureMessage( const FilePath &filePath ); ProjectSerializer(size_t allocSize = 1024 * 1024); - virtual ~ProjectSerializer(); + ~ProjectSerializer() override; void StartTag(const wxString & name) override; void EndTag(const wxString & name) override; @@ -60,7 +60,7 @@ class SAUCEDACITY_DLL_API ProjectSerializer final : public XMLWriter // Non-override functions void WriteSubTree(const ProjectSerializer & value); - const MemoryStream& GetDict() const; + static const MemoryStream& GetDict() ; const MemoryStream& GetData() const; bool IsEmpty() const; diff --git a/src/ProjectSettings.h b/src/ProjectSettings.h index 153686973d..404416db67 100644 --- a/src/ProjectSettings.h +++ b/src/ProjectSettings.h @@ -67,57 +67,57 @@ class SAUCEDACITY_DLL_API ProjectSettings final ProjectSettings &operator=( const ProjectSettings & ) = delete; - bool GetTracksFitVerticallyZoomed() const { return mTracksFitVerticallyZoomed; } //lda + [[nodiscard]] bool GetTracksFitVerticallyZoomed() const { return mTracksFitVerticallyZoomed; } //lda void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = flag; } //lda - bool GetShowId3Dialog() const { return mShowId3Dialog; } //lda + [[nodiscard]] bool GetShowId3Dialog() const { return mShowId3Dialog; } //lda void SetShowId3Dialog(bool flag) { mShowId3Dialog = flag; } //lda - bool IsSyncLocked() const; + [[nodiscard]] bool IsSyncLocked() const; void SetSyncLock(bool flag); // Rate void SetRate(double rate); - double GetRate() const; + [[nodiscard]] double GetRate() const; // Snap To void SetSnapTo(int snap); - int GetSnapTo() const; + [[nodiscard]] int GetSnapTo() const; // Current tool void SetTool(int tool) { mCurrentTool = tool; } - int GetTool() const { return mCurrentTool; } + [[nodiscard]] int GetTool() const { return mCurrentTool; } // Speed play - double GetPlaySpeed() const { + [[nodiscard]] double GetPlaySpeed() const { return mPlaySpeed.load( std::memory_order_relaxed ); } void SetPlaySpeed( double value ) { mPlaySpeed.store( value, std::memory_order_relaxed ); } // Selection Format void SetSelectionFormat(const NumericFormatSymbol & format); - const NumericFormatSymbol & GetSelectionFormat() const; + [[nodiscard]] const NumericFormatSymbol & GetSelectionFormat() const; // AudioTime format void SetAudioTimeFormat(const NumericFormatSymbol & format); - const NumericFormatSymbol & GetAudioTimeFormat() const; + [[nodiscard]] const NumericFormatSymbol & GetAudioTimeFormat() const; // Spectral Selection Formats void SetFrequencySelectionFormatName(const NumericFormatSymbol & format); - const NumericFormatSymbol & GetFrequencySelectionFormatName() const; + [[nodiscard]] const NumericFormatSymbol & GetFrequencySelectionFormatName() const; void SetBandwidthSelectionFormatName(const NumericFormatSymbol & format); - const NumericFormatSymbol & GetBandwidthSelectionFormatName() const; + [[nodiscard]] const NumericFormatSymbol & GetBandwidthSelectionFormatName() const; - bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); } - bool IsSoloNone() const { return mSoloPref == wxT("None"); } + [[nodiscard]] bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); } + [[nodiscard]] bool IsSoloNone() const { return mSoloPref == wxT("None"); } - bool EmptyCanBeDirty() const { return mEmptyCanBeDirty; } + [[nodiscard]] bool EmptyCanBeDirty() const { return mEmptyCanBeDirty; } - bool GetShowSplashScreen() const { return mShowSplashScreen; } + [[nodiscard]] bool GetShowSplashScreen() const { return mShowSplashScreen; } private: void UpdatePrefs() override; diff --git a/src/ProjectStatus.h b/src/ProjectStatus.h index 93f1794d7b..2f3a023889 100644 --- a/src/ProjectStatus.h +++ b/src/ProjectStatus.h @@ -66,7 +66,7 @@ class SAUCEDACITY_DLL_API ProjectStatus final static const StatusWidthFunctions &GetStatusWidthFunctions(); - const TranslatableString &Get( StatusBarField field = mainStatusBarField ) const; + [[nodiscard]] const TranslatableString &Get( StatusBarField field = mainStatusBarField ) const; void Set(const TranslatableString &msg, StatusBarField field = mainStatusBarField); diff --git a/src/ProjectWindow.cpp b/src/ProjectWindow.cpp index e951b96c47..daa1d6d745 100644 --- a/src/ProjectWindow.cpp +++ b/src/ProjectWindow.cpp @@ -217,11 +217,11 @@ void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized) } bool validWindowSize = false; - ProjectWindow * validProject = NULL; + ProjectWindow * validProject = nullptr; for ( auto iter = AllProjects{}.rbegin(), end = AllProjects{}.rend(); iter != end; ++iter ) { - auto pProject = *iter; + const auto& pProject = *iter; if (!GetProjectFrame( *pProject ).IsIconized()) { validWindowSize = true; validProject = &ProjectWindow::Get( *pProject ); @@ -313,7 +313,7 @@ class ScrollBar final : public wxScrollBar void OnSetFocus(wxFocusEvent & e) { wxWindow *w = e.GetWindow(); - if (w != NULL) { + if (w != nullptr) { w->SetFocus(); } } @@ -353,7 +353,7 @@ END_EVENT_TABLE() // Common mouse wheel handling in track panel cells, moved here to avoid // compilation dependencies on Track, TrackPanel, and Scrubbing at low levels // which made cycles -static struct MouseWheelHandler { +struct MouseWheelHandler { MouseWheelHandler() { @@ -1098,7 +1098,7 @@ void ProjectWindow::FixScrollbars() // Don't use the full 2^31 max int range but a bit less, so rounding // errors in calculations do not overflow max int - wxInt64 maxScrollbarRange = (wxInt64)(2147483647 * 0.999); + auto maxScrollbarRange = (wxInt64)(2147483647 * 0.999); if (viewInfo.sbarTotal > maxScrollbarRange) viewInfo.sbarScale = ((double)maxScrollbarRange) / viewInfo.sbarTotal; else diff --git a/src/ProjectWindow.h b/src/ProjectWindow.h index 62f93c4a5b..e8f9141f53 100644 --- a/src/ProjectWindow.h +++ b/src/ProjectWindow.h @@ -48,9 +48,9 @@ class SAUCEDACITY_DLL_API ProjectWindow final : public ProjectWindowBase int NextWindowID(); bool IsActive() override; - bool IsIconized() const override; + [[nodiscard]] bool IsIconized() const override; - bool IsBeingDeleted() const { return mIsDeleting; } + [[nodiscard]] bool IsBeingDeleted() const { return mIsDeleting; } void SetIsBeingDeleted() { mIsDeleting = true; } wxWindow *GetMainPage() { return mMainPage; } @@ -71,13 +71,13 @@ class SAUCEDACITY_DLL_API ProjectWindow final : public ProjectWindowBase Right, }; - Mode GetMode() const { return mMode; } + [[nodiscard]] Mode GetMode() const { return mMode; } void Activate(Mode mode) { mMode = mode; } - double GetRecentStreamTime() const { return mRecentStreamTime; } + [[nodiscard]] double GetRecentStreamTime() const { return mRecentStreamTime; } private: void OnTimer(wxCommandEvent &event); @@ -92,16 +92,16 @@ class SAUCEDACITY_DLL_API ProjectWindow final : public ProjectWindowBase PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; } void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; } - wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; } + [[nodiscard]] wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; } - void RedrawProject(const bool bForceWaveTracks = false); + void RedrawProject(bool bForceWaveTracks = false); void Zoom(double level); void ZoomInByFactor( double ZoomFactor ); void ZoomOutByFactor( double ZoomFactor ); void ZoomBy(double multiplier); void ZoomAfterImport(Track *pTrack); - double GetZoomOfToFit() const; + [[nodiscard]] double GetZoomOfToFit() const; void DoZoomFit(); void ApplyUpdatedTheme(); @@ -126,11 +126,11 @@ class SAUCEDACITY_DLL_API ProjectWindow final : public ProjectWindowBase void FinishAutoScroll(); void FixScrollbars(); - bool MayScrollBeyondZero() const; - double ScrollingLowerBoundTime() const; + [[nodiscard]] bool MayScrollBeyondZero() const; + [[nodiscard]] double ScrollingLowerBoundTime() const; // How many pixels are covered by the period from lowermost scrollable time, to the given time: // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac - double PixelWidthBeforeTime(double scrollto) const; + [[nodiscard]] double PixelWidthBeforeTime(double scrollto) const; void SetHorizontalThumb(double scrollto); // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel @@ -158,7 +158,7 @@ class SAUCEDACITY_DLL_API ProjectWindow final : public ProjectWindowBase void OnMenu(wxCommandEvent & event); void OnUpdateUI(wxUpdateUIEvent & event); - void MacShowUndockedToolbars(bool show); + static void MacShowUndockedToolbars(bool show); void OnActivate(wxActivateEvent & event); void OnMouseEvent(wxMouseEvent & event); diff --git a/src/ProjectWindowBase.h b/src/ProjectWindowBase.h index 271138fcb8..90a0e601ec 100644 --- a/src/ProjectWindowBase.h +++ b/src/ProjectWindowBase.h @@ -27,7 +27,7 @@ class ProjectWindowBase /* not final */ : public wxFrame ~ProjectWindowBase() override; SaucedacityProject &GetProject() { return mProject; } - const SaucedacityProject &GetProject() const { return mProject; } + [[nodiscard]] const SaucedacityProject &GetProject() const { return mProject; } protected: SaucedacityProject &mProject; diff --git a/src/RingBuffer.cpp b/src/RingBuffer.cpp index 3646f474ae..e4f2dd5504 100644 --- a/src/RingBuffer.cpp +++ b/src/RingBuffer.cpp @@ -44,7 +44,7 @@ RingBuffer::~RingBuffer() // Calculations of free and filled space, given snapshots taken of the start // and end values -size_t RingBuffer::Filled( size_t start, size_t end ) +size_t RingBuffer::Filled( size_t start, size_t end ) const { return (end + mBufferSize - start) % mBufferSize; } diff --git a/src/RingBuffer.h b/src/RingBuffer.h index ba33fe4572..d725e81295 100644 --- a/src/RingBuffer.h +++ b/src/RingBuffer.h @@ -42,7 +42,7 @@ class RingBuffer final : public NonInterferingBase { size_t Discard(size_t samples); private: - size_t Filled( size_t start, size_t end ); + size_t Filled( size_t start, size_t end ) const; size_t Free( size_t start, size_t end ); // Align the two atomics to avoid false sharing diff --git a/src/SampleBlock.h b/src/SampleBlock.h index dc03605c8f..4c2ef032ae 100644 --- a/src/SampleBlock.h +++ b/src/SampleBlock.h @@ -49,7 +49,7 @@ class SampleBlock virtual void CloseLock() = 0; - virtual SampleBlockID GetBlockID() const = 0; + [[nodiscard]] virtual SampleBlockID GetBlockID() const = 0; // If !mayThrow and there is an error, ignores it and returns zero. // That may be appropriate when only attempting to display samples, not edit. @@ -58,7 +58,7 @@ class SampleBlock size_t sampleoffset, size_t numsamples, bool mayThrow = true); - virtual size_t GetSampleCount() const = 0; + [[nodiscard]] virtual size_t GetSampleCount() const = 0; //! Non-throwing, should fill with zeroes on failure virtual bool @@ -76,9 +76,9 @@ class SampleBlock /// Gets extreme values for the entire block // If !mayThrow and there is an error, ignores it and returns zeroes. // That may be appropriate when only attempting to display samples, not edit. - MinMaxRMS GetMinMaxRMS(bool mayThrow = true) const; + [[nodiscard]] MinMaxRMS GetMinMaxRMS(bool mayThrow = true) const; - virtual size_t GetSpaceUsage() const = 0; + [[nodiscard]] virtual size_t GetSpaceUsage() const = 0; virtual void SaveXML(XMLWriter &xmlFile) = 0; @@ -90,7 +90,7 @@ class SampleBlock virtual MinMaxRMS DoGetMinMaxRMS(size_t start, size_t len) = 0; - virtual MinMaxRMS DoGetMinMaxRMS() const = 0; + [[nodiscard]] virtual MinMaxRMS DoGetMinMaxRMS() const = 0; }; // Makes a useful function object diff --git a/src/SaucedacityApp.cpp b/src/SaucedacityApp.cpp index 20680c0e5d..8f84393f57 100644 --- a/src/SaucedacityApp.cpp +++ b/src/SaucedacityApp.cpp @@ -205,7 +205,7 @@ void PopulatePreferences() int action = AudacityMessageBox( prompt, XO("Reset Saucedacity Preferences"), - wxYES_NO, NULL); + wxYES_NO, nullptr); if (action == wxYES) // reset { ResetPreferences(); @@ -385,7 +385,7 @@ static void QuitAudacity(bool bForce) else /*end+*/ { - if (AllProjects{}.size()) + if (!AllProjects{}.empty()) // PRL: Always did at least once before close might be vetoed // though I don't know why that is important ProjectManager::SaveWindowSize(); @@ -417,7 +417,7 @@ static void QuitAudacity(bool bForce) } //remove our logger - std::unique_ptr{ wxLog::SetActiveTarget(NULL) }; // DELETE + std::unique_ptr{ wxLog::SetActiveTarget(nullptr) }; // DELETE if (bForce) { @@ -450,12 +450,12 @@ class IPCConn final : public wxConnection { }; - ~IPCConn() + ~IPCConn() override { }; bool OnExec(const wxString & WXUNUSED(topic), - const wxString & data) + const wxString & data) override { // Add the filename to the queue. It will be opened by // the OnTimer() event when it is safe to do so. @@ -474,14 +474,14 @@ class IPCServ final : public wxServer Create(appl); }; - ~IPCServ() + ~IPCServ() override { }; wxConnectionBase *OnAcceptConnection(const wxString & topic) override { if (topic != IPC_TOPIC) { - return NULL; + return nullptr; } // Trust wxWidgets framework to DELETE it @@ -671,9 +671,9 @@ void SaucedacityApp::OnTimer(wxTimerEvent& WXUNUSED(event)) // AppleEvent messages (via wxWidgets). So, open any that are // in the queue and clean the queue. if (gInited) { - if (ofqueue.size()) { + if (!ofqueue.empty()) { // Load each file on the queue - while (ofqueue.size()) { + while (!ofqueue.empty()) { wxString name; name.swap(ofqueue[0]); ofqueue.erase( ofqueue.begin() ); @@ -1137,115 +1137,114 @@ bool SaucedacityApp::InitPart2() wxBitmap logo(logoimage); SaucedacityProject *project; - { - // Bug 718: Position splash screen on same screen - // as where Audacity project will appear. - wxRect wndRect; - bool bMaximized = false; - bool bIconized = false; - GetNextWindowPlacement(&wndRect, &bMaximized, &bIconized); - - wxSplashScreen temporarywindow( - logo, - wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, - 0, - NULL, - wxID_ANY, - wndRect.GetTopLeft(), - wxDefaultSize, - wxSTAY_ON_TOP); - - // Unfortunately with the Windows 10 Creators update, the splash screen - // now appears before setting its position. - // On a dual monitor screen it will appear on one screen and then - // possibly jump to the second. - // We could fix this by writing our own splash screen and using Hide() - // until the splash scren was correctly positioned, then Show() - - // Possibly move it on to the second screen... - temporarywindow.SetPosition( wndRect.GetTopLeft() ); - // Centered on whichever screen it is on. - temporarywindow.Center(); - temporarywindow.SetTitle(_("Saucedacity is starting up...")); - SetTopWindow(&temporarywindow); - temporarywindow.Show(); - temporarywindow.Raise(); - - - // ANSWER-ME: Why is YieldFor needed at all? - //wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_UNKNOWN); - wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); - - //JKC: Would like to put module loading here. - - // More initialization - - InitDitherers(); - try - { - AudioIO::Init(); - } catch (std::runtime_error& e) - { - /** GP: There are several possibilities for reaching this point: - * 1. atomic might be converted to atomic (AudioIO::AudioIO) - * 2. sizeof(float) is not greater than sizeof(short). - * - * This is preferrably done - **/ - AudacityMessageBox(XO("Saucedacity has encountered a critical error. This " - "is likely to do with your platform.\n\n" - "Error message (for devs): %s").Format(e.what()), - XO("Saucedacity - Critical Error") - ); + { + // Bug 718: Position splash screen on same screen + // as where Audacity project will appear. + wxRect wndRect; + bool bMaximized = false; + bool bIconized = false; + GetNextWindowPlacement(&wndRect, &bMaximized, &bIconized); + + wxSplashScreen temporarywindow( + logo, + wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, + 0, + nullptr, + wxID_ANY, + wndRect.GetTopLeft(), + wxDefaultSize, + wxSTAY_ON_TOP); + + // Unfortunately with the Windows 10 Creators update, the splash screen + // now appears before setting its position. + // On a dual monitor screen it will appear on one screen and then + // possibly jump to the second. + // We could fix this by writing our own splash screen and using Hide() + // until the splash scren was correctly positioned, then Show() + + // Possibly move it on to the second screen... + temporarywindow.SetPosition(wndRect.GetTopLeft()); + // Centered on whichever screen it is on. + temporarywindow.Center(); + temporarywindow.SetTitle(_("Saucedacity is starting up...")); + SetTopWindow(&temporarywindow); + temporarywindow.Show(); + temporarywindow.Raise(); + + + // ANSWER-ME: Why is YieldFor needed at all? + //wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_UNKNOWN); + wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); + + //JKC: Would like to put module loading here. + + // More initialization + + InitDitherers(); + try { + AudioIO::Init(); + } catch (std::runtime_error &e) { + /** GP: There are several possibilities for reaching this point: + * 1. atomic might be converted to atomic (AudioIO::AudioIO) + * 2. sizeof(float) is not greater than sizeof(short). + * + * This is preferrably done + **/ + AudacityMessageBox(XO("Saucedacity has encountered a critical error. This " + "is likely to do with your platform.\n\n" + "Error message (for devs): %s").Format(e.what()), + XO("Saucedacity - Critical Error") + ); - return false; - } + return false; + } #ifdef __WXMAC__ - // On the Mac, users don't expect a program to quit when you close the last window. - // Create a menubar that will show when all project windows are closed. + // On the Mac, users don't expect a program to quit when you close the last window. + // Create a menubar that will show when all project windows are closed. - auto fileMenu = std::make_unique(); - auto urecentMenu = std::make_unique(); - auto recentMenu = urecentMenu.get(); - fileMenu->Append(wxID_NEW, wxString(_("&New")) + wxT("\tCtrl+N")); - fileMenu->Append(wxID_OPEN, wxString(_("&Open...")) + wxT("\tCtrl+O")); - fileMenu->AppendSubMenu(urecentMenu.release(), _("Open &Recent...")); - fileMenu->Append(wxID_ABOUT, _("&About Saucedacity...")); - fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,")); + auto fileMenu = std::make_unique(); + auto urecentMenu = std::make_unique(); + auto recentMenu = urecentMenu.get(); + fileMenu->Append(wxID_NEW, wxString(_("&New")) + wxT("\tCtrl+N")); + fileMenu->Append(wxID_OPEN, wxString(_("&Open...")) + wxT("\tCtrl+O")); + fileMenu->AppendSubMenu(urecentMenu.release(), _("Open &Recent...")); + fileMenu->Append(wxID_ABOUT, _("&About Saucedacity...")); + fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,")); - { - auto menuBar = std::make_unique(); - menuBar->Append(fileMenu.release(), _("&File")); + { + auto menuBar = std::make_unique(); + menuBar->Append(fileMenu.release(), _("&File")); - // PRL: Are we sure wxWindows will not leak this menuBar? - // The online documentation is not explicit. - wxMenuBar::MacSetCommonMenuBar(menuBar.release()); - } + // PRL: Are we sure wxWindows will not leak this menuBar? + // The online documentation is not explicit. + wxMenuBar::MacSetCommonMenuBar(menuBar.release()); + } - auto &recentFiles = FileHistory::Global(); - recentFiles.UseMenu(recentMenu); + auto &recentFiles = FileHistory::Global(); + recentFiles.UseMenu(recentMenu); #endif //__WXMAC__ - temporarywindow.Show(false); - } - // Workaround Bug 1377 - Crash after Audacity starts and low disk space warning appears - // The temporary splash window is closed AND cleaned up, before attempting to create - // a project and possibly creating a modal warning dialog by doing so. - // Also fixes problem of warning being obscured. - // Downside is that we have no splash screen for the (brief) time that we spend - // creating the project. - // Root cause is problem with wxSplashScreen and other dialogs co-existing, that - // seemed to arrive with wx3. - { - project = ProjectManager::New(); - } - - if( ProjectSettings::Get( *project ).GetShowSplashScreen() ){ - SplashDialog::DoHelpWelcome(*project); - } + // Workaround Bug 1377 - Crash after Audacity starts and low disk space warning appears + // The temporary splash window is closed AND cleaned up, before attempting to create + // a project and possibly creating a modal warning dialog by doing so. + // Also fixes problem of warning being obscured. + // Downside is that we have no splash screen for the (brief) time that we spend + // creating the project. + // Root cause is problem with wxSplashScreen and other dialogs co-existing, that + // seemed to arrive with wx3. + { + project = ProjectManager::New(); + } + + if (ProjectSettings::Get(*project).GetShowSplashScreen()) { + SplashDialog::DoHelpWelcome(*project); + } + + temporarywindow.Show(false); + } #ifdef USE_FFMPEG FFmpegStartup(); @@ -1360,7 +1359,7 @@ void SaucedacityApp::InitCommandHandler() // AppCommandEvent callback - just pass the event on to the CommandHandler void SaucedacityApp::OnReceiveCommand(AppCommandEvent &event) { - wxASSERT(NULL != mCmdHandler); + wxASSERT(nullptr != mCmdHandler); mCmdHandler->OnReceiveCommand(event); } @@ -1410,7 +1409,7 @@ bool SaucedacityApp::InitTempDir() { // We need to find a temp directory location. auto tempFromPrefs = TempDirectory::TempDir(); - auto tempDefaultLoc = TempDirectory::DefaultTempDir(); + const auto& tempDefaultLoc = TempDirectory::DefaultTempDir(); wxString temp; @@ -1585,7 +1584,7 @@ bool SaucedacityApp::CreateSingleInstanceChecker(const wxString &dir) #if defined(__UNIX__) -void SaucedacityApp::CleanupIPCResources() +void SaucedacityApp::CleanupIPCResources() const { if (mWasServer) { @@ -1781,15 +1780,15 @@ bool SaucedacityApp::CreateSingleInstanceChecker(const wxString& /* unused */) sock->Connect(addr, true); if (!sock->IsConnected()) { - // All attempts to become the server or connect to one have failed. Not - // sure what we can say about the error, but it's probably not because - // Audacity is already running. - AudacityMessageBox( - XO("An unrecoverable error has occurred during startup"), - XO("Saucedacity Startup Failure"), - wxOK | wxICON_ERROR); - - return false; + // All attempts to become the server or connect to one have failed. Not + // sure what we can say about the error, but it's probably not because + // Audacity is already running. + AudacityMessageBox( + XO("Unable to connect to the IPC server. Saucedacity cannot continue."), + XO("Saucedacity Startup Failure"), + wxOK | wxICON_ERROR); + + return false; } // Parse the command line to ensure correct syntax, but ignore @@ -1815,7 +1814,7 @@ bool SaucedacityApp::CreateSingleInstanceChecker(const wxString& /* unused */) // Let the user know that another copy is running. AudacityMessageBox(XO("Another copy of Saucedacity has been detected" "running on this system. Running multiple copies of" - "Saucedacity is not supported\n\n" + "Saucedacity is not supported.\n\n" "You will now be redirected to the running copy."), XO("Saucedacity is already running"), wxOK @@ -1945,7 +1944,7 @@ void SaucedacityApp::OnEndSession(wxCloseEvent & event) // Try to close each open window. If the user hits Cancel // in a Save Changes dialog, don't continue. gIsQuitting = true; - if (AllProjects{}.size()) + if (!AllProjects{}.empty()) // PRL: Always did at least once before close might be vetoed // though I don't know why that is important ProjectManager::SaveWindowSize(); @@ -2047,7 +2046,7 @@ void SaucedacityApp::OnMenuOpen(wxCommandEvent & event) if(AllProjects{}.empty()) - ProjectManager::OpenFiles(NULL); + ProjectManager::OpenFiles(nullptr); else event.Skip(); diff --git a/src/SaucedacityApp.h b/src/SaucedacityApp.h index a5f49db35b..fef959a293 100644 --- a/src/SaucedacityApp.h +++ b/src/SaucedacityApp.h @@ -40,20 +40,20 @@ class SaucedacityProject; class SaucedacityApp final : public wxApp { public: SaucedacityApp(); - ~SaucedacityApp(); - bool OnInit(void) override; + ~SaucedacityApp() override; + bool OnInit() override; bool InitPart2(); - int OnExit(void) override; + int OnExit() override; void OnFatalException() override; bool OnExceptionInMainLoop() override; - // These are currently only used on Mac OS, where it's + // These are currently only used on macOS, where it's // possible to have a menu bar but no windows open. It doesn't // hurt any other platforms, though. - void OnMenuAbout(wxCommandEvent & event); - void OnMenuNew(wxCommandEvent & event); - void OnMenuOpen(wxCommandEvent & event); - void OnMenuPreferences(wxCommandEvent & event); + static void OnMenuAbout(wxCommandEvent & event); + static void OnMenuNew(wxCommandEvent & event); + static void OnMenuOpen(wxCommandEvent & event); + static void OnMenuPreferences(wxCommandEvent & event); void OnMenuExit(wxCommandEvent & event); void OnQueryEndSession(wxCloseEvent & event); @@ -63,7 +63,7 @@ class SaucedacityApp final : public wxApp { void OnMRUClear(wxCommandEvent &event); void OnMRUFile(wxCommandEvent &event); // Backend for above - returns true for success, false for failure - bool MRUOpen(const FilePath &fileName); + static bool MRUOpen(const FilePath &fileName); // A wrapper of the above that does not throw bool SafeMRUOpen(const wxString &fileName); @@ -105,7 +105,7 @@ class SaucedacityApp final : public wxApp { void InitCommandHandler(); - bool InitTempDir(); + static bool InitTempDir(); bool CreateSingleInstanceChecker(const wxString &dir); std::unique_ptr ParseCommandLine(); @@ -128,7 +128,7 @@ class SaucedacityApp final : public wxApp { * catastrophic happens. * **/ - void CleanupIPCResources(); + void CleanupIPCResources() const; #endif public: diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index b075efa448..7bd351f69c 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -67,7 +67,7 @@ class ScreenshotBigDialog final : public wxFrame, // constructors and destructors ScreenshotBigDialog( wxWindow *parent, wxWindowID id, SaucedacityProject &project); - virtual ~ScreenshotBigDialog(); + ~ScreenshotBigDialog() override; bool ProcessEvent(wxEvent & event) override; @@ -165,7 +165,7 @@ class ScreenFrameTimer final : public wxTimer evt.reset(event.Clone()); } - virtual ~ScreenFrameTimer() + ~ScreenFrameTimer() override { if (IsRunning()) { @@ -176,7 +176,7 @@ class ScreenFrameTimer final : public wxTimer void Notify() override { // Process timer notification just once, then destroy self - evt->SetEventObject(NULL); + evt->SetEventObject(nullptr); screenFrame->ProcessEvent(*evt); } @@ -278,7 +278,7 @@ END_EVENT_TABLE(); // Must not be called before CreateStatusBar! std::unique_ptr ScreenshotBigDialog::CreateCommand() { - wxASSERT(mStatus != NULL); + wxASSERT(mStatus != nullptr); auto output = std::make_unique(std::make_unique(), std::make_shared(*mStatus), @@ -307,8 +307,8 @@ ScreenshotBigDialog::ScreenshotBigDialog( , mProject{ project } , mContext( project ) { - mDelayCheckBox = NULL; - mDirectoryTextBox = NULL; + mDelayCheckBox = nullptr; + mDirectoryTextBox = nullptr; mStatus = CreateStatusBar(3); mCommand = CreateCommand(); @@ -525,14 +525,14 @@ bool ScreenshotBigDialog::ProcessEvent(wxEvent & e) e.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) { if( id >= IdAllDelayedEvents && id <= IdLastDelayedEvent && - e.GetEventObject() != NULL) { + e.GetEventObject() != nullptr) { mTimer = std::make_unique(this, e); mTimer->Start(5000, true); return true; } } - if (e.IsCommandEvent() && e.GetEventObject() == NULL) { + if (e.IsCommandEvent() && e.GetEventObject() == nullptr) { e.SetEventObject(this); } } @@ -661,7 +661,7 @@ void ScreenshotBigDialog::DoCapture(int captureMode) // Bug 2323: (100% hackage alert) Since the command target dialog is not // accessible from outside the command, this seems to be the only way we // can get the window on top of this dialog. - auto w = static_cast(wxFindWindowByLabel(XO("Long Message").Translation())); + auto w = dynamic_cast(wxFindWindowByLabel(XO("Long Message").Translation())); if (w) { auto endmodal = [w](wxCommandEvent &evt) { diff --git a/src/SelectedRegion.cpp b/src/SelectedRegion.cpp index 12d466fca0..b7851a0862 100644 --- a/src/SelectedRegion.cpp +++ b/src/SelectedRegion.cpp @@ -41,7 +41,7 @@ bool SelectedRegion::HandleXMLAttribute const wxChar *legacyT0Name, const wxChar *legacyT1Name) { typedef bool (SelectedRegion::*Setter)(double, bool); - Setter setter = 0; + Setter setter = nullptr; if (!wxStrcmp(attr, legacyT0Name)) setter = &SelectedRegion::setT0; else if (!wxStrcmp(attr, legacyT1Name)) diff --git a/src/SelectedRegion.h b/src/SelectedRegion.h index 48012dbb3e..4ffc294879 100644 --- a/src/SelectedRegion.h +++ b/src/SelectedRegion.h @@ -88,15 +88,15 @@ class SAUCEDACITY_DLL_API SelectedRegion { // Accessors - double t0() const { return mT0; } - double t1() const { return mT1; } - double duration() const { return mT1 - mT0; } - bool isPoint() const { return mT1 <= mT0; } + [[nodiscard]] double t0() const { return mT0; } + [[nodiscard]] double t1() const { return mT1; } + [[nodiscard]] double duration() const { return mT1 - mT0; } + [[nodiscard]] bool isPoint() const { return mT1 <= mT0; } #ifdef EXPERIMENTAL_SPECTRAL_EDITING - double f0() const { return mF0; } - double f1() const { return mF1; } - double fc() const { + [[nodiscard]] double f0() const { return mF0; } + [[nodiscard]] double f1() const { return mF1; } + [[nodiscard]] double fc() const { if (mF0 == UndefinedFrequency || mF1 == UndefinedFrequency) return UndefinedFrequency; diff --git a/src/SelectionState.cpp b/src/SelectionState.cpp index cba8bb0d0c..fad1f7087a 100644 --- a/src/SelectionState.cpp +++ b/src/SelectionState.cpp @@ -161,7 +161,7 @@ SelectionStateChanger::~SelectionStateChanger() if ( mpState ) { // roll back changes mpState->mLastPickedTrack = mInitialLastPickedTrack; - std::vector::const_iterator + auto it = mInitialTrackSelection.begin(), end = mInitialTrackSelection.end(); diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 25c396f8d7..1710e27790 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -142,7 +142,7 @@ bool Sequence::ConvertToSampleFormat(sampleFormat format, // no change return false; - if (mBlock.size() == 0) + if (mBlock.empty()) { mSampleFormat = format; return true; @@ -224,7 +224,7 @@ bool Sequence::ConvertToSampleFormat(sampleFormat format, std::pair Sequence::GetMinMax( sampleCount start, sampleCount len, bool mayThrow) const { - if (len == 0 || mBlock.size() == 0) { + if (len == 0 || mBlock.empty()) { return { 0.f, // FLT_MAX? So it doesn't look like a spurious '0' to a caller? @@ -307,7 +307,7 @@ float Sequence::GetRMS(sampleCount start, sampleCount len, bool mayThrow) const { // len is the number of samples that we want the rms of. // it may be longer than a block, and the code is carefully set up to handle that. - if (len == 0 || mBlock.size() == 0) + if (len == 0 || mBlock.empty()) return 0.f; double sumsq = 0.0; @@ -677,7 +677,7 @@ void Sequence::Paste(sampleCount s, const Sequence *src) /*! @excsafety{Strong} */ void Sequence::SetSilence(sampleCount s0, sampleCount len) { - SetSamples(NULL, mSampleFormat, s0, len); + SetSamples(nullptr, mSampleFormat, s0, len); } /*! @excsafety{Strong} */ diff --git a/src/Sequence.h b/src/Sequence.h index b03850d3df..568de62495 100644 --- a/src/Sequence.h +++ b/src/Sequence.h @@ -12,6 +12,7 @@ #define __AUDACITY_SEQUENCE__ +#include #include #include @@ -36,12 +37,12 @@ class SeqBlock { : sb{}, start(0) {} - SeqBlock(const SampleBlockPtr &sb_, sampleCount start_) - : sb(sb_), start(start_) + SeqBlock(SampleBlockPtr sb_, sampleCount start_) + : sb(std::move(sb_)), start(start_) {} // Construct a SeqBlock with changed start, same file - SeqBlock Plus(sampleCount delta) const + [[nodiscard]] SeqBlock Plus(sampleCount delta) const { return SeqBlock(sb, start + delta); } @@ -79,13 +80,13 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ Sequence( const Sequence& ) = delete; Sequence& operator= (const Sequence&) = delete; - ~Sequence(); + ~Sequence() override; // // Editing // - sampleCount GetNumSamples() const { return mNumSamples; } + [[nodiscard]] sampleCount GetNumSamples() const { return mNumSamples; } bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow) const; @@ -108,11 +109,11 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // Return non-null, or else throw! // Must pass in the correct factory for the result. If it's not the same // as in this, then block contents must be copied. - std::unique_ptr Copy( const SampleBlockFactoryPtr &pFactory, + [[nodiscard]] std::unique_ptr Copy( const SampleBlockFactoryPtr &pFactory, sampleCount s0, sampleCount s1) const; void Paste(sampleCount s0, const Sequence *src); - size_t GetIdealAppendLen() const; + [[nodiscard]] size_t GetIdealAppendLen() const; void Append(constSamplePtr buffer, sampleFormat format, size_t len); //! Append data, not coalescing blocks, returning a pointer to the new block. @@ -136,7 +137,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ XMLTagHandler *HandleXMLChild(const wxChar *tag) override; void WriteXML(XMLWriter &xmlFile) const /* not override */; - bool GetErrorOpening() { return mErrorOpening; } + bool GetErrorOpening() const { return mErrorOpening; } // // Lock all of this sequence's sample blocks, keeping them @@ -149,7 +150,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // Manipulating Sample Format // - sampleFormat GetSampleFormat() const; + [[nodiscard]] sampleFormat GetSampleFormat() const; // Return true iff there is a change bool ConvertToSampleFormat(sampleFormat format, @@ -159,21 +160,21 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // Retrieving summary info // - std::pair GetMinMax( + [[nodiscard]] std::pair GetMinMax( sampleCount start, sampleCount len, bool mayThrow) const; - float GetRMS(sampleCount start, sampleCount len, bool mayThrow) const; + [[nodiscard]] float GetRMS(sampleCount start, sampleCount len, bool mayThrow) const; // // Getting block size and alignment information // // This returns a possibly large or negative value - sampleCount GetBlockStart(sampleCount position) const; + [[nodiscard]] sampleCount GetBlockStart(sampleCount position) const; // These return a nonnegative number of samples meant to size a memory buffer - size_t GetBestBlockSize(sampleCount start) const; - size_t GetMaxBlockSize() const; - size_t GetIdealBlockSize() const; + [[nodiscard]] size_t GetBestBlockSize(sampleCount start) const; + [[nodiscard]] size_t GetMaxBlockSize() const; + [[nodiscard]] size_t GetIdealBlockSize() const; // // This should only be used if you really, really know what @@ -181,7 +182,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // BlockArray &GetBlockArray() { return mBlock; } - const BlockArray &GetBlockArray() const { return mBlock; } + [[nodiscard]] const BlockArray &GetBlockArray() const { return mBlock; } private: @@ -212,7 +213,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // Private methods // - int FindBlock(sampleCount pos) const; + [[nodiscard]] int FindBlock(sampleCount pos) const; SeqBlock::SampleBlockPtr DoAppend( constSamplePtr buffer, sampleFormat format, size_t len, bool coalesce); diff --git a/src/Snap.h b/src/Snap.h index b254850c01..1eb818c275 100644 --- a/src/Snap.h +++ b/src/Snap.h @@ -49,7 +49,7 @@ struct SnapResults { bool snappedPoint{ false }; bool snappedTime{ false }; - bool Snapped() const { return snappedPoint || snappedTime; } + [[nodiscard]] bool Snapped() const { return snappedPoint || snappedTime; } }; class SAUCEDACITY_DLL_API SnapManager diff --git a/src/SoundActivatedRecord.h b/src/SoundActivatedRecord.h index 8ea022d827..dec7a38c9b 100644 --- a/src/SoundActivatedRecord.h +++ b/src/SoundActivatedRecord.h @@ -24,12 +24,12 @@ class SoundActivatedRecordDialog final : public wxDialogWrapper { public: SoundActivatedRecordDialog(wxWindow* parent); - ~SoundActivatedRecordDialog(); + ~SoundActivatedRecordDialog() override; private: void OnOK(wxCommandEvent& event); - void PopulateOrExchange(ShuttleGui& S); + static void PopulateOrExchange(ShuttleGui& S); DECLARE_EVENT_TABLE() }; diff --git a/src/SpectrumAnalyst.cpp b/src/SpectrumAnalyst.cpp index 9e00be0f31..bd368362ec 100644 --- a/src/SpectrumAnalyst.cpp +++ b/src/SpectrumAnalyst.cpp @@ -210,7 +210,7 @@ bool SpectrumAnalyst::Calculate(Algorithm alg, int windowFunc, in[i] = log(power); } // Take IFFT - InverseRealFFT(mWindowSize, in.get(), NULL, out.get()); + InverseRealFFT(mWindowSize, in.get(), nullptr, out.get()); // Take real part of result for (size_t i = 0; i < half; i++) @@ -360,7 +360,7 @@ float SpectrumAnalyst::GetProcessedValue(float freq0, float freq1) const } binwidth = bin1 - bin0; - float value = float(0.0); + auto value = float(0.0); if (binwidth < 1.0) { float binmid = (bin0 + bin1) / 2.0; @@ -448,7 +448,7 @@ float SpectrumAnalyst::FindPeak(float xPos, float *pY) const // returns the value of this polynomial at a value x. Usually // 0 < x < 3 -float SpectrumAnalyst::CubicInterpolate(float y0, float y1, float y2, float y3, float x) const +float SpectrumAnalyst::CubicInterpolate(float y0, float y1, float y2, float y3, float x) { float a, b, c, d; @@ -463,7 +463,7 @@ float SpectrumAnalyst::CubicInterpolate(float y0, float y1, float y2, float y3, return (a * xxx + b * xx + c * x + d); } -float SpectrumAnalyst::CubicMaximize(float y0, float y1, float y2, float y3, float * max) const +float SpectrumAnalyst::CubicMaximize(float y0, float y1, float y2, float y3, float * max) { // Find coefficients of cubic diff --git a/src/SpectrumAnalyst.h b/src/SpectrumAnalyst.h index 9ba02662fc..c282da4038 100644 --- a/src/SpectrumAnalyst.h +++ b/src/SpectrumAnalyst.h @@ -39,18 +39,18 @@ class SAUCEDACITY_DLL_API SpectrumAnalyst int windowFunc, // see FFT.h for values size_t windowSize, double rate, const float *data, size_t dataLen, - float *pYMin = NULL, float *pYMax = NULL, // outputs - FreqGauge *progress = NULL); + float *pYMin = nullptr, float *pYMax = nullptr, // outputs + FreqGauge *progress = nullptr); - const float *GetProcessed() const; - int GetProcessedSize() const; + [[nodiscard]] const float *GetProcessed() const; + [[nodiscard]] int GetProcessedSize() const; - float GetProcessedValue(float freq0, float freq1) const; + [[nodiscard]] float GetProcessedValue(float freq0, float freq1) const; float FindPeak(float xPos, float *pY) const; private: - float CubicInterpolate(float y0, float y1, float y2, float y3, float x) const; - float CubicMaximize(float y0, float y1, float y2, float y3, float * max) const; + [[nodiscard]] static float CubicInterpolate(float y0, float y1, float y2, float y3, float x) ; + static float CubicMaximize(float y0, float y1, float y2, float y3, float * max) ; private: Algorithm mAlg; diff --git a/src/SplashDialog.cpp b/src/SplashDialog.cpp index 798433f2ef..51356d798a 100644 --- a/src/SplashDialog.cpp +++ b/src/SplashDialog.cpp @@ -46,7 +46,7 @@ most commonly asked questions about Audacity. #include "../images/SaucedacityLogoWithName.xpm" -SplashDialog * SplashDialog::pSelf=NULL; +SplashDialog * SplashDialog::pSelf=nullptr; enum { @@ -71,7 +71,7 @@ SplashDialog::SplashDialog(wxWindow * parent) wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { SetName(); - m_pLogo = NULL; //v + m_pLogo = nullptr; //v ShuttleGui S( this, eIsCreating ); Populate( S ); Fit(); @@ -125,7 +125,7 @@ void SplashDialog::Populate( ShuttleGui & S ) RescaledImage.Rescale( (int)(LOGOWITHNAME_WIDTH * fScale), (int)(LOGOWITHNAME_HEIGHT *fScale), wxIMAGE_QUALITY_HIGH ); wxBitmap RescaledBitmap( RescaledImage ); - wxStaticBitmap *const icon = + auto *const icon = safenew wxStaticBitmap(S.GetParent(), -1, //*m_pLogo, //v theTheme.Bitmap(bmpAudacityLogoWithName), RescaledBitmap, @@ -178,7 +178,7 @@ void SplashDialog::OnOK(wxCommandEvent & WXUNUSED(event)) void SplashDialog::Show2( wxWindow * pParent ) { - if( pSelf == NULL ) + if( pSelf == nullptr ) { // pParent owns it wxASSERT(pParent); diff --git a/src/SplashDialog.h b/src/SplashDialog.h index 92e559c3e4..eabe56bfad 100644 --- a/src/SplashDialog.h +++ b/src/SplashDialog.h @@ -27,7 +27,7 @@ class SplashDialog final : public wxDialogWrapper { static void DoHelpWelcome( SaucedacityProject &project ); SplashDialog(wxWindow * parent); - virtual ~ SplashDialog(); + ~ SplashDialog() override; void OnOK(wxCommandEvent & event); static void Show2( wxWindow * pParent ); @@ -35,7 +35,7 @@ class SplashDialog final : public wxDialogWrapper { private: - void OnChar(wxMouseEvent &event); + static void OnChar(wxMouseEvent &event); void Populate( ShuttleGui & S ); void OnDontShow( wxCommandEvent & Evt ); diff --git a/src/SqliteSampleBlock.cpp b/src/SqliteSampleBlock.cpp index d0d20c5504..ac4757ffd9 100644 --- a/src/SqliteSampleBlock.cpp +++ b/src/SqliteSampleBlock.cpp @@ -9,6 +9,7 @@ Paul Licameli -- split from SampleBlock.cpp and SampleBlock.h **********************************************************************/ #include +#include #include #include "DBConnection.h" @@ -30,7 +31,7 @@ class SqliteSampleBlock final : public SampleBlock public: explicit SqliteSampleBlock( - const std::shared_ptr &pFactory); + std::shared_ptr pFactory); ~SqliteSampleBlock() override; void CloseLock() override; @@ -44,32 +45,32 @@ class SqliteSampleBlock final : public SampleBlock void Delete(); - SampleBlockID GetBlockID() const override; + [[nodiscard]] SampleBlockID GetBlockID() const override; size_t DoGetSamples(samplePtr dest, sampleFormat destformat, size_t sampleoffset, size_t numsamples) override; - sampleFormat GetSampleFormat() const; - size_t GetSampleCount() const override; + [[nodiscard]] sampleFormat GetSampleFormat() const; + [[nodiscard]] size_t GetSampleCount() const override; bool GetSummary256(float *dest, size_t frameoffset, size_t numframes) override; bool GetSummary64k(float *dest, size_t frameoffset, size_t numframes) override; - double GetSumMin() const; - double GetSumMax() const; - double GetSumRms() const; + [[nodiscard]] double GetSumMin() const; + [[nodiscard]] double GetSumMax() const; + [[nodiscard]] double GetSumRms() const; /// Gets extreme values for the specified region MinMaxRMS DoGetMinMaxRMS(size_t start, size_t len) override; /// Gets extreme values for the entire block - MinMaxRMS DoGetMinMaxRMS() const override; + [[nodiscard]] MinMaxRMS DoGetMinMaxRMS() const override; - size_t GetSpaceUsage() const override; + [[nodiscard]] size_t GetSpaceUsage() const override; void SaveXML(XMLWriter &xmlFile) override; private: - bool IsSilent() const { return mBlockID <= 0; } + [[nodiscard]] bool IsSilent() const { return mBlockID <= 0; } void Load(SampleBlockID sbid); bool GetSummary(float *dest, size_t frameoffset, @@ -93,8 +94,8 @@ class SqliteSampleBlock final : public SampleBlock private: //! This must never be called for silent blocks /*! @post return value is not null */ - DBConnection *Conn() const; - sqlite3 *DB() const + [[nodiscard]] DBConnection *Conn() const; + [[nodiscard]] sqlite3 *DB() const { return Conn()->DB(); } @@ -292,8 +293,8 @@ auto SqliteSampleBlockFactory::SetBlockDeletionCallback( } SqliteSampleBlock::SqliteSampleBlock( - const std::shared_ptr &pFactory) -: mpFactory(pFactory) + std::shared_ptr pFactory) +: mpFactory(std::move(pFactory)) { mSampleFormat = floatSample; mSampleBytes = 0; @@ -497,7 +498,7 @@ MinMaxRMS SqliteSampleBlock::DoGetMinMaxRMS(size_t start, size_t len) // TODO: actually use summaries SampleBuffer blockData(len, floatSample); - float *samples = (float *) blockData.ptr(); + auto *samples = (float *) blockData.ptr(); size_t copied = DoGetSamples((samplePtr) samples, floatSample, start, len); for (size_t i = 0; i < copied; ++i, ++samples) @@ -587,8 +588,8 @@ size_t SqliteSampleBlock::GetBlob(void *dest, } // Retrieve returned data - samplePtr src = (samplePtr) sqlite3_column_blob(stmt, 0); - size_t blobbytes = (size_t) sqlite3_column_bytes(stmt, 0); + auto src = (samplePtr) sqlite3_column_blob(stmt, 0); + auto blobbytes = (size_t) sqlite3_column_bytes(stmt, 0); srcoffset = std::min(srcoffset, blobbytes); minbytes = std::min(srcbytes, blobbytes - srcoffset); @@ -855,8 +856,8 @@ void SqliteSampleBlock::CalcSummary(Sizes sizes) mSummary256.reinit(mSummary256Bytes); mSummary64k.reinit(mSummary64kBytes); - float *summary256 = (float *) mSummary256.get(); - float *summary64k = (float *) mSummary64k.get(); + auto *summary256 = (float *) mSummary256.get(); + auto *summary64k = (float *) mSummary64k.get(); float min; float max; @@ -947,7 +948,7 @@ void SqliteSampleBlock::CalcSummary(Sizes sizes) } double denom = (i < sumLen - 1) ? 256.0 : summaries - fraction; - float rms = (float) sqrt(sumsq / denom); + auto rms = (float) sqrt(sumsq / denom); summary64k[i * fields] = min; summary64k[i * fields + 1] = max; diff --git a/src/Tags.cpp b/src/Tags.cpp index 24b40f2119..d15e5b43ff 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -328,7 +328,7 @@ void Tags::LoadDefaults() gPrefs->SetPath(path); } -bool Tags::IsEmpty() +bool Tags::IsEmpty() const { // At least one of these should be filled in, otherwise // it's assumed that the tags have not been set... @@ -398,8 +398,8 @@ int Tags::GetNumUserGenres() void Tags::LoadDefaultGenres() { mGenres.clear(); - for (size_t i = 0; i < WXSIZEOF(DefaultGenres); i++) { - mGenres.push_back(DefaultGenres[i]); + for (auto & DefaultGenre : DefaultGenres) { + mGenres.push_back(DefaultGenre); } } @@ -506,7 +506,7 @@ void Tags::SetTag(const wxString & name, const wxString & value, const bool bSpe key.UpperCase(); // Look it up - TagMap::iterator iter = mXref.find(key); + auto iter = mXref.find(key); // The special tags, if empty, should not exist. // However it is allowable for a custom tag to be empty. @@ -599,7 +599,7 @@ XMLTagHandler *Tags::HandleXMLChild(const wxChar *tag) return this; } - return NULL; + return nullptr; } void Tags::WriteXML(XMLWriter &xmlFile) const @@ -673,7 +673,7 @@ class ComboEditor final : public wxGridCellChoiceEditor // Fix for Bug 1389 // July 2016: ANSWER-ME: Does this need reporting upstream to wxWidgets? - virtual void StartingKey(wxKeyEvent& event) override + void StartingKey(wxKeyEvent& event) override { // Lifted from wxGridCellTextEditor and adapted to combo. @@ -724,7 +724,7 @@ class ComboEditor final : public wxGridCellChoiceEditor } // Clone is required by wxwidgets; implemented via copy constructor - wxGridCellEditor *Clone() const override + [[nodiscard]] wxGridCellEditor *Clone() const override { return safenew ComboEditor{ m_choices, m_allowOthers }; } @@ -816,7 +816,7 @@ TagsEditorDialog::TagsEditorDialog(wxWindow * parent, { SetName(); - mGrid = NULL; + mGrid = nullptr; // Make a local copy of the passed in tags mLocal = *mTags; @@ -891,7 +891,7 @@ void TagsEditorDialog::PopulateOrExchange(ShuttleGui & S) } S.EndHorizontalLay(); - if (mGrid == NULL) { + if (mGrid == nullptr) { mGrid = safenew Grid(S.GetParent(), wxID_ANY, wxDefaultPosition, @@ -1131,8 +1131,7 @@ void TagsEditorDialog::OnChange(wxGridEvent & event) } } - return; -} + } void TagsEditorDialog::OnEdit(wxCommandEvent & WXUNUSED(event)) { @@ -1290,8 +1289,6 @@ void TagsEditorDialog::OnLoad(wxCommandEvent & WXUNUSED(event)) // Go fill up the window TransferDataToWindow(); - - return; } void TagsEditorDialog::OnSave(wxCommandEvent & WXUNUSED(event)) @@ -1494,7 +1491,7 @@ void TagsEditorDialog::SetEditors() mGrid->SetCellEditor(i, 1, mGrid->GetDefaultEditorForType(wxT("Combo"))); } else { - mGrid->SetCellEditor(i, 1, NULL); //mGrid->GetDefaultEditor()); + mGrid->SetCellEditor(i, 1, nullptr); //mGrid->GetDefaultEditor()); } } } @@ -1522,7 +1519,7 @@ void TagsEditorDialog::PopulateGenres() editor->DecRef(); } -bool TagsEditorDialog::IsWindowRectValid(const wxRect *windowRect) const +bool TagsEditorDialog::IsWindowRectValid(const wxRect *windowRect) { wxDisplay display; wxPoint topLeft(windowRect->GetTopLeft().x, windowRect->GetTopLeft().y); diff --git a/src/Tags.h b/src/Tags.h index e22e72b2a5..b2a30be7be 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -83,7 +83,7 @@ class SAUCEDACITY_DLL_API Tags final Tags(); // constructor Tags( const Tags& ) = default; //Tags( Tags && ) = default; - virtual ~Tags(); + ~Tags() override; std::shared_ptr Duplicate() const; @@ -109,8 +109,8 @@ class SAUCEDACITY_DLL_API Tags final int GetNumUserGenres(); wxString GetUserGenre(int value); - wxString GetGenre(int value); - int GetGenre(const wxString & name); + static wxString GetGenre(int value); + static int GetGenre(const wxString & name); bool HasTag(const wxString & name) const; wxString GetTag(const wxString & name) const; @@ -118,10 +118,10 @@ class SAUCEDACITY_DLL_API Tags final using Iterators = IteratorRange; Iterators GetRange() const; - void SetTag(const wxString & name, const wxString & value, const bool bSpecialTag=false); + void SetTag(const wxString & name, const wxString & value, bool bSpecialTag=false); void SetTag(const wxString & name, const int & value); - bool IsEmpty(); + bool IsEmpty() const; void Clear(); friend bool operator == (const Tags &lhs, const Tags &rhs); @@ -149,7 +149,7 @@ class TagsEditorDialog final : public wxDialogWrapper bool editTitle, bool editTrack); - virtual ~TagsEditorDialog(); + ~TagsEditorDialog() override; #if !defined(__WXMSW__) bool IsEscapeKey(const wxKeyEvent& /*event*/) override { return false; } @@ -186,7 +186,7 @@ class TagsEditorDialog final : public wxDialogWrapper void OnKeyDown(wxKeyEvent &event); - bool IsWindowRectValid(const wxRect *windowRect) const; + static bool IsWindowRectValid(const wxRect *windowRect) ; private: Tags *mTags; diff --git a/src/TimeDialog.cpp b/src/TimeDialog.cpp index 9f7f5871dc..d187403312 100644 --- a/src/TimeDialog.cpp +++ b/src/TimeDialog.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include "shuttle/ShuttleGui.h" #include "widgets/NumericTextCtrl.h" @@ -30,16 +32,16 @@ END_EVENT_TABLE() TimeDialog::TimeDialog(wxWindow *parent, const TranslatableString &title, - const NumericFormatSymbol &format, + NumericFormatSymbol format, double rate, double time, - const TranslatableString &prompt) + TranslatableString prompt) : wxDialogWrapper(parent, wxID_ANY, title), - mPrompt(prompt), - mFormat(format), + mPrompt(std::move(prompt)), + mFormat(std::move(format)), mRate(rate), mTime(time), - mTimeCtrl(NULL) + mTimeCtrl(nullptr) { SetName(); ShuttleGui S(this, eIsCreating); @@ -94,7 +96,7 @@ bool TimeDialog::TransferDataFromWindow() return true; } -const double TimeDialog::GetTimeValue() +const double TimeDialog::GetTimeValue() const { return mTime; } diff --git a/src/TimeDialog.h b/src/TimeDialog.h index d01a150858..cd5717f2f7 100644 --- a/src/TimeDialog.h +++ b/src/TimeDialog.h @@ -27,15 +27,15 @@ class SAUCEDACITY_DLL_API TimeDialog final : public wxDialogWrapper TimeDialog(wxWindow *parent, const TranslatableString &title, - const NumericFormatSymbol &format, + NumericFormatSymbol format, double rate, double time, - const TranslatableString &prompt = XO("Duration")); + TranslatableString prompt = XO("Duration")); void SetFormatString(const NumericFormatSymbol &formatString); void SetSampleRate(double sampleRate); void SetTimeValue(double newTime); - const double GetTimeValue(); + const double GetTimeValue() const; private: diff --git a/src/TimeTrack.cpp b/src/TimeTrack.cpp index 9640c504ca..7ab5e5dfeb 100644 --- a/src/TimeTrack.cpp +++ b/src/TimeTrack.cpp @@ -278,7 +278,7 @@ XMLTagHandler *TimeTrack::HandleXMLChild(const wxChar *tag) if (!wxStrcmp(tag, wxT("envelope"))) return mEnvelope.get(); - return NULL; + return nullptr; } void TimeTrack::WriteXML(XMLWriter &xmlFile) const diff --git a/src/TimeTrack.h b/src/TimeTrack.h index 1436541e11..ffe4bf0ef1 100644 --- a/src/TimeTrack.h +++ b/src/TimeTrack.h @@ -37,7 +37,7 @@ class SAUCEDACITY_DLL_API TimeTrack final : public Track { */ TimeTrack(const TimeTrack &orig, double *pT0 = nullptr, double *pT1 = nullptr); - virtual ~TimeTrack(); + ~TimeTrack() override; bool SupportsBasicEditing() const override; diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index a91bb2e057..ac9dfcb36c 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -166,13 +166,13 @@ TimerRecordDialog::TimerRecordDialog( m_TimeSpan_Duration = wxTimeSpan::Seconds(seconds); m_DateTime_End = m_DateTime_Start + m_TimeSpan_Duration; - m_pDatePickerCtrl_Start = NULL; - m_pTimeTextCtrl_Start = NULL; + m_pDatePickerCtrl_Start = nullptr; + m_pTimeTextCtrl_Start = nullptr; - m_pDatePickerCtrl_End = NULL; - m_pTimeTextCtrl_End = NULL; + m_pDatePickerCtrl_End = nullptr; + m_pTimeTextCtrl_End = nullptr; - m_pTimeTextCtrl_Duration = NULL; + m_pTimeTextCtrl_Duration = nullptr; // Do we allow the user to change the Automatic Save file? m_bProjectAlreadySaved = bAlreadySaved; diff --git a/src/TimerRecordDialog.h b/src/TimerRecordDialog.h index b625acddbb..71bff0b52c 100644 --- a/src/TimerRecordDialog.h +++ b/src/TimerRecordDialog.h @@ -59,7 +59,7 @@ class TimerRecordDialog final : public wxDialogWrapper TimerRecordDialog( wxWindow* parent, SaucedacityProject &project, bool bAlreadySaved); - ~TimerRecordDialog(); + ~TimerRecordDialog() override; void OnTimer(wxTimerEvent& event); ///Runs the wait for start dialog. Returns false if the user clicks stop. @@ -77,7 +77,7 @@ class TimerRecordDialog final : public wxDialogWrapper void OnOK(wxCommandEvent& event); void OnHelpButtonClick(wxCommandEvent& event); - TranslatableString GetDisplayDate(wxDateTime & dt); + static TranslatableString GetDisplayDate(wxDateTime & dt); void PopulateOrExchange(ShuttleGui& S); bool TransferDataFromWindow() override; @@ -97,8 +97,8 @@ class TimerRecordDialog final : public wxDialogWrapper void UpdateTextBoxControls(); // Add Path Controls to Form - wxTextCtrlWrapper *NewPathControl( - wxWindow *wParent, const int iID, + static wxTextCtrlWrapper *NewPathControl( + wxWindow *wParent, int iID, const TranslatableString &sCaption, const TranslatableString &sValue); int ExecutePostRecordActions(bool bWasStopped); diff --git a/src/Track.cpp b/src/Track.cpp index 5ffd79abf9..518711319c 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -129,7 +129,7 @@ Track::~Track() TrackNodePointer Track::GetNode() const { - wxASSERT(mList.lock() == NULL || this == mNode.first->get()); + wxASSERT(mList.lock() == nullptr || this == mNode.first->get()); return mNode; } @@ -818,7 +818,7 @@ void TrackList::Clear(bool sendEvent) // the temporary ListOfTracks below. for ( auto pTrack: *this ) pTrack->SetOwner( {}, {} ); - for ( auto pTrack: mPendingUpdates ) + for ( const auto& pTrack: mPendingUpdates ) pTrack->SetOwner( {}, {} ); ListOfTracks tempList; @@ -891,12 +891,12 @@ Track *TrackList::GetPrev(Track * t, bool linked) const bool TrackList::CanMoveUp(Track * t) const { - return GetPrev(t, true) != NULL; + return GetPrev(t, true) != nullptr; } bool TrackList::CanMoveDown(Track * t) const { - return GetNext(t, true) != NULL; + return GetNext(t, true) != nullptr; } // This is used when you want to swap the channel group starting diff --git a/src/Track.h b/src/Track.h index 8f4d21230b..c177430545 100644 --- a/src/Track.h +++ b/src/Track.h @@ -13,6 +13,7 @@ #define __AUDACITY_TRACK__ +#include #include #include #include @@ -202,9 +203,9 @@ class ConstTrackInterval { ConstTrackInterval( ConstTrackInterval&& ) = default; ConstTrackInterval &operator=( ConstTrackInterval&& ) = default; - double Start() const { return start; } - double End() const { return end; } - const TrackIntervalData *Extra() const { return pExtra.get(); } + [[nodiscard]] double Start() const { return start; } + [[nodiscard]] double End() const { return end; } + [[nodiscard]] const TrackIntervalData *Extra() const { return pExtra.get(); } private: double start, end; @@ -222,7 +223,7 @@ class TrackInterval : public ConstTrackInterval { TrackInterval(TrackInterval&&) = default; TrackInterval &operator= (TrackInterval&&) = default; - TrackIntervalData *Extra() const { return pExtra.get(); } + [[nodiscard]] TrackIntervalData *Extra() const { return pExtra.get(); } }; //! Template generated base class for Track lets it host opaque UI related objects @@ -409,7 +410,7 @@ class SAUCEDACITY_DLL_API Track /* not final */ Track(); Track(const Track &orig); - virtual ~ Track(); + ~ Track() override; void Init(const Track &orig); @@ -842,7 +843,7 @@ class SAUCEDACITY_DLL_API AudioTrack /* not final */ : public Track void WriteXMLAttributes(XMLWriter &WXUNUSED(xmlFile)) const {} // Return true iff the attribute is recognized. - bool HandleXMLAttribute(const wxChar * /*attr*/, const wxChar * /*value*/) + static bool HandleXMLAttribute(const wxChar * /*attr*/, const wxChar * /*value*/) { return false; } }; @@ -948,7 +949,7 @@ template < TrackNodePointer end, //!< Remember upper bound FunctionType pred = {} //!< %Optional filter ) - : mBegin( begin ), mIter( iter ), mEnd( end ) + : mBegin(std::move( begin )), mIter(std::move( iter )), mEnd(std::move( end )) , mPred( std::move(pred) ) { // Establish the class invariant @@ -969,7 +970,7 @@ template < /*! Advance to the first position at or after the old position that satisfies the type constraint, or to the end */ template < typename TrackType2 > - auto Filter() const + [[nodiscard]] auto Filter() const -> typename std::enable_if< std::is_base_of< TrackType, TrackType2 >::value && (!std::is_const::value || @@ -980,7 +981,7 @@ template < return { this->mBegin, this->mIter, this->mEnd, this->mPred }; } - const FunctionType &GetPredicate() const + [[nodiscard]] const FunctionType &GetPredicate() const { return this->mPred; } //! Safe to call even when at the end @@ -995,7 +996,7 @@ template < } //! @copydoc operator++ - TrackIter operator ++ (int) + const TrackIter operator ++ (int) { TrackIter result { *this }; this-> operator ++ (); @@ -1018,7 +1019,7 @@ template < } //! @copydoc operator-- - TrackIter operator -- (int) + const TrackIter operator -- (int) { TrackIter result { *this }; this->operator -- (); @@ -1039,7 +1040,7 @@ template < } //! This might be called operator + , but it's not constant-time as with a random access iterator - TrackIter advance( + [[nodiscard]] TrackIter advance( long amount //!< may be negative ) const { @@ -1071,7 +1072,7 @@ template < and **mIter is of the appropriate subclass, and mPred is null or mPred(&**mIter) is true. */ //! Test satisfaction of the invariant, while initializing, incrementing, or decrementing - bool valid() const + [[nodiscard]] bool valid() const { // assume mIter != mEnd const auto pTrack = track_cast< TrackType * >( &**this->mIter.first ); @@ -1149,7 +1150,7 @@ template < } template< typename TrackType2 > - TrackIterRange< TrackType2 > Filter() const + [[nodiscard]] TrackIterRange< TrackType2 > Filter() const { return { this-> first.template Filter< TrackType2 >(), @@ -1220,15 +1221,15 @@ struct TrackListEvent : public wxCommandEvent explicit TrackListEvent( wxEventType commandType, - const std::weak_ptr &pTrack = {}, int code = -1) + std::weak_ptr pTrack = {}, int code = -1) : wxCommandEvent{ commandType } - , mpTrack{ pTrack } + , mpTrack{std::move( pTrack )} , mCode{ code } {} TrackListEvent( const TrackListEvent& ) = default; - wxEvent *Clone() const override { + [[nodiscard]] wxEvent *Clone() const override { // wxWidgets will own the event object return safenew TrackListEvent(*this); } @@ -1306,7 +1307,7 @@ class SAUCEDACITY_DLL_API TrackList final void Swap(TrackList &that); // Destructor - virtual ~TrackList(); + ~TrackList() override; // Find the owning project, which may be null SaucedacityProject *GetOwner() { return mOwner; } diff --git a/src/TrackArtist.h b/src/TrackArtist.h index aef4b627ad..c5c50633e7 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -76,7 +76,7 @@ namespace TrackArt { const wxRect & rect ); SAUCEDACITY_DLL_API - wxString TruncateText(wxDC& dc, const wxString& text, const int maxWidth); + wxString TruncateText(wxDC& dc, const wxString& text, int maxWidth); } class SAUCEDACITY_DLL_API TrackArtist final : private PrefsListener { @@ -97,11 +97,11 @@ class SAUCEDACITY_DLL_API TrackArtist final : private PrefsListener { }; TrackArtist( TrackPanel *parent_ ); - ~TrackArtist(); + ~TrackArtist() override; static TrackArtist *Get( TrackPanelDrawingContext & ); - void SetBackgroundBrushes(wxBrush unselectedBrushIn, wxBrush selectedBrushIn, - wxPen unselectedPenIn, wxPen selectedPenIn) { + void SetBackgroundBrushes(const wxBrush& unselectedBrushIn, const wxBrush& selectedBrushIn, + const wxPen& unselectedPenIn, const wxPen& selectedPenIn) { this->unselectedBrush = unselectedBrushIn; this->selectedBrush = selectedBrushIn; this->unselectedPen = unselectedPenIn; diff --git a/src/TrackInfo.cpp b/src/TrackInfo.cpp index ae421f8e50..f23524dd75 100644 --- a/src/TrackInfo.cpp +++ b/src/TrackInfo.cpp @@ -217,7 +217,7 @@ void TrackInfo::DrawItems ( TrackPanelDrawingContext &context, const wxRect &rect, const Track &track ) { - auto &trackControl = static_cast( + auto &trackControl = dynamic_cast( TrackControls::Get( track ) ); const auto &topLines = trackControl.GetTCPLines(); const auto &bottomLines = commonTrackTCPBottomLines; diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 1757f8c435..fcf4022bcd 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -88,6 +88,7 @@ is time to refresh some aspect of the screen. #include "../images/Cursors.h" #include +#include #include #include @@ -249,14 +250,14 @@ void TrackPanel::Destroy( SaucedacityProject &project ) TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, const wxPoint & pos, const wxSize & size, - const std::shared_ptr &tracks, + std::shared_ptr tracks, ViewInfo * viewInfo, SaucedacityProject * project, AdornedRulerPanel * ruler) : CellularPanel(parent, id, pos, size, viewInfo, wxWANTS_CHARS | wxNO_BORDER), mListener( &ProjectWindow::Get( *project ) ), - mTracks(tracks), + mTracks(std::move(tracks)), mRuler(ruler), mTrackArtist(nullptr), mRefreshBacking(false) @@ -351,12 +352,12 @@ SaucedacityProject * TrackPanel::GetProject() const //Do it in two stages in case 'this' is not a wxWindow. //when the compiler will flag the error. wxWindow const * const pConstWind = this; - wxWindow * pWind=(wxWindow*)pConstWind; + auto * pWind=(wxWindow*)pConstWind; pWind = pWind->GetParent(); //MainPanel wxASSERT( pWind ); pWind = pWind->GetParent(); //ProjectWindow wxASSERT( pWind ); - return &static_cast( pWind )->GetProject(); + return &dynamic_cast( pWind )->GetProject(); } void TrackPanel::OnSize( wxSizeEvent &evt ) @@ -523,7 +524,7 @@ namespace { std::shared_ptr FindTrack(TrackPanelCell *pCell ) { if (pCell) - return static_cast( pCell )->FindTrack(); + return dynamic_cast( pCell )->FindTrack(); return {}; } } @@ -554,8 +555,8 @@ void TrackPanel::ProcessUIHandleResult panel->UpdateViewIfNoTracks(); // Beware stale pointer! if (pLatestTrack == pClickedTrack) - pLatestTrack = NULL; - pClickedTrack = NULL; + pLatestTrack = nullptr; + pClickedTrack = nullptr; } if (pClickedTrack && (refreshResult & RefreshCode::UpdateVRuler)) @@ -604,7 +605,7 @@ void TrackPanel::HandlePageDownKey() mListener->TP_ScrollWindow(mViewInfo->GetScreenEndTime()); } -bool TrackPanel::IsAudioActive() +bool TrackPanel::IsAudioActive() const { SaucedacityProject *p = GetProject(); return ProjectAudioIO::Get( *p ).IsAudioActive(); @@ -842,7 +843,7 @@ void TrackPanel::DrawTracks(wxDC * dc) const bool hasSolo = GetTracks()->Any< PlayableTrack >() .any_of( []( const PlayableTrack *pt ) { - pt = static_cast< const PlayableTrack * >( + pt = dynamic_cast< const PlayableTrack * >( pt->SubstitutePendingChangedTrack().get() ); return (pt && pt->GetSolo()); } ); @@ -1222,7 +1223,7 @@ struct EmptyCell final : CommonTrackPanelCell { std::vector< UIHandlePtr > HitTest( const TrackPanelMouseState &, const SaucedacityProject *) override { return {}; } - virtual std::shared_ptr< Track > DoFindTrack() override { return {}; } + std::shared_ptr< Track > DoFindTrack() override { return {}; } static std::shared_ptr Instance() { static auto instance = std::make_shared< EmptyCell >(); @@ -1248,8 +1249,8 @@ struct EmptyCell final : CommonTrackPanelCell { // A vertical ruler left of a channel struct VRulerAndChannel final : TrackPanelGroup { VRulerAndChannel( - const std::shared_ptr< TrackView > &pView, wxCoord leftOffset ) - : mpView{ pView }, mLeftOffset{ leftOffset } {} + std::shared_ptr< TrackView > pView, wxCoord leftOffset ) + : mpView{std::move( pView )}, mLeftOffset{ leftOffset } {} Subdivision Children( const wxRect &rect ) override { return { Axis::X, Refinement{ @@ -1266,9 +1267,9 @@ struct VRulerAndChannel final : TrackPanelGroup { // a vertical ruler and a channel struct VRulersAndChannels final : TrackPanelGroup { VRulersAndChannels( - const std::shared_ptr &pTrack, + std::shared_ptr pTrack, TrackView::Refinement refinement, wxCoord leftOffset ) - : mpTrack{ pTrack } + : mpTrack{std::move( pTrack )} , mRefinement{ std::move( refinement ) } , mLeftOffset{ leftOffset } {} Subdivision Children( const wxRect &rect ) override @@ -1338,14 +1339,14 @@ class EmptyPanelRect final : public CommonTrackPanelCell std::shared_ptr mTrack; int mFillBrushName; public: - explicit EmptyPanelRect(const std::shared_ptr& track, int fillBrushName) - : mTrack(track), mFillBrushName(fillBrushName) + explicit EmptyPanelRect(std::shared_ptr track, int fillBrushName) + : mTrack(std::move(track)), mFillBrushName(fillBrushName) { } - ~EmptyPanelRect() { } + ~EmptyPanelRect() override { } - void Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass) + void Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass) override { if (iPass == TrackArtist::PassBackground) { @@ -1362,7 +1363,7 @@ class EmptyPanelRect final : public CommonTrackPanelCell return mTrack; } - std::vector HitTest(const TrackPanelMouseState& state, const SaucedacityProject* pProject) + std::vector HitTest(const TrackPanelMouseState& state, const SaucedacityProject* pProject) override { return {}; } @@ -1390,8 +1391,8 @@ struct HorizontalGroup final : TrackPanelGroup { // alternating with n - 1 resizers; // each channel-ruler pair might be divided into multiple views struct ChannelGroup final : TrackPanelGroup { - ChannelGroup( const std::shared_ptr< Track > &pTrack, wxCoord leftOffset ) - : mpTrack{ pTrack }, mLeftOffset{ leftOffset } {} + ChannelGroup( std::shared_ptr< Track > pTrack, wxCoord leftOffset ) + : mpTrack{std::move( pTrack )}, mLeftOffset{ leftOffset } {} Subdivision Children( const wxRect &rect_ ) override { auto rect = rect_; @@ -1474,8 +1475,8 @@ struct ChannelGroup final : TrackPanelGroup { // alternating with n - 1 resizers struct LabeledChannelGroup final : TrackPanelGroup { LabeledChannelGroup( - const std::shared_ptr< Track > &pTrack, wxCoord leftOffset ) - : mpTrack{ pTrack }, mLeftOffset{ leftOffset } {} + std::shared_ptr< Track > pTrack, wxCoord leftOffset ) + : mpTrack{std::move( pTrack )}, mLeftOffset{ leftOffset } {} Subdivision Children( const wxRect &rect ) override { return { Axis::X, Refinement{ { rect.GetLeft(), @@ -1551,8 +1552,8 @@ struct LabeledChannelGroup final : TrackPanelGroup { // which is associated with the last channel struct ResizingChannelGroup final : TrackPanelGroup { ResizingChannelGroup( - const std::shared_ptr< Track > &pTrack, wxCoord leftOffset ) - : mpTrack{ pTrack }, mLeftOffset{ leftOffset } {} + std::shared_ptr< Track > pTrack, wxCoord leftOffset ) + : mpTrack{std::move( pTrack )}, mLeftOffset{ leftOffset } {} Subdivision Children( const wxRect &rect ) override { return { Axis::Y, Refinement{ { rect.GetTop(), diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 75be0f012c..a6f94393cd 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -71,12 +71,12 @@ class SAUCEDACITY_DLL_API TrackPanel final wxWindowID id, const wxPoint & pos, const wxSize & size, - const std::shared_ptr &tracks, + std::shared_ptr tracks, ViewInfo * viewInfo, SaucedacityProject * project, AdornedRulerPanel * ruler ); - virtual ~ TrackPanel(); + ~ TrackPanel() override; void UpdatePrefs() override; @@ -102,16 +102,16 @@ class SAUCEDACITY_DLL_API TrackPanel final void OnUndoReset( wxCommandEvent &event ); void Refresh - (bool eraseBackground = true, const wxRect *rect = (const wxRect *) NULL) + (bool eraseBackground = true, const wxRect *rect = (const wxRect *) nullptr) override; void RefreshTrack(Track *trk, bool refreshbacking = true); void HandlePageUpKey(); void HandlePageDownKey(); - SaucedacityProject * GetProject() const override; + [[nodiscard]] SaucedacityProject * GetProject() const override; - void OnTrackMenu(Track *t = NULL); + void OnTrackMenu(Track *t = nullptr); void VerticalScroll( float fracPosition); @@ -124,10 +124,10 @@ class SAUCEDACITY_DLL_API TrackPanel final void UpdateVRulerSize(); protected: - bool IsAudioActive(); + bool IsAudioActive() const; public: - size_t GetSelectedTrackCount() const; + [[nodiscard]] size_t GetSelectedTrackCount() const; protected: void UpdateSelectionDisplay(); @@ -164,7 +164,7 @@ class SAUCEDACITY_DLL_API TrackPanel final public: // JKC Nov-2011: These four functions only used from within a dll // They work around some messy problems with constructors. - const TrackList * GetTracks() const { return mTracks.get(); } + [[nodiscard]] const TrackList * GetTracks() const { return mTracks.get(); } TrackList * GetTracks() { return mTracks.get(); } ViewInfo * GetViewInfo(){ return mViewInfo;} TrackPanelListener * GetListener(){ return mListener;} diff --git a/src/TrackPanelAx.h b/src/TrackPanelAx.h index b23ad21d69..be0b178ce1 100644 --- a/src/TrackPanelAx.h +++ b/src/TrackPanelAx.h @@ -130,7 +130,7 @@ class TrackPanelAx final // Modify focus or selection wxAccStatus Select(int childId, wxAccSelectionFlags selectFlags) override; #else - wxWindow *GetWindow() const { return mWindow; } + [[nodiscard]] wxWindow *GetWindow() const { return mWindow; } void SetWindow( wxWindow *window ) { mWindow = window; } #endif diff --git a/src/TrackPanelCell.h b/src/TrackPanelCell.h index 4c45786989..c85f15b4e8 100644 --- a/src/TrackPanelCell.h +++ b/src/TrackPanelCell.h @@ -39,7 +39,7 @@ class SAUCEDACITY_DLL_API /* not final */ TrackPanelNode { public: TrackPanelNode(); - virtual ~TrackPanelNode() = 0; + ~TrackPanelNode() override = 0; }; // A node of the TrackPanel that contains other nodes. @@ -47,7 +47,7 @@ class SAUCEDACITY_DLL_API TrackPanelGroup /* not final */ : public TrackPanelNod { public: TrackPanelGroup(); - virtual ~TrackPanelGroup(); + ~TrackPanelGroup() override; enum class Axis { X, Y }; @@ -77,7 +77,7 @@ class SAUCEDACITY_DLL_API TrackPanelCell /* not final */ : public TrackPanelNode TrackPanelCell( const TrackPanelCell & ) = delete; TrackPanelCell &operator=( const TrackPanelCell & ) = delete; - virtual ~TrackPanelCell () = 0; + ~TrackPanelCell () override = 0; // May supply default cursor, status message, and tooltip, when there is no // handle to hit at the mouse position, or the handle does not supply them. diff --git a/src/TrackPanelMouseEvent.h b/src/TrackPanelMouseEvent.h index 8685871564..e3b4697b6b 100644 --- a/src/TrackPanelMouseEvent.h +++ b/src/TrackPanelMouseEvent.h @@ -17,6 +17,7 @@ class wxRect; class wxSize; class TrackPanelCell; #include +#include // This is a hack so that the code that fakes a MOUSE_LEFT_BTN_UP on // capture lost doesn't get in the way of handling MOUSE_RIGHT_BTN_UP. @@ -28,10 +29,10 @@ struct TrackPanelMouseState { TrackPanelMouseState ( wxMouseState &state_, const wxRect &rect_, - const std::shared_ptr &pCell_ ) + std::shared_ptr pCell_ ) : state{ state_ } , rect{ rect_ } - , pCell{ pCell_ } + , pCell{std::move( pCell_ )} { } @@ -46,11 +47,11 @@ struct TrackPanelMouseEvent { TrackPanelMouseEvent ( wxMouseEvent &event_, const wxRect &rect_, const wxSize &whole_, - const std::shared_ptr &pCell_ ) + std::shared_ptr pCell_ ) : event{ event_ } , rect{ rect_ } , whole{ whole_ } - , pCell{ pCell_ } + , pCell{std::move( pCell_ )} , steps{ 0 } { } diff --git a/src/TrackPanelResizeHandle.h b/src/TrackPanelResizeHandle.h index 43f2ea6c00..5be455ce67 100644 --- a/src/TrackPanelResizeHandle.h +++ b/src/TrackPanelResizeHandle.h @@ -26,9 +26,9 @@ class TrackPanelResizeHandle final : public UIHandle static HitTestPreview HitPreview(bool bLinked); - virtual ~TrackPanelResizeHandle(); + ~TrackPanelResizeHandle() override; - std::shared_ptr GetTrack() const { return mpTrack.lock(); } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpTrack.lock(); } Result Click (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) override; diff --git a/src/UIHandle.h b/src/UIHandle.h index b5680eb0fb..994d845f5e 100644 --- a/src/UIHandle.h +++ b/src/UIHandle.h @@ -40,7 +40,7 @@ class SAUCEDACITY_DLL_API UIHandle /* not final */ : public TrackPanelDrawable // Future: may generalize away from current Track class using Cell = TrackPanelCell; - virtual ~UIHandle() = 0; + ~UIHandle() override = 0; // Before clicking, the handle is notified that it has been "hit" // This might put the handle into its first rotated state @@ -50,7 +50,7 @@ class SAUCEDACITY_DLL_API UIHandle /* not final */ : public TrackPanelDrawable // Tell whether the handle has more than one TAB key rotation state. // Default is always false. - virtual bool HasRotation() const; + [[nodiscard]] virtual bool HasRotation() const; // If not previously in the last rotation state (or first if !forward), // change rotation state and return true; else return false @@ -60,7 +60,7 @@ class SAUCEDACITY_DLL_API UIHandle /* not final */ : public TrackPanelDrawable // Tell whether the handle has its own escape action. In case it is already // clicked, it will not cancel on Escape key if true. // Default is always false. - virtual bool HasEscape() const; + [[nodiscard]] virtual bool HasEscape() const; // The handle may change state and mark itself for highlight change. // Default does nothing and returns false @@ -119,7 +119,7 @@ class SAUCEDACITY_DLL_API UIHandle /* not final */ : public TrackPanelDrawable virtual void OnProjectChange(SaucedacityProject *pProject); public: - Result GetChangeHighlight() const { return mChangeHighlight; } + [[nodiscard]] Result GetChangeHighlight() const { return mChangeHighlight; } void SetChangeHighlight(Result val) { mChangeHighlight = val; } // If AssignUIHandlePtr is used, then this function is also called before any diff --git a/src/UndoManager.h b/src/UndoManager.h index e84c3f3fee..ebb1952262 100644 --- a/src/UndoManager.h +++ b/src/UndoManager.h @@ -49,6 +49,7 @@ #ifndef __AUDACITY_UNDOMANAGER__ #define __AUDACITY_UNDOMANAGER__ +#include #include #include // to declare custom event types #include "ClientData.h" @@ -84,9 +85,9 @@ class TrackList; struct UndoState { UndoState(std::shared_ptr &&tracks_, - const std::shared_ptr &tags_, + std::shared_ptr tags_, const SelectedRegion &selectedRegion_) - : tracks(std::move(tracks_)), tags(tags_), selectedRegion(selectedRegion_) + : tracks(std::move(tracks_)), tags(std::move(tags_)), selectedRegion(selectedRegion_) {} std::shared_ptr tracks; @@ -97,13 +98,13 @@ struct UndoState { struct UndoStackElem { UndoStackElem(std::shared_ptr &&tracks_, - const TranslatableString &description_, - const TranslatableString &shortDescription_, + TranslatableString description_, + TranslatableString shortDescription_, const SelectedRegion &selectedRegion_, const std::shared_ptr &tags_) : state(std::move(tracks_), tags_, selectedRegion_) - , description(description_) - , shortDescription(shortDescription_) + , description(std::move(description_)) + , shortDescription(std::move(shortDescription_)) { } @@ -141,7 +142,7 @@ class SAUCEDACITY_DLL_API UndoManager final explicit UndoManager( SaucedacityProject &project ); - ~UndoManager(); + ~UndoManager() override; UndoManager( const UndoManager& ) = delete; UndoManager& operator = ( const UndoManager& ) = delete; @@ -192,8 +193,8 @@ class SAUCEDACITY_DLL_API UndoManager final bool UndoAvailable(); bool RedoAvailable(); - bool UnsavedChanges() const; - int GetSavedState() const; + [[nodiscard]] bool UnsavedChanges() const; + [[nodiscard]] int GetSavedState() const; void StateSaved(); // Return value must first be calculated by CalculateSpaceUsage(): diff --git a/src/ViewInfo.h b/src/ViewInfo.h index 45121a36da..23ad666cec 100644 --- a/src/ViewInfo.h +++ b/src/ViewInfo.h @@ -27,7 +27,7 @@ struct SelectedRegionEvent : public wxEvent SelectedRegionEvent( wxEventType commandType, NotifyingSelectedRegion *pRegion ); - wxEvent *Clone() const override; + [[nodiscard]] wxEvent *Clone() const override; wxWeakRef< NotifyingSelectedRegion > pRegion; }; @@ -42,13 +42,13 @@ class SAUCEDACITY_DLL_API NotifyingSelectedRegion : public wxEvtHandler { public: // Expose SelectedRegion's const accessors - double t0 () const { return mRegion.t0(); } - double t1 () const { return mRegion.t1(); } - double f0 () const { return mRegion.f0(); } - double f1 () const { return mRegion.f1(); } - double fc () const { return mRegion.fc(); } - bool isPoint() const { return mRegion.isPoint(); } - double duration() const { return mRegion.duration(); } + [[nodiscard]] double t0 () const { return mRegion.t0(); } + [[nodiscard]] double t1 () const { return mRegion.t1(); } + [[nodiscard]] double f0 () const { return mRegion.f0(); } + [[nodiscard]] double f1 () const { return mRegion.f1(); } + [[nodiscard]] double fc () const { return mRegion.fc(); } + [[nodiscard]] bool isPoint() const { return mRegion.isPoint(); } + [[nodiscard]] double duration() const { return mRegion.duration(); } // Writing and reading of persistent fields -- the read is mutating but // does not emit events @@ -125,18 +125,18 @@ class PlayRegion return *this; } - bool Locked() const { return mLocked; } + [[nodiscard]] bool Locked() const { return mLocked; } void SetLocked( bool locked ) { mLocked = locked; } - bool Empty() const { return GetStart() == GetEnd(); } - double GetStart() const + [[nodiscard]] bool Empty() const { return GetStart() == GetEnd(); } + [[nodiscard]] double GetStart() const { if ( mEnd < 0 ) return mStart; else return std::min( mStart, mEnd ); } - double GetEnd() const + [[nodiscard]] double GetEnd() const { if ( mStart < 0 ) return mEnd; @@ -173,20 +173,20 @@ class SAUCEDACITY_DLL_API ViewInfo final ViewInfo( const ViewInfo & ) = delete; ViewInfo &operator=( const ViewInfo & ) = delete; - int GetHeight() const { return mHeight; } + [[nodiscard]] int GetHeight() const { return mHeight; } void SetHeight( int height ) { mHeight = height; } static int UpdateScrollPrefsID(); void UpdatePrefs() override; void UpdateSelectedPrefs( int id ) override; - double GetBeforeScreenWidth() const + [[nodiscard]] double GetBeforeScreenWidth() const { return h * zoom; } void SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, double lowerBoundTime = 0.0); - double GetTotalWidth() const + [[nodiscard]] double GetTotalWidth() const { return total * zoom; } // Current selection diff --git a/src/VoiceKey.cpp b/src/VoiceKey.cpp index 82e2c8dc20..a057d1f04c 100644 --- a/src/VoiceKey.cpp +++ b/src/VoiceKey.cpp @@ -396,8 +396,8 @@ sampleCount VoiceKey::OffForward ( //Change the millisecond-based parameters into sample-based parameters double rate = t.GetRate(); //Translates seconds to samples - unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine - unsigned int SilentWindowSizeInt = (unsigned int)(rate * mSilentWindowSize); //This much signal is necessary to trip key + auto WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine + auto SilentWindowSizeInt = (unsigned int)(rate * mSilentWindowSize); //This much signal is necessary to trip key sampleCount samplesleft ( len.as_double() - WindowSizeInt ); //Indexes the number of samples remaining in the selection auto lastsubthresholdsample = start; //start this off at the selection start @@ -532,7 +532,7 @@ sampleCount VoiceKey::OffBackward ( //Change the millisecond-based parameters into sample-based parameters double rate = t.GetRate(); //Translates seconds to samples - unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine + auto WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine //unsigned int SilentWindowSizeInt = (unsigned int)(rate * mSilentWindowSize); //This much signal is necessary to trip key auto samplesleft = len - WindowSizeInt; //Indexes the number of samples remaining in the selection @@ -756,7 +756,7 @@ void VoiceKey::CalibrateNoise(const WaveTrack & t, sampleCount start, sampleCoun //Now, change the millisecond-based parameters into sample-based parameters //(This depends on WaveTrack t) double rate = t.GetRate(); - unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); + auto WindowSizeInt = (unsigned int)(rate * mWindowSize); // unsigned int SignalWindowSizeInt = (unsigned int)(rate * mSignalWindowSize); @@ -961,7 +961,7 @@ double VoiceKey::TestDirectionChanges( const auto blockSize = limitSampleBufferSize( t.GetMaxBlockSize(), len); //Determine size of sampling buffer unsigned long directionchanges = 1; - float lastval=float(0); + auto lastval=float(0); int lastdirection=1; Floats buffer{ blockSize }; //Get a sampling buffer diff --git a/src/VoiceKey.h b/src/VoiceKey.h index 03a102b245..ce3bb40b14 100644 --- a/src/VoiceKey.h +++ b/src/VoiceKey.h @@ -80,16 +80,16 @@ class VoiceKey { double mSilentWindowSize; //Time in milliseconds of below-threshold windows required for silence double mSignalWindowSize; //Time in milliseconds of above-threshold windows required for speech - double TestEnergy (const WaveTrack & t, sampleCount start,sampleCount len); - double TestSignChanges ( + static double TestEnergy (const WaveTrack & t, sampleCount start,sampleCount len); + static double TestSignChanges ( const WaveTrack & t, sampleCount start, sampleCount len); - double TestDirectionChanges( + static double TestDirectionChanges( const WaveTrack & t, sampleCount start, sampleCount len); - void TestEnergyUpdate (double & prevErg, int length, const float & drop, const float & add); - void TestSignChangesUpdate(double & currentsignchanges,int length, const float & a1, + static void TestEnergyUpdate (double & prevErg, int length, const float & drop, const float & add); + static void TestSignChangesUpdate(double & currentsignchanges,int length, const float & a1, const float & a2, const float & z1, const float & z2); - void TestDirectionChangesUpdate(double & currentdirectionchanges,int length, + static void TestDirectionChangesUpdate(double & currentdirectionchanges,int length, int & atrend, const float & a1, const float & a2, int & ztrend, const float & z1, const float & z2); diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 0d69e14f56..1f33895105 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -317,7 +317,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0, { t0 += GetTrimLeft(); - const bool allocated = (display.where != 0); + const bool allocated = (display.where != nullptr); const size_t numPixels = (int)display.width; @@ -385,7 +385,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0, )); } if (!(copyEnd > copyBegin)) - oldCache.reset(0); + oldCache.reset(nullptr); mWaveCache = std::make_unique(numPixels, pixelsPerSecond, mRate, t0, mDirty); min = &mWaveCache->min[0]; @@ -614,7 +614,7 @@ bool SpecCache::CalculateOneSpectrum // We can avoid copying memory when ComputeSpectrum is used below bool copy = !autocorrelation || (padding > 0) || reassignment; - float *useBuffer = 0; + float *useBuffer = nullptr; float *adj = scratch + padding; { @@ -1294,7 +1294,7 @@ XMLTagHandler *WaveClip::HandleXMLChild(const wxChar *tag) return mCutLines.back().get(); } else - return NULL; + return nullptr; } void WaveClip::WriteXML(XMLWriter &xmlFile) const @@ -1353,7 +1353,7 @@ void WaveClip::Paste(double t0, const WaveClip* other) if (clipNeedsResampling || clipNeedsNewFormat) { - auto copy = std::make_unique(*newClip.get(), mSequence->GetFactory(), true); + auto copy = std::make_unique(*newClip, mSequence->GetFactory(), true); if (clipNeedsResampling) // The other clip's rate is different from ours, so resample copy->Resample(mRate); @@ -1392,7 +1392,7 @@ void WaveClip::Paste(double t0, const WaveClip* other) } /*! @excsafety{Strong} */ -void WaveClip::InsertSilence( double t, double len, double *pEnvelopeValue ) +void WaveClip::InsertSilence( double t, double len, const double *pEnvelopeValue ) { if (t == GetPlayStartTime() && t > GetSequenceStartTime()) ClearSequence(GetSequenceStartTime(), t); diff --git a/src/WaveClip.h b/src/WaveClip.h index 821f5e0796..aee365bb0a 100644 --- a/src/WaveClip.h +++ b/src/WaveClip.h @@ -53,14 +53,14 @@ class SAUCEDACITY_DLL_API SpecCache { { } - bool Matches(int dirty_, double pixelsPerSecond, + [[nodiscard]] bool Matches(int dirty_, double pixelsPerSecond, const SpectrogramSettings &settings, double rate) const; // Calculate one column of the spectrum bool CalculateOneSpectrum (const SpectrogramSettings &settings, WaveTrackCache &waveTrackCache, - const int xx, sampleCount numSamples, + int xx, sampleCount numSamples, double offset, double rate, double pixelsPerSecond, int lowerBoundX, int upperBoundX, const std::vector &gainFactors, @@ -140,7 +140,7 @@ class WaveDisplay public: WaveDisplay(int w) - : width(w), where(0), min(0), max(0), rms(0), bl(0) + : width(w), where(nullptr), min(nullptr), max(nullptr), rms(nullptr), bl(nullptr) { } @@ -161,8 +161,8 @@ class WaveDisplay bl = &ownBl[0]; } else { - min = max = rms = 0; - bl = 0; + min = max = rms = nullptr; + bl = nullptr; } } @@ -198,7 +198,7 @@ class SAUCEDACITY_DLL_API WaveClip final : public XMLTagHandler bool copyCutlines, double t0, double t1); - virtual ~WaveClip(); + ~WaveClip() override; void ConvertToSampleFormat(sampleFormat format, const std::function & progressReport = {}); @@ -215,7 +215,7 @@ class SAUCEDACITY_DLL_API WaveClip final : public XMLTagHandler // Resample clip. This also will set the rate, but without changing // the length of the clip - void Resample(int rate, ProgressDialog *progress = NULL); + void Resample(int rate, ProgressDialog *progress = nullptr); void SetColourIndex( int index ){ mColourIndex = index;}; int GetColourIndex( ) const { return mColourIndex;}; @@ -336,7 +336,7 @@ class SAUCEDACITY_DLL_API WaveClip final : public XMLTagHandler /** Insert silence - note that this is an efficient operation for large * amounts of silence */ - void InsertSilence( double t, double len, double *pEnvelopeValue = nullptr ); + void InsertSilence( double t, double len, const double *pEnvelopeValue = nullptr ); /** Insert silence at the end, and causes the envelope to ramp linearly to the given value */ @@ -352,8 +352,8 @@ class SAUCEDACITY_DLL_API WaveClip final : public XMLTagHandler * in cutLineStart and cutLineEnd (if specified) if a cut line at this * position could be found. Return false otherwise. */ bool FindCutLine(double cutLinePosition, - double* cutLineStart = NULL, - double *cutLineEnd = NULL) const; + double* cutLineStart = nullptr, + double *cutLineEnd = nullptr) const; /** Expand cut line (that is, re-insert audio, then DELETE audio saved in * cut line). Returns true if a cut line could be found and successfully diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 4e58d40cc6..64d0a53e65 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -918,7 +918,7 @@ void WaveTrack::ClearAndPaste(double t0, // Start of time to clear Paste(t0, src); { // First, merge the NEW clip(s) in with the existing clips - if (merge && splits.size() > 0) + if (merge && !splits.empty()) { // Now t1 represents the absolute end of the pasted data. t1 = t0 + src->GetEndTime(); @@ -1544,9 +1544,8 @@ void WaveTrack::Disjoin(double t0, double t1) } } - for( unsigned int i = 0; i < regions.size(); i++ ) + for(auto & region : regions) { - const Region ®ion = regions.at(i); SplitDelete(region.start, region.end ); } } @@ -1575,7 +1574,7 @@ void WaveTrack::Join(double t0, double t1) } //if there are no clips to DELETE, nothing to do - if( clipsToDelete.size() == 0 ) + if( clipsToDelete.empty() ) return; auto t = clipsToDelete[0]->GetSequenceStartTime(); @@ -1796,7 +1795,7 @@ XMLTagHandler *WaveTrack::HandleXMLChild(const wxChar *tag) if (!wxStrcmp(tag, wxT("waveclip"))) return CreateClip(); else - return NULL; + return nullptr; } void WaveTrack::WriteXML(XMLWriter &xmlFile) const @@ -1993,7 +1992,7 @@ bool WaveTrack::Get(samplePtr buffer, sampleFormat format, else if( fill==fillTwo ) { wxASSERT( format==floatSample ); - float * pBuffer = (float*)buffer; + auto * pBuffer = (float*)buffer; for(size_t i=0;iGetEnvelope(); else - return NULL; + return nullptr; } Sequence* WaveTrack::GetSequenceAtTime(double time) @@ -2209,7 +2208,7 @@ Sequence* WaveTrack::GetSequenceAtTime(double time) if (clip) return clip->GetSequence(); else - return NULL; + return nullptr; } WaveClip* WaveTrack::CreateClip(double offset, const wxString& name) @@ -2438,10 +2437,10 @@ void WaveTrack::UpdateLocationsCache() const if (clip->WithinPlayRegion(cutlinePosition)) { // Add cut line expander point - mDisplayLocationsCache.push_back(WaveTrackLocation{ + mDisplayLocationsCache.emplace_back( cutlinePosition, WaveTrackLocation::locationCutLine - }); + ); } // If cutline is skipped, we still need to count it // so that curpos match num at the end @@ -2454,12 +2453,12 @@ void WaveTrack::UpdateLocationsCache() const < WAVETRACK_MERGE_POINT_TOLERANCE) { // Add merge point - mDisplayLocationsCache.push_back(WaveTrackLocation{ + mDisplayLocationsCache.emplace_back( previousClip->GetPlayEndTime(), WaveTrackLocation::locationMergePoint, GetClipIndex(previousClip), GetClipIndex(clip) - }); + ); curpos++; } } @@ -2777,7 +2776,7 @@ const float *WaveTrackCache::GetFloats( // See comment below about casting if (!mPTrack->GetFloats( reinterpret_cast(buffer), start, remaining, fillZero, mayThrow)) - return 0; + return nullptr; } // Overlap buffer was meant for the more general support of sample formats diff --git a/src/WrappedType.cpp b/src/WrappedType.cpp index 0408812285..ed567cb8d9 100644 --- a/src/WrappedType.cpp +++ b/src/WrappedType.cpp @@ -34,14 +34,14 @@ #include /// @return true iff the wrapped type is a string. -bool WrappedType::IsString() +bool WrappedType::IsString() const { return eWrappedType == eWrappedString; } -wxString WrappedType::ReadAsString() +wxString WrappedType::ReadAsString() const { switch( eWrappedType ) { @@ -67,7 +67,7 @@ wxString WrappedType::ReadAsString() return wxT("ERROR"); //Compiler pacifier } -int WrappedType::ReadAsInt() +int WrappedType::ReadAsInt() const { switch( eWrappedType ) { @@ -97,7 +97,7 @@ int WrappedType::ReadAsInt() return -1;//Compiler pacifier } -double WrappedType::ReadAsDouble() +double WrappedType::ReadAsDouble() const { switch( eWrappedType ) { @@ -123,7 +123,7 @@ double WrappedType::ReadAsDouble() return -1.0f;//Compiler pacifier } -bool WrappedType::ReadAsBool() +bool WrappedType::ReadAsBool() const { switch( eWrappedType ) { @@ -151,7 +151,7 @@ bool WrappedType::ReadAsBool() } -void WrappedType::WriteToAsString( const wxString & InStr) +void WrappedType::WriteToAsString( const wxString & InStr) const { switch( eWrappedType ) { @@ -180,7 +180,7 @@ void WrappedType::WriteToAsString( const wxString & InStr) } } -void WrappedType::WriteToAsInt( const int InInt) +void WrappedType::WriteToAsInt( const int InInt) const { switch( eWrappedType ) { @@ -205,7 +205,7 @@ void WrappedType::WriteToAsInt( const int InInt) } } -void WrappedType::WriteToAsDouble( const double InDouble) +void WrappedType::WriteToAsDouble( const double InDouble) const { switch( eWrappedType ) { @@ -232,7 +232,7 @@ void WrappedType::WriteToAsDouble( const double InDouble) } -void WrappedType::WriteToAsBool( const bool InBool) +void WrappedType::WriteToAsBool( const bool InBool) const { switch( eWrappedType ) { diff --git a/src/WrappedType.h b/src/WrappedType.h index 29d9c58317..e6bdff81fd 100644 --- a/src/WrappedType.h +++ b/src/WrappedType.h @@ -47,17 +47,17 @@ class SAUCEDACITY_DLL_API WrappedType : eWrappedType{ eWrappedNotSet } {} - bool IsString(); + bool IsString() const; - wxString ReadAsString(); - int ReadAsInt(); - double ReadAsDouble(); - bool ReadAsBool(); + wxString ReadAsString() const; + int ReadAsInt() const; + double ReadAsDouble() const; + bool ReadAsBool() const; - void WriteToAsString( const wxString & InStr); - void WriteToAsInt( const int InInt); - void WriteToAsDouble( const double InDouble); - void WriteToAsBool( const bool InBool); + void WriteToAsString( const wxString & InStr) const; + void WriteToAsInt( int InInt) const; + void WriteToAsDouble( double InDouble) const; + void WriteToAsBool( bool InBool) const; public : diff --git a/src/ZoomInfo.cpp b/src/ZoomInfo.cpp index ea623ec408..a7a8210226 100644 --- a/src/ZoomInfo.cpp +++ b/src/ZoomInfo.cpp @@ -18,8 +18,8 @@ #include namespace { -static const double gMaxZoom = 6000000; -static const double gMinZoom = 0.001; +const double gMaxZoom = 6000000; +const double gMinZoom = 0.001; } ZoomInfo::ZoomInfo(double start, double pixelsPerSecond) diff --git a/src/ZoomInfo.h b/src/ZoomInfo.h index cfce604f32..4243a78af2 100644 --- a/src/ZoomInfo.h +++ b/src/ZoomInfo.h @@ -49,7 +49,7 @@ class SAUCEDACITY_DLL_API ZoomInfo /* not final */ { public: ZoomInfo(double start, double pixelsPerSecond); - ~ZoomInfo(); + ~ZoomInfo() override; // Be sure we don't slice ZoomInfo(const ZoomInfo&) = delete; @@ -71,7 +71,7 @@ class SAUCEDACITY_DLL_API ZoomInfo /* not final */ // Instead, call twice to convert start and end times, // and take the difference. // origin specifies the pixel corresponding to time h - double PositionToTime(wxInt64 position, + [[nodiscard]] double PositionToTime(wxInt64 position, wxInt64 origin = 0 , bool ignoreFisheye = false ) const; @@ -87,23 +87,23 @@ class SAUCEDACITY_DLL_API ZoomInfo /* not final */ // This always ignores the fisheye. Use with caution! // You should prefer to call TimeToPosition twice, for endpoints, and take the difference! - double TimeRangeToPixelWidth(double timeRange) const; + [[nodiscard]] double TimeRangeToPixelWidth(double timeRange) const; - double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye = false) const + [[nodiscard]] double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye = false) const { return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye); } - int GetWidth() const { return mWidth; } + [[nodiscard]] int GetWidth() const { return mWidth; } void SetWidth( int width ) { mWidth = width; } - int GetVRulerWidth() const { return mVRulerWidth; } + [[nodiscard]] int GetVRulerWidth() const { return mVRulerWidth; } void SetVRulerWidth( int width ) { mVRulerWidth = width; } - int GetVRulerOffset() const { return kTrackInfoWidth + kLeftMargin; } - int GetLabelWidth() const { return GetVRulerOffset() + GetVRulerWidth(); } - int GetLeftOffset() const { return GetLabelWidth() + 1;} + static int GetVRulerOffset() { return kTrackInfoWidth + kLeftMargin; } + [[nodiscard]] int GetLabelWidth() const { return GetVRulerOffset() + GetVRulerWidth(); } + [[nodiscard]] int GetLeftOffset() const { return GetLabelWidth() + 1;} - int GetTracksUsableWidth() const + [[nodiscard]] int GetTracksUsableWidth() const { return std::max( 0, GetWidth() - ( GetLeftOffset() + kRightMargin ) ); @@ -111,14 +111,14 @@ class SAUCEDACITY_DLL_API ZoomInfo /* not final */ // Returns the time corresponding to the pixel column one past the track area // (ignoring any fisheye) - double GetScreenEndTime() const + [[nodiscard]] double GetScreenEndTime() const { auto width = GetTracksUsableWidth(); return PositionToTime(width, 0, true); } - bool ZoomInAvailable() const; - bool ZoomOutAvailable() const; + [[nodiscard]] bool ZoomInAvailable() const; + [[nodiscard]] bool ZoomOutAvailable() const; static double GetDefaultZoom() { return 44100.0 / 512.0; } @@ -129,7 +129,7 @@ class SAUCEDACITY_DLL_API ZoomInfo /* not final */ // This function should not be used to convert positions to times and back // Use TimeToPosition and PositionToTime and OffsetTimeByPixels instead - double GetZoom() const; + [[nodiscard]] double GetZoom() const; static double GetMaxZoom( ); static double GetMinZoom( ); @@ -161,20 +161,20 @@ class SAUCEDACITY_DLL_API ZoomInfo /* not final */ NUM_STATES, }; - FisheyeState GetFisheyeState() const + static FisheyeState GetFisheyeState() { return HIDDEN; } // stub // Return true if the mouse position is anywhere in the fisheye // origin specifies the pixel corresponding to time h - bool InFisheye(wxInt64 /*position*/, wxInt64 WXUNUSED(origin = 0)) const + static bool InFisheye(wxInt64 /*position*/, wxInt64 WXUNUSED(origin = 0)) {return false;} // stub // These accessors ignore the fisheye hiding state. // Inclusive: - wxInt64 GetFisheyeLeftBoundary(wxInt64 WXUNUSED(origin = 0)) const + static wxInt64 GetFisheyeLeftBoundary(wxInt64 WXUNUSED(origin = 0)) {return 0;} // stub // Exclusive: - wxInt64 GetFisheyeRightBoundary(wxInt64 WXUNUSED(origin = 0)) const + static wxInt64 GetFisheyeRightBoundary(wxInt64 WXUNUSED(origin = 0)) {return 0;} // stub int mWidth{ 0 }; diff --git a/src/commands/AppCommandEvent.h b/src/commands/AppCommandEvent.h index 9106ed1b74..d1bc8fb7c7 100644 --- a/src/commands/AppCommandEvent.h +++ b/src/commands/AppCommandEvent.h @@ -32,12 +32,12 @@ class AppCommandEvent final : public wxCommandEvent OldStyleCommandPointer mCommand; public: - AppCommandEvent(wxEventType commandType = wxEVT_APP_COMMAND_RECEIVED, int id = 0); + explicit AppCommandEvent(wxEventType commandType = wxEVT_APP_COMMAND_RECEIVED, int id = 0); AppCommandEvent(const AppCommandEvent &event); - ~AppCommandEvent(); + ~AppCommandEvent() override; - wxEvent *Clone() const override; + [[nodiscard]] wxEvent *Clone() const override; void SetCommand(const OldStyleCommandPointer &cmd); OldStyleCommandPointer GetCommand(); diff --git a/src/commands/AudacityCommand.cpp b/src/commands/AudacityCommand.cpp index d7c2227481..58253ee612 100644 --- a/src/commands/AudacityCommand.cpp +++ b/src/commands/AudacityCommand.cpp @@ -67,9 +67,9 @@ auto AudacityCommand::SetVetoDialogHook( VetoDialogHook hook ) AudacityCommand::AudacityCommand() { - mProgress = NULL; - mUIParent = NULL; - mUIDialog = NULL; + mProgress = nullptr; + mUIParent = nullptr; + mUIDialog = nullptr; mUIDebug = false; mIsBatch = false; mNeedsInit = true; @@ -134,7 +134,7 @@ wxDialog *AudacityCommand::CreateUI(wxWindow *parent, AudacityCommand * WXUNUSED // release() is safe because parent will own it return dlg.release(); } - return NULL; + return nullptr; } bool AudacityCommand::GetAutomationParameters(wxString & parms) diff --git a/src/commands/AudacityCommand.h b/src/commands/AudacityCommand.h index 337d010b7c..bfb32f8d7d 100644 --- a/src/commands/AudacityCommand.h +++ b/src/commands/AudacityCommand.h @@ -43,7 +43,7 @@ class SAUCEDACITY_DLL_API AudacityCommand /* not final */ : public wxEvtHandler, //CommandOutputTargets * mOutput; public: AudacityCommand(); - virtual ~AudacityCommand(); + ~AudacityCommand() override; // Type of a registered function that, if it returns true, // causes ShowInterface to return early without making any dialog @@ -60,7 +60,7 @@ class SAUCEDACITY_DLL_API AudacityCommand /* not final */ : public wxEvtHandler, //These two must be implemented by instances. ComponentInterfaceSymbol GetSymbol() override = 0; - virtual TranslatableString GetDescription() override + TranslatableString GetDescription() override {wxFAIL_MSG( "Implement a Description for this command");return XO("FAIL");}; // Name of page in the Audacity alpha manual @@ -118,7 +118,7 @@ class SAUCEDACITY_DLL_API AudacityCommand /* not final */ : public wxEvtHandler, // effect, after either successful or failed or exception-aborted processing. // Invoked inside a "finally" block so it must be no-throw. virtual void End(){;}; - virtual void PopulateOrExchange(ShuttleGui & WXUNUSED(S)){return;}; + virtual void PopulateOrExchange(ShuttleGui & WXUNUSED(S)){}; virtual bool TransferDataToWindow(); virtual bool TransferDataFromWindow(); diff --git a/src/commands/BatchEvalCommand.h b/src/commands/BatchEvalCommand.h index c5902b7f57..c4985ce09d 100644 --- a/src/commands/BatchEvalCommand.h +++ b/src/commands/BatchEvalCommand.h @@ -44,7 +44,7 @@ class BatchEvalCommand final : public CommandImplementation : CommandImplementation(project, type) { } - virtual ~BatchEvalCommand(); + ~BatchEvalCommand() override; bool Apply(const CommandContext &context) override; }; diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 763e5a7612..6466855a1d 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -101,8 +101,7 @@ bool OldStyleCommand::SetParameter(const wxString & WXUNUSED(paramName), } DecoratedCommand::~DecoratedCommand() -{ -} += default; ComponentInterfaceSymbol DecoratedCommand::GetSymbol() { @@ -145,7 +144,7 @@ bool ApplyAndSendResponse::Apply() // the command it holds. auto result = GuardedCall( [&] { - bool bResult = mCommand->Apply(*( mCtx.get())); + bool bResult = mCommand->Apply(*( mCtx)); return bResult; } ); wxString response = wxT( "\n" ); @@ -179,8 +178,7 @@ CommandImplementation::CommandImplementation( } CommandImplementation::~CommandImplementation() -{ -} += default; void CommandImplementation::TypeCheck(const wxString &typeName, const wxString ¶mName, @@ -262,7 +260,7 @@ bool CommandImplementation::SetParameter(const wxString ¶mName, const wxVari { wxASSERT(!paramValue.IsType(wxT("null"))); CommandContext context( mProject ); - ParamValueMap::iterator iter = mParams.find(paramName); + auto iter = mParams.find(paramName); if (iter == mParams.end()) { // Translated format, but untranslated command name substituted into it? diff --git a/src/commands/Command.h b/src/commands/Command.h index 8eb5de6371..b2e6aaf271 100644 --- a/src/commands/Command.h +++ b/src/commands/Command.h @@ -30,8 +30,8 @@ class OldStyleCommand /* not final */ public: SaucedacityProject &mProject; - OldStyleCommand(SaucedacityProject &project) : mProject{ project } {}; - virtual ~OldStyleCommand() { } + explicit OldStyleCommand(SaucedacityProject &project) : mProject{ project } {}; + virtual ~OldStyleCommand() = default; virtual ComponentInterfaceSymbol GetSymbol() = 0; virtual CommandSignature &GetSignature() = 0; virtual bool SetParameter(const wxString ¶mName, const wxVariant ¶mValue); @@ -48,12 +48,12 @@ class DecoratedCommand /* not final */ : public OldStyleCommand protected: OldStyleCommandPointer mCommand; public: - DecoratedCommand(const OldStyleCommandPointer &cmd) + explicit DecoratedCommand(const OldStyleCommandPointer &cmd) : OldStyleCommand{ cmd->mProject }, mCommand(cmd) { - wxASSERT(cmd != NULL); + wxASSERT(cmd != nullptr); } - virtual ~DecoratedCommand(); + ~DecoratedCommand() override; ComponentInterfaceSymbol GetSymbol() override; CommandSignature &GetSignature() override; bool SetParameter(const wxString ¶mName, const wxVariant ¶mValue) override; @@ -101,7 +101,7 @@ class SAUCEDACITY_DLL_API CommandImplementation /* not final */ /// ensures name and params are set appropriately for the command. CommandImplementation(SaucedacityProject &project, OldStyleCommandType &type); - virtual ~CommandImplementation(); + ~CommandImplementation() override; /// An instance method for getting the command name (for consistency) ComponentInterfaceSymbol GetSymbol() override; diff --git a/src/commands/CommandBuilder.cpp b/src/commands/CommandBuilder.cpp index a7727a10f2..be1ac9b4e8 100644 --- a/src/commands/CommandBuilder.cpp +++ b/src/commands/CommandBuilder.cpp @@ -45,10 +45,9 @@ CommandBuilder::CommandBuilder(SaucedacityProject *project, } CommandBuilder::~CommandBuilder() -{ -} += default; -bool CommandBuilder::WasValid() +bool CommandBuilder::WasValid() const { return mValid; } @@ -102,13 +101,12 @@ void CommandBuilder::BuildCommand(SaucedacityProject *project, // Fall back to hoping the Batch Command system can handle it #endif OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("BatchCommand")); - wxASSERT(type != NULL); + wxASSERT(type != nullptr); mCommand = type->Create(project, nullptr); mCommand->SetParameter(wxT("CommandName"), cmdName); mCommand->SetParameter(wxT("ParamString"), cmdParamsArg); auto aCommand = std::make_shared(mCommand, output); Success(aCommand); - return; #ifdef OLD_BATCH_SYSTEM } diff --git a/src/commands/CommandBuilder.h b/src/commands/CommandBuilder.h index 130e496baf..e8b677146d 100644 --- a/src/commands/CommandBuilder.h +++ b/src/commands/CommandBuilder.h @@ -47,7 +47,7 @@ class CommandBuilder CommandBuilder(SaucedacityProject *project, const wxString &cmdName, const wxString &cmdParams); ~CommandBuilder(); - bool WasValid(); + [[nodiscard]] bool WasValid() const; OldStyleCommandPointer GetCommand(); wxString GetResponse(); }; diff --git a/src/commands/CommandContext.cpp b/src/commands/CommandContext.cpp index b8508dfbec..0aab76c492 100644 --- a/src/commands/CommandContext.cpp +++ b/src/commands/CommandContext.cpp @@ -24,6 +24,7 @@ messaging from a command back to its invoker. #include "CommandContext.h" #include +#include #include #include #include @@ -42,7 +43,7 @@ CommandContext::CommandContext( , pOutput( std::make_unique() ) , pEvt{ e } , index{ ii } - , parameter{ param } + , parameter{std::move( param )} { } diff --git a/src/commands/CommandContext.h b/src/commands/CommandContext.h index 738b2e98ff..d01dddb8c0 100644 --- a/src/commands/CommandContext.h +++ b/src/commands/CommandContext.h @@ -33,12 +33,12 @@ struct TemporarySelection { class SAUCEDACITY_DLL_API CommandContext { public: - CommandContext( - SaucedacityProject &p - , const wxEvent *e = nullptr - , int ii = 0 - , const CommandParameter ¶m = CommandParameter{} - ); + CommandContext( + SaucedacityProject &p + , const wxEvent *e = nullptr + , int ii = 0 + , const CommandParameter ¶m = CommandParameter{} + ); CommandContext( SaucedacityProject &p, @@ -58,8 +58,8 @@ class SAUCEDACITY_DLL_API CommandContext { void StartField(const wxString &name) const; void EndField() const; void AddItem(const wxString &value , const wxString &name = {} ) const; - void AddBool(const bool value , const wxString &name = {} ) const; - void AddItem(const double value , const wxString &name = {} ) const; + void AddBool(bool value , const wxString &name = {} ) const; + void AddItem(double value , const wxString &name = {} ) const; SaucedacityProject &project; std::unique_ptr pOutput; diff --git a/src/commands/CommandDirectory.cpp b/src/commands/CommandDirectory.cpp index 877301a01f..effeb1e9a2 100644 --- a/src/commands/CommandDirectory.cpp +++ b/src/commands/CommandDirectory.cpp @@ -60,10 +60,9 @@ CommandDirectory::CommandDirectory() } CommandDirectory::~CommandDirectory() -{ -} += default; -OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) const +OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) { auto iter = sCmdMap().find(cmdName); if (iter == sCmdMap().end()) @@ -81,7 +80,7 @@ CommandMap &CommandDirectory::sCmdMap() void CommandDirectory::AddCommand(std::unique_ptr type) { - wxASSERT(type != NULL); + wxASSERT(type != nullptr); // Internal string is shown but only in assertion message auto cmdName = type->GetSymbol().Internal(); wxASSERT_MSG(sCmdMap().find(cmdName) == sCmdMap().end() diff --git a/src/commands/CommandDirectory.h b/src/commands/CommandDirectory.h index 6920a39da9..da9e6cbfa7 100644 --- a/src/commands/CommandDirectory.h +++ b/src/commands/CommandDirectory.h @@ -38,7 +38,7 @@ class SAUCEDACITY_DLL_API CommandDirectory /// Register a type of command with the directory with a statically /// constructed instance of this class. struct RegisterType{ - RegisterType( std::unique_ptr type ) + explicit RegisterType( std::unique_ptr type ) { AddCommand( std::move( type ) ); } }; @@ -47,7 +47,7 @@ class SAUCEDACITY_DLL_API CommandDirectory /// If a command with the given name has been registered in the directory, /// return a pointer to the factory for commands of that type. /// Otherwise return NULL. - OldStyleCommandType *LookUp(const wxString &cmdName) const; + [[nodiscard]] static OldStyleCommandType *LookUp(const wxString &cmdName) ; /// Get a pointer to the singleton instance static CommandDirectory *Get(); diff --git a/src/commands/CommandHandler.cpp b/src/commands/CommandHandler.cpp index aa31d4709a..6acc6987a9 100644 --- a/src/commands/CommandHandler.cpp +++ b/src/commands/CommandHandler.cpp @@ -29,12 +29,10 @@ #include "../commands/Command.h" CommandHandler::CommandHandler() -{ -} += default; CommandHandler::~CommandHandler() -{ -} += default; void CommandHandler::OnReceiveCommand(AppCommandEvent &event) { diff --git a/src/commands/CommandHandler.h b/src/commands/CommandHandler.h index 3a1dcc2b48..beb6f9b15d 100644 --- a/src/commands/CommandHandler.h +++ b/src/commands/CommandHandler.h @@ -29,7 +29,7 @@ class CommandHandler ~CommandHandler(); // Whenever a command is received, process it. - void OnReceiveCommand(AppCommandEvent &event); + static void OnReceiveCommand(AppCommandEvent &event); }; #endif /* End of include guard: __COMMANDHANDLER__ */ diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index babb3e4448..201fac7cbc 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -90,6 +90,10 @@ CommandManager. It holds the callback for one command. #include #include +#include + +#include + #include "../Journal.h" #include "../JournalOutput.h" #include "../JournalRegistry.h" @@ -126,7 +130,7 @@ struct MenuBarListEntry struct SubMenuListEntry { - SubMenuListEntry( const TranslatableString &name_ ); + explicit SubMenuListEntry( TranslatableString name_ ); SubMenuListEntry( SubMenuListEntry&& ) = default; ~SubMenuListEntry(); @@ -169,12 +173,10 @@ struct CommandListEntry }; NonKeystrokeInterceptingWindow::~NonKeystrokeInterceptingWindow() -{ -} += default; TopLevelKeystrokeHandlingWindow::~TopLevelKeystrokeHandlingWindow() -{ -} += default; MenuBarListEntry::MenuBarListEntry(const wxString &name_, wxMenuBar *menubar_) : name(name_), menubar(menubar_) @@ -182,17 +184,15 @@ MenuBarListEntry::MenuBarListEntry(const wxString &name_, wxMenuBar *menubar_) } MenuBarListEntry::~MenuBarListEntry() -{ -} += default; -SubMenuListEntry::SubMenuListEntry( const TranslatableString &name_ ) - : name(name_), menu( std::make_unique< wxMenu >() ) +SubMenuListEntry::SubMenuListEntry( TranslatableString name_ ) + : name(std::move(name_)), menu( std::make_unique< wxMenu >() ) { } SubMenuListEntry::~SubMenuListEntry() -{ -} += default; /// static const SaucedacityProject::AttachedObjects::RegisteredFactory key{ @@ -385,7 +385,7 @@ wxMenuBar * CommandManager::GetMenuBar(const wxString & sMenu) const return entry.menubar; } - return NULL; + return nullptr; } @@ -395,7 +395,7 @@ wxMenuBar * CommandManager::GetMenuBar(const wxString & sMenu) const wxMenuBar * CommandManager::CurrentMenuBar() const { if(mMenuBarList.empty()) - return NULL; + return nullptr; return mMenuBarList.back().menubar; } @@ -505,7 +505,7 @@ void CommandManager::EndSubMenu() wxMenu * CommandManager::CurrentSubMenu() const { if(mSubMenuList.empty()) - return NULL; + return nullptr; return mSubMenuList.back().menu.get(); } @@ -517,7 +517,7 @@ wxMenu * CommandManager::CurrentSubMenu() const wxMenu * CommandManager::CurrentMenu() const { if(!mCurrentMenu) - return NULL; + return nullptr; wxMenu * tmpCurrentSubMenu = CurrentSubMenu(); @@ -583,7 +583,7 @@ void CommandManager::AddItem(SaucedacityProject &project, } auto CommandManager::Options::MakeCheckFn( - const wxString key, bool defaultValue ) -> CheckFn + const wxString& key, bool defaultValue ) -> CheckFn { return [=](SaucedacityProject&){ return gPrefs->ReadBool( key, defaultValue ); }; } @@ -603,7 +603,7 @@ auto CommandManager::Options::MakeCheckFn( void CommandManager::AddItemList(const CommandID & name, const ComponentInterfaceSymbol items[], size_t nItems, - CommandHandlerFinder finder, + const CommandHandlerFinder& finder, CommandFunctorPointer callback, CommandFlag flags, bool bIsEffect) @@ -633,7 +633,7 @@ void CommandManager::AddGlobalCommand(const CommandID &name, const Options &options) { CommandListEntry *entry = - NewIdentifier(name, label_in, NULL, finder, callback, + NewIdentifier(name, label_in, nullptr, std::move(finder), callback, {}, 0, 0, options); entry->enabled = false; @@ -680,7 +680,7 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn, const wxString & accel = options.accel; bool bIsEffect = options.bIsEffect; - CommandID parameter = options.parameter == "" ? nameIn : options.parameter; + CommandID parameter = options.parameter.empty() ? nameIn : options.parameter; // if empty, new identifier's long label will be same as label, below: const auto &longLabel = options.longName; @@ -745,7 +745,7 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn, entry->labelPrefix = labelPrefix; entry->labelTop = mCurrentMenuName.Stripped(); entry->menu = menu; - entry->finder = finder; + entry->finder = std::move(finder); entry->callback = callback; entry->isEffect = bIsEffect; entry->multi = multi; @@ -840,10 +840,10 @@ wxString CommandManager::FormatLabelForMenu(const CommandListEntry *entry) const wxString CommandManager::FormatLabelForMenu( const TranslatableString &translatableLabel, - const NormalizedKeyString &keyStr) const + const NormalizedKeyString &keyStr) { auto label = translatableLabel.Translation(); - auto key = keyStr.GET(); + const auto& key = keyStr.GET(); if (!key.empty()) { // using GET to compose menu item name for wxWidgets @@ -858,7 +858,7 @@ wxString CommandManager::FormatLabelForMenu( // catch them in normal wxWidgets processing, rather than passing the key presses on // to the controls that had the focus. We would like all the menu accelerators to be // disabled, in fact. -wxString CommandManager::FormatLabelWithDisabledAccel(const CommandListEntry *entry) const +wxString CommandManager::FormatLabelWithDisabledAccel(const CommandListEntry *entry) { auto label = entry->label.Translation(); #if 1 @@ -1107,7 +1107,7 @@ bool CommandManager::FilterKeyEvent(SaucedacityProject *project, const wxKeyEven auto pWindow = FindProjectFrame( project ); CommandListEntry *entry = mCommandKeyHash[KeyEventToKeyString(evt)]; - if (entry == NULL) + if (entry == nullptr) { return false; } @@ -1132,7 +1132,7 @@ bool CommandManager::FilterKeyEvent(SaucedacityProject *project, const wxKeyEven // Bug 1557. MixerBoard should count as 'destined for project' // MixerBoard IS a TopLevelWindow, and its parent is the project. if( pParent && pParent->GetParent() == pWindow ){ - if( dynamic_cast< TopLevelKeystrokeHandlingWindow* >( pParent ) != NULL ) + if( dynamic_cast< TopLevelKeystrokeHandlingWindow* >( pParent ) != nullptr ) validTarget = true; } validTarget = validTarget && wxEventLoop::GetActive()->IsMain(); @@ -1291,8 +1291,7 @@ void CommandManager::RegisterLastAnalyzer(const CommandContext& context) { auto lastEffectDesc = XO("Repeat %s").Format(mNiceName); Modify(wxT("RepeatLastAnalyzer"), lastEffectDesc); } - return; -} + } // Called by Selected Tools to mark them as Last Tools. // Note that Repeat data has previously been collected @@ -1304,8 +1303,7 @@ void CommandManager::RegisterLastTool(const CommandContext& context) { auto lastEffectDesc = XO("Repeat %s").Format(mNiceName); Modify(wxT("RepeatLastTool"), lastEffectDesc); } - return; -} + } // Used to invoke Repeat Last Analyzer Process for built-in, non-nyquist plug-ins. void CommandManager::DoRepeatProcess(const CommandContext& context, int id) { diff --git a/src/commands/CommandManager.h b/src/commands/CommandManager.h index 4634122f12..913397744a 100644 --- a/src/commands/CommandManager.h +++ b/src/commands/CommandManager.h @@ -25,6 +25,8 @@ #include "Keyboard.h" +#include +#include #include #include @@ -73,7 +75,7 @@ class SAUCEDACITY_DLL_API CommandManager final // CommandManager(); - virtual ~CommandManager(); + ~CommandManager() override; CommandManager(const CommandManager&) = delete; CommandManager &operator= (const CommandManager&) = delete; @@ -103,8 +105,8 @@ class SAUCEDACITY_DLL_API CommandManager final // A two-argument constructor for another common case Options( const wxChar *accel_, - const TranslatableString &longName_ ) - : accel{ accel_ }, longName{ longName_ } {} + TranslatableString longName_ ) + : accel{ accel_ }, longName{std::move( longName_ )} {} Options &&Accel (const wxChar *value) && { accel = value; return std::move(*this); } @@ -159,7 +161,7 @@ class SAUCEDACITY_DLL_API CommandManager final private: static CheckFn - MakeCheckFn( const wxString key, bool defaultValue ); + MakeCheckFn( const wxString& key, bool defaultValue ); static CheckFn MakeCheckFn( const BoolSetting &setting ); }; @@ -167,7 +169,7 @@ class SAUCEDACITY_DLL_API CommandManager final void AddItemList(const CommandID & name, const ComponentInterfaceSymbol items[], size_t nItems, - CommandHandlerFinder finder, + const CommandHandlerFinder& finder, CommandFunctorPointer callback, CommandFlag flags, bool bIsEffect = false); @@ -289,7 +291,7 @@ class SAUCEDACITY_DLL_API CommandManager final // Creating menus and adding commands // - int NextIdentifier(int ID); + static int NextIdentifier(int ID); CommandListEntry *NewIdentifier(const CommandID & name, const TranslatableString & label, wxMenu *menu, @@ -347,10 +349,10 @@ class SAUCEDACITY_DLL_API CommandManager final private: wxString FormatLabelForMenu(const CommandListEntry *entry) const; - wxString FormatLabelForMenu( + static wxString FormatLabelForMenu( const TranslatableString &translatableLabel, - const NormalizedKeyString &keyStr) const; - wxString FormatLabelWithDisabledAccel(const CommandListEntry *entry) const; + const NormalizedKeyString &keyStr) ; + static wxString FormatLabelWithDisabledAccel(const CommandListEntry *entry) ; // // Loading/Saving @@ -407,9 +409,9 @@ struct SAUCEDACITY_DLL_API MenuVisitor : Registry::Visitor struct ToolbarMenuVisitor : MenuVisitor { - explicit ToolbarMenuVisitor( SaucedacityProject &p ) : project{ p } {} - operator SaucedacityProject & () const { return project; } - SaucedacityProject &project; + ToolbarMenuVisitor( SaucedacityProject &p ) : project{ p } {} + operator SaucedacityProject & () const { return project; } + SaucedacityProject &project; }; // Define items that populate tables that specifically describe menu trees @@ -421,7 +423,7 @@ namespace MenuTable { virtual ~MenuSection(); }; struct SAUCEDACITY_DLL_API WholeMenu { - WholeMenu( bool extend = false ) : extension{ extend } {} + explicit WholeMenu( bool extend = false ) : extension{ extend } {} virtual ~WholeMenu(); bool extension; }; @@ -433,14 +435,14 @@ namespace MenuTable { // Construction from an internal name and a previously built-up // vector of pointers MenuItem( const Identifier &internalName, - const TranslatableString &title_, BaseItemPtrs &&items_ ); + TranslatableString title_, BaseItemPtrs &&items_ ); // In-line, variadic constructor that doesn't require building a vector template< typename... Args > MenuItem( const Identifier &internalName, - const TranslatableString &title_, Args&&... args ) + TranslatableString title_, Args&&... args ) : ConcreteGroupItem< false, ToolbarMenuVisitor >{ internalName, std::forward(args)... } - , title{ title_ } + , title{std::move( title_ )} {} ~MenuItem() override; @@ -463,7 +465,7 @@ namespace MenuTable { Condition condition_, Args&&... args ) : ConcreteGroupItem< false, ToolbarMenuVisitor >{ internalName, std::forward(args)... } - , condition{ condition_ } + , condition{std::move( std::move(condition_) )} {} ~ConditionalGroupItem() override; @@ -489,7 +491,7 @@ namespace MenuTable { static CommandHandlerFinder DefaultFinder() { return sFinder; } explicit - FinderScope( CommandHandlerFinder finder ) + FinderScope( const CommandHandlerFinder& finder ) : ValueRestorer( sFinder, finder ) {} }; @@ -497,10 +499,10 @@ namespace MenuTable { // Describes one command in a menu struct SAUCEDACITY_DLL_API CommandItem final : SingleItem { CommandItem(const CommandID &name_, - const TranslatableString &label_in_, + TranslatableString label_in_, CommandFunctorPointer callback_, CommandFlag flags_, - const CommandManager::Options &options_, + CommandManager::Options options_, CommandHandlerFinder finder_); // Takes a pointer to member function directly, and delegates to the @@ -566,9 +568,9 @@ namespace MenuTable { { using Appender = std::function< void( SaucedacityProject&, wxMenu& ) >; - explicit SpecialItem( const Identifier &internalName, const Appender &fn_ ) + explicit SpecialItem( const Identifier &internalName, Appender fn_ ) : SingleItem{ internalName } - , fn{ fn_ } + , fn{std::move( fn_ )} {} ~SpecialItem() override; @@ -642,7 +644,7 @@ namespace MenuTable { { return std::make_unique( internalName, condition, std::forward(args)... ); } inline std::unique_ptr ConditionalItems( - const Identifier &internalName, ConditionalGroupItem::Condition condition, + const Identifier &internalName, const ConditionalGroupItem::Condition& condition, BaseItemPtrs &&items ) { return std::make_unique( internalName, condition, std::move( items ) ); } diff --git a/src/commands/CommandSignature.cpp b/src/commands/CommandSignature.cpp index 00f12573c2..1be71a848e 100644 --- a/src/commands/CommandSignature.cpp +++ b/src/commands/CommandSignature.cpp @@ -19,8 +19,7 @@ CommandSignature::CommandSignature() = default; CommandSignature::~CommandSignature() -{ -} += default; void CommandSignature::AddParameter(const wxString &name, const wxVariant &dft, diff --git a/src/commands/CommandSignature.h b/src/commands/CommandSignature.h index ece6a83155..ba83adeffa 100644 --- a/src/commands/CommandSignature.h +++ b/src/commands/CommandSignature.h @@ -45,7 +45,7 @@ class SAUCEDACITY_DLL_API CommandSignature std::unique_ptr &&valid); // Methods for accessing the signature - ParamValueMap GetDefaults() const; + [[nodiscard]] ParamValueMap GetDefaults() const; Validator &GetValidator(const wxString ¶mName); }; diff --git a/src/commands/CommandTargets.cpp b/src/commands/CommandTargets.cpp index e4ef23b6c1..5bdd43826f 100644 --- a/src/commands/CommandTargets.cpp +++ b/src/commands/CommandTargets.cpp @@ -70,7 +70,7 @@ void CommandMessageTarget::AddItem(const wxString &value, const wxString &name){ if( name.empty() ) Update( wxString::Format( "%s%s\"%s\"", (mCounts.back()>0)?", ":"", Padding, Escaped(value))); else - Update( wxString::Format( "%s%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", Padding, name, Escaped(value))); + Update( wxString::Format( R"(%s%s"%s":"%s")", (mCounts.back()>0)?", ":"", Padding, name, Escaped(value))); mCounts.back() += 1; } @@ -78,7 +78,7 @@ void CommandMessageTarget::AddBool(const bool value, const wxString &name){ if( name.empty() ) Update( wxString::Format( "%s\"%s\"", (mCounts.back()>0)?", ":"", value?"true":"false")); else - Update( wxString::Format( "%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", name,value?"true":"false")); + Update( wxString::Format( R"(%s"%s":"%s")", (mCounts.back()>0)?", ":"", name,value?"true":"false")); mCounts.back() += 1; } @@ -264,7 +264,7 @@ LispifiedCommandOutputTargets::LispifiedCommandOutputTargets( CommandOutputTarge pToRestore( &target ) { mProgressTarget = std::move(target.mProgressTarget), - mStatusTarget = std::make_shared( *target.mStatusTarget.get() ), + mStatusTarget = std::make_shared( *target.mStatusTarget ), mErrorTarget = std::move( target.mErrorTarget ); } @@ -281,7 +281,7 @@ BriefCommandOutputTargets::BriefCommandOutputTargets( CommandOutputTargets & tar pToRestore( &target ) { mProgressTarget = std::move(target.mProgressTarget), - mStatusTarget = std::make_shared( *target.mStatusTarget.get() ), + mStatusTarget = std::make_shared( *target.mStatusTarget ), mErrorTarget = std::move( target.mErrorTarget ); } @@ -312,7 +312,7 @@ class SAUCEDACITY_DLL_API LongMessageDialog /* not final */ : public wxDialogWra int type = 0, int flags = wxDEFAULT_DIALOG_STYLE, int additionalButtons = 0); - ~LongMessageDialog(); + ~LongMessageDialog() override; bool Init(); virtual void OnOk(wxCommandEvent & evt); @@ -333,7 +333,7 @@ class SAUCEDACITY_DLL_API LongMessageDialog /* not final */ : public wxDialogWra }; -LongMessageDialog * LongMessageDialog::pDlg = NULL; +LongMessageDialog * LongMessageDialog::pDlg = nullptr; BEGIN_EVENT_TABLE(LongMessageDialog, wxDialogWrapper) @@ -357,7 +357,7 @@ LongMessageDialog::LongMessageDialog(wxWindow * parent, } LongMessageDialog::~LongMessageDialog(){ - pDlg = NULL; + pDlg = nullptr; } @@ -393,7 +393,7 @@ void LongMessageDialog::OnCancel(wxCommandEvent & WXUNUSED(evt)){ void LongMessageDialog::AcceptText( const wxString & Text ) { - if( pDlg == NULL ){ + if( pDlg == nullptr ){ pDlg = new LongMessageDialog( wxTheApp->GetTopWindow(), XO( "Long Message" ) ); pDlg->Init(); @@ -426,7 +426,7 @@ LongMessageDialog class MessageDialogTarget final : public CommandMessageTarget { public: - virtual ~MessageDialogTarget() {Flush();} + ~MessageDialogTarget() override {Flush();} void Update(const wxString &message) override { LongMessageDialog::AcceptText(message); diff --git a/src/commands/CommandTargets.h b/src/commands/CommandTargets.h index 2347319fa7..b5c779def9 100644 --- a/src/commands/CommandTargets.h +++ b/src/commands/CommandTargets.h @@ -66,7 +66,7 @@ class wxStatusBar; class CommandProgressTarget /* not final */ { public: - virtual ~CommandProgressTarget() {} + virtual ~CommandProgressTarget() = default; virtual void Update(double completed) = 0; }; @@ -82,20 +82,20 @@ class SAUCEDACITY_DLL_API CommandMessageTarget /* not final */ virtual void StartStruct(); virtual void EndStruct(); virtual void AddItem(const wxString &value , const wxString &name = {} ); - virtual void AddBool(const bool value , const wxString &name = {} ); - virtual void AddItem(const double value , const wxString &name = {} ); + virtual void AddBool(bool value , const wxString &name = {} ); + virtual void AddItem(double value , const wxString &name = {} ); virtual void StartField( const wxString &name = {} ); virtual void EndField( ); virtual void Flush(); - wxString Escaped( const wxString & str); + static wxString Escaped( const wxString & str); std::vector mCounts; }; class CommandMessageTargetDecorator : public CommandMessageTarget { public: - CommandMessageTargetDecorator( CommandMessageTarget & target): mTarget(target) {} - ~CommandMessageTargetDecorator() override { } + explicit CommandMessageTargetDecorator( CommandMessageTarget & target): mTarget(target) {} + ~CommandMessageTargetDecorator() override = default; void Update(const wxString &message) override { mTarget.Update( message );} void StartArray() override { mTarget.StartArray();} void EndArray() override { mTarget.EndArray();} @@ -119,38 +119,38 @@ class CommandMessageTargetDecorator : public CommandMessageTarget class LispyCommandMessageTarget : public CommandMessageTargetDecorator /* not final */ { public: - LispyCommandMessageTarget( CommandMessageTarget & target): CommandMessageTargetDecorator(target) {}; - virtual void StartArray() override; - virtual void EndArray() override; - virtual void StartStruct() override; - virtual void EndStruct() override; - virtual void AddItem(const wxString &value , const wxString &name = {} )override; - virtual void AddBool(const bool value , const wxString &name = {} )override; - virtual void AddItem(const double value , const wxString &name = {} )override; - virtual void StartField( const wxString &name = {} )override; - virtual void EndField( ) override; + explicit LispyCommandMessageTarget( CommandMessageTarget & target): CommandMessageTargetDecorator(target) {}; + void StartArray() override; + void EndArray() override; + void StartStruct() override; + void EndStruct() override; + void AddItem(const wxString &value , const wxString &name = {} )override; + void AddBool(bool value , const wxString &name = {} )override; + void AddItem(double value , const wxString &name = {} )override; + void StartField( const wxString &name = {} )override; + void EndField( ) override; }; class BriefCommandMessageTarget : public CommandMessageTargetDecorator /* not final */ { public: - BriefCommandMessageTarget( CommandMessageTarget & target): CommandMessageTargetDecorator(target) {}; - virtual void StartArray() override; - virtual void EndArray() override; - virtual void StartStruct() override; - virtual void EndStruct() override; - virtual void AddItem(const wxString &value , const wxString &name = {} )override; - virtual void AddBool(const bool value , const wxString &name = {} )override; - virtual void AddItem(const double value , const wxString &name = {} )override; - virtual void StartField( const wxString &name = {} )override; - virtual void EndField( ) override; + explicit BriefCommandMessageTarget( CommandMessageTarget & target): CommandMessageTargetDecorator(target) {}; + void StartArray() override; + void EndArray() override; + void StartStruct() override; + void EndStruct() override; + void AddItem(const wxString &value , const wxString &name = {} )override; + void AddBool(bool value , const wxString &name = {} )override; + void AddItem(double value , const wxString &name = {} )override; + void StartField( const wxString &name = {} )override; + void EndField( ) override; }; /// Used to ignore a command's progress updates class NullProgressTarget final : public CommandProgressTarget { public: - virtual ~NullProgressTarget() {} + ~NullProgressTarget() override = default; void Update(double WXUNUSED(completed)) override {} }; @@ -182,12 +182,11 @@ class ProgressToMessageTarget final : public CommandProgressTarget private: std::unique_ptr mTarget; public: - ProgressToMessageTarget(std::unique_ptr &&target) + explicit ProgressToMessageTarget(std::unique_ptr &&target) : mTarget(std::move(target)) { } - virtual ~ProgressToMessageTarget() - { - } + ~ProgressToMessageTarget() override + = default; void Update(double completed) override { mTarget->Update(wxString::Format(wxT("%.2f%%"), completed*100)); @@ -198,7 +197,7 @@ class ProgressToMessageTarget final : public CommandProgressTarget class NullMessageTarget final : public CommandMessageTarget { public: - virtual ~NullMessageTarget() {} + ~NullMessageTarget() override = default; void Update(const wxString &) override {} }; @@ -206,7 +205,7 @@ class NullMessageTarget final : public CommandMessageTarget class SAUCEDACITY_DLL_API MessageBoxTarget final : public CommandMessageTarget { public: - virtual ~MessageBoxTarget() {} + ~MessageBoxTarget() override = default; void Update(const wxString &message) override; }; @@ -216,7 +215,7 @@ class SAUCEDACITY_DLL_API StatusBarTarget final : public CommandMessageTarget private: wxStatusBar &mStatus; public: - StatusBarTarget(wxStatusBar &sb) + explicit StatusBarTarget(wxStatusBar &sb) : mStatus(sb) {} void Update(const wxString &message) override; @@ -236,14 +235,13 @@ class ResponseTarget final : public CommandMessageTarget // Cater for handling long responses quickly. mBuffer.Alloc(40000); } - virtual ~ResponseTarget() - { - } + ~ResponseTarget() override + = default; void Update(const wxString &message) override { mBuffer += message; } - virtual void Flush() override + void Flush() override { mSemaphore.Post(); } @@ -267,9 +265,8 @@ class CombinedMessageTarget final : public CommandMessageTarget wxASSERT(m1); wxASSERT(m2); } - ~CombinedMessageTarget() - { - } + ~CombinedMessageTarget() override + = default; void Update(const wxString &message) override { m1->Update(message); @@ -312,16 +309,15 @@ class CommandOutputTargets /* not final */ // && is not a reference to a reference, but rather a way to allow reference to a temporary // that will be gone or transferred after we have taken it. It's a reference to an xvalue, // or 'expiring value'. - CommandOutputTargets(std::unique_ptr &&pt = TargetFactory::ProgressDefault(), + explicit CommandOutputTargets(std::unique_ptr &&pt = TargetFactory::ProgressDefault(), std::shared_ptr &&st = TargetFactory::MessageDefault(), std::shared_ptr &&et = TargetFactory::MessageDefault()) : mProgressTarget(std::move(pt)), mStatusTarget(st), mErrorTarget(et) { } ~CommandOutputTargets() - { - } + = default; // Lots of forwarding... - void Progress(double completed) + void Progress(double completed) const { if (mProgressTarget) mProgressTarget->Update(completed); @@ -390,7 +386,7 @@ class SAUCEDACITY_DLL_API LispifiedCommandOutputTargets : public CommandOutputTargets { public : - LispifiedCommandOutputTargets( CommandOutputTargets & target ); + explicit LispifiedCommandOutputTargets( CommandOutputTargets & target ); ~LispifiedCommandOutputTargets(); private: CommandOutputTargets * pToRestore; @@ -399,7 +395,7 @@ public : class SAUCEDACITY_DLL_API BriefCommandOutputTargets : public CommandOutputTargets { public : - BriefCommandOutputTargets( CommandOutputTargets & target ); + explicit BriefCommandOutputTargets( CommandOutputTargets & target ); ~BriefCommandOutputTargets(); private: CommandOutputTargets * pToRestore; diff --git a/src/commands/CommandType.cpp b/src/commands/CommandType.cpp index e50d9f0e14..0cd11db255 100644 --- a/src/commands/CommandType.cpp +++ b/src/commands/CommandType.cpp @@ -27,8 +27,7 @@ OldStyleCommandType::OldStyleCommandType() { } OldStyleCommandType::~OldStyleCommandType() -{ -} += default; ComponentInterfaceSymbol OldStyleCommandType::GetSymbol() { diff --git a/src/commands/CommandType.h b/src/commands/CommandType.h index 0526cd2ded..2e4c4da0ea 100644 --- a/src/commands/CommandType.h +++ b/src/commands/CommandType.h @@ -49,7 +49,7 @@ class SAUCEDACITY_DLL_API OldStyleCommandType : public AudacityCommand public: OldStyleCommandType(); - virtual ~OldStyleCommandType(); + ~OldStyleCommandType() override; ComponentInterfaceSymbol GetSymbol() override; CommandSignature &GetSignature(); wxString Describe(); // for debugging only ? diff --git a/src/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp index 3a8f394436..523708da71 100644 --- a/src/commands/CompareAudioCommand.cpp +++ b/src/commands/CompareAudioCommand.cpp @@ -80,13 +80,13 @@ bool CompareAudioCommand::GetSelection(const CommandContext &context, Saucedacit // compare auto trackRange = TrackList::Get( proj ).Selected< const WaveTrack >(); mTrack0 = *trackRange.first; - if (mTrack0 == NULL) + if (mTrack0 == nullptr) { context.Error(wxT("No tracks selected! Select two tracks to compare.")); return false; } mTrack1 = * ++ trackRange.first; - if (mTrack1 == NULL) + if (mTrack1 == nullptr) { context.Error(wxT("Only one track selected! Select two tracks to compare.")); return false; diff --git a/src/commands/CompareAudioCommand.h b/src/commands/CompareAudioCommand.h index bd5dede61d..fe45c661e8 100644 --- a/src/commands/CompareAudioCommand.h +++ b/src/commands/CompareAudioCommand.h @@ -49,7 +49,7 @@ class CompareAudioCommand final : public AudacityCommand bool GetSelection(const CommandContext &context, SaucedacityProject &proj); protected: - double CompareSample(double value1, double value2) /* not override */; + static double CompareSample(double value1, double value2) /* not override */; }; diff --git a/src/commands/DragCommand.cpp b/src/commands/DragCommand.cpp index 986f83a865..e5bba7f7c5 100644 --- a/src/commands/DragCommand.cpp +++ b/src/commands/DragCommand.cpp @@ -34,8 +34,7 @@ const ComponentInterfaceSymbol DragCommand::Symbol namespace{ BuiltinCommandsModule::Registration< DragCommand > reg; } DragCommand::DragCommand() -{ -} += default; enum kCoordTypes { diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index 1e1c79e8e9..4f39e4fd93 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -130,7 +130,7 @@ bool GetInfoCommand::Apply(const CommandContext &context) { CommandContext LispyContext( context.project, - std::make_unique( *context.pOutput.get() ) + std::make_unique( *context.pOutput ) ); return ApplyInner( LispyContext ); } @@ -139,7 +139,7 @@ bool GetInfoCommand::Apply(const CommandContext &context) { CommandContext BriefContext( context.project, - std::make_unique( *context.pOutput.get() ) + std::make_unique( *context.pOutput ) ); return ApplyInner( BriefContext ); } @@ -203,7 +203,7 @@ class ShuttleGuiGetDefinition : public ShuttleGui, public CommandMessageTargetDe { public: ShuttleGuiGetDefinition(wxWindow * pParent,CommandMessageTarget & target ); - virtual ~ShuttleGuiGetDefinition(); + ~ShuttleGuiGetDefinition() override; wxCheckBox * TieCheckBox( const TranslatableString &Prompt, @@ -225,25 +225,25 @@ class ShuttleGuiGetDefinition : public ShuttleGui, public CommandMessageTargetDe wxTextCtrl * TieTextBox( const TranslatableString &Prompt, const StringSetting &Setting, - const int nChars) override; + int nChars) override; wxTextCtrl * TieIntegerTextBox( const TranslatableString & Prompt, const IntSetting &Setting, - const int nChars) override; + int nChars) override; wxTextCtrl * TieNumericTextBox( const TranslatableString & Prompt, const DoubleSetting &Setting, - const int nChars) override; + int nChars) override; wxSlider * TieSlider( const TranslatableString & Prompt, const IntSetting &Setting, - const int max, - const int min = 0) override; + int max, + int min = 0) override; wxSpinCtrl * TieSpinCtrl( const TranslatableString &Prompt, const IntSetting &Setting, - const int max, - const int min) override; + int max, + int min) override; }; ShuttleGuiGetDefinition::ShuttleGuiGetDefinition( @@ -253,9 +253,8 @@ ShuttleGuiGetDefinition::ShuttleGuiGetDefinition( { } -ShuttleGuiGetDefinition::~ShuttleGuiGetDefinition(void) -{ -} +ShuttleGuiGetDefinition::~ShuttleGuiGetDefinition() += default; wxCheckBox * ShuttleGuiGetDefinition::TieCheckBox( const TranslatableString &Prompt, diff --git a/src/commands/HelpCommand.cpp b/src/commands/HelpCommand.cpp index feb4767f6c..6022890b48 100644 --- a/src/commands/HelpCommand.cpp +++ b/src/commands/HelpCommand.cpp @@ -80,7 +80,7 @@ bool HelpCommand::Apply(const CommandContext &context) { CommandContext LispyContext( context.project, - std::make_unique( *context.pOutput.get() ) + std::make_unique( *context.pOutput ) ); return ApplyInner( LispyContext ); } @@ -89,7 +89,7 @@ bool HelpCommand::Apply(const CommandContext &context) { CommandContext BriefContext( context.project, - std::make_unique( *context.pOutput.get() ) + std::make_unique( *context.pOutput ) ); return ApplyInner( BriefContext ); } @@ -97,7 +97,7 @@ bool HelpCommand::Apply(const CommandContext &context) return false; } -bool HelpCommand::ApplyInner(const CommandContext & context){ +bool HelpCommand::ApplyInner(const CommandContext & context) const{ EffectManager & em = EffectManager::Get(); PluginID ID = em.GetEffectByIdentifier( mCommandName ); if( ID.empty() ) diff --git a/src/commands/HelpCommand.h b/src/commands/HelpCommand.h index 62bddb87dc..321d7066ca 100644 --- a/src/commands/HelpCommand.h +++ b/src/commands/HelpCommand.h @@ -35,7 +35,7 @@ class HelpCommand : public AudacityCommand bool DefineParams( ShuttleParams & S ) override; void PopulateOrExchange(ShuttleGui & S) override; bool Apply(const CommandContext & context) override; - bool ApplyInner(const CommandContext & context); + [[nodiscard]] bool ApplyInner(const CommandContext & context) const; // AudacityCommand overrides ManualPageID ManualPage() override {return L"Extra_Menu:_Scriptables_II#help";} diff --git a/src/commands/Keyboard.h b/src/commands/Keyboard.h index 63b291780f..fb64d18d5e 100644 --- a/src/commands/Keyboard.h +++ b/src/commands/Keyboard.h @@ -26,7 +26,7 @@ struct SAUCEDACITY_DLL_API NormalizedKeyString : NormalizedKeyStringBase NormalizedKeyString() = default; explicit NormalizedKeyString( const wxString &key ); - wxString Display(bool usesSpecialChars = false) const; + [[nodiscard]] wxString Display(bool usesSpecialChars = false) const; }; namespace std diff --git a/src/commands/LoadCommands.cpp b/src/commands/LoadCommands.cpp index 44dfd69974..70bff056f9 100644 --- a/src/commands/LoadCommands.cpp +++ b/src/commands/LoadCommands.cpp @@ -72,12 +72,10 @@ DECLARE_BUILTIN_MODULE(BuiltinsCommandBuiltin); /////////////////////////////////////////////////////////////////////////////// BuiltinCommandsModule::BuiltinCommandsModule() -{ -} += default; BuiltinCommandsModule::~BuiltinCommandsModule() -{ -} += default; // ============================================================================ // ComponentInterface implementation @@ -127,8 +125,7 @@ bool BuiltinCommandsModule::Initialize() void BuiltinCommandsModule::Terminate() { // Nothing to do here - return; -} + } EffectFamilySymbol BuiltinCommandsModule::GetOptionalFamilySymbol() { diff --git a/src/commands/LoadCommands.h b/src/commands/LoadCommands.h index 79a6659994..be2176dff9 100644 --- a/src/commands/LoadCommands.h +++ b/src/commands/LoadCommands.h @@ -31,7 +31,7 @@ class SAUCEDACITY_DLL_API BuiltinCommandsModule final : public ModuleInterface { public: BuiltinCommandsModule(); - virtual ~BuiltinCommandsModule(); + ~BuiltinCommandsModule() override; using Factory = std::function< std::unique_ptr () >; diff --git a/src/commands/ResponseQueue.cpp b/src/commands/ResponseQueue.cpp index a906ce77fd..44e41e73ee 100644 --- a/src/commands/ResponseQueue.cpp +++ b/src/commands/ResponseQueue.cpp @@ -24,9 +24,9 @@ ResponseQueue::ResponseQueue() { } ResponseQueue::~ResponseQueue() -{ } += default; -void ResponseQueue::AddResponse(Response response) +void ResponseQueue::AddResponse(const Response& response) { wxMutexLocker locker(mMutex); mResponses.push(response); diff --git a/src/commands/ResponseQueue.h b/src/commands/ResponseQueue.h index 6b5f6ad1a3..e8766260be 100644 --- a/src/commands/ResponseQueue.h +++ b/src/commands/ResponseQueue.h @@ -67,7 +67,7 @@ class ResponseQueue { ResponseQueue(); ~ResponseQueue(); - void AddResponse(Response response); + void AddResponse(const Response& response); Response WaitAndGetResponse(); }; diff --git a/src/commands/ScreenshotCommand.cpp b/src/commands/ScreenshotCommand.cpp index 27c77ee1c8..48a586fe51 100644 --- a/src/commands/ScreenshotCommand.cpp +++ b/src/commands/ScreenshotCommand.cpp @@ -105,7 +105,7 @@ kBackgroundStrings[ ScreenshotCommand::nBackgrounds ] = ScreenshotCommand::ScreenshotCommand() { mbBringToTop=true; - mIgnore=NULL; + mIgnore=nullptr; static std::once_flag flag; std::call_once( flag, []{ @@ -139,18 +139,18 @@ void ScreenshotCommand::PopulateOrExchange(ShuttleGui & S) } // static member variable. -void (*ScreenshotCommand::mIdleHandler)(wxIdleEvent& event) = NULL; +void (*ScreenshotCommand::mIdleHandler)(wxIdleEvent& event) = nullptr; static SaucedacityProject *pIdleHandlerProject = nullptr; // This static variable is used to get from an idle event to the screenshot // command that caused the idle event interception to be set up. -ScreenshotCommand * ScreenshotCommand::mpShooter=NULL; +ScreenshotCommand * ScreenshotCommand::mpShooter=nullptr; // IdleHandler is expected to be called from EVT_IDLE when a dialog has been // fully created. Usually the dialog will have been created by invoking // an effects gui. void IdleHandler(wxIdleEvent& event){ event.Skip(); - wxWindow * pWin = dynamic_cast(event.GetEventObject()); + auto * pWin = dynamic_cast(event.GetEventObject()); wxASSERT( pWin ); pWin->Unbind(wxEVT_IDLE, IdleHandler); CommandContext context( *pIdleHandlerProject ); @@ -167,7 +167,7 @@ void ScreenshotCommand::SetIdleHandler( SaucedacityProject &project ) wxTopLevelWindow *ScreenshotCommand::GetFrontWindow(SaucedacityProject *project) { - wxWindow *front = NULL; + wxWindow *front = nullptr; wxWindow *proj = wxGetTopLevelParent( ProjectWindow::Find( project ) ); for (auto & win : wxTopLevelWindows) @@ -345,10 +345,10 @@ bool ScreenshotCommand::CaptureDock( // Handed a dialog, which it is given the option to capture. bool ScreenshotCommand::MayCapture( wxDialog * pDlg ) { - if( mIdleHandler == NULL ) + if( mIdleHandler == nullptr ) return false; pDlg->Bind( wxEVT_IDLE, mIdleHandler ); - mIdleHandler = NULL; + mIdleHandler = nullptr; pDlg->ShowModal(); return true; } @@ -357,7 +357,7 @@ void ScreenshotCommand::CaptureWindowOnIdle( const CommandContext & context, wxWindow * pWin ) { - wxDialog * pDlg = dynamic_cast(pWin); + auto * pDlg = dynamic_cast(pWin); if( !pDlg ){ wxLogDebug("Event from bogus dlg" ); return; diff --git a/src/commands/ScreenshotCommand.h b/src/commands/ScreenshotCommand.h index 93c30ab651..4f35140a2e 100644 --- a/src/commands/ScreenshotCommand.h +++ b/src/commands/ScreenshotCommand.h @@ -114,9 +114,9 @@ class SAUCEDACITY_DLL_API ScreenshotCommand : public AudacityCommand wxString mFileName; int mCaptureMode; - wxString MakeFileName(const wxString &path, const wxString &basename); + static wxString MakeFileName(const wxString &path, const wxString &basename); - wxRect GetBackgroundRect(); + static wxRect GetBackgroundRect(); bool CaptureToolbar(const CommandContext & Context, ToolManager *man, int type, const wxString &name); bool CaptureDock(const CommandContext & Context, wxWindow *win, const wxString &fileName); @@ -129,13 +129,13 @@ class SAUCEDACITY_DLL_API ScreenshotCommand : public AudacityCommand const wxString &basename, wxWindow *window, wxRect rect, bool bg = false); - wxRect GetWindowRect(wxTopLevelWindow *w); + static wxRect GetWindowRect(wxTopLevelWindow *w); wxRect GetFullWindowRect(wxTopLevelWindow *w); - wxRect GetScreenRect(); - wxRect GetPanelRect(TrackPanel * panel); - wxRect GetRulerRect(AdornedRulerPanel *ruler); - wxRect GetTracksRect(TrackPanel * panel); - wxRect GetTrackRect( SaucedacityProject * pProj, TrackPanel * panel,int n); + static wxRect GetScreenRect(); + static wxRect GetPanelRect(TrackPanel * panel); + static wxRect GetRulerRect(AdornedRulerPanel *ruler); + static wxRect GetTracksRect(TrackPanel * panel); + static wxRect GetTrackRect( SaucedacityProject * pProj, TrackPanel * panel,int n); wxString WindowFileName(SaucedacityProject * proj, wxTopLevelWindow *w); public: diff --git a/src/commands/ScriptCommandRelay.cpp b/src/commands/ScriptCommandRelay.cpp index fae084e930..d5667acef1 100644 --- a/src/commands/ScriptCommandRelay.cpp +++ b/src/commands/ScriptCommandRelay.cpp @@ -76,7 +76,7 @@ static int ExecFromMain(wxString *pIn, wxString *pOut) /// Starts the script server void ScriptCommandRelay::StartScriptServer(tpRegScriptServerFunc scriptFn) { - wxASSERT(scriptFn != NULL); + wxASSERT(scriptFn != nullptr); auto server = [](tpRegScriptServerFunc function) { diff --git a/src/commands/SetClipCommand.cpp b/src/commands/SetClipCommand.cpp index 46f4574674..d05c887494 100644 --- a/src/commands/SetClipCommand.cpp +++ b/src/commands/SetClipCommand.cpp @@ -31,8 +31,7 @@ const ComponentInterfaceSymbol SetClipCommand::Symbol namespace{ BuiltinCommandsModule::Registration< SetClipCommand > reg; } SetClipCommand::SetClipCommand() -{ -} += default; enum kColours { diff --git a/src/commands/SetEnvelopeCommand.cpp b/src/commands/SetEnvelopeCommand.cpp index f9ad5c100c..1269674f7a 100644 --- a/src/commands/SetEnvelopeCommand.cpp +++ b/src/commands/SetEnvelopeCommand.cpp @@ -36,8 +36,7 @@ namespace{ BuiltinCommandsModule::Registration< SetEnvelopeCommand > reg; } SetEnvelopeCommand::SetEnvelopeCommand() -{ -} += default; bool SetEnvelopeCommand::DefineParams( ShuttleParams & S ){ diff --git a/src/commands/SetLabelCommand.cpp b/src/commands/SetLabelCommand.cpp index 602da99798..8e5777b6c4 100644 --- a/src/commands/SetLabelCommand.cpp +++ b/src/commands/SetLabelCommand.cpp @@ -35,8 +35,7 @@ const ComponentInterfaceSymbol SetLabelCommand::Symbol namespace{ BuiltinCommandsModule::Registration< SetLabelCommand > reg; } SetLabelCommand::SetLabelCommand() -{ -} += default; bool SetLabelCommand::DefineParams( ShuttleParams & S ){ diff --git a/src/commands/SetProjectCommand.cpp b/src/commands/SetProjectCommand.cpp index 67e3960313..f488d05b91 100644 --- a/src/commands/SetProjectCommand.cpp +++ b/src/commands/SetProjectCommand.cpp @@ -36,8 +36,7 @@ const ComponentInterfaceSymbol SetProjectCommand::Symbol namespace{ BuiltinCommandsModule::Registration< SetProjectCommand > reg; } SetProjectCommand::SetProjectCommand() -{ -} += default; bool SetProjectCommand::DefineParams( ShuttleParams & S ){ diff --git a/src/commands/SetTrackInfoCommand.h b/src/commands/SetTrackInfoCommand.h index 9e551c4c63..6778880e16 100644 --- a/src/commands/SetTrackInfoCommand.h +++ b/src/commands/SetTrackInfoCommand.h @@ -28,8 +28,8 @@ class SetTrackBase : public AudacityCommand SetTrackBase(); bool Apply(const CommandContext & context) override; virtual bool ApplyInner( const CommandContext &context, Track *t ); - virtual bool DefineParams( ShuttleParams & S ) override; - virtual void PopulateOrExchange(ShuttleGui & S) override; + bool DefineParams( ShuttleParams & S ) override; + void PopulateOrExchange(ShuttleGui & S) override; int mTrackIndex; int mChannelIndex; diff --git a/src/commands/Validators.h b/src/commands/Validators.h index cc46a785bf..67746c371b 100644 --- a/src/commands/Validators.h +++ b/src/commands/Validators.h @@ -55,8 +55,8 @@ class Validator /* not final */ wxVariant mConverted; public: - Validator() {}; - virtual ~Validator() {}; + Validator() = default;; + virtual ~Validator() = default;; void SetConverted (const wxVariant &v) { mConverted = v; @@ -75,20 +75,20 @@ class Validator /* not final */ /// Return a description (for error messages) /// should be of the form 'v must be $description' - virtual wxString GetDescription() const + [[nodiscard]] virtual wxString GetDescription() const { return wxT("any value"); } /// This MUST be overridden, to avoid slicing! using Holder = std::unique_ptr; - virtual Holder GetClone() const = 0; + [[nodiscard]] virtual Holder GetClone() const = 0; }; class DefaultValidator final : public Validator { public: - virtual Holder GetClone() const + [[nodiscard]] Holder GetClone() const override { return std::make_unique(*this); } @@ -113,7 +113,7 @@ class OptionValidator final : public Validator SetConverted(v); return make_iterator_range( mOptions ).contains( v.GetString() ); } - wxString GetDescription() const override + [[nodiscard]] wxString GetDescription() const override { wxString desc = wxT("one of: "); int optionCount = mOptions.size(); @@ -125,7 +125,7 @@ class OptionValidator final : public Validator desc += mOptions[optionCount-1]; return desc; } - Holder GetClone() const override + [[nodiscard]] Holder GetClone() const override { auto v = std::make_unique(); v->mOptions = mOptions; @@ -144,11 +144,11 @@ class BoolValidator final : public Validator SetConverted(val); return GetConverted().IsType(wxT("bool")); } - wxString GetDescription() const override + [[nodiscard]] wxString GetDescription() const override { return wxT("true/false or 1/0 or yes/no"); } - Holder GetClone() const override + [[nodiscard]] Holder GetClone() const override { return std::make_unique(); } @@ -157,22 +157,22 @@ class BoolValidator final : public Validator class BoolArrayValidator final : public Validator { public: - virtual bool Validate(const wxVariant &v) override + bool Validate(const wxVariant &v) override { wxString val; // Validate a string of chars containing only 0, 1 and x. if (!v.Convert(&val)) return false; SetConverted(val); - for(size_t i=0; i != val.length(); i++) - if( val[i] != '0' && val[i] != '1' && val[i] != 'x' && val[i] != 'X') + for(auto && i : val) + if( i != '0' && i != '1' && i != 'x' && i != 'X') return false; return true; } - wxString GetDescription() const override + [[nodiscard]] wxString GetDescription() const override { return wxT("0X101XX101...etc. where 0=false, 1=true, and X=don't care. Numbering starts at leftmost = track 0"); } - Holder GetClone() const override + [[nodiscard]] Holder GetClone() const override { return std::make_unique(); } @@ -188,11 +188,11 @@ class DoubleValidator final : public Validator SetConverted(val); return GetConverted().IsType(wxT("double")); } - wxString GetDescription() const override + [[nodiscard]] wxString GetDescription() const override { return wxT("a floating-point number"); } - Holder GetClone() const override + [[nodiscard]] Holder GetClone() const override { return std::make_unique(); } @@ -213,11 +213,11 @@ class RangeValidator final : public Validator SetConverted(val); return ((mLower < val) && (val < mUpper)); } - wxString GetDescription() const override + [[nodiscard]] wxString GetDescription() const override { return wxString::Format(wxT("between %f and %f"), mLower, mUpper); } - Holder GetClone() const override + [[nodiscard]] Holder GetClone() const override { return std::make_unique(mLower, mUpper); } @@ -234,11 +234,11 @@ class IntValidator final : public Validator if (!GetConverted().IsType(wxT("double"))) return false; return ((long)val == val); } - wxString GetDescription() const override + [[nodiscard]] wxString GetDescription() const override { return wxT("an integer"); } - Holder GetClone() const override + [[nodiscard]] Holder GetClone() const override { return std::make_unique(); } diff --git a/src/effects/Amplify.cpp b/src/effects/Amplify.cpp index ce958b0755..ddf8ca4e98 100644 --- a/src/effects/Amplify.cpp +++ b/src/effects/Amplify.cpp @@ -83,8 +83,7 @@ EffectAmplify::EffectAmplify() } EffectAmplify::~EffectAmplify() -{ -} += default; // ComponentInterface implementation @@ -286,8 +285,6 @@ void EffectAmplify::PopulateOrExchange(ShuttleGui & S) S.EndHorizontalLay(); } S.EndVerticalLay(); - - return; } bool EffectAmplify::TransferDataToWindow() diff --git a/src/effects/Amplify.h b/src/effects/Amplify.h index 896d7d5699..df154ff739 100644 --- a/src/effects/Amplify.h +++ b/src/effects/Amplify.h @@ -29,7 +29,7 @@ class EffectAmplify final : public Effect static const ComponentInterfaceSymbol Symbol; EffectAmplify(); - virtual ~EffectAmplify(); + ~EffectAmplify() override; // ComponentInterface implementation diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index ca5741898e..a60f91ba77 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -99,14 +99,13 @@ EffectAutoDuck::EffectAutoDuck() SetLinearEffectFlag(true); - mControlTrack = NULL; + mControlTrack = nullptr; - mPanel = NULL; + mPanel = nullptr; } EffectAutoDuck::~EffectAutoDuck() -{ -} += default; // ComponentInterface implementation @@ -215,10 +214,10 @@ bool EffectAutoDuck::Startup() bool EffectAutoDuck::Init() { - mControlTrack = NULL; + mControlTrack = nullptr; bool lastWasSelectedWaveTrack = false; - const WaveTrack *controlTrackCandidate = NULL; + const WaveTrack *controlTrackCandidate = nullptr; for (auto t : inputTracks()->Any()) { @@ -268,7 +267,7 @@ bool EffectAutoDuck::Init() void EffectAutoDuck::End() { - mControlTrack = NULL; + mControlTrack = nullptr; } bool EffectAutoDuck::Process() @@ -364,9 +363,9 @@ bool EffectAutoDuck::Process() double duckRegionEnd = mControlTrack->LongSamplesToTime(i - curSamplesPause); - regions.push_back(AutoDuckRegion( + regions.emplace_back( duckRegionStart - mOuterFadeDownLen, - duckRegionEnd + mOuterFadeUpLen)); + duckRegionEnd + mOuterFadeUpLen); inDuckRegion = false; } @@ -391,9 +390,9 @@ bool EffectAutoDuck::Process() { double duckRegionEnd = mControlTrack->LongSamplesToTime(end - curSamplesPause); - regions.push_back(AutoDuckRegion( + regions.emplace_back( duckRegionStart - mOuterFadeDownLen, - duckRegionEnd + mOuterFadeUpLen)); + duckRegionEnd + mOuterFadeUpLen); } } @@ -405,9 +404,8 @@ bool EffectAutoDuck::Process() for( auto iterTrack : mOutputTracks->Selected< WaveTrack >() ) { - for (size_t i = 0; i < regions.size(); i++) + for (auto & region : regions) { - const AutoDuckRegion& region = regions[i]; if (ApplyDuckFade(trackNum, iterTrack, region.t0, region.t1)) { cancel = true; @@ -504,8 +502,6 @@ void EffectAutoDuck::PopulateOrExchange(ShuttleGui & S) } S.EndVerticalLay(); - - return; } bool EffectAutoDuck::TransferDataToWindow() @@ -644,7 +640,7 @@ EffectAutoDuckPanel::EffectAutoDuckPanel( mParent = parent; mEffect = effect; mCurrentControlPoint = none; - mBackgroundBitmap = NULL; + mBackgroundBitmap = nullptr; ResetControlPoints(); } @@ -759,7 +755,7 @@ void EffectAutoDuckPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) for (int i = 0; i < AUTO_DUCK_PANEL_NUM_CONTROL_POINTS; i++) { - EControlPoint cp = (EControlPoint)i; + auto cp = (EControlPoint)i; int digits; float value; diff --git a/src/effects/AutoDuck.h b/src/effects/AutoDuck.h index c13bd065a5..c3966de885 100644 --- a/src/effects/AutoDuck.h +++ b/src/effects/AutoDuck.h @@ -26,7 +26,7 @@ class EffectAutoDuck final : public Effect static const ComponentInterfaceSymbol Symbol; EffectAutoDuck(); - virtual ~EffectAutoDuck(); + ~EffectAutoDuck() override; // ComponentInterface implementation @@ -91,7 +91,7 @@ class EffectAutoDuckPanel final : public wxPanelWrapper public: EffectAutoDuckPanel( wxWindow *parent, wxWindowID winid, EffectAutoDuck *effect); - virtual ~EffectAutoDuckPanel(); + ~EffectAutoDuckPanel() override; private: enum EControlPoint @@ -104,9 +104,9 @@ class EffectAutoDuckPanel final : public wxPanelWrapper none = 99, }; - bool AcceptsFocus() const override { return false; } + [[nodiscard]] bool AcceptsFocus() const override { return false; } // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581 - bool AcceptsFocusFromKeyboard() const override { return false; } + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override { return false; } void OnPaint(wxPaintEvent & evt); diff --git a/src/effects/BassTreble.cpp b/src/effects/BassTreble.cpp index a16c26d0ca..9900a9d7ce 100644 --- a/src/effects/BassTreble.cpp +++ b/src/effects/BassTreble.cpp @@ -85,8 +85,7 @@ EffectBassTreble::EffectBassTreble() } EffectBassTreble::~EffectBassTreble() -{ -} += default; // ComponentInterface implementation @@ -317,7 +316,7 @@ bool EffectBassTreble::TransferDataFromWindow() // EffectBassTreble implementation -void EffectBassTreble::InstanceInit(EffectBassTrebleState & data, float sampleRate) +void EffectBassTreble::InstanceInit(EffectBassTrebleState & data, float sampleRate) const { data.samplerate = sampleRate; data.slope = 0.4f; // same slope for both filters diff --git a/src/effects/BassTreble.h b/src/effects/BassTreble.h index b25243fc16..0726dccc91 100644 --- a/src/effects/BassTreble.h +++ b/src/effects/BassTreble.h @@ -39,7 +39,7 @@ class EffectBassTreble final : public Effect static const ComponentInterfaceSymbol Symbol; EffectBassTreble(); - virtual ~EffectBassTreble(); + ~EffectBassTreble() override; // ComponentInterface implementation @@ -56,7 +56,7 @@ class EffectBassTreble final : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -81,12 +81,12 @@ class EffectBassTreble final : public Effect private: // EffectBassTreble implementation - void InstanceInit(EffectBassTrebleState & data, float sampleRate); + void InstanceInit(EffectBassTrebleState & data, float sampleRate) const; size_t InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, size_t blockLen); - void Coefficients(double hz, double slope, double gain, double samplerate, int type, + static void Coefficients(double hz, double slope, double gain, double samplerate, int type, double& a0, double& a1, double& a2, double& b0, double& b1, double& b2); - float DoFilter(EffectBassTrebleState & data, float in); + static float DoFilter(EffectBassTrebleState & data, float in); void OnBassText(wxCommandEvent & evt); void OnTrebleText(wxCommandEvent & evt); diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index d6b381d6ec..bac6070ef2 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -120,25 +120,24 @@ EffectChangePitch::EffectChangePitch() // NULL out these control members because there are some cases where the // event table handlers get called during this method, and those handlers that // can cause trouble check for NULL. - m_pChoice_FromPitch = NULL; - m_pSpin_FromOctave = NULL; - m_pChoice_ToPitch = NULL; - m_pSpin_ToOctave = NULL; + m_pChoice_FromPitch = nullptr; + m_pSpin_FromOctave = nullptr; + m_pChoice_ToPitch = nullptr; + m_pSpin_ToOctave = nullptr; - m_pTextCtrl_SemitonesChange = NULL; + m_pTextCtrl_SemitonesChange = nullptr; - m_pTextCtrl_FromFrequency = NULL; - m_pTextCtrl_ToFrequency = NULL; + m_pTextCtrl_FromFrequency = nullptr; + m_pTextCtrl_ToFrequency = nullptr; - m_pTextCtrl_PercentChange = NULL; - m_pSlider_PercentChange = NULL; + m_pTextCtrl_PercentChange = nullptr; + m_pSlider_PercentChange = nullptr; SetLinearEffectFlag(true); } EffectChangePitch::~EffectChangePitch() -{ -} += default; // ComponentInterface implementation @@ -385,7 +384,6 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S) } S.EndVerticalLay(); - return; } bool EffectChangePitch::TransferDataToWindow() diff --git a/src/effects/ChangePitch.h b/src/effects/ChangePitch.h index 71364a4a90..f1c60c2c7e 100644 --- a/src/effects/ChangePitch.h +++ b/src/effects/ChangePitch.h @@ -40,7 +40,7 @@ class EffectChangePitch final : public EffectSoundTouch static const ComponentInterfaceSymbol Symbol; EffectChangePitch(); - virtual ~EffectChangePitch(); + ~EffectChangePitch() override; // ComponentInterface implementation diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index 7179c38f98..55173f4f16 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -110,8 +110,7 @@ EffectChangeSpeed::EffectChangeSpeed() } EffectChangeSpeed::~EffectChangeSpeed() -{ -} += default; // ComponentInterface implementation @@ -483,7 +482,7 @@ bool EffectChangeSpeed::ProcessLabelTrack(LabelTrack *lt) bool EffectChangeSpeed::ProcessOne(WaveTrack * track, sampleCount start, sampleCount end) { - if (track == NULL) + if (track == nullptr) return false; // initialization, per examples of Mixer::Mixer and @@ -567,14 +566,14 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track, if (st >= mCurT0 || et < mCurT1) { if (mCurT0 < st && clip == front) { - gaps.push_back(std::make_pair(mCurT0, st)); + gaps.emplace_back(mCurT0, st); } else if (last < st && mCurT0 <= last ) { - gaps.push_back(std::make_pair(last, st)); + gaps.emplace_back(last, st); } if (et < mCurT1 && clip == back) { - gaps.push_back(std::make_pair(et, mCurT1)); + gaps.emplace_back(et, mCurT1); } } last = et; diff --git a/src/effects/ChangeSpeed.h b/src/effects/ChangeSpeed.h index 33b0d29228..b0238f4f10 100644 --- a/src/effects/ChangeSpeed.h +++ b/src/effects/ChangeSpeed.h @@ -27,7 +27,7 @@ class EffectChangeSpeed final : public Effect static const ComponentInterfaceSymbol Symbol; EffectChangeSpeed(); - virtual ~EffectChangeSpeed(); + ~EffectChangeSpeed() override; // ComponentInterface implementation diff --git a/src/effects/ChangeTempo.cpp b/src/effects/ChangeTempo.cpp index f93c8d99aa..ba27efbfb0 100644 --- a/src/effects/ChangeTempo.cpp +++ b/src/effects/ChangeTempo.cpp @@ -109,8 +109,7 @@ EffectChangeTempo::EffectChangeTempo() } EffectChangeTempo::~EffectChangeTempo() -{ -} += default; // ComponentInterface implementation @@ -326,8 +325,6 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S) } S.EndVerticalLay(); - - return; } bool EffectChangeTempo::TransferDataToWindow() diff --git a/src/effects/ChangeTempo.h b/src/effects/ChangeTempo.h index 777da2b9c9..66c23f6f6e 100644 --- a/src/effects/ChangeTempo.h +++ b/src/effects/ChangeTempo.h @@ -34,7 +34,7 @@ class EffectChangeTempo final : public EffectSoundTouch static const ComponentInterfaceSymbol Symbol; EffectChangeTempo(); - virtual ~EffectChangeTempo(); + ~EffectChangeTempo() override; // ComponentInterface implementation diff --git a/src/effects/ClickRemoval.cpp b/src/effects/ClickRemoval.cpp index 8e7410b4c7..76c7e7ed52 100644 --- a/src/effects/ClickRemoval.cpp +++ b/src/effects/ClickRemoval.cpp @@ -80,8 +80,7 @@ EffectClickRemoval::EffectClickRemoval() } EffectClickRemoval::~EffectClickRemoval() -{ -} += default; // ComponentInterface implementation @@ -378,8 +377,6 @@ void EffectClickRemoval::PopulateOrExchange(ShuttleGui & S) .AddSlider( {}, mClickWidth, MAX_Width, MIN_Width); } S.EndMultiColumn(); - - return; } bool EffectClickRemoval::TransferDataToWindow() diff --git a/src/effects/ClickRemoval.h b/src/effects/ClickRemoval.h index 68b68fe7ed..6b4f850e38 100644 --- a/src/effects/ClickRemoval.h +++ b/src/effects/ClickRemoval.h @@ -29,7 +29,7 @@ class EffectClickRemoval final : public Effect static const ComponentInterfaceSymbol Symbol; EffectClickRemoval(); - virtual ~EffectClickRemoval(); + ~EffectClickRemoval() override; // ComponentInterface implementation diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index 7a1cceaa27..153f5f87e5 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -102,8 +102,7 @@ EffectCompressor::EffectCompressor() } EffectCompressor::~EffectCompressor() -{ -} += default; // ComponentInterface implementation @@ -463,7 +462,7 @@ bool EffectCompressor::TwoBufferProcessPass1 // This makes sure that the initial value is well-chosen // buffer1 == NULL on the first and only the first call - if (buffer1 == NULL) { + if (buffer1 == nullptr) { // Initialize the mLastLevel to the peak level in the first buffer // This avoids problems with large spike events near the beginning of the track mLastLevel = mThreshold; @@ -474,11 +473,11 @@ bool EffectCompressor::TwoBufferProcessPass1 } // buffer2 is NULL on the last and only the last call - if(buffer2 != NULL) { + if(buffer2 != nullptr) { Follow(buffer2, mFollow2.get(), len2, mFollow1.get(), len1); } - if(buffer1 != NULL) { + if(buffer1 != nullptr) { for (size_t i = 0; i < len1; i++) { buffer1[i] = DoCompression(buffer1[i], mFollow1[i]); } @@ -610,7 +609,7 @@ void EffectCompressor::Follow(float *buffer, float *env, size_t len, float *prev last = env[i]; } - if((previous != NULL) && (previous_len > 0)) { + if((previous != nullptr) && (previous_len > 0)) { // If the previous envelope was passed, propagate the rise back until we intersect for(size_t i = previous_len; i--;) { last *= mAttackInverseFactor; @@ -693,8 +692,6 @@ void EffectCompressor::UpdateUI() mDecayText->SetName(mDecayText->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) mPanel->Refresh(false); - - return; } //---------------------------------------------------------------------------- @@ -736,7 +733,7 @@ void EffectCompressorPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) vRuler.SetRange(0, -rangeDB); vRuler.SetFormat(Ruler::LinearDBFormat); vRuler.SetUnits(XO("dB")); - vRuler.GetMaxSize(&w, NULL); + vRuler.GetMaxSize(&w, nullptr); Ruler hRuler; hRuler.SetBounds(0, 0, width, height); @@ -745,7 +742,7 @@ void EffectCompressorPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) hRuler.SetFormat(Ruler::LinearDBFormat); hRuler.SetUnits(XO("dB")); hRuler.SetFlip(true); - hRuler.GetMaxSize(NULL, &h); + hRuler.GetMaxSize(nullptr, &h); vRuler.SetBounds(0, 0, w, height - h); hRuler.SetBounds(w, height - h, width, height); diff --git a/src/effects/Compressor.h b/src/effects/Compressor.h index a01389a20c..a5f5b6a30d 100644 --- a/src/effects/Compressor.h +++ b/src/effects/Compressor.h @@ -25,7 +25,7 @@ class EffectCompressor final : public EffectTwoPassSimpleMono static const ComponentInterfaceSymbol Symbol; EffectCompressor(); - virtual ~EffectCompressor(); + ~EffectCompressor() override; // ComponentInterface implementation diff --git a/src/effects/Compressor2.cpp b/src/effects/Compressor2.cpp index c81caea654..44af56274e 100644 --- a/src/effects/Compressor2.cpp +++ b/src/effects/Compressor2.cpp @@ -16,7 +16,8 @@ #include "Compressor2.h" -#include +#include +#include #include #include @@ -556,10 +557,10 @@ void PipelineBuffer::free() EffectCompressor2::EffectCompressor2() : mIgnoreGuiEvents(false), - mAlgorithmCtrl(0), - mPreprocCtrl(0), - mAttackTimeCtrl(0), - mLookaheadTimeCtrl(0) + mAlgorithmCtrl(nullptr), + mPreprocCtrl(nullptr), + mAttackTimeCtrl(nullptr), + mLookaheadTimeCtrl(nullptr) { mAlgorithm = DEF_Algorithm; mCompressBy = DEF_CompressBy; @@ -578,8 +579,7 @@ EffectCompressor2::EffectCompressor2() } EffectCompressor2::~EffectCompressor2() -{ -} += default; // ComponentInterface implementation @@ -764,8 +764,8 @@ RegistryPaths EffectCompressor2::GetFactoryPresets() { RegistryPaths names; - for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) - names.push_back( FactoryPresets[i].name.Translation() ); + for (const auto & FactoryPreset : FactoryPresets) + names.push_back( FactoryPreset.name.Translation() ); return names; } @@ -893,15 +893,15 @@ void EffectCompressor2::PopulateOrExchange(ShuttleGui & S) PlotData* plot; S.StartVerticalLay(); - S.AddVariableText(XO("Envelope dependent gain"), 0, + S.AddVariableText(XO("Envelope dependent gain"), false, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); mGainPlot = S.MinSize( { 400, 200 } ) .AddPlot({}, -60, 0, -60, 0, XO("dB"), XO("dB"), Ruler::LinearDBFormat, Ruler::LinearDBFormat); plot = mGainPlot->GetPlotData(0); - plot->pen = std::unique_ptr( - safenew wxPen(AColor::WideEnvelopePen)); + plot->pen = std::make_unique( + AColor::WideEnvelopePen); plot->xdata.resize(61); plot->ydata.resize(61); std::iota(plot->xdata.begin(), plot->xdata.end(), -60); @@ -909,7 +909,7 @@ void EffectCompressor2::PopulateOrExchange(ShuttleGui & S) S.EndVerticalLay(); S.StartVerticalLay(); - S.AddVariableText(XO("Compressor step response"), 0, + S.AddVariableText(XO("Compressor step response"), false, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); mResponsePlot = S.MinSize( { 400, 200 } ) .AddPlot({}, 0, 5, -0.2, 1.2, XO("s"), XO(""), @@ -917,15 +917,15 @@ void EffectCompressor2::PopulateOrExchange(ShuttleGui & S) mResponsePlot->SetName(XO("Compressor step response plot")); plot = mResponsePlot->GetPlotData(0); - plot->pen = std::unique_ptr( - safenew wxPen(AColor::WideEnvelopePen)); + plot->pen = std::make_unique( + AColor::WideEnvelopePen); plot->xdata = {0, RESPONSE_PLOT_STEP_START, RESPONSE_PLOT_STEP_START, RESPONSE_PLOT_STEP_STOP, RESPONSE_PLOT_STEP_STOP, 5}; plot->ydata = {0.1, 0.1, 1, 1, 0.1, 0.1}; plot = mResponsePlot->GetPlotData(1); - plot->pen = std::unique_ptr( - safenew wxPen(AColor::WideEnvelopePen)); + plot->pen = std::make_unique( + AColor::WideEnvelopePen); plot->pen->SetColour(wxColor( 230,80,80 )); // Same color as TrackArtist RMS red. plot->pen->SetWidth(2); plot->xdata.resize(RESPONSE_PLOT_SAMPLES+1); @@ -1131,7 +1131,7 @@ bool EffectCompressor2::TransferDataFromWindow() // EffectCompressor2 implementation -double EffectCompressor2::CompressorGain(double env) +double EffectCompressor2::CompressorGain(double env) const { double kneeCond; double envDB = LINEAR_TO_DB(env); @@ -1176,7 +1176,7 @@ std::unique_ptr EffectCompressor2::InitPreprocessor( } std::unique_ptr EffectCompressor2::InitEnvelope( - double rate, size_t blockSize, bool preview) + double rate, size_t blockSize, bool preview) const { if(mAlgorithm == kExpFit) return std::unique_ptr(safenew @@ -1198,12 +1198,12 @@ size_t EffectCompressor2::CalcBufferSize(double sampleRate) return capacity; } -size_t EffectCompressor2::CalcLookaheadLength(double rate) +size_t EffectCompressor2::CalcLookaheadLength(double rate) const { return std::max(0, int(round(mLookaheadTime * rate))); } -size_t EffectCompressor2::CalcWindowLength(double rate) +size_t EffectCompressor2::CalcWindowLength(double rate) const { return std::max(1, int(round((mLookaheadTime + mLookbehindTime) * rate))); } @@ -1231,8 +1231,8 @@ void EffectCompressor2::AllocPipeline() // be shorter than the length of the track being processed. stereoTrackFound = stereoTrackFound && !mStereoInd; capacity = CalcBufferSize(maxSampleRate); - for(size_t i = 0; i < PIPELINE_DEPTH; ++i) - mPipeline[i].init(capacity, stereoTrackFound); + for(auto & i : mPipeline) + i.init(capacity, stereoTrackFound); } void EffectCompressor2::AllocRealtimePipeline() @@ -1244,17 +1244,17 @@ void EffectCompressor2::AllocRealtimePipeline() size_t riseTime = round(5.0 * (0.1 + mAttackTime)) * mSampleRate; blockSize = std::max(blockSize, riseTime); } - for(size_t i = 0; i < PIPELINE_DEPTH; ++i) + for(auto & i : mPipeline) { - mPipeline[i].init(blockSize, true); - mPipeline[i].size = blockSize; + i.init(blockSize, true); + i.size = blockSize; } } void EffectCompressor2::FreePipeline() { - for(size_t i = 0; i < PIPELINE_DEPTH; ++i) - mPipeline[i].free(); + for(auto & i : mPipeline) + i.free(); } void EffectCompressor2::SwapPipeline() @@ -1314,7 +1314,7 @@ void EffectCompressor2::SwapPipeline() /// ProcessOne() takes a track, transforms it to bunch of buffer-blocks, /// and executes ProcessData, on it... -bool EffectCompressor2::ProcessOne(TrackIterRange range) +bool EffectCompressor2::ProcessOne(const TrackIterRange& range) { WaveTrack* track = *range.begin(); @@ -1429,7 +1429,7 @@ bool EffectCompressor2::ProcessOne(TrackIterRange range) } bool EffectCompressor2::LoadPipeline( - TrackIterRange range, size_t len) + const TrackIterRange& range, size_t len) { sampleCount read_size = -1; sampleCount last_read_size = -1; @@ -1586,9 +1586,9 @@ inline void EffectCompressor2::CompressSample(float env, size_t wp) bool EffectCompressor2::PipelineHasData() { - for(size_t i = 0; i < PIPELINE_DEPTH; ++i) + for(auto & i : mPipeline) { - if(mPipeline[i].size != 0) + if(i.size != 0) return true; } return false; @@ -1636,7 +1636,7 @@ void EffectCompressor2::DrainPipeline() } } -void EffectCompressor2::StorePipeline(TrackIterRange range) +void EffectCompressor2::StorePipeline(const TrackIterRange& range) { #ifdef DEBUG_COMPRESSOR2_TRACE std::cerr << "StoreBlock at: " << mPipeline[0].trackPos.as_size_t() << @@ -1674,7 +1674,7 @@ void EffectCompressor2::UpdateUI() { UpdateCompressorPlot(); UpdateResponsePlot(); - if(mEnvelope.get() != nullptr) + if(mEnvelope != nullptr) UpdateRealtimeParams(); } diff --git a/src/effects/Compressor2.h b/src/effects/Compressor2.h index c4c1159c93..da73e25d91 100644 --- a/src/effects/Compressor2.h +++ b/src/effects/Compressor2.h @@ -38,10 +38,10 @@ class SlidingRmsPreprocessor : public SamplePreprocessor public: SlidingRmsPreprocessor(size_t windowSize, float gain = 2.0); - virtual float ProcessSample(float value); - virtual float ProcessSample(float valueL, float valueR); - virtual void Reset(float value = 0); - virtual void SetWindowSize(size_t windowSize); + float ProcessSample(float value) override; + float ProcessSample(float valueL, float valueR) override; + void Reset(float value = 0) override; + void SetWindowSize(size_t windowSize) override; static const size_t REFRESH_WINDOW_EVERY = 1048576; // 1 MB @@ -61,10 +61,10 @@ class SlidingMaxPreprocessor : public SamplePreprocessor public: SlidingMaxPreprocessor(size_t windowSize); - virtual float ProcessSample(float value); - virtual float ProcessSample(float valueL, float valueR); - virtual void Reset(float value = 0); - virtual void SetWindowSize(size_t windowSize); + float ProcessSample(float value) override; + float ProcessSample(float valueL, float valueR) override; + void Reset(float value = 0) override; + void SetWindowSize(size_t windowSize) override; private: std::vector mWindow; @@ -80,12 +80,12 @@ class EnvelopeDetector EnvelopeDetector(size_t buffer_size); float ProcessSample(float value); - size_t GetBlockSize() const; - const float* GetBuffer(int idx) const; + [[nodiscard]] size_t GetBlockSize() const; + [[nodiscard]] const float* GetBuffer(int idx) const; virtual void CalcInitialCondition(float value); - inline float InitialCondition() const { return mInitialCondition; } - inline size_t InitialConditionSize() const { return mInitialBlockSize; } + [[nodiscard]] inline float InitialCondition() const { return mInitialCondition; } + [[nodiscard]] inline size_t InitialConditionSize() const { return mInitialBlockSize; } virtual void Reset(float value = 0) = 0; virtual void SetParams(float sampleRate, float attackTime, @@ -111,15 +111,15 @@ class ExpFitEnvelopeDetector : public EnvelopeDetector ExpFitEnvelopeDetector(float rate, float attackTime, float releaseTime, size_t buffer_size); - virtual void Reset(float value); - virtual void SetParams(float sampleRate, float attackTime, - float releaseTime); + void Reset(float value) override; + void SetParams(float sampleRate, float attackTime, + float releaseTime) override; private: double mAttackFactor; double mReleaseFactor; - virtual void Follow(); + void Follow() override; }; class Pt1EnvelopeDetector : public EnvelopeDetector @@ -127,13 +127,13 @@ class Pt1EnvelopeDetector : public EnvelopeDetector public: Pt1EnvelopeDetector(float rate, float attackTime, float releaseTime, size_t buffer_size, bool correctGain = true); - virtual void CalcInitialCondition(float value); + void CalcInitialCondition(float value) override; - virtual void Reset(float value); - virtual void SetParams(float sampleRate, float attackTime, - float releaseTime); - virtual float AttackFactor(); - virtual float DecayFactor(); + void Reset(float value) override; + void SetParams(float sampleRate, float attackTime, + float releaseTime) override; + float AttackFactor() override; + float DecayFactor() override; private: bool mCorrectGain; @@ -141,7 +141,7 @@ class Pt1EnvelopeDetector : public EnvelopeDetector double mAttackFactor; double mReleaseFactor; - virtual void Follow(); + void Follow() override; }; struct PipelineBuffer @@ -158,7 +158,7 @@ struct PipelineBuffer void swap(PipelineBuffer& other); void init(size_t size, bool stereo); void fill(float value, bool stereo); - inline size_t capacity() const { return mCapacity; } + [[nodiscard]] inline size_t capacity() const { return mCapacity; } void free(); private: @@ -172,7 +172,7 @@ class EffectCompressor2 final : public Effect static const ComponentInterfaceSymbol Symbol; EffectCompressor2(); - virtual ~EffectCompressor2(); + ~EffectCompressor2() override; // ComponentInterface implementation @@ -211,22 +211,22 @@ class EffectCompressor2 final : public Effect private: // EffectCompressor2 implementation - double CompressorGain(double env); + [[nodiscard]] double CompressorGain(double env) const; std::unique_ptr InitPreprocessor( double rate, bool preview = false); - std::unique_ptr InitEnvelope( - double rate, size_t blockSize = 0, bool preview = false); + [[nodiscard]] std::unique_ptr InitEnvelope( + double rate, size_t blockSize = 0, bool preview = false) const; size_t CalcBufferSize(double sampleRate); - inline size_t CalcLookaheadLength(double rate); - inline size_t CalcWindowLength(double rate); + [[nodiscard]] inline size_t CalcLookaheadLength(double rate) const; + [[nodiscard]] inline size_t CalcWindowLength(double rate) const; void AllocPipeline(); void AllocRealtimePipeline(); void FreePipeline(); void SwapPipeline(); - bool ProcessOne(TrackIterRange range); - bool LoadPipeline(TrackIterRange range, size_t len); + bool ProcessOne(const TrackIterRange& range); + bool LoadPipeline(const TrackIterRange& range, size_t len); void FillPipeline(); void ProcessPipeline(); inline float PreprocSample(PipelineBuffer& pbuf, size_t rp); @@ -234,7 +234,7 @@ class EffectCompressor2 final : public Effect inline void CompressSample(float env, size_t wp); bool PipelineHasData(); void DrainPipeline(); - void StorePipeline(TrackIterRange range); + void StorePipeline(const TrackIterRange& range); bool UpdateProgress(); void OnUpdateUI(wxCommandEvent & evt); diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 80ef6878dd..3c23e74b8a 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -52,7 +52,7 @@ bool ContrastDialog::GetDB(float &dB) { - float rms = float(0.0); + auto rms = float(0.0); // For stereo tracks: sqrt((mean(L)+mean(R))/2) double meanSq = 0.0; @@ -189,7 +189,6 @@ void ContrastDialog::OnChar(wxKeyEvent &event) // ignore any other key event.Skip(false); - return; } ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, @@ -208,10 +207,10 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, mBackgroundIsDefined = false; // NULL out the control members until the controls are created. - mForegroundStartT = NULL; - mForegroundEndT = NULL; - mBackgroundStartT = NULL; - mBackgroundEndT = NULL; + mForegroundStartT = nullptr; + mForegroundEndT = nullptr; + mBackgroundStartT = nullptr; + mBackgroundEndT = nullptr; wxString number; auto p = FindProjectFromWindow( this ); diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index f67d877247..9598311044 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -106,27 +106,27 @@ FactoryPresets[] = // Defaults: 0 false -6.0 -70.0(off) 50.0 50.0 1 // // xgettext:no-c-format - { XO("Hard clip -12dB, 80% make-up gain"), { 0, 0, -12.0, -70.0, 0.0, 80.0, 0 } }, + { XO("Hard clip -12dB, 80% make-up gain"), { 0, false, -12.0, -70.0, 0.0, 80.0, 0 } }, // xgettext:no-c-format - { XO("Soft clip -12dB, 80% make-up gain"), { 1, 0, -12.0, -70.0, 50.0, 80.0, 0 } }, - { XO("Fuzz Box"), { 1, 0, -30.0, -70.0, 80.0, 80.0, 0 } }, - { XO("Walkie-talkie"), { 1, 0, -50.0, -70.0, 60.0, 80.0, 0 } }, - { XO("Blues drive sustain"), { 2, 0, -6.0, -70.0, 30.0, 80.0, 0 } }, - { XO("Light Crunch Overdrive"), { 3, 0, -6.0, -70.0, 20.0, 80.0, 0 } }, - { XO("Heavy Overdrive"), { 4, 0, -6.0, -70.0, 90.0, 80.0, 0 } }, - { XO("3rd Harmonic (Perfect Fifth)"), { 5, 0, -6.0, -70.0, 100.0, 60.0, 0 } }, - { XO("Valve Overdrive"), { 6, 1, -6.0, -70.0, 30.0, 40.0, 0 } }, - { XO("2nd Harmonic (Octave)"), { 6, 1, -6.0, -70.0, 50.0, 0.0, 0 } }, - { XO("Gated Expansion Distortion"), { 7, 0, -6.0, -70.0, 30.0, 80.0, 0 } }, - { XO("Leveller, Light, -70dB noise floor"), { 8, 0, -6.0, -70.0, 0.0, 50.0, 1 } }, - { XO("Leveller, Moderate, -70dB noise floor"), { 8, 0, -6.0, -70.0, 0.0, 50.0, 2 } }, - { XO("Leveller, Heavy, -70dB noise floor"), { 8, 0, -6.0, -70.0, 0.0, 50.0, 3 } }, - { XO("Leveller, Heavier, -70dB noise floor"), { 8, 0, -6.0, -70.0, 0.0, 50.0, 4 } }, - { XO("Leveller, Heaviest, -70dB noise floor"), { 8, 0, -6.0, -70.0, 0.0, 50.0, 5 } }, - { XO("Half-wave Rectifier"), { 9, 0, -6.0, -70.0, 50.0, 50.0, 0 } }, - { XO("Full-wave Rectifier"), { 9, 0, -6.0, -70.0, 100.0, 50.0, 0 } }, - { XO("Full-wave Rectifier (DC blocked)"), { 9, 1, -6.0, -70.0, 100.0, 50.0, 0 } }, - { XO("Percussion Limiter"), {10, 0, -12.0, -70.0, 100.0, 30.0, 0 } }, + { XO("Soft clip -12dB, 80% make-up gain"), { 1, false, -12.0, -70.0, 50.0, 80.0, 0 } }, + { XO("Fuzz Box"), { 1, false, -30.0, -70.0, 80.0, 80.0, 0 } }, + { XO("Walkie-talkie"), { 1, false, -50.0, -70.0, 60.0, 80.0, 0 } }, + { XO("Blues drive sustain"), { 2, false, -6.0, -70.0, 30.0, 80.0, 0 } }, + { XO("Light Crunch Overdrive"), { 3, false, -6.0, -70.0, 20.0, 80.0, 0 } }, + { XO("Heavy Overdrive"), { 4, false, -6.0, -70.0, 90.0, 80.0, 0 } }, + { XO("3rd Harmonic (Perfect Fifth)"), { 5, false, -6.0, -70.0, 100.0, 60.0, 0 } }, + { XO("Valve Overdrive"), { 6, true, -6.0, -70.0, 30.0, 40.0, 0 } }, + { XO("2nd Harmonic (Octave)"), { 6, true, -6.0, -70.0, 50.0, 0.0, 0 } }, + { XO("Gated Expansion Distortion"), { 7, false, -6.0, -70.0, 30.0, 80.0, 0 } }, + { XO("Leveller, Light, -70dB noise floor"), { 8, false, -6.0, -70.0, 0.0, 50.0, 1 } }, + { XO("Leveller, Moderate, -70dB noise floor"), { 8, false, -6.0, -70.0, 0.0, 50.0, 2 } }, + { XO("Leveller, Heavy, -70dB noise floor"), { 8, false, -6.0, -70.0, 0.0, 50.0, 3 } }, + { XO("Leveller, Heavier, -70dB noise floor"), { 8, false, -6.0, -70.0, 0.0, 50.0, 4 } }, + { XO("Leveller, Heaviest, -70dB noise floor"), { 8, false, -6.0, -70.0, 0.0, 50.0, 5 } }, + { XO("Half-wave Rectifier"), { 9, false, -6.0, -70.0, 50.0, 50.0, 0 } }, + { XO("Full-wave Rectifier"), { 9, false, -6.0, -70.0, 100.0, 50.0, 0 } }, + { XO("Full-wave Rectifier (DC blocked)"), { 9, true, -6.0, -70.0, 100.0, 50.0, 0 } }, + { XO("Percussion Limiter"), {10, false, -12.0, -70.0, 100.0, 30.0, 0 } }, }; TranslatableString defaultLabel(int index) @@ -185,8 +185,7 @@ EffectDistortion::EffectDistortion() } EffectDistortion::~EffectDistortion() -{ -} += default; // ComponentInterface implementation @@ -330,9 +329,9 @@ RegistryPaths EffectDistortion::GetFactoryPresets() { RegistryPaths names; - for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) + for (const auto & FactoryPreset : FactoryPresets) { - names.push_back( FactoryPresets[i].name.Translation() ); + names.push_back( FactoryPreset.name.Translation() ); } return names; @@ -490,8 +489,6 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S) S.EndStatic(); } S.EndVerticalLay(); - - return; } bool EffectDistortion::TransferDataToWindow() @@ -547,8 +544,6 @@ void EffectDistortion::InstanceInit(EffectDistortionState & data, float sampleRa data.queuesamples.pop(); MakeTable(); - - return; } size_t EffectDistortion::InstanceProcess(EffectDistortionState& data, float** inBlock, float** outBlock, size_t blockLen) @@ -1135,17 +1130,17 @@ void EffectDistortion::CubicTable() } } else { - for (int i = 0; i < TABLESIZE; i++) { - mTable[i] = gain * Cubic(x); + for (double & i : mTable) { + i = gain * Cubic(x); for (int j = 0; j < mParams.mRepeats; j++) { - mTable[i] = gain * Cubic(mTable[i] * amount); + i = gain * Cubic(i * amount); } x += stepsize; } } } -double EffectDistortion::Cubic(double x) +double EffectDistortion::Cubic(double x) const { if (mParams.mParam1 == 0.0) return x; @@ -1163,8 +1158,8 @@ void EffectDistortion::EvenHarmonicTable() double step = 1.0 / STEPS; double xval = -1.0; - for (int i = 0; i < TABLESIZE; i++) { - mTable[i] = ((1 + amount) * xval) - + for (double & i : mTable) { + i = ((1 + amount) * xval) - (xval * (amount / std::tanh(C)) * std::tanh(C * xval)); xval += step; } diff --git a/src/effects/Distortion.h b/src/effects/Distortion.h index f3d5a68ed0..cef4977cd5 100644 --- a/src/effects/Distortion.h +++ b/src/effects/Distortion.h @@ -48,7 +48,7 @@ class EffectDistortion final : public Effect static const ComponentInterfaceSymbol Symbol; EffectDistortion(); - virtual ~EffectDistortion(); + ~EffectDistortion() override; struct Params { @@ -76,7 +76,7 @@ class EffectDistortion final : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -133,11 +133,11 @@ class EffectDistortion final : public Effect void OnRepeatsSlider(wxCommandEvent & evt); void UpdateUI(); void UpdateControl(control id, bool enable, TranslatableString name); - void UpdateControlText(wxTextCtrl *textCtrl, wxString &string, bool enabled); + static void UpdateControlText(wxTextCtrl *textCtrl, wxString &string, bool enabled); void MakeTable(); float WaveShaper(float sample); - float DCFilter(EffectDistortionState & data, float sample); + static float DCFilter(EffectDistortionState & data, float sample); // Preset tables for gain lookup @@ -160,11 +160,11 @@ class EffectDistortion final : public Effect // Used by Soft Clipping but could be used for other tables. // Log curve formula: y = T + (((e^(RT - Rx)) - 1) / -R) // where R is the ratio, T is the threshold, and x is from T to 1. - inline float LogCurve(double threshold, float value, double ratio); + static inline float LogCurve(double threshold, float value, double ratio); // Used by Cubic curve but could be used for other tables // Cubic formula: y = x - (x^3 / 3.0) - inline double Cubic(double x); + [[nodiscard]] inline double Cubic(double x) const; private: diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index 3df7ae7e7d..d0fc1b2534 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -97,8 +97,7 @@ EffectDtmf::EffectDtmf() } EffectDtmf::~EffectDtmf() -{ -} += default; // ComponentInterface implementation @@ -270,9 +269,9 @@ bool EffectDtmf::SetAutomationParameters(CommandParameters & parms) ReadAndVerifyString(Sequence); wxString symbols; - for (unsigned int i = 0; i < WXSIZEOF(kSymbols); i++) + for (auto & kSymbol : kSymbols) { - symbols += kSymbols[i]; + symbols += kSymbol; } if (Sequence.find_first_not_of(symbols) != wxString::npos) @@ -600,7 +599,7 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, size_t len, float fs, wxChar tone, return true; } -void EffectDtmf::UpdateUI(void) +void EffectDtmf::UpdateUI() { mDtmfDutyT->SetLabel(wxString::Format(wxT("%.1f %%"), dtmfDutyCycle)); mDtmfDutyT->SetName(mDtmfDutyT->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) diff --git a/src/effects/DtmfGen.h b/src/effects/DtmfGen.h index 44ce1f4c63..ead7b27f62 100644 --- a/src/effects/DtmfGen.h +++ b/src/effects/DtmfGen.h @@ -28,7 +28,7 @@ class EffectDtmf final : public Effect static const ComponentInterfaceSymbol Symbol; EffectDtmf(); - virtual ~EffectDtmf(); + ~EffectDtmf() override; // ComponentInterface implementation @@ -43,7 +43,7 @@ class EffectDtmf final : public Effect // EffectClientInterface implementation unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool DefineParams( ShuttleParams & S ) override; bool GetAutomationParameters(CommandParameters & parms) override; diff --git a/src/effects/EBUR128.h b/src/effects/EBUR128.h index 0c8f798930..22afe11fb5 100644 --- a/src/effects/EBUR128.h +++ b/src/effects/EBUR128.h @@ -33,7 +33,7 @@ class EBUR128 void ProcessSampleFromChannel(float x_in, size_t channel); void NextSample(); double IntegrativeLoudness(); - inline double IntegrativeLoudnessToLUFS(double loudness) + static inline double IntegrativeLoudnessToLUFS(double loudness) { return 10 * log10(loudness); } private: diff --git a/src/effects/Echo.cpp b/src/effects/Echo.cpp index 9ffe3f6a71..1d8027271b 100644 --- a/src/effects/Echo.cpp +++ b/src/effects/Echo.cpp @@ -52,8 +52,7 @@ EffectEcho::EffectEcho() } EffectEcho::~EffectEcho() -{ -} += default; // ComponentInterface implementation @@ -115,7 +114,7 @@ bool EffectEcho::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames return false; } - return history != NULL; + return history != nullptr; } bool EffectEcho::ProcessFinalize() diff --git a/src/effects/Echo.h b/src/effects/Echo.h index b4db4fdc8a..9b19744bfd 100644 --- a/src/effects/Echo.h +++ b/src/effects/Echo.h @@ -22,7 +22,7 @@ class EffectEcho final : public Effect static const ComponentInterfaceSymbol Symbol; EffectEcho(); - virtual ~EffectEcho(); + ~EffectEcho() override; // ComponentInterface implementation @@ -38,7 +38,7 @@ class EffectEcho final : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; bool ProcessFinalize() override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool DefineParams( ShuttleParams & S ) override; diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 37cb24124b..296e8c15ca 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -86,9 +86,9 @@ auto Effect::SetVetoDialogHook( VetoDialogHook hook ) Effect::Effect() { - mClient = NULL; + mClient = nullptr; - mTracks = NULL; + mTracks = nullptr; mT0 = 0.0; mT1 = 0.0; mDuration = 0.0; @@ -98,10 +98,10 @@ Effect::Effect() mPreviewFullSelection = false; mNumTracks = 0; mNumGroups = 0; - mProgress = NULL; + mProgress = nullptr; - mUIParent = NULL; - mUIDialog = NULL; + mUIParent = nullptr; + mUIDialog = nullptr; mUIFlags = 0; mNumAudioIn = 0; @@ -656,8 +656,8 @@ bool Effect::CloseUI() if (mUIParent) mUIParent->RemoveEventHandler(this); - mUIParent = NULL; - mUIDialog = NULL; + mUIParent = nullptr; + mUIDialog = nullptr; return true; } @@ -703,7 +703,7 @@ void Effect::ExportPresets() XO("Could not open file: \"%s\"").Format( path ), XO("Error Saving Effect Presets"), wxICON_EXCLAMATION, - NULL); + nullptr); return; } @@ -714,7 +714,7 @@ void Effect::ExportPresets() XO("Error writing to file: \"%s\"").Format( path ), XO("Error Saving Effect Presets"), wxICON_EXCLAMATION, - NULL); + nullptr); } f.Close(); @@ -850,8 +850,6 @@ void Effect::SetDuration(double seconds) } mDuration = seconds; - - return; } RegistryPath Effect::GetUserPresetsGroup(const RegistryPath & name) @@ -1042,7 +1040,7 @@ bool Effect::Startup(EffectClientInterface *client) if (!SetHost(this)) { // Bail if the client startup fails - mClient = NULL; + mClient = nullptr; return false; } @@ -1292,7 +1290,7 @@ bool Effect::DoEffect(double projectRate, Names.push_back(wxT("control-f0")); if( mF1 != SelectedRegion::UndefinedFrequency ) Names.push_back(wxT("control-f1")); - SetPresetParameters( &Names, NULL ); + SetPresetParameters( &Names, nullptr ); #endif CountWaveTracks(); @@ -1912,8 +1910,7 @@ void Effect::End() void Effect::PopulateOrExchange(ShuttleGui & WXUNUSED(S)) { - return; -} + } bool Effect::TransferDataToWindow() { @@ -2042,7 +2039,7 @@ bool Effect::TrackGroupProgress(int whichGroup, double frac, const TranslatableS void Effect::GetBounds( const WaveTrack &track, const WaveTrack *pRight, - sampleCount *start, sampleCount *len) + sampleCount *start, sampleCount *len) const { auto t0 = std::max( mT0, track.GetStartTime() ); auto t1 = std::min( mT1, track.GetEndTime() ); @@ -2099,7 +2096,7 @@ void Effect::CopyInputTracks(bool allSyncLockSelected) Track *Effect::AddToOutputTracks(const std::shared_ptr &t) { - mIMap.push_back(NULL); + mIMap.push_back(nullptr); mOMap.push_back(t.get()); return mOutputTracks->Add(t); } @@ -2115,7 +2112,7 @@ Effect::AddedAnalysisTrack::AddedAnalysisTrack(Effect *pEffect, const wxString & } Effect::AddedAnalysisTrack::AddedAnalysisTrack(AddedAnalysisTrack &&that) -{ + noexcept { mpEffect = that.mpEffect; mpTrack = that.mpTrack; that.Commit(); @@ -2147,7 +2144,7 @@ Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack // copy LabelTrack here, so it can be undone on cancel auto newTrack = pOrigTrack->Copy(pOrigTrack->GetStartTime(), pOrigTrack->GetEndTime()); - mpTrack = static_cast(newTrack.get()); + mpTrack = dynamic_cast(newTrack.get()); // Why doesn't LabelTrack::Copy complete the job? : mpTrack->SetOffset(pOrigTrack->GetStartTime()); @@ -2162,7 +2159,7 @@ Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack } Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(ModifiedAnalysisTrack &&that) -{ + noexcept { mpEffect = that.mpEffect; mpTrack = that.mpTrack; mpOrigTrack = std::move(that.mpOrigTrack); @@ -2237,7 +2234,7 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult) iterOut = mOutputTracks->erase(iterOut); const auto t = mIMap[i]; - if (t == NULL) + if (t == nullptr) { // This track is a NEW addition to output tracks; add it to mTracks mTracks->Add( o ); @@ -2406,7 +2403,7 @@ void Effect::Preview(bool dryOnly) if (src->GetSelected() || mPreviewWithNotSelected) { auto dest = src->Copy(mT0, t1); dest->SetSelected(src->GetSelected()); - WaveTrackView::Get( *static_cast(dest.get()) ) + WaveTrackView::Get( *dynamic_cast(dest.get()) ) .SetDisplay(WaveTrackViewConstants::NoDisplay); mTracks->Add( dest ); } diff --git a/src/effects/Effect.h b/src/effects/Effect.h index e0e747ae4f..dfacab0d09 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -81,7 +81,7 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, // The constructor is called once by each subclass at the beginning of the program. // Avoid allocating memory or doing time-consuming processing here. Effect(); - virtual ~Effect(); + ~Effect() override; // Type of a registered function that, if it returns true, // causes ShowInterface to return early without making any dialog @@ -123,10 +123,10 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, void SetSampleRate(double rate) override; size_t SetBlockSize(size_t maxBlockSize) override; - size_t GetBlockSize() const override; + [[nodiscard]] size_t GetBlockSize() const override; bool IsReady() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; bool ProcessFinalize() override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; @@ -343,13 +343,13 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, // (when doing stereo groups at a time) bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString & = {}); - int GetNumWaveTracks() { return mNumTracks; } - int GetNumWaveGroups() { return mNumGroups; } + [[nodiscard]] int GetNumWaveTracks() const { return mNumTracks; } + [[nodiscard]] int GetNumWaveGroups() const { return mNumGroups; } // Calculates the start time and length in samples for one or two channels void GetBounds( const WaveTrack &track, const WaveTrack *pRight, - sampleCount *start, sampleCount *len); + sampleCount *start, sampleCount *len) const; // Previewing linear effect can be optimised by pre-mixing. However this // should not be used for non-linear effects such as dynamic processors @@ -361,7 +361,7 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, void SetPreviewFullSelectionFlag(bool previewDurationFlag); // Use this if the effect needs to know if it is previewing - bool IsPreviewing() { return mIsPreview; } + [[nodiscard]] bool IsPreviewing() const { return mIsPreview; } // Most effects only require selected tracks to be copied for Preview. // If IncludeNotSelectedPreviewTracks(true), then non-linear effects have @@ -385,12 +385,12 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, public: - AddedAnalysisTrack() {} + AddedAnalysisTrack() = default; // So you can have a vector of them - AddedAnalysisTrack(AddedAnalysisTrack &&that); + AddedAnalysisTrack(AddedAnalysisTrack &&that) noexcept ; - LabelTrack *get() const { return mpTrack; } + [[nodiscard]] LabelTrack *get() const { return mpTrack; } // Call this to indicate successful completion of the analyzer. void Commit(); @@ -419,9 +419,9 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, ModifiedAnalysisTrack(); // So you can have a vector of them - ModifiedAnalysisTrack(ModifiedAnalysisTrack &&that); + ModifiedAnalysisTrack(ModifiedAnalysisTrack &&that) noexcept ; - LabelTrack *get() const { return mpTrack; } + [[nodiscard]] LabelTrack *get() const { return mpTrack; } // Call this to indicate successful completion of the analyzer. void Commit(); @@ -442,7 +442,7 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, // If bGoodResult, replace mWaveTracks tracks in mTracks with successfully processed // mOutputTracks copies, get rid of old mWaveTracks, and set mWaveTracks to mOutputTracks. // Else clear and DELETE mOutputTracks copies. - void ReplaceProcessedTracks(const bool bGoodResult); + void ReplaceProcessedTracks(bool bGoodResult); // Use this to append a NEW output track. Track *AddToOutputTracks(const std::shared_ptr &t); @@ -461,8 +461,8 @@ class SAUCEDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, double mSampleRate; wxWeakRef mpSelectedRegion{}; WaveTrackFactory *mFactory; - const TrackList *inputTracks() const { return mTracks; } - const SaucedacityProject *FindProject() const; + [[nodiscard]] const TrackList *inputTracks() const { return mTracks; } + [[nodiscard]] const SaucedacityProject *FindProject() const; std::shared_ptr mOutputTracks; // used only if CopyInputTracks() is called. double mT0; double mT1; @@ -608,7 +608,7 @@ inline long TrapLong(long x, long min, long max) #define ReadParam(type, name) \ type name = DEF_ ## name; \ - if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, MIN_ ## name, MAX_ ## name)) \ + if (!parms.ReadAndVerify(KEY_ ## name, &(name), DEF_ ## name, MIN_ ## name, MAX_ ## name)) \ return false; #define ReadBasic(type, name) \ @@ -616,17 +616,17 @@ inline long TrapLong(long x, long min, long max) wxUnusedVar(MIN_ ##name); \ wxUnusedVar(MAX_ ##name); \ wxUnusedVar(SCL_ ##name); \ - if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name)) \ + if (!parms.ReadAndVerify(KEY_ ## name, &(name), DEF_ ## name)) \ return false; #define ReadAndVerifyEnum(name, list, listSize) \ int name; \ - if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, list, listSize)) \ + if (!parms.ReadAndVerify(KEY_ ## name, &(name), DEF_ ## name, list, listSize)) \ return false; #define ReadAndVerifyEnumWithObsoletes(name, list, listSize, obsoleteList, nObsolete) \ int name; \ - if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, \ + if (!parms.ReadAndVerify(KEY_ ## name, &(name), DEF_ ## name, \ list, listSize, obsoleteList, nObsolete)) \ return false; diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index 21083f8684..704e499db6 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -51,8 +51,7 @@ EffectManager::EffectManager() } EffectManager::~EffectManager() -{ -} += default; // Here solely for the purpose of Nyquist Workbench until // a better solution is devised. @@ -69,7 +68,7 @@ const PluginID & EffectManager::RegisterEffect(std::unique_ptr uEffect) // a better solution is devised. void EffectManager::UnregisterEffect(const PluginID & ID) { - PluginID id = ID; + const PluginID& id = ID; PluginManager::Get().UnregisterPlugin(id); mEffects.erase(id); } @@ -176,7 +175,7 @@ void EffectManager::GetCommandDefinition(const PluginID & ID, const CommandConte return; // This is capturing the output context into the shuttle. - ShuttleGetDefinition S( *context.pOutput.get()->mStatusTarget.get() ); + ShuttleGetDefinition S( *context.pOutput->mStatusTarget ); S.StartStruct(); // using GET to expose a CommandID to the user! // Macro command details are one place that we do expose Identifier @@ -216,7 +215,7 @@ void EffectManager::SetSkipStateFlag(bool flag) mSkipStateFlag = flag; } -bool EffectManager::GetSkipStateFlag() +bool EffectManager::GetSkipStateFlag() const { return mSkipStateFlag; } @@ -339,8 +338,8 @@ bool EffectManager::HasPresets(const PluginID & ID) return false; } - return effect->GetUserPresets().size() > 0 || - effect->GetFactoryPresets().size() > 0 || + return !effect->GetUserPresets().empty() || + !effect->GetFactoryPresets().empty() || effect->HasCurrentSettings() || effect->HasFactoryDefaults(); } @@ -361,9 +360,9 @@ class EffectPresetsDialog final : public wxDialogWrapper { public: EffectPresetsDialog(wxWindow *parent, Effect *effect); - virtual ~EffectPresetsDialog(); + ~EffectPresetsDialog() override; - wxString GetSelected() const; + [[nodiscard]] wxString GetSelected() const; void SetSelected(const wxString & parms); private: @@ -423,12 +422,12 @@ EffectPresetsDialog::EffectPresetsDialog(wxWindow *parent, Effect *effect) mUserPresets = effect->GetUserPresets(); mFactoryPresets = effect->GetFactoryPresets(); - if (mUserPresets.size() > 0) + if (!mUserPresets.empty()) { mType->Append(_("User Presets")); } - if (mFactoryPresets.size() > 0) + if (!mFactoryPresets.empty()) { mType->Append(_("Factory Presets")); } @@ -447,8 +446,7 @@ EffectPresetsDialog::EffectPresetsDialog(wxWindow *parent, Effect *effect) } EffectPresetsDialog::~EffectPresetsDialog() -{ -} += default; wxString EffectPresetsDialog::GetSelected() const { @@ -499,9 +497,8 @@ void EffectPresetsDialog::SetPrefix( else if (type == XO("Factory Presets")) { mPresets->Clear(); - for (size_t i = 0, cnt = mFactoryPresets.size(); i < cnt; i++) + for (auto label : mFactoryPresets) { - auto label = mFactoryPresets[i]; if (label.empty()) { label = _("None"); @@ -564,9 +561,8 @@ void EffectPresetsDialog::UpdateUI() } mPresets->Clear(); - for (size_t i = 0, cnt = mFactoryPresets.size(); i < cnt; i++) + for (auto label : mFactoryPresets) { - auto label = mFactoryPresets[i]; if (label.empty()) { label = _("None"); @@ -710,22 +706,22 @@ Effect *EffectManager::GetEffect(const PluginID & ID) // Must have a "valid" ID if (ID.empty()) { - return NULL; + return nullptr; } // If it is actually a command then refuse it (as an effect). if( mCommands.find( ID ) != mCommands.end() ) - return NULL; + return nullptr; // TODO: This is temporary and should be redone when all effects are converted if (mEffects.find(ID) == mEffects.end()) { // This will instantiate the effect client if it hasn't already been done - EffectDefinitionInterface *ident = dynamic_cast(PluginManager::Get().GetInstance(ID)); + auto *ident = dynamic_cast(PluginManager::Get().GetInstance(ID)); if (ident && ident->IsLegacy()) { auto effect = dynamic_cast(ident); - if (effect && effect->Startup(NULL)) + if (effect && effect->Startup(nullptr)) { mEffects[ID] = effect; return effect; @@ -735,7 +731,7 @@ Effect *EffectManager::GetEffect(const PluginID & ID) auto effect = std::make_shared(); // TODO: use make_unique and store in std::unordered_map if (effect) { - EffectClientInterface *client = dynamic_cast(ident); + auto *client = dynamic_cast(ident); if (client && effect->Startup(client)) { auto pEffect = effect.get(); @@ -753,7 +749,7 @@ Effect *EffectManager::GetEffect(const PluginID & ID) .Format( GetCommandName(ID) ), XO("Effect failed to initialize")); - return NULL; + return nullptr; } return mEffects[ID]; @@ -764,7 +760,7 @@ AudacityCommand *EffectManager::GetAudacityCommand(const PluginID & ID) // Must have a "valid" ID if (ID.empty()) { - return NULL; + return nullptr; } // TODO: This is temporary and should be redone when all effects are converted @@ -811,7 +807,7 @@ AudacityCommand *EffectManager::GetAudacityCommand(const PluginID & ID) .Format( GetCommandName(ID) ), XO("Command failed to initialize")); - return NULL; + return nullptr; } return mCommands[ID]; diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index 9abf2df7cf..5cfc134e4a 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -93,9 +93,9 @@ class SAUCEDACITY_DLL_API EffectManager bool shouldPrompt = true ); // Renamed from 'Effect' to 'Command' prior to moving out of this class. - ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID); + static ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID); TranslatableString GetCommandName(const PluginID & ID); - CommandID GetCommandIdentifier(const PluginID & ID); + static CommandID GetCommandIdentifier(const PluginID & ID); TranslatableString GetCommandDescription(const PluginID & ID); ManualPageID GetCommandUrl(const PluginID & ID); TranslatableString GetCommandTip(const PluginID & ID); @@ -104,7 +104,7 @@ class SAUCEDACITY_DLL_API EffectManager bool IsHidden(const PluginID & ID); /** Support for batch commands */ - bool SupportsAutomation(const PluginID & ID); + static bool SupportsAutomation(const PluginID & ID); wxString GetEffectParameters(const PluginID & ID); bool SetEffectParameters(const PluginID & ID, const wxString & params); bool PromptUser( const PluginID & ID, @@ -132,7 +132,7 @@ class SAUCEDACITY_DLL_API EffectManager /** Allow effects to disable saving the state at run time */ void SetSkipStateFlag(bool flag); - bool GetSkipStateFlag(); + bool GetSkipStateFlag() const; const PluginID & GetEffectByIdentifier(const CommandID & strTarget); diff --git a/src/effects/EffectUI.cpp b/src/effects/EffectUI.cpp index e94921acf7..0156a8ed4c 100644 --- a/src/effects/EffectUI.cpp +++ b/src/effects/EffectUI.cpp @@ -599,7 +599,7 @@ EffectRack &EffectRack::Get( SaucedacityProject &project ) class EffectPanel final : public wxPanelWrapper { public: - EffectPanel(wxWindow *parent) + explicit EffectPanel(wxWindow *parent) : wxPanelWrapper(parent) { // This fools NVDA into not saying "Panel" when the dialog gets focus @@ -609,21 +609,20 @@ class EffectPanel final : public wxPanelWrapper mAcceptsFocus = true; } - virtual ~EffectPanel() - { - } + ~EffectPanel() override + = default; // ============================================================================ // wxWindow implementation // ============================================================================ - bool AcceptsFocus() const override + [[nodiscard]] bool AcceptsFocus() const override { return mAcceptsFocus; } // So that wxPanel is not included in Tab traversal, when required - see wxWidgets bug 15581 - bool AcceptsFocusFromKeyboard() const override + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override { return mAcceptsFocus; } @@ -735,7 +734,7 @@ EffectUIHost::EffectUIHost(wxWindow *parent, mParent = parent; mEffect = effect; - mCommand = NULL; + mCommand = nullptr; mClient = client; mProject = &project; @@ -768,7 +767,7 @@ EffectUIHost::EffectUIHost(wxWindow *parent, SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); mParent = parent; - mEffect = NULL; + mEffect = nullptr; mCommand = command; mClient = client; @@ -798,7 +797,7 @@ EffectUIHost::~EffectUIHost() Resume(); mClient->CloseUI(); - mClient = NULL; + mClient = nullptr; } } @@ -1125,7 +1124,7 @@ void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt)) if (mNeedsResume) Resume(); mClient->CloseUI(); - mClient = NULL; + mClient = nullptr; Destroy(); } @@ -1261,7 +1260,7 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt)) LoadUserPresets(); - if (mUserPresets.size() == 0) + if (mUserPresets.empty()) { menu.Append(kUserPresetsDummyID, _("User Presets"))->Enable(false); } @@ -1277,7 +1276,7 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt)) menu.Append(kSaveAsID, _("Save Preset...")); - if (mUserPresets.size() == 0) + if (mUserPresets.empty()) { menu.Append(kDeletePresetDummyID, _("Delete Preset"))->Enable(false); } @@ -1298,7 +1297,7 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt)) { auto sub = std::make_unique(); sub->Append(kDefaultsID, _("Defaults")); - if (factory.size() > 0) + if (!factory.empty()) { sub->AppendSeparator(); for (size_t i = 0, cnt = factory.size(); i < cnt; i++) @@ -1527,15 +1526,11 @@ void EffectUIHost::OnUserPreset(wxCommandEvent & evt) int preset = evt.GetId() - kUserPresetsID; mEffect->LoadUserPreset(mEffect->GetUserPresetsGroup(mUserPresets[preset])); - - return; } void EffectUIHost::OnFactoryPreset(wxCommandEvent & evt) { mEffect->LoadFactoryPreset(evt.GetId() - kFactoryPresetsID); - - return; } void EffectUIHost::OnDeletePreset(wxCommandEvent & evt) @@ -1552,8 +1547,6 @@ void EffectUIHost::OnDeletePreset(wxCommandEvent & evt) } LoadUserPresets(); - - return; } void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt)) @@ -1631,16 +1624,13 @@ void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt)) break; } - return; -} + } void EffectUIHost::OnImport(wxCommandEvent & WXUNUSED(evt)) { mClient->ImportPresets(); LoadUserPresets(); - - return; } void EffectUIHost::OnExport(wxCommandEvent & WXUNUSED(evt)) @@ -1648,22 +1638,16 @@ void EffectUIHost::OnExport(wxCommandEvent & WXUNUSED(evt)) // may throw // exceptions are handled in SaucedacityApp::OnExceptionInMainLoop mClient->ExportPresets(); - - return; } void EffectUIHost::OnOptions(wxCommandEvent & WXUNUSED(evt)) { mClient->ShowOptions(); - - return; } void EffectUIHost::OnDefaults(wxCommandEvent & WXUNUSED(evt)) { mEffect->LoadFactoryDefaults(); - - return; } wxBitmap EffectUIHost::CreateBitmap(const char * const xpm[], bool up, bool pusher) @@ -1785,8 +1769,6 @@ void EffectUIHost::LoadUserPresets() mEffect->GetPrivateConfigSubgroups(mEffect->GetUserPresetsGroup(wxEmptyString), mUserPresets); std::sort( mUserPresets.begin(), mUserPresets.end() ); - - return; } void EffectUIHost::InitializeRealtime() @@ -2078,8 +2060,7 @@ void EffectDialog::Init() /// kind of dialog. void EffectDialog::PopulateOrExchange(ShuttleGui & WXUNUSED(S)) { - return; -} + } bool EffectDialog::TransferDataToWindow() { @@ -2104,8 +2085,7 @@ bool EffectDialog::Validate() void EffectDialog::OnPreview(wxCommandEvent & WXUNUSED(evt)) { - return; -} + } void EffectDialog::OnOk(wxCommandEvent & WXUNUSED(evt)) { @@ -2119,5 +2099,4 @@ void EffectDialog::OnOk(wxCommandEvent & WXUNUSED(evt)) EndModal(true); } - return; -} + } diff --git a/src/effects/EffectUI.h b/src/effects/EffectUI.h index 5f900fae96..ad41f7ceec 100644 --- a/src/effects/EffectUI.h +++ b/src/effects/EffectUI.h @@ -131,7 +131,7 @@ class EffectUIHost final : public wxDialogWrapper, SaucedacityProject &project, AudacityCommand *command, EffectUIClientInterface *client); - virtual ~EffectUIHost(); + ~EffectUIHost() override; bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -169,7 +169,7 @@ class EffectUIHost final : public wxDialogWrapper, void OnDefaults(wxCommandEvent & evt); void UpdateControls(); - wxBitmap CreateBitmap(const char * const xpm[], bool up, bool pusher); + static wxBitmap CreateBitmap(const char * const xpm[], bool up, bool pusher); void LoadUserPresets(); void InitializeRealtime(); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index b9c50a52b8..a436d1065e 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -251,11 +251,11 @@ EffectEqualization::EffectEqualization(int Options) , mFilterFuncI{ windowSize } { mOptions = Options; - mGraphic = NULL; - mDraw = NULL; - mCurve = NULL; - mPanel = NULL; - mMSlider = NULL; + mGraphic = nullptr; + mDraw = nullptr; + mCurve = nullptr; + mPanel = nullptr; + mMSlider = nullptr; hFFT = GetFFT(windowSize); @@ -334,8 +334,7 @@ EffectEqualization::EffectEqualization(int Options) EffectEqualization::~EffectEqualization() -{ -} += default; // ComponentInterface implementation @@ -405,7 +404,7 @@ bool EffectEqualization::DefineParams( ShuttleParams & S ){ S.Define( d, nameVal, 0.0, -10000.0, 10000.0, 0.0 ); if( f <= 0.0 ) break; - mCurves[0].points.push_back( EQPoint( f,d )); + mCurves[0].points.emplace_back( f,d ); } setCurve( 0 ); } @@ -496,11 +495,11 @@ RegistryPaths EffectEqualization::GetFactoryPresets() { RegistryPaths names; - for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) + for (const auto & FactoryPreset : FactoryPresets) { - if ((mOptions == kEqOptionGraphic) && (FactoryPresets[i].bForBoth == false)) + if ((mOptions == kEqOptionGraphic) && (FactoryPreset.bForBoth == false)) continue; - names.push_back(FactoryPresets[i].name.Translation()); + names.push_back(FactoryPreset.name.Translation()); } return names; @@ -589,7 +588,7 @@ bool EffectEqualization::ValidateUI() // Effect implementation -wxString EffectEqualization::GetPrefsPrefix() +wxString EffectEqualization::GetPrefsPrefix() const { wxString base = wxT("/Effects/Equalization/"); if( mOptions == kEqOptionGraphic ) @@ -753,8 +752,8 @@ bool EffectEqualization::Process() bool EffectEqualization::CloseUI() { - mCurve = NULL; - mPanel = NULL; + mCurve = nullptr; + mPanel = nullptr; return Effect::CloseUI(); } @@ -1178,8 +1177,6 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) szrV->SetMinSize(sz); } ForceRecalc(); - - return; } // @@ -1246,7 +1243,7 @@ bool EffectEqualization::TransferDataFromWindow() wxString tip; bool rr = false; - float dB = (float) mdBMinSlider->GetValue(); + auto dB = (float) mdBMinSlider->GetValue(); if (dB != mdBMin) { rr = true; mdBMin = dB; @@ -1418,7 +1415,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t, continue; // clip is not within selection //save the actual clip start/end so that we can rejoin them after we paste. - clipRealStartEndTimes.push_back(std::pair(clipStartT,clipEndT)); + clipRealStartEndTimes.emplace_back(clipStartT,clipEndT); if( clipStartT < startT ) // does selection cover the whole clip? clipStartT = startT; // don't copy all the NEW clip @@ -1426,7 +1423,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t, clipEndT = startT + lenT; // don't copy all the NEW clip //save them - clipStartEndTimes.push_back(std::pair(clipStartT,clipEndT)); + clipStartEndTimes.emplace_back(clipStartT,clipEndT); } //now go thru and replace the old clips with NEW for(unsigned int i = 0; i < clipStartEndTimes.size(); i++) @@ -1513,7 +1510,7 @@ bool EffectEqualization::CalcFilter() //transfer to time domain to do the padding and windowing Floats outr{ mWindowSize }; Floats outi{ mWindowSize }; - InverseRealFFT(mWindowSize, mFilterFuncR.get(), NULL, outr.get()); // To time domain + InverseRealFFT(mWindowSize, mFilterFuncR.get(), nullptr, outr.get()); // To time domain { size_t i = 0; @@ -1595,12 +1592,12 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append) // We've disabled the XML management of curves. // Just going via .cfg files now. #if 1 - (void)fileName; - (void)append; - mCurves.clear(); - mCurves.push_back( wxT("unnamed") ); // we still need a default curve to use + (void)fileName; + (void)append; + mCurves.clear(); + mCurves.push_back( wxT("unnamed") ); // we still need a default curve to use #else - // Construct normal curve filename + // Construct normal curve filename // // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict // between wxStandardPaths and wxConfig under Linux. The latter @@ -1682,15 +1679,13 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append) mCurves.back().points = tempCustom.points; } #endif - return; } - // // Update presets to match Audacity version. // void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) { - if (mCurves.size() == 0) + if (mCurves.empty()) return; wxString unnamed = wxT("unnamed"); @@ -1799,8 +1794,6 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) wxString eqCurvesCurrentVersion = wxString::Format(wxT("%d.%d"), EQCURVES_VERSION, EQCURVES_REVISION); gPrefs->Write(GetPrefsPrefix()+"PresetVersion", eqCurvesCurrentVersion); gPrefs->Flush(); - - return; } // @@ -2120,7 +2113,7 @@ void EffectEqualization::EnvelopeUpdated(Envelope *env, bool lin) double db = value[ point ]; // Add it to the curve - mCurves[ curve ].points.push_back( EQPoint( freq, db ) ); + mCurves[ curve ].points.emplace_back( freq, db ); } } else @@ -2136,7 +2129,7 @@ void EffectEqualization::EnvelopeUpdated(Envelope *env, bool lin) double db = value[ point ]; // Add it to the curve - mCurves[ curve ].points.push_back( EQPoint( freq, db ) ); + mCurves[ curve ].points.emplace_back( freq, db ); } } // Remember that we've updated the unnamed curve @@ -2149,7 +2142,7 @@ void EffectEqualization::EnvelopeUpdated(Envelope *env, bool lin) // // // -bool EffectEqualization::IsLinear() +bool EffectEqualization::IsLinear() const { return mDrawMode && mLin; } @@ -2217,11 +2210,11 @@ bool EffectEqualization::HandleXMLTag(const wxChar *tag, const wxChar **attrs) do { exists = false; - for(size_t i = 0; i < mCurves.size(); i++) + for(auto & mCurve : mCurves) { if(n>0) strValueTemp.Printf(wxT("%s (%d)"),strValue,n); - if(mCurves[i].Name == strValueTemp) + if(mCurve.Name == strValueTemp) { exists = true; break; @@ -2274,7 +2267,7 @@ bool EffectEqualization::HandleXMLTag(const wxChar *tag, const wxChar **attrs) } // Create a NEW point - mCurves[ mCurves.size() - 1 ].points.push_back( EQPoint( f, d ) ); + mCurves[ mCurves.size() - 1 ].points.emplace_back( f, d ); // Tell caller it was processed return true; @@ -2304,7 +2297,7 @@ XMLTagHandler *EffectEqualization::HandleXMLChild(const wxChar *tag) return this; } - return NULL; + return nullptr; } // @@ -2359,12 +2352,12 @@ void EffectEqualization::UpdateCurves() if( mCurve ) mCurve->Clear(); bool selectedCurveExists = false; - for (size_t i = 0, cnt = mCurves.size(); i < cnt; i++) + for (auto & curve : mCurves) { - if (mCurveName == mCurves[ i ].Name) + if (mCurveName == curve.Name) selectedCurveExists = true; if( mCurve ) - mCurve->Append(mCurves[ i ].Name); + mCurve->Append(curve.Name); } // In rare circumstances, mCurveName may not exist (bug 1891) if (!selectedCurveExists) @@ -2494,7 +2487,7 @@ void EffectEqualization::UpdateGraphic() mDrawMode = false; } -void EffectEqualization::EnvLogToLin(void) +void EffectEqualization::EnvLogToLin() { size_t numPoints = mLogEnvelope->GetNumberOfPoints(); if( numPoints == 0 ) @@ -2518,7 +2511,7 @@ void EffectEqualization::EnvLogToLin(void) mLinEnvelope->Reassign(1., value[numPoints-1]); } -void EffectEqualization::EnvLinToLog(void) +void EffectEqualization::EnvLinToLog() { size_t numPoints = mLinEnvelope->GetNumberOfPoints(); if( numPoints == 0 ) @@ -2560,7 +2553,7 @@ void EffectEqualization::EnvLinToLog(void) EnvelopeUpdated(mLogEnvelope.get(), false); } -void EffectEqualization::ErrMin(void) +void EffectEqualization::ErrMin() { double vals[NUM_PTS]; double error = 0.0; @@ -2651,14 +2644,14 @@ void EffectEqualization::GraphicEQ(Envelope *env) case kBspline: // B-spline { int minF = 0; - for(size_t i = 0; i < NUM_PTS; i++) + for(double mWhen : mWhens) { - while( (mWhenSliders[minF] <= mWhens[i]) & (minF < (int)mBandsInUse) ) + while( (mWhenSliders[minF] <= mWhen) & (minF < (int)mBandsInUse) ) minF++; minF--; if( minF < 0 ) //before first slider { - dist = mWhens[i] - mWhenSliders[0]; + dist = mWhen - mWhenSliders[0]; span = mWhenSliders[1] - mWhenSliders[0]; s = dist/span; if( s < -1.5 ) @@ -2670,9 +2663,9 @@ void EffectEqualization::GraphicEQ(Envelope *env) } else { - if( mWhens[i] > mWhenSliders[mBandsInUse-1] ) //after last fader + if( mWhen > mWhenSliders[mBandsInUse-1] ) //after last fader { - dist = mWhens[i] - mWhenSliders[mBandsInUse-1]; + dist = mWhen - mWhenSliders[mBandsInUse-1]; span = mWhenSliders[mBandsInUse-1] - mWhenSliders[mBandsInUse-2]; s = dist/span; if( s > 1.5 ) @@ -2685,7 +2678,7 @@ void EffectEqualization::GraphicEQ(Envelope *env) } else //normal case { - dist = mWhens[i] - mWhenSliders[minF]; + dist = mWhen - mWhenSliders[minF]; span = mWhenSliders[minF+1] - mWhenSliders[minF]; s = dist/span; if(s < .5 ) @@ -2706,9 +2699,9 @@ void EffectEqualization::GraphicEQ(Envelope *env) } } } - if(mWhens[i]<=0.) + if(mWhen<=0.) env->Reassign(0., value); - env->Insert( mWhens[i], value ); + env->Insert( mWhen, value ); } env->Reassign( 1., value ); break; @@ -2717,14 +2710,14 @@ void EffectEqualization::GraphicEQ(Envelope *env) case kCosine: // Cosine squared { int minF = 0; - for(size_t i = 0; i < NUM_PTS; i++) + for(double mWhen : mWhens) { - while( (mWhenSliders[minF] <= mWhens[i]) & (minF < (int)mBandsInUse) ) + while( (mWhenSliders[minF] <= mWhen) & (minF < (int)mBandsInUse) ) minF++; minF--; if( minF < 0 ) //before first slider { - dist = mWhenSliders[0] - mWhens[i]; + dist = mWhenSliders[0] - mWhen; span = mWhenSliders[1] - mWhenSliders[0]; if( dist < span ) value = mEQVals[0]*(1. + cos(M_PI*dist/span))/2.; @@ -2733,10 +2726,10 @@ void EffectEqualization::GraphicEQ(Envelope *env) } else { - if( mWhens[i] > mWhenSliders[mBandsInUse-1] ) //after last fader + if( mWhen > mWhenSliders[mBandsInUse-1] ) //after last fader { span = mWhenSliders[mBandsInUse-1] - mWhenSliders[mBandsInUse-2]; - dist = mWhens[i] - mWhenSliders[mBandsInUse-1]; + dist = mWhen - mWhenSliders[mBandsInUse-1]; if( dist < span ) value = mEQVals[mBandsInUse-1]*(1. + cos(M_PI*dist/span))/2.; else @@ -2745,14 +2738,14 @@ void EffectEqualization::GraphicEQ(Envelope *env) else //normal case { span = mWhenSliders[minF+1] - mWhenSliders[minF]; - dist = mWhenSliders[minF+1] - mWhens[i]; + dist = mWhenSliders[minF+1] - mWhen; value = mEQVals[minF]*(1. + cos(M_PI*(span-dist)/span))/2. + mEQVals[minF+1]*(1. + cos(M_PI*dist/span))/2.; } } - if(mWhens[i]<=0.) + if(mWhen<=0.) env->Reassign(0., value); - env->Insert( mWhens[i], value ); + env->Insert( mWhen, value ); } env->Reassign( 1., value ); break; @@ -2774,7 +2767,7 @@ void EffectEqualization::GraphicEQ(Envelope *env) ForceRecalc(); } -void EffectEqualization::spline(double x[], double y[], size_t n, double y2[]) +void EffectEqualization::spline(const double x[], const double y[], size_t n, double y2[]) { wxASSERT( n > 0 ); @@ -2796,7 +2789,7 @@ void EffectEqualization::spline(double x[], double y[], size_t n, double y2[]) y2[i] = y2[i]*y2[i+1] + u[i]; } -double EffectEqualization::splint(double x[], double y[], size_t n, double y2[], double xr) +double EffectEqualization::splint(const double x[], const double y[], size_t n, const double y2[], double xr) { wxASSERT( n > 1 ); @@ -2829,7 +2822,7 @@ void EffectEqualization::OnSize(wxSizeEvent & event) void EffectEqualization::OnSlider(wxCommandEvent & event) { - wxSlider *s = (wxSlider *)event.GetEventObject(); + auto *s = (wxSlider *)event.GetEventObject(); for (size_t i = 0; i < mBandsInUse; i++) { if( s == mSliders[i]) @@ -2910,7 +2903,7 @@ void EffectEqualization::OnSliderDBMAX(wxCommandEvent & WXUNUSED(event)) void EffectEqualization::OnCurve(wxCommandEvent & WXUNUSED(event)) { // Select NEW curve - wxASSERT( mCurve != NULL ); + wxASSERT( mCurve != nullptr ); setCurve( mCurve->GetCurrentSelection() ); if( !mDrawMode ) UpdateGraphic(); @@ -3080,7 +3073,7 @@ EqualizationPanel::EqualizationPanel( mParent = parent; mEffect = effect; - mBitmap = NULL; + mBitmap = nullptr; mWidth = 0; mHeight = 0; @@ -3383,8 +3376,7 @@ wxDialogWrapper(parent, wxID_ANY, XO("Manage Curves List"), } EditCurvesDialog::~EditCurvesDialog() -{ -} += default; /// Creates the dialog and its contents. void EditCurvesDialog::Populate() @@ -3429,8 +3421,6 @@ void EditCurvesDialog::PopulateOrExchange(ShuttleGui & S) S.EndStatic(); PopulateList(mPosition); Fit(); - - return; } void EditCurvesDialog::PopulateList(int position) @@ -3642,9 +3632,7 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event)) item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } - PopulateList(firstItem); // Note: only saved to file when you OK out of the dialog - return; -} + PopulateList(firstItem); } // Delete curve/curves void EditCurvesDialog::OnDelete(wxCommandEvent & WXUNUSED(event)) @@ -3765,9 +3753,7 @@ void EditCurvesDialog::OnImport( wxCommandEvent & WXUNUSED(event)) mEffect->LoadCurves(fileName, true); // use main interface to load imported curves mEditCurves = mEffect->mCurves; // copy back to this interface mEffect->mCurves = temp; // and reset the main interface how it was - PopulateList(0); // update the EditCurvesDialog dialog - return; -} + PopulateList(0); } void EditCurvesDialog::OnExport( wxCommandEvent & WXUNUSED(event)) { diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h index ad7dd4190e..e44067a2fb 100644 --- a/src/effects/Equalization.h +++ b/src/effects/Equalization.h @@ -97,9 +97,9 @@ class EffectEqualization : public Effect, public: static const ComponentInterfaceSymbol Symbol; - EffectEqualization(int Options = kEqLegacy); + explicit EffectEqualization(int Options = kEqLegacy); - virtual ~EffectEqualization(); + ~EffectEqualization() override; // ComponentInterface implementation @@ -138,7 +138,7 @@ class EffectEqualization : public Effect, private: // EffectEqualization implementation - wxString GetPrefsPrefix(); + [[nodiscard]] wxString GetPrefsPrefix() const; // Number of samples in an FFT window static const size_t windowSize = 16384u; //MJS - work out the optimum for this at run time? Have a dialog box for it? @@ -156,7 +156,7 @@ class EffectEqualization : public Effect, void ForceRecalc(); void EnvelopeUpdated(); void EnvelopeUpdated(Envelope *env, bool lin); - bool IsLinear(); + [[nodiscard]] bool IsLinear() const; void LoadCurves(const wxString &fileName = {}, bool append = false); void SaveCurves(const wxString &fileName = {}); @@ -165,8 +165,8 @@ class EffectEqualization : public Effect, void Select(int sel); void setCurve(int currentCurve); void setCurve(const wxString &curveName); - void setCurve(void); - bool GetDefaultFileName(wxFileName &fileName); + void setCurve(); + static bool GetDefaultFileName(wxFileName &fileName); // XMLTagHandler callback methods for loading and saving bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override; @@ -177,13 +177,13 @@ class EffectEqualization : public Effect, void UpdateDraw(); //void LayoutEQSliders(); - void UpdateGraphic(void); - void EnvLogToLin(void); - void EnvLinToLog(void); - void ErrMin(void); + void UpdateGraphic(); + void EnvLogToLin(); + void EnvLinToLog(); + void ErrMin(); void GraphicEQ(Envelope *env); - void spline(double x[], double y[], size_t n, double y2[]); - double splint(double x[], double y[], size_t n, double y2[], double xr); + static void spline(const double x[], const double y[], size_t n, double y2[]); + static double splint(const double x[], const double y[], size_t n, const double y2[], double xr); void OnErase( wxEvent &event ); void OnSize( wxSizeEvent & event ); @@ -304,12 +304,12 @@ class EqualizationPanel final : public wxPanelWrapper public: EqualizationPanel( wxWindow *parent, wxWindowID winid, EffectEqualization *effect); - ~EqualizationPanel(); + ~EqualizationPanel() override; // We don't need or want to accept focus. - bool AcceptsFocus() const { return false; } + [[nodiscard]] bool AcceptsFocus() const override { return false; } // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581 - bool AcceptsFocusFromKeyboard() const { return false; } + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override { return false; } void ForceRecalc(); @@ -355,7 +355,7 @@ class EditCurvesDialog final : public wxDialogWrapper { public: EditCurvesDialog(wxWindow * parent, EffectEqualization * effect, int position); - ~EditCurvesDialog(); + ~EditCurvesDialog() override; private: diff --git a/src/effects/Fade.cpp b/src/effects/Fade.cpp index 38a48fb116..16bc4b0a23 100644 --- a/src/effects/Fade.cpp +++ b/src/effects/Fade.cpp @@ -36,8 +36,7 @@ EffectFade::EffectFade(bool fadeIn) } EffectFade::~EffectFade() -{ -} += default; // ComponentInterface implementation diff --git a/src/effects/Fade.h b/src/effects/Fade.h index 526fbcdfbf..e615b3132b 100644 --- a/src/effects/Fade.h +++ b/src/effects/Fade.h @@ -16,8 +16,8 @@ class EffectFade : public Effect { public: - EffectFade(bool fadeIn = false); - virtual ~EffectFade(); + explicit EffectFade(bool fadeIn = false); + ~EffectFade() override; // ComponentInterface implementation @@ -33,7 +33,7 @@ class EffectFade : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; private: diff --git a/src/effects/FindClipping.cpp b/src/effects/FindClipping.cpp index 960b4851c4..a76062fff3 100644 --- a/src/effects/FindClipping.cpp +++ b/src/effects/FindClipping.cpp @@ -54,8 +54,7 @@ EffectFindClipping::EffectFindClipping() } EffectFindClipping::~EffectFindClipping() -{ -} += default; // ComponentInterface implementation diff --git a/src/effects/FindClipping.h b/src/effects/FindClipping.h index 88bab70801..a24e612602 100644 --- a/src/effects/FindClipping.h +++ b/src/effects/FindClipping.h @@ -24,7 +24,7 @@ class EffectFindClipping final : public Effect static const ComponentInterfaceSymbol Symbol; EffectFindClipping(); - virtual ~EffectFindClipping(); + ~EffectFindClipping() override; // ComponentInterface implementation diff --git a/src/effects/Generator.h b/src/effects/Generator.h index 52ea162de8..f52db81cd0 100644 --- a/src/effects/Generator.h +++ b/src/effects/Generator.h @@ -24,7 +24,7 @@ class Generator /* not final */ : public Effect { public: - Generator() { } + Generator() = default; protected: // [ GenerateTrack() must be overridden by the actual generator class ] @@ -58,7 +58,7 @@ class Generator /* not final */ : public Effect // showing a progress bar class BlockGenerator /* not final */ : public Generator { public: - BlockGenerator() { } + BlockGenerator() = default; protected: // Number of samples to generate sampleCount numSamples; diff --git a/src/effects/Invert.cpp b/src/effects/Invert.cpp index a66eed76b1..0e0677c080 100644 --- a/src/effects/Invert.cpp +++ b/src/effects/Invert.cpp @@ -27,12 +27,10 @@ const ComponentInterfaceSymbol EffectInvert::Symbol namespace{ BuiltinEffectsModule::Registration< EffectInvert > reg; } EffectInvert::EffectInvert() -{ -} += default; EffectInvert::~EffectInvert() -{ -} += default; // ComponentInterface implementation diff --git a/src/effects/Invert.h b/src/effects/Invert.h index 00dfbdfa78..9a4f3cd750 100644 --- a/src/effects/Invert.h +++ b/src/effects/Invert.h @@ -21,7 +21,7 @@ class EffectInvert final : public Effect static const ComponentInterfaceSymbol Symbol; EffectInvert(); - virtual ~EffectInvert(); + ~EffectInvert() override; // ComponentInterface implementation diff --git a/src/effects/LoadEffects.cpp b/src/effects/LoadEffects.cpp index 447021b0b5..166d0b8727 100644 --- a/src/effects/LoadEffects.cpp +++ b/src/effects/LoadEffects.cpp @@ -69,12 +69,10 @@ DECLARE_BUILTIN_MODULE(BuiltinsEffectBuiltin); /////////////////////////////////////////////////////////////////////////////// BuiltinEffectsModule::BuiltinEffectsModule() -{ -} += default; BuiltinEffectsModule::~BuiltinEffectsModule() -{ -} += default; // ============================================================================ // ComponentInterface implementation @@ -123,8 +121,7 @@ bool BuiltinEffectsModule::Initialize() void BuiltinEffectsModule::Terminate() { // Nothing to do here - return; -} + } EffectFamilySymbol BuiltinEffectsModule::GetOptionalFamilySymbol() { diff --git a/src/effects/LoadEffects.h b/src/effects/LoadEffects.h index 13b7a2339b..d693a11c46 100644 --- a/src/effects/LoadEffects.h +++ b/src/effects/LoadEffects.h @@ -30,14 +30,14 @@ class SAUCEDACITY_DLL_API BuiltinEffectsModule final : public ModuleInterface { public: BuiltinEffectsModule(); - virtual ~BuiltinEffectsModule(); + ~BuiltinEffectsModule() override; using Factory = std::function< std::unique_ptr () >; // Typically you make a static object of this type in the .cpp file that // also implements the Effect subclass. template< typename Subclass > - struct Registration final { Registration( bool excluded = false ) { + struct Registration final { explicit Registration( bool excluded = false ) { DoRegistration( Subclass::Symbol, []{ return std::make_unique< Subclass >(); }, excluded ); diff --git a/src/effects/Loudness.cpp b/src/effects/Loudness.cpp index b6ad2d3633..f711957205 100644 --- a/src/effects/Loudness.cpp +++ b/src/effects/Loudness.cpp @@ -18,6 +18,7 @@ #include "Loudness.h" #include +#include #include #include @@ -78,8 +79,7 @@ EffectLoudness::EffectLoudness() } EffectLoudness::~EffectLoudness() -{ -} += default; // ComponentInterface implementation @@ -218,7 +218,7 @@ bool EffectLoudness::Process() if(mNormalizeTo == kLoudness) { - mLoudnessProcessor.reset(safenew EBUR128(mCurRate, range.size())); + mLoudnessProcessor = std::make_unique(mCurRate, range.size()); mLoudnessProcessor->Initialize(); if(!ProcessOne(range, true)) { @@ -441,7 +441,7 @@ void EffectLoudness::FreeBuffers() mTrackBuffer[1].reset(); } -bool EffectLoudness::GetTrackRMS(WaveTrack* track, float& rms) +bool EffectLoudness::GetTrackRMS(WaveTrack* track, float& rms) const { // set mRMS. No progress bar here as it's fast. float _rms = track->GetRMS(mCurT0, mCurT1); // may throw @@ -455,7 +455,7 @@ bool EffectLoudness::GetTrackRMS(WaveTrack* track, float& rms) /// mMult must be set before this is called /// In analyse mode, it executes the selected analyse operation on it... /// mMult does not have to be set before this is called -bool EffectLoudness::ProcessOne(TrackIterRange range, bool analyse) +bool EffectLoudness::ProcessOne(const TrackIterRange& range, bool analyse) { WaveTrack* track = *range.begin(); @@ -508,7 +508,7 @@ bool EffectLoudness::ProcessOne(TrackIterRange range, bool analyse) return true; } -void EffectLoudness::LoadBufferBlock(TrackIterRange range, +void EffectLoudness::LoadBufferBlock(const TrackIterRange& range, sampleCount pos, size_t len) { // Get the samples from the track and put them in the buffer @@ -552,7 +552,7 @@ bool EffectLoudness::ProcessBufferBlock() return true; } -void EffectLoudness::StoreBufferBlock(TrackIterRange range, +void EffectLoudness::StoreBufferBlock(const TrackIterRange& range, sampleCount pos, size_t len) { int idx = 0; diff --git a/src/effects/Loudness.h b/src/effects/Loudness.h index a7e1bdd7f3..57b3b5bcf1 100644 --- a/src/effects/Loudness.h +++ b/src/effects/Loudness.h @@ -32,7 +32,7 @@ class EffectLoudness final : public Effect static const ComponentInterfaceSymbol Symbol; EffectLoudness(); - virtual ~EffectLoudness(); + ~EffectLoudness() override; // ComponentInterface implementation @@ -64,13 +64,13 @@ class EffectLoudness final : public Effect void AllocBuffers(); void FreeBuffers(); - bool GetTrackRMS(WaveTrack* track, float& rms); - bool ProcessOne(TrackIterRange range, bool analyse); - void LoadBufferBlock(TrackIterRange range, + bool GetTrackRMS(WaveTrack* track, float& rms) const; + bool ProcessOne(const TrackIterRange& range, bool analyse); + void LoadBufferBlock(const TrackIterRange& range, sampleCount pos, size_t len); bool AnalyseBufferBlock(); bool ProcessBufferBlock(); - void StoreBufferBlock(TrackIterRange range, + void StoreBufferBlock(const TrackIterRange& range, sampleCount pos, size_t len); bool UpdateProgress(); diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index a4c84a67b0..c2ee1f5191 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -78,8 +78,7 @@ EffectNoise::EffectNoise() } EffectNoise::~EffectNoise() -{ -} += default; // ComponentInterface implementation diff --git a/src/effects/Noise.h b/src/effects/Noise.h index 77f424bb61..1c1f6866a4 100644 --- a/src/effects/Noise.h +++ b/src/effects/Noise.h @@ -24,7 +24,7 @@ class EffectNoise final : public Effect static const ComponentInterfaceSymbol Symbol; EffectNoise(); - virtual ~EffectNoise(); + ~EffectNoise() override; // ComponentInterface implementation diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index afdd41164e..f50b35b9d9 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -55,6 +55,7 @@ #include "../widgets/valnum.h" #include +#include #include #include @@ -209,15 +210,15 @@ class EffectNoiseReduction::Settings { public: Settings(); - ~Settings() {} + ~Settings() = default; bool PromptUser(EffectNoiseReduction *effect, wxWindow &parent, bool bHasProfile, bool bAllowTwiddleSettings); bool PrefsIO(bool read); bool Validate(EffectNoiseReduction *effect) const; - size_t WindowSize() const { return 1u << (3 + mWindowSizeChoice); } - unsigned StepsPerWindow() const { return 1u << (1 + mStepsPerWindowChoice); } + [[nodiscard]] size_t WindowSize() const { return 1u << (3 + mWindowSizeChoice); } + [[nodiscard]] unsigned StepsPerWindow() const { return 1u << (1 + mStepsPerWindowChoice); } bool mDoProfile; @@ -287,7 +288,7 @@ class EffectNoiseReduction::Worker inline bool Classify(const Statistics &statistics, int band); void ReduceNoise(const Statistics &statistics, WaveTrack *outputTrack); void RotateHistoryWindows(); - void FinishTrackStatistics(Statistics &statistics); + static void FinishTrackStatistics(Statistics &statistics); void FinishTrack(Statistics &statistics, WaveTrack *outputTrack); private: @@ -335,7 +336,7 @@ class EffectNoiseReduction::Worker struct Record { - Record(size_t spectrumSize) + explicit Record(size_t spectrumSize) : mSpectrums(spectrumSize) , mGains(spectrumSize) , mRealFFTs(spectrumSize - 1) @@ -376,7 +377,7 @@ class EffectNoiseReduction::Dialog final : public EffectDialog bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - const Settings &GetTempSettings() const + [[nodiscard]] const Settings &GetTempSettings() const { return mTempSettings; } private: @@ -434,8 +435,7 @@ EffectNoiseReduction::EffectNoiseReduction() } EffectNoiseReduction::~EffectNoiseReduction() -{ -} += default; // ComponentInterface implementation @@ -665,8 +665,7 @@ bool EffectNoiseReduction::Process() } EffectNoiseReduction::Worker::~Worker() -{ -} += default; bool EffectNoiseReduction::Worker::Process (EffectNoiseReduction &effect, Statistics &statistics, WaveTrackFactory &factory, @@ -968,7 +967,7 @@ void EffectNoiseReduction::Worker::ProcessSamples void EffectNoiseReduction::Worker::FillFirstHistoryWindow() { // Transform samples to frequency domain, windowed as needed - if (mInWindow.size() > 0) + if (!mInWindow.empty()) for (size_t ii = 0; ii < mWindowSize; ++ii) mFFTBuffer[ii] = mInWaveBuffer[ii] * mInWindow[ii]; else @@ -1274,7 +1273,7 @@ void EffectNoiseReduction::Worker::ReduceNoise InverseRealFFTf(&mFFTBuffer[0], hFFT.get()); // Overlap-add - if (mOutWindow.size() > 0) { + if (!mOutWindow.empty()) { float *pOut = &mOutOverlapBuffer[0]; float *pWindow = &mOutWindow[0]; int *pBitReversed = &hFFT->BitReversed[0]; @@ -1310,7 +1309,7 @@ bool EffectNoiseReduction::Worker::ProcessOne (EffectNoiseReduction &effect, Statistics &statistics, WaveTrackFactory &factory, int count, WaveTrack * track, sampleCount start, sampleCount len) { - if (track == NULL) + if (track == nullptr) return false; StartNewTrack(); @@ -1424,21 +1423,21 @@ namespace { struct ControlInfo { typedef double (EffectNoiseReduction::Settings::*MemberPointer); - double Value(long sliderSetting) const + [[nodiscard]] double Value(long sliderSetting) const { return valueMin + (double(sliderSetting) / sliderMax) * (valueMax - valueMin); } - long SliderSetting(double value) const + [[nodiscard]] long SliderSetting(double value) const { return TrapLong( 0.5 + sliderMax * (value - valueMin) / (valueMax - valueMin), 0, sliderMax); } - wxString Text(double value) const + [[nodiscard]] wxString Text(double value) const { if (formatAsInt) return wxString::Format(format, (int)(value)); @@ -1476,9 +1475,9 @@ struct ControlInfo { const TranslatableString sliderName; ControlInfo(MemberPointer f, double vMin, double vMax, long sMax, const wxChar* fmt, bool fAsInt, - const TranslatableString &caption, const TranslatableString &name) + TranslatableString caption, TranslatableString name) : field(f), valueMin(vMin), valueMax(vMax), sliderMax(sMax), format(fmt), formatAsInt(fAsInt) - , textBoxCaption(caption), sliderName(name) + , textBoxCaption(std::move(caption)), sliderName(std::move(name)) { } }; @@ -1571,19 +1570,19 @@ EffectNoiseReduction::Dialog::Dialog , mbHasProfile(bHasProfile) , mbAllowTwiddleSettings(bAllowTwiddleSettings) // NULL out the control members until the controls are created. - , mKeepSignal(NULL) + , mKeepSignal(nullptr) #ifdef ISOLATE_CHOICE , mKeepNoise(NULL) #endif #ifdef RESIDUE_CHOICE - , mResidue(NULL) + , mResidue(nullptr) #endif { EffectDialog::Init(); - wxButton *const pButtonPreview = + auto *const pButtonPreview = (wxButton *)wxWindow::FindWindowById(ID_EFFECT_PREVIEW, this); - wxButton *const pButtonReduceNoise = + auto *const pButtonReduceNoise = (wxButton *)wxWindow::FindWindowById(wxID_OK, this); if (mbHasProfile || mbAllowTwiddleSettings) { @@ -1852,10 +1851,10 @@ bool EffectNoiseReduction::Dialog::TransferDataToWindow() return false; for (int id = FIRST_SLIDER; id < END_OF_SLIDERS; id += 2) { - wxSlider* slider = - static_cast(wxWindow::FindWindowById(id, this)); - wxTextCtrl* text = - static_cast(wxWindow::FindWindowById(id + 1, this)); + auto* slider = + dynamic_cast(wxWindow::FindWindowById(id, this)); + auto* text = + dynamic_cast(wxWindow::FindWindowById(id + 1, this)); const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2]; const double field = mTempSettings.*(info.field); text->SetValue(info.Text(field)); @@ -1898,10 +1897,10 @@ void EffectNoiseReduction::Dialog::OnText(wxCommandEvent &event) int id = event.GetId(); int idx = (id - FIRST_SLIDER - 1) / 2; const ControlInfo &info = controlInfo()[idx]; - wxTextCtrl* text = - static_cast(wxWindow::FindWindowById(id, this)); - wxSlider* slider = - static_cast(wxWindow::FindWindowById(id - 1, this)); + auto* text = + dynamic_cast(wxWindow::FindWindowById(id, this)); + auto* slider = + dynamic_cast(wxWindow::FindWindowById(id - 1, this)); double &field = mTempSettings.*(info.field); text->GetValue().ToDouble(&field); @@ -1913,10 +1912,10 @@ void EffectNoiseReduction::Dialog::OnSlider(wxCommandEvent &event) int id = event.GetId(); int idx = (id - FIRST_SLIDER) / 2; const ControlInfo &info = controlInfo()[idx]; - wxSlider* slider = - static_cast(wxWindow::FindWindowById(id, this)); - wxTextCtrl* text = - static_cast(wxWindow::FindWindowById(id + 1, this)); + auto* slider = + dynamic_cast(wxWindow::FindWindowById(id, this)); + auto* text = + dynamic_cast(wxWindow::FindWindowById(id + 1, this)); double &field = mTempSettings.*(info.field); field = info.Value(slider->GetValue()); diff --git a/src/effects/NoiseReduction.h b/src/effects/NoiseReduction.h index 53f1fff9aa..3228660f98 100644 --- a/src/effects/NoiseReduction.h +++ b/src/effects/NoiseReduction.h @@ -20,7 +20,7 @@ class EffectNoiseReduction final : public Effect { static const ComponentInterfaceSymbol Symbol; EffectNoiseReduction(); - virtual ~EffectNoiseReduction(); + ~EffectNoiseReduction() override; using Effect::TrackProgress; diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index 6fbab8a0a4..c951ea1bd1 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -65,8 +65,7 @@ EffectNormalize::EffectNormalize() } EffectNormalize::~EffectNormalize() -{ -} += default; // ComponentInterface implementation @@ -522,13 +521,13 @@ bool EffectNormalize::ProcessOne( } /// @see AnalyseDataLoudnessDC -void EffectNormalize::AnalyseDataDC(float *buffer, size_t len) +void EffectNormalize::AnalyseDataDC(const float *buffer, size_t len) { for(decltype(len) i = 0; i < len; i++) mSum += (double)buffer[i]; } -void EffectNormalize::ProcessData(float *buffer, size_t len, float offset) +void EffectNormalize::ProcessData(float *buffer, size_t len, float offset) const { for(decltype(len) i = 0; i < len; i++) { float adjFrame = (buffer[i] + offset) * mMult; diff --git a/src/effects/Normalize.h b/src/effects/Normalize.h index 554667a29f..d7b2b1e47e 100644 --- a/src/effects/Normalize.h +++ b/src/effects/Normalize.h @@ -26,7 +26,7 @@ class EffectNormalize final : public Effect static const ComponentInterfaceSymbol Symbol; EffectNormalize(); - virtual ~EffectNormalize(); + ~EffectNormalize() override; // ComponentInterface implementation @@ -62,8 +62,8 @@ class EffectNormalize final : public Effect double &progress, float &offset, float &extent); bool AnalyseTrackData(const WaveTrack * track, const TranslatableString &msg, double &progress, float &offset); - void AnalyseDataDC(float *buffer, size_t len); - void ProcessData(float *buffer, size_t len, float offset); + void AnalyseDataDC(const float *buffer, size_t len); + void ProcessData(float *buffer, size_t len, float offset) const; void OnUpdateUI(wxCommandEvent & evt); void UpdateUI(); diff --git a/src/effects/Paulstretch.cpp b/src/effects/Paulstretch.cpp index 011e69ccb5..08b0afa78f 100644 --- a/src/effects/Paulstretch.cpp +++ b/src/effects/Paulstretch.cpp @@ -52,10 +52,10 @@ class PaulStretch //in_bufsize is also a half of a FFT buffer (in samples) virtual ~PaulStretch(); - void process(float *smps, size_t nsmps); + void process(const float *smps, size_t nsmps); size_t get_nsamples();//how many samples are required to be added in the pool next time - size_t get_nsamples_for_fill();//how many samples are required to be added for a complete buffer refill (at start of the song or after seek) + [[nodiscard]] size_t get_nsamples_for_fill() const;//how many samples are required to be added for a complete buffer refill (at start of the song or after seek) private: void process_spectrum(float *WXUNUSED(freq)) {}; @@ -104,8 +104,7 @@ EffectPaulstretch::EffectPaulstretch() } EffectPaulstretch::~EffectPaulstretch() -{ -} += default; // ComponentInterface implementation @@ -244,7 +243,7 @@ void EffectPaulstretch::OnText(wxCommandEvent & WXUNUSED(evt)) EnableApply(mUIParent->TransferDataFromWindow()); } -size_t EffectPaulstretch::GetBufferSize(double rate) +size_t EffectPaulstretch::GetBufferSize(double rate) const { // Audacity's fft requires a power of 2 float tmp = rate * mTime_resolution / 2.0; @@ -440,13 +439,12 @@ PaulStretch::PaulStretch(float rap_, size_t in_bufsize_, float samplerate_ ) } PaulStretch::~PaulStretch() -{ -} += default; -void PaulStretch::process(float *smps, size_t nsmps) +void PaulStretch::process(const float *smps, size_t nsmps) { //add NEW samples to the pool - if ((smps != NULL) && (nsmps != 0)) { + if ((smps != nullptr) && (nsmps != 0)) { if (nsmps > poolsize) { nsmps = poolsize; } @@ -539,7 +537,7 @@ size_t PaulStretch::get_nsamples() return ri; } -size_t PaulStretch::get_nsamples_for_fill() +size_t PaulStretch::get_nsamples_for_fill() const { return poolsize; } diff --git a/src/effects/Paulstretch.h b/src/effects/Paulstretch.h index 8e20a7aad0..2e55db274d 100644 --- a/src/effects/Paulstretch.h +++ b/src/effects/Paulstretch.h @@ -20,7 +20,7 @@ class EffectPaulstretch final : public Effect static const ComponentInterfaceSymbol Symbol; EffectPaulstretch(); - virtual ~EffectPaulstretch(); + ~EffectPaulstretch() override; // ComponentInterface implementation @@ -50,7 +50,7 @@ class EffectPaulstretch final : public Effect // EffectPaulstretch implementation void OnText(wxCommandEvent & evt); - size_t GetBufferSize(double rate); + [[nodiscard]] size_t GetBufferSize(double rate) const; bool ProcessOne(WaveTrack *track, double t0, double t1, int count); diff --git a/src/effects/Phaser.cpp b/src/effects/Phaser.cpp index 1a21b96d54..09881b41cf 100644 --- a/src/effects/Phaser.cpp +++ b/src/effects/Phaser.cpp @@ -100,8 +100,7 @@ EffectPhaser::EffectPhaser() } EffectPhaser::~EffectPhaser() -{ -} += default; // ComponentInterface implementation @@ -379,7 +378,7 @@ bool EffectPhaser::TransferDataFromWindow() // EffectPhaser implementation -void EffectPhaser::InstanceInit(EffectPhaserState & data, float sampleRate) +void EffectPhaser::InstanceInit(EffectPhaserState & data, float sampleRate) const { data.samplerate = sampleRate; @@ -393,11 +392,9 @@ void EffectPhaser::InstanceInit(EffectPhaserState & data, float sampleRate) data.fbout = 0; data.laststages = 0; data.outgain = 0; - - return; } -size_t EffectPhaser::InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, size_t blockLen) +size_t EffectPhaser::InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, size_t blockLen) const { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Phaser.h b/src/effects/Phaser.h index dded23ff19..1b8e99f101 100644 --- a/src/effects/Phaser.h +++ b/src/effects/Phaser.h @@ -45,7 +45,7 @@ class EffectPhaser final : public Effect static const ComponentInterfaceSymbol Symbol; EffectPhaser(); - virtual ~EffectPhaser(); + ~EffectPhaser() override; // ComponentInterface implementation @@ -62,7 +62,7 @@ class EffectPhaser final : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -84,8 +84,8 @@ class EffectPhaser final : public Effect private: // EffectPhaser implementation - void InstanceInit(EffectPhaserState & data, float sampleRate); - size_t InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, size_t blockLen); + void InstanceInit(EffectPhaserState & data, float sampleRate) const; + size_t InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, size_t blockLen) const; void OnStagesSlider(wxCommandEvent & evt); void OnDryWetSlider(wxCommandEvent & evt); diff --git a/src/effects/RealtimeEffectManager.cpp b/src/effects/RealtimeEffectManager.cpp index 122a904b72..7f16783255 100644 --- a/src/effects/RealtimeEffectManager.cpp +++ b/src/effects/RealtimeEffectManager.cpp @@ -24,7 +24,7 @@ class RealtimeEffectState public: explicit RealtimeEffectState( EffectClientInterface &effect ); - EffectClientInterface &GetEffect() const { return mEffect; } + [[nodiscard]] EffectClientInterface &GetEffect() const { return mEffect; } bool RealtimeSuspend(); bool RealtimeResume(); @@ -64,8 +64,7 @@ RealtimeEffectManager::RealtimeEffectManager() } RealtimeEffectManager::~RealtimeEffectManager() -{ -} += default; #if defined(EXPERIMENTAL_EFFECTS_RACK) void RealtimeEffectManager::RealtimeSetEffects(const EffectArray & effects) @@ -110,10 +109,10 @@ void RealtimeEffectManager::RealtimeSetEffects(const EffectArray & effects) bool RealtimeEffectManager::RealtimeIsActive() { - return mStates.size() != 0; + return !mStates.empty(); } -bool RealtimeEffectManager::RealtimeIsSuspended() +bool RealtimeEffectManager::RealtimeIsSuspended() const { return mRealtimeSuspended; } diff --git a/src/effects/RealtimeEffectManager.h b/src/effects/RealtimeEffectManager.h index 81a4ed7914..01dd582345 100644 --- a/src/effects/RealtimeEffectManager.h +++ b/src/effects/RealtimeEffectManager.h @@ -29,7 +29,7 @@ class SAUCEDACITY_DLL_API RealtimeEffectManager final // Realtime effect processing bool RealtimeIsActive(); - bool RealtimeIsSuspended(); + [[nodiscard]] bool RealtimeIsSuspended() const; void RealtimeAddEffect(EffectClientInterface *effect); void RealtimeRemoveEffect(EffectClientInterface *effect); void RealtimeSetEffects(const EffectArray & mActive); diff --git a/src/effects/Repair.cpp b/src/effects/Repair.cpp index 1918da15f7..e89614c382 100644 --- a/src/effects/Repair.cpp +++ b/src/effects/Repair.cpp @@ -42,12 +42,10 @@ const ComponentInterfaceSymbol EffectRepair::Symbol namespace{ BuiltinEffectsModule::Registration< EffectRepair > reg; } EffectRepair::EffectRepair() -{ -} += default; EffectRepair::~EffectRepair() -{ -} += default; // ComponentInterface implementation diff --git a/src/effects/Repair.h b/src/effects/Repair.h index 5d69664f05..fe3e562eed 100644 --- a/src/effects/Repair.h +++ b/src/effects/Repair.h @@ -21,7 +21,7 @@ class EffectRepair final : public Effect static const ComponentInterfaceSymbol Symbol; EffectRepair(); - virtual ~EffectRepair(); + ~EffectRepair() override; // ComponentInterface implementation diff --git a/src/effects/Repeat.cpp b/src/effects/Repeat.cpp index de703fa686..a4b4971458 100644 --- a/src/effects/Repeat.cpp +++ b/src/effects/Repeat.cpp @@ -60,8 +60,7 @@ EffectRepeat::EffectRepeat() } EffectRepeat::~EffectRepeat() -{ -} += default; // ComponentInterface implementation diff --git a/src/effects/Repeat.h b/src/effects/Repeat.h index 0e1b940c90..b6335ff492 100644 --- a/src/effects/Repeat.h +++ b/src/effects/Repeat.h @@ -24,7 +24,7 @@ class EffectRepeat final : public Effect static const ComponentInterfaceSymbol Symbol; EffectRepeat(); - virtual ~EffectRepeat(); + ~EffectRepeat() override; // ComponentInterface implementation diff --git a/src/effects/Reverb.cpp b/src/effects/Reverb.cpp index 18ad7ad5b7..aa1ca0cde9 100644 --- a/src/effects/Reverb.cpp +++ b/src/effects/Reverb.cpp @@ -136,8 +136,7 @@ EffectReverb::EffectReverb() } EffectReverb::~EffectReverb() -{ -} += default; // ComponentInterface implementation @@ -222,8 +221,8 @@ bool EffectReverb::ProcessFinalize() size_t EffectReverb::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { - float *ichans[2] = {NULL, NULL}; - float *ochans[2] = {NULL, NULL}; + float *ichans[2] = {nullptr, nullptr}; + float *ochans[2] = {nullptr, nullptr}; for (unsigned int c = 0; c < mNumChans; c++) { @@ -341,9 +340,9 @@ RegistryPaths EffectReverb::GetFactoryPresets() { RegistryPaths names; - for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) + for (const auto & FactoryPreset : FactoryPresets) { - names.push_back( FactoryPresets[i].name.Translation() ); + names.push_back( FactoryPreset.name.Translation() ); } return names; @@ -473,8 +472,6 @@ void EffectReverb::PopulateOrExchange(ShuttleGui & S) AddCheckBox(XXO("Wet O&nly"), DEF_WetOnly); } S.EndHorizontalLay(); - - return; } bool EffectReverb::TransferDataToWindow() diff --git a/src/effects/Reverb.h b/src/effects/Reverb.h index 0accfc8311..d21dffddcc 100644 --- a/src/effects/Reverb.h +++ b/src/effects/Reverb.h @@ -27,7 +27,7 @@ class EffectReverb final : public Effect static const ComponentInterfaceSymbol Symbol; EffectReverb(); - virtual ~EffectReverb(); + ~EffectReverb() override; struct Params { @@ -57,7 +57,7 @@ class EffectReverb final : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; bool ProcessFinalize() override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool DefineParams( ShuttleParams & S ) override; diff --git a/src/effects/Reverb_libSoX.h b/src/effects/Reverb_libSoX.h index 509475cbb7..c852e51e23 100644 --- a/src/effects/Reverb_libSoX.h +++ b/src/effects/Reverb_libSoX.h @@ -23,13 +23,13 @@ using std::min; using std::max; -#define array_length(a) (sizeof(a)/sizeof(a[0])) +#define array_length(a) (sizeof(a)/sizeof((a)[0])) #define dB_to_linear(x) exp((x) * M_LN10 * 0.05) #define midi_to_freq(n) (440 * pow(2,((n)-69)/12.)) #define FIFO_SIZE_T size_t #define FIFO_MIN 0x4000 #define fifo_read_ptr(f) fifo_read(f, (FIFO_SIZE_T)0, NULL) -#define lsx_zalloc(var, n) var = (float *)calloc(n, sizeof(*var)) +#define lsx_zalloc(var, n) var = (float *)calloc(n, sizeof(*(var))) #define filter_advance(p) if (--(p)->ptr < (p)->buffer) (p)->ptr += (p)->size #define filter_delete(p) free((p)->buffer) @@ -53,7 +53,7 @@ static void * fifo_reserve(fifo_t * f, FIFO_SIZE_T n) if (f->begin == f->end) fifo_clear(f); - while (1) { + while (true) { if (f->end + n <= f->allocation) { void *p = f->data + f->end; @@ -84,7 +84,7 @@ static void * fifo_read(fifo_t * f, FIFO_SIZE_T n, void * data) char * ret = f->data + f->begin; n *= f->item_size; if (n > (FIFO_SIZE_T)(f->end - f->begin)) - return NULL; + return nullptr; if (data) memcpy(data, ret, (size_t)n); f->begin += n; @@ -243,7 +243,7 @@ static void reverb_create(reverb_t * p, double sample_rate_Hz, p->hf_damping = hf_damping / 100 * .3 + .2; p->gain = dB_to_linear(wet_gain_dB) * .015; fifo_create(&p->input_fifo, sizeof(float)); - memset(fifo_write(&p->input_fifo, delay, 0), 0, delay * sizeof(float)); + memset(fifo_write(&p->input_fifo, delay, nullptr), 0, delay * sizeof(float)); for (i = 0; i <= ceil(depth); ++i) { filter_array_create(p->chan + i, sample_rate_Hz, scale, i * depth, fc_highpass, fc_lowpass); out[i] = lsx_zalloc(p->out[i], buffer_size); @@ -255,7 +255,7 @@ static void reverb_process(reverb_t * p, size_t length) size_t i; for (i = 0; i < 2 && p->out[i]; ++i) filter_array_process(p->chan + i, length, (float *) fifo_read_ptr(&p->input_fifo), p->out[i], &p->feedback, &p->hf_damping, &p->gain); - fifo_read(&p->input_fifo, length, NULL); + fifo_read(&p->input_fifo, length, nullptr); } static void reverb_delete(reverb_t * p) diff --git a/src/effects/Reverse.cpp b/src/effects/Reverse.cpp index 8a90ebfa4a..db2f5831d4 100644 --- a/src/effects/Reverse.cpp +++ b/src/effects/Reverse.cpp @@ -36,12 +36,10 @@ const ComponentInterfaceSymbol EffectReverse::Symbol namespace{ BuiltinEffectsModule::Registration< EffectReverse > reg; } EffectReverse::EffectReverse() -{ -} += default; EffectReverse::~EffectReverse() -{ -} += default; // ComponentInterface implementation @@ -111,8 +109,8 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta // perform a split at the start and/or end of the reverse selection const auto &clips = track->GetClips(); // Beware, the array grows as we loop over it. Use integer subscripts, not iterators. - for (size_t ii = 0; ii < clips.size(); ++ii) { - const auto &clip = clips[ii].get(); + for (const auto & ii : clips) { + const auto &clip = ii.get(); auto clipStart = clip->GetPlayStartSample(); auto clipEnd = clip->GetPlayEndSample(); if (clipStart < start && clipEnd > start && clipEnd <= end) { // the reverse selection begins at the inside of a clip diff --git a/src/effects/Reverse.h b/src/effects/Reverse.h index 29018355a3..188823a77d 100644 --- a/src/effects/Reverse.h +++ b/src/effects/Reverse.h @@ -21,7 +21,7 @@ class EffectReverse final : public Effect static const ComponentInterfaceSymbol Symbol; EffectReverse(); - virtual ~EffectReverse(); + ~EffectReverse() override; // ComponentInterface implementation diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 00c2562592..85dad3f744 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -178,8 +178,7 @@ EffectScienFilter::EffectScienFilter() } EffectScienFilter::~EffectScienFilter() -{ -} += default; // ComponentInterface implementation @@ -537,8 +536,6 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) S.AddSpace(1, 1); } S.EndMultiColumn(); - - return; } // @@ -829,7 +826,7 @@ EffectScienFilterPanel::EffectScienFilterPanel( mEffect = effect; mParent = parent; - mBitmap = NULL; + mBitmap = nullptr; mWidth = 0; mHeight = 0; mLoFreq = 0.0; @@ -841,8 +838,7 @@ EffectScienFilterPanel::EffectScienFilterPanel( } EffectScienFilterPanel::~EffectScienFilterPanel() -{ -} += default; void EffectScienFilterPanel::SetFreqRange(double lo, double hi) { diff --git a/src/effects/ScienFilter.h b/src/effects/ScienFilter.h index 7ba8406656..81cf96103c 100644 --- a/src/effects/ScienFilter.h +++ b/src/effects/ScienFilter.h @@ -35,7 +35,7 @@ class EffectScienFilter final : public Effect static const ComponentInterfaceSymbol Symbol; EffectScienFilter(); - virtual ~EffectScienFilter(); + ~EffectScienFilter() override; // ComponentInterface implementation @@ -51,7 +51,7 @@ class EffectScienFilter final : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool DefineParams( ShuttleParams & S ) override; bool GetAutomationParameters(CommandParameters & parms) override; @@ -135,12 +135,12 @@ class EffectScienFilterPanel final : public wxPanelWrapper EffectScienFilterPanel( wxWindow *parent, wxWindowID winid, EffectScienFilter *effect, double lo, double hi); - virtual ~EffectScienFilterPanel(); + ~EffectScienFilterPanel() override; // We don't need or want to accept focus. - bool AcceptsFocus() const; + [[nodiscard]] bool AcceptsFocus() const override; // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581 - bool AcceptsFocusFromKeyboard() const; + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override; void SetFreqRange(double lo, double hi); void SetDbRange(double min, double max); diff --git a/src/effects/Silence.cpp b/src/effects/Silence.cpp index 5c48567088..7339a9d6da 100644 --- a/src/effects/Silence.cpp +++ b/src/effects/Silence.cpp @@ -35,8 +35,7 @@ EffectSilence::EffectSilence() } EffectSilence::~EffectSilence() -{ -} += default; // ComponentInterface implementation @@ -87,8 +86,6 @@ void EffectSilence::PopulateOrExchange(ShuttleGui & S) S.EndHorizontalLay(); } S.EndVerticalLay(); - - return; } bool EffectSilence::TransferDataToWindow() diff --git a/src/effects/Silence.h b/src/effects/Silence.h index 7596a28ab3..1dea7962e6 100644 --- a/src/effects/Silence.h +++ b/src/effects/Silence.h @@ -23,7 +23,7 @@ class EffectSilence final : public Generator static const ComponentInterfaceSymbol Symbol; EffectSilence(); - virtual ~EffectSilence(); + ~EffectSilence() override; // ComponentInterface implementation diff --git a/src/effects/SoundTouchEffect.cpp b/src/effects/SoundTouchEffect.cpp index d397aa92df..e6f0efae5b 100644 --- a/src/effects/SoundTouchEffect.cpp +++ b/src/effects/SoundTouchEffect.cpp @@ -47,8 +47,7 @@ EffectSoundTouch::EffectSoundTouch() #endif EffectSoundTouch::~EffectSoundTouch() -{ -} += default; bool EffectSoundTouch::ProcessLabelTrack( LabelTrack *lt, const TimeWarper &warper) @@ -61,7 +60,7 @@ bool EffectSoundTouch::ProcessLabelTrack( } #ifdef USE_MIDI -bool EffectSoundTouch::ProcessNoteTrack(NoteTrack *nt, const TimeWarper &warper) +bool EffectSoundTouch::ProcessNoteTrack(NoteTrack *nt, const TimeWarper &warper) const { nt->WarpAndTransposeNotes(mCurT0, mCurT1, warper, mSemitones); return true; @@ -413,14 +412,14 @@ void EffectSoundTouch::Finalize(WaveTrack* orig, WaveTrack* out, const TimeWarpe if (st >= mCurT0 || et < mCurT1) { if (mCurT0 < st && clip == front) { - gaps.push_back(std::make_pair(mCurT0, st)); + gaps.emplace_back(mCurT0, st); } else if (last < st && mCurT0 <= last ) { - gaps.push_back(std::make_pair(last, st)); + gaps.emplace_back(last, st); } if (et < mCurT1 && clip == back) { - gaps.push_back(std::make_pair(et, mCurT1)); + gaps.emplace_back(et, mCurT1); } } last = et; diff --git a/src/effects/SoundTouchEffect.h b/src/effects/SoundTouchEffect.h index 81be775c22..6da042e575 100644 --- a/src/effects/SoundTouchEffect.h +++ b/src/effects/SoundTouchEffect.h @@ -58,9 +58,9 @@ class EffectSoundTouch /* not final */ : public Effect double mCurT1; private: - bool ProcessLabelTrack(LabelTrack *track, const TimeWarper &warper); + static bool ProcessLabelTrack(LabelTrack *track, const TimeWarper &warper); #ifdef USE_MIDI - bool ProcessNoteTrack(NoteTrack *track, const TimeWarper &warper); + bool ProcessNoteTrack(NoteTrack *track, const TimeWarper &warper) const; #endif bool ProcessOne( WaveTrack * t, sampleCount start, sampleCount end, @@ -68,7 +68,7 @@ class EffectSoundTouch /* not final */ : public Effect bool ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack, sampleCount start, sampleCount end, const TimeWarper &warper); - bool ProcessStereoResults(const size_t outputCount, + bool ProcessStereoResults(size_t outputCount, WaveTrack* outputLeftTrack, WaveTrack* outputRightTrack); void Finalize(WaveTrack* orig, WaveTrack* out, const TimeWarper &warper); diff --git a/src/effects/StereoToMono.cpp b/src/effects/StereoToMono.cpp index f745933dd5..57df81818e 100644 --- a/src/effects/StereoToMono.cpp +++ b/src/effects/StereoToMono.cpp @@ -30,12 +30,10 @@ const ComponentInterfaceSymbol EffectStereoToMono::Symbol namespace{ BuiltinEffectsModule::Registration< EffectStereoToMono > reg; } EffectStereoToMono::EffectStereoToMono() -{ -} += default; EffectStereoToMono::~EffectStereoToMono() -{ -} += default; // ComponentInterface implementation diff --git a/src/effects/StereoToMono.h b/src/effects/StereoToMono.h index 811c8ba617..c7f929dd28 100644 --- a/src/effects/StereoToMono.h +++ b/src/effects/StereoToMono.h @@ -19,7 +19,7 @@ class EffectStereoToMono final : public Effect static const ComponentInterfaceSymbol Symbol; EffectStereoToMono(); - virtual ~EffectStereoToMono(); + ~EffectStereoToMono() override; // ComponentInterface implementation diff --git a/src/effects/TimeWarper.h b/src/effects/TimeWarper.h index 16e985f7de..9c0c4f4b58 100644 --- a/src/effects/TimeWarper.h +++ b/src/effects/TimeWarper.h @@ -62,13 +62,13 @@ class SAUCEDACITY_DLL_API TimeWarper /* not final */ { public: virtual ~TimeWarper(); - virtual double Warp(double originalTime) const = 0; + [[nodiscard]] virtual double Warp(double originalTime) const = 0; }; class SAUCEDACITY_DLL_API IdentityTimeWarper final : public TimeWarper { public: - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API ShiftTimeWarper final : public TimeWarper @@ -79,8 +79,8 @@ class SAUCEDACITY_DLL_API ShiftTimeWarper final : public TimeWarper public: ShiftTimeWarper(std::unique_ptr &&warper, double shiftAmount) : mWarper(std::move(warper)), mShift(shiftAmount) { } - virtual ~ShiftTimeWarper() {} - double Warp(double originalTime) const override; + ~ShiftTimeWarper() override = default; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API LinearTimeWarper final : public TimeWarper @@ -94,7 +94,7 @@ class SAUCEDACITY_DLL_API LinearTimeWarper final : public TimeWarper : mScale((tAfter1 - tAfter0)/(tBefore1 - tBefore0)), mShift(tAfter0 - mScale*tBefore0) { } - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API LinearInputRateTimeWarper final : public TimeWarper @@ -107,7 +107,7 @@ class SAUCEDACITY_DLL_API LinearInputRateTimeWarper final : public TimeWarper public: LinearInputRateTimeWarper(double tStart, double tEnd, double rStart, double rEnd); - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API LinearOutputRateTimeWarper final : public TimeWarper @@ -122,7 +122,7 @@ class SAUCEDACITY_DLL_API LinearOutputRateTimeWarper final : public TimeWarper public: LinearOutputRateTimeWarper(double tStart, double tEnd, double rStart, double rEnd); - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API LinearInputStretchTimeWarper final : public TimeWarper @@ -135,7 +135,7 @@ class SAUCEDACITY_DLL_API LinearInputStretchTimeWarper final : public TimeWarper public: LinearInputStretchTimeWarper(double tStart, double tEnd, double rStart, double rEnd); - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API LinearOutputStretchTimeWarper final : public TimeWarper @@ -148,7 +148,7 @@ class SAUCEDACITY_DLL_API LinearOutputStretchTimeWarper final : public TimeWarpe public: LinearOutputStretchTimeWarper(double tStart, double tEnd, double rStart, double rEnd); - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API GeometricInputTimeWarper final : public TimeWarper @@ -161,7 +161,7 @@ class SAUCEDACITY_DLL_API GeometricInputTimeWarper final : public TimeWarper public: GeometricInputTimeWarper(double tStart, double tEnd, double rStart, double rEnd); - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API GeometricOutputTimeWarper final : public TimeWarper @@ -174,7 +174,7 @@ class SAUCEDACITY_DLL_API GeometricOutputTimeWarper final : public TimeWarper public: GeometricOutputTimeWarper(double tStart, double tEnd, double rStart, double rEnd); - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; class SAUCEDACITY_DLL_API PasteTimeWarper final : public TimeWarper @@ -183,7 +183,7 @@ class SAUCEDACITY_DLL_API PasteTimeWarper final : public TimeWarper const double mOldT1, mNewT1; public: PasteTimeWarper(double oldT1, double newT1); - double Warp(double originalTime) const override; + [[nodiscard]] double Warp(double originalTime) const override; }; @@ -200,8 +200,8 @@ class SAUCEDACITY_DLL_API RegionTimeWarper final : public TimeWarper : mWarper(std::move(warper)), mTStart(tStart), mTEnd(tEnd), mOffset(mWarper->Warp(mTEnd)-mTEnd) { } - virtual ~RegionTimeWarper() {} - double Warp(double originalTime) const override + ~RegionTimeWarper() override = default; + [[nodiscard]] double Warp(double originalTime) const override { if (originalTime < mTStart) { diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index d7ac18f421..d561c6e786 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -120,8 +120,7 @@ EffectToneGen::EffectToneGen(bool isChirp) } EffectToneGen::~EffectToneGen() -{ -} += default; // ComponentInterface implementation @@ -466,8 +465,6 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) .AddWindow(mToneDurationT); } S.EndMultiColumn(); - - return; } bool EffectToneGen::TransferDataToWindow() diff --git a/src/effects/ToneGen.h b/src/effects/ToneGen.h index c30bf91c3f..a18c486e5c 100644 --- a/src/effects/ToneGen.h +++ b/src/effects/ToneGen.h @@ -21,8 +21,8 @@ class ShuttleGui; class EffectToneGen : public Effect { public: - EffectToneGen(bool isChirp); - virtual ~EffectToneGen(); + explicit EffectToneGen(bool isChirp); + ~EffectToneGen() override; // ComponentInterface implementation @@ -37,7 +37,7 @@ class EffectToneGen : public Effect // EffectClientInterface implementation unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool DefineParams( ShuttleParams & S ) override; bool GetAutomationParameters(CommandParameters & parms) override; diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index 5c0a707c95..55de1093ea 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -155,8 +155,7 @@ EffectTruncSilence::EffectTruncSilence() } EffectTruncSilence::~EffectTruncSilence() -{ -} += default; // ComponentInterface implementation @@ -620,7 +619,7 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList, const sampleCount previewLen( previewLength * wt->GetRate() ); // Keep position in overall silences list for optimization - RegionList::iterator rit(silenceList.begin()); + auto rit(silenceList.begin()); // Allocate buffer Floats buffer{ blockLen }; @@ -866,14 +865,14 @@ void EffectTruncSilence::Intersect(RegionList &dest, const RegionList &src) // Any time we reach the end of the dest list we're finished if (destIter == dest.end()) return; - RegionList::iterator curDest = destIter; + auto curDest = destIter; // Operation: find non-silent regions in src, remove them from dest. double nsStart = curDest->start; double nsEnd; bool lastRun = false; // must run the loop one extra time - RegionList::const_iterator srcIter = src.begin(); + auto srcIter = src.begin(); // This logic, causing the loop to run once after end of src, must occur // each time srcIter is updated @@ -921,7 +920,7 @@ void EffectTruncSilence::Intersect(RegionList &dest, const RegionList &src) curDest->end = nsStart; // Insert second region after first - RegionList::iterator nextIt(destIter); + auto nextIt(destIter); ++nextIt; // This should just read: destIter = dest.insert(nextIt, r); but we diff --git a/src/effects/TruncSilence.h b/src/effects/TruncSilence.h index fa8a249963..5dfebcf25f 100644 --- a/src/effects/TruncSilence.h +++ b/src/effects/TruncSilence.h @@ -32,7 +32,7 @@ class EffectTruncSilence final : public Effect static const ComponentInterfaceSymbol Symbol; EffectTruncSilence(); - virtual ~EffectTruncSilence(); + ~EffectTruncSilence() override; // ComponentInterface implementation @@ -64,8 +64,8 @@ class EffectTruncSilence final : public Effect sampleCount* silentFrame, sampleCount* index, int whichTrack, - double* inputLength = NULL, - double* minInputLength = NULL); + double* inputLength = nullptr, + double* minInputLength = nullptr); bool Process() override; void PopulateOrExchange(ShuttleGui & S) override; @@ -77,7 +77,7 @@ class EffectTruncSilence final : public Effect //ToDo ... put BlendFrames in Effects, Project, or other class // void BlendFrames(float* buffer, int leftIndex, int rightIndex, int blendFrameCount); - void Intersect(RegionList &dest, const RegionList & src); + static void Intersect(RegionList &dest, const RegionList & src); void OnControlChange(wxCommandEvent & evt); void UpdateUI(); diff --git a/src/effects/TwoPassSimpleMono.cpp b/src/effects/TwoPassSimpleMono.cpp index 21fd01e23f..caca6954c7 100644 --- a/src/effects/TwoPassSimpleMono.cpp +++ b/src/effects/TwoPassSimpleMono.cpp @@ -134,9 +134,9 @@ bool EffectTwoPassSimpleMono::ProcessOne(WaveTrack * track, WaveTrack * outTrack // Process the first buffer with a NULL previous buffer if (mPass == 0) - ret = TwoBufferProcessPass1(NULL, 0, buffer1.get(), samples1); + ret = TwoBufferProcessPass1(nullptr, 0, buffer1.get(), samples1); else - ret = TwoBufferProcessPass2(NULL, 0, buffer1.get(), samples1); + ret = TwoBufferProcessPass2(nullptr, 0, buffer1.get(), samples1); if (!ret) //Return false because the effect failed. return false; @@ -196,9 +196,9 @@ bool EffectTwoPassSimpleMono::ProcessOne(WaveTrack * track, WaveTrack * outTrack // Send the last buffer with a NULL pointer for the current buffer if (mPass == 0) - ret = TwoBufferProcessPass1(buffer1.get(), samples1, NULL, 0); + ret = TwoBufferProcessPass1(buffer1.get(), samples1, nullptr, 0); else - ret = TwoBufferProcessPass2(buffer1.get(), samples1, NULL, 0); + ret = TwoBufferProcessPass2(buffer1.get(), samples1, nullptr, 0); if (!ret) //Return false because the effect failed. diff --git a/src/effects/TwoPassSimpleMono.h b/src/effects/TwoPassSimpleMono.h index d7656bbb40..b854353799 100644 --- a/src/effects/TwoPassSimpleMono.h +++ b/src/effects/TwoPassSimpleMono.h @@ -55,10 +55,10 @@ class SAUCEDACITY_DLL_API EffectTwoPassSimpleMono /* not final */ : public Effec // The default just calls the one-buffer-at-a-time method virtual bool TwoBufferProcessPass1 (float *buffer1, size_t len1, float * WXUNUSED(buffer2), size_t WXUNUSED(len2)) - { if(buffer1 != NULL) return ProcessPass1(buffer1, len1); else return true; } + { if(buffer1 != nullptr) return ProcessPass1(buffer1, len1); else return true; } virtual bool TwoBufferProcessPass2 (float *buffer1, size_t len1, float * WXUNUSED(buffer2), size_t WXUNUSED(len2)) - { if(buffer1 != NULL) return ProcessPass2(buffer1, len1); else return true; } + { if(buffer1 != nullptr) return ProcessPass2(buffer1, len1); else return true; } // End of NEW virtuals diff --git a/src/effects/VST/VSTControl.h b/src/effects/VST/VSTControl.h index 0bebe0de65..d11ae6920c 100644 --- a/src/effects/VST/VSTControl.h +++ b/src/effects/VST/VSTControl.h @@ -27,11 +27,11 @@ class VSTControlBase /* not final */ : public wxControl public: VSTControlBase() { - mParent = NULL; - mLink = NULL; + mParent = nullptr; + mLink = nullptr; } - virtual ~VSTControlBase() + ~VSTControlBase() override { } diff --git a/src/effects/VST/VSTControlGTK.cpp b/src/effects/VST/VSTControlGTK.cpp index a93226ec11..a1b7edd1f6 100644 --- a/src/effects/VST/VSTControlGTK.cpp +++ b/src/effects/VST/VSTControlGTK.cpp @@ -24,7 +24,7 @@ static int X11TrapHandler(Display *, XErrorEvent *err) VSTControl::VSTControl() : VSTControlBase() { - mXdisp = 0; + mXdisp = nullptr; mXwin = 0; } @@ -33,7 +33,7 @@ VSTControl::~VSTControl() if (mXwin) { mLink->callDispatcher(effEditClose, 0, (intptr_t)mXdisp, (void *)mXwin, 0.0); - mXdisp = 0; + mXdisp = nullptr; mXwin = 0; } } diff --git a/src/effects/VST/VSTControlGTK.h b/src/effects/VST/VSTControlGTK.h index 24f0889660..d31ffa3cd3 100644 --- a/src/effects/VST/VSTControlGTK.h +++ b/src/effects/VST/VSTControlGTK.h @@ -25,9 +25,9 @@ class VSTControl final : public VSTControlBase { public: VSTControl(); - ~VSTControl(); + ~VSTControl() override; - bool Create(wxWindow *parent, VSTEffectLink *link); + bool Create(wxWindow *parent, VSTEffectLink *link) override; private: Display *mXdisp; diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 6e677a487c..9d661323b2 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -33,8 +33,8 @@ #if USE_VST -#include -#include +#include +#include #include #include // for wxUSE_* macros @@ -163,7 +163,7 @@ DECLARE_BUILTIN_MODULE(VSTBuiltin); class VSTSubEntry final : public wxModule { public: - bool OnInit() + bool OnInit() override { // Have we been started to check a plugin? if (wxTheApp && wxTheApp->argc == 3 && wxStrcmp(wxTheApp->argv[1], VSTCMDKEY) == 0) @@ -185,7 +185,7 @@ class VSTSubEntry final : public wxModule return true; }; - void OnExit() {}; + void OnExit() override {}; DECLARE_DYNAMIC_CLASS(VSTSubEntry) }; @@ -354,8 +354,7 @@ bool VSTEffectsModule::Initialize() void VSTEffectsModule::Terminate() { // Nothing to do here - return; -} + } EffectFamilySymbol VSTEffectsModule::GetOptionalFamilySymbol() { @@ -703,18 +702,18 @@ VSTEffectsModule::CreateInstance(const PluginPath & path) void VSTEffectsModule::Check(const wxChar *path) { VSTEffect effect(path); - if (effect.SetHost(NULL)) + if (effect.SetHost(nullptr)) { auto effectIDs = effect.GetEffectIDs(); wxString out; - if (effectIDs.size() > 0) + if (!effectIDs.empty()) { wxString subids; - for (size_t i = 0, cnt = effectIDs.size(); i < cnt; i++) + for (int effectID : effectIDs) { - subids += wxString::Format(wxT("%d;"), effectIDs[i]); + subids += wxString::Format(wxT("%d;"), effectID); } out = wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeySubIDs, subids.RemoveLast()); @@ -752,7 +751,7 @@ class VSTEffectOptionsDialog final : public wxDialogWrapper { public: VSTEffectOptionsDialog(wxWindow * parent, EffectHostInterface *host); - virtual ~VSTEffectOptionsDialog(); + ~VSTEffectOptionsDialog() override; void PopulateOrExchange(ShuttleGui & S); @@ -894,11 +893,11 @@ class VSTEffectTimer final : public wxTimer { } - ~VSTEffectTimer() + ~VSTEffectTimer() override { } - void Notify() + void Notify() override { mEffect->OnTimer(); } @@ -940,7 +939,7 @@ intptr_t VSTEffect::AudioMaster(AEffect * effect, void * ptr, float opt) { - VSTEffect *vst = (effect ? (VSTEffect *) effect->ptr2 : NULL); + VSTEffect *vst = (effect ? (VSTEffect *) effect->ptr2 : nullptr); // Handles operations during initialization...before VSTEffect has had a // chance to set its instance pointer. @@ -1125,10 +1124,10 @@ VSTEffect::VSTEffect(const PluginPath & path, VSTEffect *master) : mPath(path), mMaster(master) { - mHost = NULL; - mModule = NULL; - mAEffect = NULL; - mDialog = NULL; + mHost = nullptr; + mModule = nullptr; + mAEffect = nullptr; + mDialog = nullptr; mTimer = std::make_unique(this); mTimerGuard = 0; @@ -1160,7 +1159,7 @@ VSTEffect::VSTEffect(const PluginPath & path, VSTEffect *master) // UI mGui = false; - mContainer = NULL; + mContainer = nullptr; // If we're a slave then go ahead a load immediately if (mMaster) @@ -1399,8 +1398,8 @@ bool VSTEffect::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames W mTimeInfo.flags = kVstTempoValid | kVstNanosValid | kVstTransportPlaying; // Set processing parameters...power must be off for this - callDispatcher(effSetSampleRate, 0, 0, NULL, mSampleRate); - callDispatcher(effSetBlockSize, 0, mBlockSize, NULL, 0.0); + callDispatcher(effSetSampleRate, 0, 0, nullptr, mSampleRate); + callDispatcher(effSetBlockSize, 0, mBlockSize, nullptr, 0.0); // Turn on the power PowerOn(); @@ -1437,7 +1436,7 @@ size_t VSTEffect::ProcessBlock(float **inBlock, float **outBlock, size_t blockLe return blockLen; } -unsigned VSTEffect::GetChannelCount() +unsigned VSTEffect::GetChannelCount() const { return mNumChannels; } @@ -1452,7 +1451,7 @@ bool VSTEffect::RealtimeInitialize() mMasterIn.reinit( mAudioIns, mBlockSize, true ); mMasterOut.reinit( mAudioOuts, mBlockSize ); - return ProcessInitialize(0, NULL); + return ProcessInitialize(0, nullptr); } bool VSTEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate) @@ -1467,7 +1466,7 @@ bool VSTEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate) int clen = 0; if (mAEffect->flags & effFlagsProgramChunks) { - void *chunk = NULL; + void *chunk = nullptr; clen = (int) callDispatcher(effGetChunk, 1, 0, &chunk, 0.0); // get master's chunk, for the program only if (clen != 0) @@ -1478,17 +1477,17 @@ bool VSTEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRate) if (clen == 0) { - callDispatcher(effBeginSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effBeginSetProgram, 0, 0, nullptr, 0.0); for (int i = 0; i < mAEffect->numParams; i++) { slave->callSetParameter(i, callGetParameter(i)); } - callDispatcher(effEndSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effEndSetProgram, 0, 0, nullptr, 0.0); } - return slave->ProcessInitialize(0, NULL); + return slave->ProcessInitialize(0, nullptr); } bool VSTEffect::RealtimeFinalize() @@ -1608,7 +1607,7 @@ bool VSTEffect::ShowInterface( { mSampleRate = 44100; mBlockSize = 8192; - ProcessInitialize(0, NULL); + ProcessInitialize(0, nullptr); } if ( factory ) @@ -1654,7 +1653,7 @@ bool VSTEffect::GetAutomationParameters(CommandParameters & parms) bool VSTEffect::SetAutomationParameters(CommandParameters & parms) { - callDispatcher(effBeginSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effBeginSetProgram, 0, 0, nullptr, 0.0); for (int i = 0; i < mAEffect->numParams; i++) { wxString name = GetString(effGetParamName, i); @@ -1676,7 +1675,7 @@ bool VSTEffect::SetAutomationParameters(CommandParameters & parms) slave->callSetParameter(i, d); } } - callDispatcher(effEndSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effEndSetProgram, 0, 0, nullptr, 0.0); return true; } @@ -1750,7 +1749,7 @@ void VSTEffect::SetHostUI(EffectUIHostInterface *host) bool VSTEffect::PopulateUI(ShuttleGui &S) { auto parent = S.GetParent(); - mDialog = static_cast(wxGetTopLevelParent(parent)); + mDialog = dynamic_cast(wxGetTopLevelParent(parent)); mParent = parent; mParent->PushEventHandler(this); @@ -1828,9 +1827,9 @@ bool VSTEffect::CloseUI() mDisplays.reset(); mLabels.reset(); - mUIHost = NULL; - mParent = NULL; - mDialog = NULL; + mUIHost = nullptr; + mParent = nullptr; + mDialog = nullptr; return true; } @@ -1860,7 +1859,7 @@ void VSTEffect::ExportPresets() { XO("Audacity VST preset file"), { wxT("xml") }, true }, }, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, - NULL); + nullptr); // User canceled... if (path.empty()) @@ -1964,8 +1963,6 @@ void VSTEffect::ImportPresets() } RefreshParameters(); - - return; } bool VSTEffect::HasOptions() @@ -2000,8 +1997,8 @@ bool VSTEffect::Load() mPath.AfterFirst(wxT(';')).ToLong(&effectID); mCurrentEffectID = (intptr_t) effectID; - mModule = NULL; - mAEffect = NULL; + mModule = nullptr; + mAEffect = nullptr; #if defined(__WXMAC__) // Start clean @@ -2140,10 +2137,10 @@ bool VSTEffect::Load() // Try to find the entry point, while suppressing error messages pluginMain = (vstPluginMain) dlsym(lib.get(), "VSTPluginMain"); - if (pluginMain == NULL) + if (pluginMain == nullptr) { pluginMain = (vstPluginMain) dlsym(lib.get(), "main"); - if (pluginMain == NULL) + if (pluginMain == nullptr) return false; } @@ -2160,7 +2157,7 @@ bool VSTEffect::Load() catch (...) { wxLogMessage(wxT("VST plugin initialization failed\n")); - mAEffect = NULL; + mAEffect = nullptr; } // Was it successful? @@ -2174,21 +2171,21 @@ bool VSTEffect::Load() mAEffect->ptr2 = this; // Give the plugin an initial sample rate and blocksize - callDispatcher(effSetSampleRate, 0, 0, NULL, 48000.0); - callDispatcher(effSetBlockSize, 0, 512, NULL, 0); + callDispatcher(effSetSampleRate, 0, 0, nullptr, 48000.0); + callDispatcher(effSetBlockSize, 0, 512, nullptr, 0); // Ask the plugin to identify itself...might be needed for older plugins - callDispatcher(effIdentify, 0, 0, NULL, 0); + callDispatcher(effIdentify, 0, 0, nullptr, 0); // Open the plugin - callDispatcher(effOpen, 0, 0, NULL, 0.0); + callDispatcher(effOpen, 0, 0, nullptr, 0.0); // Get the VST version the plugin understands - mVstVersion = callDispatcher(effGetVstVersion, 0, 0, NULL, 0); + mVstVersion = callDispatcher(effGetVstVersion, 0, 0, nullptr, 0); // Set it again in case plugin ignored it before the effOpen - callDispatcher(effSetSampleRate, 0, 0, NULL, 48000.0); - callDispatcher(effSetBlockSize, 0, 512, NULL, 0); + callDispatcher(effSetSampleRate, 0, 0, nullptr, 48000.0); + callDispatcher(effSetBlockSize, 0, 512, nullptr, 0); // Ensure that it looks like a plugin and can deal with ProcessReplacing // calls. Also exclude synths for now. @@ -2212,7 +2209,7 @@ bool VSTEffect::Load() if (mVstVersion >= 2) { mVendor = GetString(effGetVendorString); - mVersion = wxINT32_SWAP_ON_LE(callDispatcher(effGetVendorVersion, 0, 0, NULL, 0)); + mVersion = wxINT32_SWAP_ON_LE(callDispatcher(effGetVendorVersion, 0, 0, nullptr, 0)); } if (mVersion == 0) { @@ -2235,7 +2232,7 @@ bool VSTEffect::Load() mAutomatable = false; for (int i = 0; i < mAEffect->numParams; i++) { - if (callDispatcher(effCanBeAutomated, 0, i, NULL, 0.0)) + if (callDispatcher(effCanBeAutomated, 0, i, nullptr, 0.0)) { mAutomatable = true; break; @@ -2274,8 +2271,8 @@ void VSTEffect::Unload() PowerOff(); // Finally, close the plugin - callDispatcher(effClose, 0, 0, NULL, 0.0); - mAEffect = NULL; + callDispatcher(effClose, 0, 0, nullptr, 0.0); + mAEffect = nullptr; } if (mModule) @@ -2286,7 +2283,7 @@ void VSTEffect::Unload() #endif mModule.reset(); - mAEffect = NULL; + mAEffect = nullptr; } } @@ -2295,7 +2292,7 @@ std::vector VSTEffect::GetEffectIDs() std::vector effectIDs; // Are we a shell? - if (mVstVersion >= 2 && (VstPlugCategory) callDispatcher(effGetPlugCategory, 0, 0, NULL, 0) == kPlugCategShell) + if (mVstVersion >= 2 && (VstPlugCategory) callDispatcher(effGetPlugCategory, 0, 0, nullptr, 0) == kPlugCategShell) { char name[64]; int effectID; @@ -2363,7 +2360,7 @@ bool VSTEffect::SaveParameters(const RegistryPath & group) if (mAEffect->flags & effFlagsProgramChunks) { - void *chunk = NULL; + void *chunk = nullptr; int clen = (int) callDispatcher(effGetChunk, 1, 0, &chunk, 0.0); if (clen <= 0) { @@ -2401,7 +2398,7 @@ void VSTEffect::OnTimer() if (mVstVersion >= 2 && mWantsIdle) { - int ret = callDispatcher(effIdle, 0, 0, NULL, 0.0); + int ret = callDispatcher(effIdle, 0, 0, nullptr, 0.0); if (!ret) { mWantsIdle = false; @@ -2410,7 +2407,7 @@ void VSTEffect::OnTimer() if (mWantsEditIdle) { - callDispatcher(effEditIdle, 0, 0, NULL, 0.0); + callDispatcher(effEditIdle, 0, 0, nullptr, 0.0); } } @@ -2432,12 +2429,12 @@ VstTimeInfo *VSTEffect::GetTimeInfo() return &mTimeInfo; } -float VSTEffect::GetSampleRate() +float VSTEffect::GetSampleRate() const { return mTimeInfo.sampleRate; } -int VSTEffect::GetProcessLevel() +int VSTEffect::GetProcessLevel() const { return mProcessLevel; } @@ -2447,12 +2444,12 @@ void VSTEffect::PowerOn() if (!mHasPower) { // Turn the power on - callDispatcher(effMainsChanged, 0, 1, NULL, 0.0); + callDispatcher(effMainsChanged, 0, 1, nullptr, 0.0); // Tell the effect we're going to start processing if (mVstVersion >= 2) { - callDispatcher(effStartProcess, 0, 0, NULL, 0.0); + callDispatcher(effStartProcess, 0, 0, nullptr, 0.0); } // Set state @@ -2467,11 +2464,11 @@ void VSTEffect::PowerOff() // Tell the effect we're going to stop processing if (mVstVersion >= 2) { - callDispatcher(effStopProcess, 0, 0, NULL, 0.0); + callDispatcher(effStopProcess, 0, 0, nullptr, 0.0); } // Turn the power off - callDispatcher(effMainsChanged, 0, 0, NULL, 0.0); + callDispatcher(effMainsChanged, 0, 0, nullptr, 0.0); // Set state mHasPower = false; @@ -2489,8 +2486,7 @@ void VSTEffect::SizeWindow(int w, int h) mParent->GetEventHandler()->AddPendingEvent(sw); } - return; -} + } void VSTEffect::UpdateDisplay() { @@ -2502,8 +2498,7 @@ void VSTEffect::UpdateDisplay() mParent->GetEventHandler()->AddPendingEvent(ud); } #endif - return; -} + } void VSTEffect::Automate(int index, float value) { @@ -2515,8 +2510,6 @@ void VSTEffect::Automate(int index, float value) for (const auto &slave : mSlaves) slave->callSetParameter(index, value); - - return; } void VSTEffect::SetBufferDelay(int samples) @@ -2527,8 +2520,7 @@ void VSTEffect::SetBufferDelay(int samples) mBufferDelay = samples; } - return; -} + } int VSTEffect::GetString(wxString & outstr, int opcode, int index) { @@ -2581,7 +2573,7 @@ float VSTEffect::callGetParameter(int index) void VSTEffect::callSetParameter(int index, float value) { - if (mVstVersion == 0 || callDispatcher(effCanBeAutomated, 0, index, NULL, 0.0)) + if (mVstVersion == 0 || callDispatcher(effCanBeAutomated, 0, index, nullptr, 0.0)) { mAEffect->setParameter(mAEffect, index, value); @@ -2592,13 +2584,13 @@ void VSTEffect::callSetParameter(int index, float value) void VSTEffect::callSetProgram(int index) { - callDispatcher(effBeginSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effBeginSetProgram, 0, 0, nullptr, 0.0); - callDispatcher(effSetProgram, 0, index, NULL, 0.0); + callDispatcher(effSetProgram, 0, index, nullptr, 0.0); for (const auto &slave : mSlaves) slave->callSetProgram(index); - callDispatcher(effEndSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effEndSetProgram, 0, 0, nullptr, 0.0); } void VSTEffect::callSetChunk(bool isPgm, int len, void *buf) @@ -2633,9 +2625,9 @@ void VSTEffect::callSetChunk(bool isPgm, int len, void *buf, VstPatchChunkInfo * } } - callDispatcher(effBeginSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effBeginSetProgram, 0, 0, nullptr, 0.0); callDispatcher(effSetChunk, isPgm ? 1 : 0, len, buf, 0.0); - callDispatcher(effEndSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effEndSetProgram, 0, 0, nullptr, 0.0); for (const auto &slave : mSlaves) slave->callSetChunk(isPgm, len, buf, info); @@ -2656,7 +2648,7 @@ const static char padc = wxT('='); wxString VSTEffect::b64encode(const void *in, int len) { - unsigned char *p = (unsigned char *) in; + auto *p = (unsigned char *) in; wxString out; unsigned long temp; @@ -2697,7 +2689,7 @@ wxString VSTEffect::b64encode(const void *in, int len) int VSTEffect::b64decode(const wxString &in, void *out) { int len = in.length(); - unsigned char *p = (unsigned char *) out; + auto *p = (unsigned char *) out; if (len % 4) //Sanity check { @@ -2785,7 +2777,7 @@ static void OnSize(wxSizeEvent & evt) // This is a bit of a hack to prevent VSTs GUI windows from resizing // there's no real reason to allow it. But, there should be a better // way of handling it. - wxWindow *w = (wxWindow *) evt.GetEventObject(); + auto *w = (wxWindow *) evt.GetEventObject(); wxSize sz = w->GetMinSize(); if (sz != wxDefaultSize) @@ -2822,20 +2814,12 @@ void VSTEffect::BuildFancy() NeedEditIdle(true); mDialog->Bind(wxEVT_SIZE, OnSize); - -#ifdef __WXMAC__ -#ifdef __WX_EVTLOOP_BUSY_WAITING__ - wxEventLoop::SetBusyWaiting(true); -#endif -#endif - - return; } void VSTEffect::BuildPlain() { wxASSERT(mParent); // To justify safenew - wxScrolledWindow *const scroller = safenew wxScrolledWindow(mParent, + auto *const scroller = safenew wxScrolledWindow(mParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -3035,7 +3019,7 @@ void VSTEffect::OnSizeWindow(wxCommandEvent & evt) void VSTEffect::OnSlider(wxCommandEvent & evt) { - wxSlider *s = (wxSlider *) evt.GetEventObject(); + auto *s = (wxSlider *) evt.GetEventObject(); int i = s->GetId() - ID_Sliders; callSetParameter(i, s->GetValue() / 1000.0); @@ -3082,7 +3066,7 @@ bool VSTEffect::LoadFXB(const wxFileName & fn) } // Most references to the data are via an "int" array - int32_t *iptr = (int32_t *) bptr; + auto *iptr = (int32_t *) bptr; // Verify that we have at least enough for the header if (len < 156) @@ -3271,7 +3255,7 @@ bool VSTEffect::LoadFXP(const wxFileName & fn) bool VSTEffect::LoadFXProgram(unsigned char **bptr, ssize_t & len, int index, bool dryrun) { // Most references to the data are via an "int" array - int32_t *iptr = (int32_t *) *bptr; + auto *iptr = (int32_t *) *bptr; // Verify that we have at least enough for a program without parameters if (len < 28) @@ -3358,13 +3342,13 @@ bool VSTEffect::LoadFXProgram(unsigned char **bptr, ssize_t & len, int index, bo } // Load all of the parameters - callDispatcher(effBeginSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effBeginSetProgram, 0, 0, nullptr, 0.0); for (int i = 0; i < numParams; i++) { wxUint32 val = wxUINT32_SWAP_ON_LE(iptr[14 + i]); callSetParameter(i, reinterpretAsFloat(val)); } - callDispatcher(effEndSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effEndSetProgram, 0, 0, nullptr, 0.0); } // Update in case we're loading an "FxBk" format bank file @@ -3435,7 +3419,7 @@ bool VSTEffect::LoadXML(const wxFileName & fn) // Something went wrong with the file, clean up if (mInSet) { - callDispatcher(effEndSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effEndSetProgram, 0, 0, nullptr, 0.0); mInSet = false; } @@ -3537,8 +3521,6 @@ void VSTEffect::SaveFXB(const wxFileName & fn) } f.Close(); - - return; } void VSTEffect::SaveFXP(const wxFileName & fn) @@ -3558,7 +3540,7 @@ void VSTEffect::SaveFXP(const wxFileName & fn) wxMemoryBuffer buf; - int ndx = callDispatcher(effGetProgram, 0, 0, NULL, 0.0); + int ndx = callDispatcher(effGetProgram, 0, 0, nullptr, 0.0); SaveFXProgram(buf, ndx); f.Write(buf.GetData(), buf.GetDataLen()); @@ -3572,8 +3554,6 @@ void VSTEffect::SaveFXP(const wxFileName & fn) } f.Close(); - - return; } void VSTEffect::SaveFXProgram(wxMemoryBuffer & buf, int index) @@ -3631,8 +3611,7 @@ void VSTEffect::SaveFXProgram(wxMemoryBuffer & buf, int index) } } - return; -} + } // Throws exceptions rather than giving error return. void VSTEffect::SaveXML(const wxFileName & fn) @@ -3656,7 +3635,7 @@ void VSTEffect::SaveXML(const wxFileName & fn) int clen = 0; if (mAEffect->flags & effFlagsProgramChunks) { - void *chunk = NULL; + void *chunk = nullptr; clen = (int) callDispatcher(effGetChunk, 1, 0, &chunk, 0.0); if (clen != 0) @@ -3858,7 +3837,7 @@ bool VSTEffect::HandleXMLTag(const wxChar *tag, const wxChar **attrs) return false; } - callDispatcher(effBeginSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effBeginSetProgram, 0, 0, nullptr, 0.0); mInSet = true; @@ -3960,7 +3939,7 @@ void VSTEffect::HandleXMLEndTag(const wxChar *tag) { if (mInSet) { - callDispatcher(effEndSetProgram, 0, 0, NULL, 0.0); + callDispatcher(effEndSetProgram, 0, 0, nullptr, 0.0); mInSet = false; } @@ -4002,7 +3981,7 @@ XMLTagHandler *VSTEffect::HandleXMLChild(const wxChar *tag) return this; } - return NULL; + return nullptr; } #endif // USE_VST diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index c45d1edb97..7fe6e5f95c 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -96,8 +96,8 @@ class VSTEffect final : public wxEvtHandler, public VSTEffectLink { public: - VSTEffect(const PluginPath & path, VSTEffect *master = NULL); - virtual ~VSTEffect(); + VSTEffect(const PluginPath & path, VSTEffect *master = nullptr); + ~VSTEffect() override; // ComponentInterface implementation @@ -132,10 +132,10 @@ class VSTEffect final : public wxEvtHandler, void SetSampleRate(double rate) override; size_t SetBlockSize(size_t maxBlockSize) override; - size_t GetBlockSize() const override; + [[nodiscard]] size_t GetBlockSize() const override; bool IsReady() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; bool ProcessFinalize() override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; @@ -207,7 +207,7 @@ class VSTEffect final : public wxEvtHandler, static int b64decode(const wxString &in, void *out); // Realtime - unsigned GetChannelCount(); + [[nodiscard]] unsigned GetChannelCount() const; void SetChannelCount(unsigned numChannels); // UI @@ -246,13 +246,13 @@ class VSTEffect final : public wxEvtHandler, // Utility methods VstTimeInfo *GetTimeInfo(); - float GetSampleRate(); - int GetProcessLevel(); + [[nodiscard]] float GetSampleRate() const; + [[nodiscard]] int GetProcessLevel() const; void SetBufferDelay(int samples); void NeedIdle(); void NeedEditIdle(bool state); void SizeWindow(int w, int h); - void UpdateDisplay(); + static void UpdateDisplay(); void Automate(int index, float value); void PowerOn(); void PowerOff(); @@ -404,7 +404,7 @@ class VSTEffectsModule final : public ModuleInterface { public: VSTEffectsModule(); - virtual ~VSTEffectsModule(); + ~VSTEffectsModule() override; // ComponentInterface implementation diff --git a/src/effects/VST/aeffectx.h b/src/effects/VST/aeffectx.h index c9e5a2066c..eaf4b442bd 100644 --- a/src/effects/VST/aeffectx.h +++ b/src/effects/VST/aeffectx.h @@ -26,10 +26,10 @@ #ifndef _AEFFECTX_H #define _AEFFECTX_H -#define CCONST(a, b, c, d)( ( ( (int) a ) << 24 ) | \ - ( ( (int) b ) << 16 ) | \ - ( ( (int) c ) << 8 ) | \ - ( ( (int) d ) << 0 ) ) +#define CCONST(a, b, c, d)( ( ( (int) (a) ) << 24 ) | \ + ( ( (int) (b) ) << 16 ) | \ + ( ( (int) (c) ) << 8 ) | \ + ( ( (int) (d) ) << 0 ) ) const int audioMasterAutomate = 0; const int audioMasterVersion = 1; @@ -252,7 +252,7 @@ class VstParameterProperties } ; -#include +#include class AEffect { diff --git a/src/effects/Wahwah.cpp b/src/effects/Wahwah.cpp index cc1f80a961..d6830e8ad5 100644 --- a/src/effects/Wahwah.cpp +++ b/src/effects/Wahwah.cpp @@ -91,8 +91,7 @@ EffectWahwah::EffectWahwah() } EffectWahwah::~EffectWahwah() -{ -} += default; // ComponentInterface implementation @@ -343,7 +342,7 @@ bool EffectWahwah::TransferDataFromWindow() // EffectWahwah implementation -void EffectWahwah::InstanceInit(EffectWahwahState & data, float sampleRate) +void EffectWahwah::InstanceInit(EffectWahwahState & data, float sampleRate) const { data.samplerate = sampleRate; data.lfoskip = mFreq * 2 * M_PI / sampleRate; @@ -365,7 +364,7 @@ void EffectWahwah::InstanceInit(EffectWahwahState & data, float sampleRate) data.outgain = DB_TO_LINEAR(mOutGain); } -size_t EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, size_t blockLen) +size_t EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, size_t blockLen) const { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Wahwah.h b/src/effects/Wahwah.h index 2bce0895e2..f0da642584 100644 --- a/src/effects/Wahwah.h +++ b/src/effects/Wahwah.h @@ -42,7 +42,7 @@ class EffectWahwah final : public Effect static const ComponentInterfaceSymbol Symbol; EffectWahwah(); - virtual ~EffectWahwah(); + ~EffectWahwah() override; // ComponentInterface implementation @@ -59,7 +59,7 @@ class EffectWahwah final : public Effect unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -81,8 +81,8 @@ class EffectWahwah final : public Effect private: // EffectWahwah implementation - void InstanceInit(EffectWahwahState & data, float sampleRate); - size_t InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, size_t blockLen); + void InstanceInit(EffectWahwahState & data, float sampleRate) const; + size_t InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, size_t blockLen) const; void OnFreqSlider(wxCommandEvent & evt); void OnPhaseSlider(wxCommandEvent & evt); diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 83edff8976..a292998679 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -29,7 +29,7 @@ effects from this one class. #include #include -#include +#include #if !defined(__WXMSW__) #include @@ -156,8 +156,7 @@ bool LadspaEffectsModule::Initialize() void LadspaEffectsModule::Terminate() { // Nothing to do here - return; -} + } EffectFamilySymbol LadspaEffectsModule::GetOptionalFamilySymbol() { @@ -205,10 +204,10 @@ bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) FilePaths files; TranslatableString ignoredErrMsg; - for (int i = 0; i < (int)WXSIZEOF(kShippedEffects); i++) + for (auto & kShippedEffect : kShippedEffects) { files.clear(); - pm.FindFilesInPathList(kShippedEffects[i], pathList, files); + pm.FindFilesInPathList(kShippedEffect, pathList, files); for (size_t j = 0, cnt = files.size(); j < cnt; j++) { if (!pm.IsPluginRegistered(files[j])) @@ -273,7 +272,7 @@ unsigned LadspaEffectsModule::DiscoverPluginsAtPath( int index = 0; int nLoaded = 0; - LADSPA_Descriptor_Function mainFn = NULL; + LADSPA_Descriptor_Function mainFn = nullptr; #if defined(__WXMSW__) wxDynamicLibrary lib; if (lib.Load(path, wxDL_NOW)) { @@ -291,7 +290,7 @@ unsigned LadspaEffectsModule::DiscoverPluginsAtPath( for (data = mainFn(index); data; data = mainFn(++index)) { LadspaEffect effect(path, index); - if (effect.SetHost(NULL)) { + if (effect.SetHost(nullptr)) { ++nLoaded; if (callback) callback( this, &effect ); @@ -399,7 +398,7 @@ class LadspaEffectOptionsDialog final : public wxDialogWrapper { public: LadspaEffectOptionsDialog(wxWindow * parent, EffectHostInterface *host); - virtual ~LadspaEffectOptionsDialog(); + ~LadspaEffectOptionsDialog() override; void PopulateOrExchange(ShuttleGui & S); @@ -501,7 +500,7 @@ class LadspaEffectMeter final : public wxWindow { public: LadspaEffectMeter(wxWindow *parent, const float & val, float min, float max); - virtual ~LadspaEffectMeter(); + ~LadspaEffectMeter() override; private: void OnErase(wxEraseEvent & evt); @@ -608,10 +607,10 @@ LadspaEffect::LadspaEffect(const wxString & path, int index) { mPath = path; mIndex = index; - mData = NULL; + mData = nullptr; - mHost = NULL; - mMaster = NULL; + mHost = nullptr; + mMaster = nullptr; mReady = false; mInteractive = false; @@ -625,8 +624,8 @@ LadspaEffect::LadspaEffect(const wxString & path, int index) mLatencyPort = -1; - mDialog = NULL; - mParent = NULL; + mDialog = nullptr; + mParent = nullptr; } LadspaEffect::~LadspaEffect() @@ -756,7 +755,7 @@ bool LadspaEffect::SetHost(EffectHostInterface *host) mInteractive = true; LADSPA_PortRangeHint hint = mData->PortRangeHints[p]; - float val = float(1.0); + auto val = float(1.0); float lower = hint.LowerBound; float upper = hint.UpperBound; @@ -965,7 +964,7 @@ bool LadspaEffect::ProcessFinalize() mReady = false; FreeInstance(mMaster); - mMaster = NULL; + mMaster = nullptr; } return true; @@ -1010,9 +1009,9 @@ bool LadspaEffect::RealtimeAddProcessor(unsigned WXUNUSED(numChannels), float sa bool LadspaEffect::RealtimeFinalize() { - for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++) + for (auto & mSlave : mSlaves) { - FreeInstance(mSlaves[i]); + FreeInstance(mSlave); } mSlaves.clear(); @@ -1199,7 +1198,7 @@ bool LadspaEffect::PopulateUI(ShuttleGui &S) mMeters.reinit( mData->PortCount ); wxASSERT(mParent); // To justify safenew - wxScrolledWindow *const w = safenew wxScrolledWindow(mParent, + auto *const w = safenew wxScrolledWindow(mParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -1536,9 +1535,9 @@ bool LadspaEffect::CloseUI() mFields.reset(); mLabels.reset(); - mUIHost = NULL; - mParent = NULL; - mDialog = NULL; + mUIHost = nullptr; + mParent = nullptr; + mDialog = nullptr; return true; } @@ -1589,7 +1588,7 @@ bool LadspaEffect::Load() wxString saveOldCWD = ff.GetCwd(); ff.SetCwd(); - LADSPA_Descriptor_Function mainFn = NULL; + LADSPA_Descriptor_Function mainFn = nullptr; if (mLib.Load(mPath, wxDL_NOW)) { @@ -1662,7 +1661,7 @@ LADSPA_Handle LadspaEffect::InitInstance(float sampleRate) LADSPA_Handle handle = mData->instantiate(mData, sampleRate); if (!handle) { - return NULL; + return nullptr; } for (unsigned long p = 0; p < mData->PortCount; p++) @@ -1711,8 +1710,8 @@ void LadspaEffect::OnSlider(wxCommandEvent & evt) int p = evt.GetId() - ID_Sliders; float val; - float lower = float(0.0); - float upper = float(10.0); + auto lower = float(0.0); + auto upper = float(10.0); float range; bool forceint = false; @@ -1748,8 +1747,8 @@ void LadspaEffect::OnTextCtrl(wxCommandEvent & evt) int p = evt.GetId() - ID_Texts; float val; - float lower = float(0.0); - float upper = float(10.0); + auto lower = float(0.0); + auto upper = float(10.0); float range; val = Internat::CompatibleToDouble(that->mFields[p]->GetValue()); diff --git a/src/effects/ladspa/LadspaEffect.h b/src/effects/ladspa/LadspaEffect.h index 5506f4324c..d655627ab9 100644 --- a/src/effects/ladspa/LadspaEffect.h +++ b/src/effects/ladspa/LadspaEffect.h @@ -45,7 +45,7 @@ class LadspaEffect final : public wxEvtHandler, { public: LadspaEffect(const wxString & path, int index); - virtual ~LadspaEffect(); + ~LadspaEffect() override; // ComponentInterface implementation @@ -77,13 +77,13 @@ class LadspaEffect final : public wxEvtHandler, void SetSampleRate(double rate) override; size_t SetBlockSize(size_t maxBlockSize) override; - size_t GetBlockSize() const override; + [[nodiscard]] size_t GetBlockSize() const override; sampleCount GetLatency() override; size_t GetTailSize() override; bool IsReady() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; bool ProcessFinalize() override; size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; @@ -209,7 +209,7 @@ class LadspaEffectsModule final : public ModuleInterface { public: LadspaEffectsModule(); - virtual ~LadspaEffectsModule(); + ~LadspaEffectsModule() override; // ComponentInterface implementation @@ -242,6 +242,6 @@ class LadspaEffectsModule final : public ModuleInterface // LadspaEffectModule implementation - FilePaths GetSearchPaths(); + static FilePaths GetSearchPaths(); }; diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index 424ad21ba9..398797f067 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -102,8 +103,8 @@ URIDLIST class LV2EffectMeter final : public wxWindow { public: - LV2EffectMeter(wxWindow *parent, const LV2ControlPortPtr ctrl); - virtual ~LV2EffectMeter(); + LV2EffectMeter(wxWindow *parent, const LV2ControlPortPtr& ctrl); + ~LV2EffectMeter() override; private: void OnErase(wxEraseEvent &evt); @@ -125,7 +126,7 @@ BEGIN_EVENT_TABLE(LV2EffectMeter, wxWindow) EVT_SIZE(LV2EffectMeter::OnSize) END_EVENT_TABLE() -LV2EffectMeter::LV2EffectMeter(wxWindow *parent, const LV2ControlPortPtr port) +LV2EffectMeter::LV2EffectMeter(wxWindow *parent, const LV2ControlPortPtr& port) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDEFAULT_CONTROL_BORDER), mControlPort(port) { @@ -200,7 +201,7 @@ class LV2EffectSettingsDialog final : public wxDialogWrapper { public: LV2EffectSettingsDialog(wxWindow *parent, LV2Effect *effect); - virtual ~LV2EffectSettingsDialog(); + ~LV2EffectSettingsDialog() override; void PopulateOrExchange(ShuttleGui &S); @@ -366,10 +367,10 @@ LV2Effect::LV2Effect(const LilvPlugin *plug) { mPlug = plug; - mHost = NULL; - mMaster = NULL; - mProcess = NULL; - mSuilInstance = NULL; + mHost = nullptr; + mMaster = nullptr; + mProcess = nullptr; + mSuilInstance = nullptr; mSampleRate = 44100; mBlockSize = DEFAULT_BLOCKSIZE; @@ -384,10 +385,10 @@ LV2Effect::LV2Effect(const LilvPlugin *plug) mRolling = false; mActivated = false; - mDialog = NULL; + mDialog = nullptr; - mUIIdleInterface = NULL; - mUIShowInterface = NULL; + mUIIdleInterface = nullptr; + mUIShowInterface = nullptr; mAudioIn = 0; mAudioOut = 0; @@ -400,7 +401,7 @@ LV2Effect::LV2Effect(const LilvPlugin *plug) mPositionSpeed = 1.0; mPositionFrame = 0.0; - mNativeWin = NULL; + mNativeWin = nullptr; mNativeWinInitialSize = wxDefaultSize; mNativeWinLastSize = wxDefaultSize; mResizing = false; @@ -408,8 +409,8 @@ LV2Effect::LV2Effect(const LilvPlugin *plug) mResized = false; #endif - mExternalUIHost.plugin_human_id = NULL; - mExternalWidget = NULL; + mExternalUIHost.plugin_human_id = nullptr; + mExternalWidget = nullptr; mExternalUIClosed = false; mNoResize = false; @@ -491,7 +492,7 @@ EffectFamilySymbol LV2Effect::GetFamily() bool LV2Effect::IsInteractive() { - return mControlPorts.size() != 0; + return !mControlPorts.empty(); } bool LV2Effect::IsDefault() @@ -533,7 +534,7 @@ bool LV2Effect::SetHost(EffectHostInterface *host) sizeof(mSampleRate), urid_Float, &mSampleRate); - AddOption(0, 0, 0, NULL); + AddOption(0, 0, 0, nullptr); if (!ValidateOptions(lilv_plugin_get_uri(mPlug))) { @@ -562,12 +563,12 @@ bool LV2Effect::SetHost(EffectHostInterface *host) mExternalUIHost.plugin_human_id = lilv_node_as_string(pluginName); lilv_node_free(pluginName); - AddFeature(LV2_UI__noUserResize, NULL); - AddFeature(LV2_UI__fixedSize, NULL); - AddFeature(LV2_UI__idleInterface, NULL); - AddFeature(LV2_UI__makeResident, NULL); - AddFeature(LV2_BUF_SIZE__boundedBlockLength, NULL); - AddFeature(LV2_BUF_SIZE__fixedBlockLength, NULL); + AddFeature(LV2_UI__noUserResize, nullptr); + AddFeature(LV2_UI__fixedSize, nullptr); + AddFeature(LV2_UI__idleInterface, nullptr); + AddFeature(LV2_UI__makeResident, nullptr); + AddFeature(LV2_BUF_SIZE__boundedBlockLength, nullptr); + AddFeature(LV2_BUF_SIZE__fixedBlockLength, nullptr); AddFeature(LV2_OPTIONS__options, mOptions.data()); AddFeature(LV2_URI_MAP_URI, &mUriMapFeature); AddFeature(LV2_URID__map, &mURIDMapFeature); @@ -578,19 +579,19 @@ bool LV2Effect::SetHost(EffectHostInterface *host) AddFeature(LV2_EXTERNAL_UI__Host, &mExternalUIHost); AddFeature(LV2_EXTERNAL_UI_DEPRECATED_URI, &mExternalUIHost); // Some plugins specify this as a feature - AddFeature(LV2_EXTERNAL_UI__Widget, NULL); + AddFeature(LV2_EXTERNAL_UI__Widget, nullptr); - mInstanceAccessFeature = AddFeature(LV2_INSTANCE_ACCESS_URI, NULL); - mParentFeature = AddFeature(LV2_UI__parent, NULL); + mInstanceAccessFeature = AddFeature(LV2_INSTANCE_ACCESS_URI, nullptr); + mParentFeature = AddFeature(LV2_UI__parent, nullptr); - AddFeature(NULL, NULL); + AddFeature(nullptr, nullptr); if (!ValidateFeatures(lilv_plugin_get_uri(mPlug))) { return false; } - auto minLength = lilv_world_get(gWorld, lilv_plugin_get_uri(mPlug), node_MinBlockLength, NULL); + auto minLength = lilv_world_get(gWorld, lilv_plugin_get_uri(mPlug), node_MinBlockLength, nullptr); if (minLength) { if (lilv_node_is_int(minLength)) @@ -604,7 +605,7 @@ bool LV2Effect::SetHost(EffectHostInterface *host) lilv_node_free(minLength); } - auto maxLength = lilv_world_get(gWorld, lilv_plugin_get_uri(mPlug), node_MaxBlockLength, NULL); + auto maxLength = lilv_world_get(gWorld, lilv_plugin_get_uri(mPlug), node_MaxBlockLength, nullptr); if (maxLength) { if (lilv_node_is_int(maxLength)) @@ -667,10 +668,10 @@ bool LV2Effect::SetHost(EffectHostInterface *host) LilvNode *group = lilv_port_get(mPlug, port, node_Group); if (group) { - groupName = LilvString(lilv_world_get(gWorld, group, node_Label, NULL), true); + groupName = LilvString(lilv_world_get(gWorld, group, node_Label, nullptr), true); if (groupName.empty()) { - groupName = LilvString(lilv_world_get(gWorld, group, node_Name, NULL), true); + groupName = LilvString(lilv_world_get(gWorld, group, node_Name, nullptr), true); } if (groupName.empty()) @@ -986,9 +987,9 @@ void LV2Effect::SetSampleRate(double rate) mMaster->SetSampleRate(); } - for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++) + for (auto & mSlave : mSlaves) { - mSlaves[i]->SetSampleRate(); + mSlave->SetSampleRate(); } } @@ -1010,9 +1011,9 @@ size_t LV2Effect::SetBlockSize(size_t maxBlockSize) mMaster->SetBlockSize(); } - for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++) + for (auto & mSlave : mSlaves) { - mSlaves[i]->SetBlockSize(); + mSlave->SetBlockSize(); } return mBlockSize; @@ -1041,7 +1042,7 @@ size_t LV2Effect::GetTailSize() bool LV2Effect::IsReady() { - return mMaster != NULL; + return mMaster != nullptr; } bool LV2Effect::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames WXUNUSED(chanMap)) @@ -1070,7 +1071,7 @@ bool LV2Effect::ProcessFinalize() if (mProcess) { FreeInstance(mProcess); - mProcess = NULL; + mProcess = nullptr; } return true; @@ -1107,7 +1108,7 @@ size_t LV2Effect::ProcessBlock(float **inbuf, float **outbuf, size_t size) port->mBuffer.size()); LV2_Atom_Forge_Frame seqFrame; - LV2_Atom_Sequence *seq = ( LV2_Atom_Sequence *) + auto *seq = ( LV2_Atom_Sequence *) lv2_atom_forge_sequence_head(&mForge, &seqFrame, 0); if (port->mWantsPosition) @@ -1166,7 +1167,7 @@ size_t LV2Effect::ProcessBlock(float **inbuf, float **outbuf, size_t size) { port->mBuffer.resize(port->mMinimumSize); - LV2_Atom *chunk = ( LV2_Atom *) port->mBuffer.data(); + auto *chunk = ( LV2_Atom *) port->mBuffer.data(); chunk->size = port->mMinimumSize; chunk->type = urid_Chunk; } @@ -1279,7 +1280,7 @@ bool LV2Effect::RealtimeProcessStart() port->mBuffer.size()); LV2_Atom_Forge_Frame seqFrame; - LV2_Atom_Sequence *seq = (LV2_Atom_Sequence *) + auto *seq = (LV2_Atom_Sequence *) lv2_atom_forge_sequence_head(&mForge, &seqFrame, 0); if (port->mWantsPosition) @@ -1394,7 +1395,7 @@ size_t LV2Effect::RealtimeProcess(int group, float **inbuf, float **outbuf, size { port->mBuffer.resize(port->mMinimumSize); - LV2_Atom *chunk = ( LV2_Atom *) buf; + auto *chunk = ( LV2_Atom *) buf; chunk->size = port->mMinimumSize; chunk->type = urid_Chunk; } @@ -1564,11 +1565,11 @@ bool LV2Effect::PopulateUI(ShuttleGui &S) mParent->PushEventHandler(this); - mSuilHost = NULL; - mSuilInstance = NULL; + mSuilHost = nullptr; + mSuilInstance = nullptr; mMaster = InitInstance(mSampleRate); - if (mMaster == NULL) + if (mMaster == nullptr) { AudacityMessageBox( XO("Couldn't instantiate effect") ); return false; @@ -1643,32 +1644,32 @@ bool LV2Effect::CloseUI() if (mNativeWin) { mNativeWin->Destroy(); - mNativeWin = NULL; + mNativeWin = nullptr; } - mUIIdleInterface = NULL; - mUIShowInterface = NULL; - mExternalWidget = NULL; + mUIIdleInterface = nullptr; + mUIShowInterface = nullptr; + mExternalWidget = nullptr; suil_instance_free(mSuilInstance); - mSuilInstance = NULL; + mSuilInstance = nullptr; } if (mSuilHost) { suil_host_free(mSuilHost); - mSuilHost = NULL; + mSuilHost = nullptr; } if (mMaster) { FreeInstance(mMaster); - mMaster = NULL; + mMaster = nullptr; } - mUIHost = NULL; - mParent = NULL; - mDialog = NULL; + mUIHost = nullptr; + mParent = nullptr; + mDialog = nullptr; return true; } @@ -1706,7 +1707,7 @@ RegistryPaths LV2Effect::GetFactoryPresets() lilv_world_load_resource(gWorld, preset); - LilvNodes *labels = lilv_world_find_nodes(gWorld, preset, node_Label, NULL); + LilvNodes *labels = lilv_world_find_nodes(gWorld, preset, node_Label, nullptr); if (labels) { const LilvNode *label = lilv_nodes_get_first(labels); @@ -1745,7 +1746,7 @@ bool LV2Effect::LoadFactoryPreset(int id) LilvState *state = lilv_state_new_from_world(gWorld, &mURIDMapFeature, preset); if (state) { - lilv_state_restore(state, mMaster->GetInstance(), set_value_func, this, 0, NULL); + lilv_state_restore(state, mMaster->GetInstance(), set_value_func, this, 0, nullptr); lilv_state_free(state); @@ -1754,7 +1755,7 @@ bool LV2Effect::LoadFactoryPreset(int id) lilv_node_free(preset); - return state != NULL; + return state != nullptr; } bool LV2Effect::LoadFactoryDefaults() @@ -1863,7 +1864,7 @@ LV2_Feature *LV2Effect::AddFeature(const char *uri, void *data) if (uri) { - mFeatures[ndx].reset(safenew LV2_Feature); + mFeatures[ndx] = std::make_unique(); mFeatures[ndx]->URI = uri; mFeatures[ndx]->data = data; } @@ -1885,7 +1886,7 @@ bool LV2Effect::CheckFeatures(const LilvNode *subject, const LilvNode *predicate { bool supported = true; - LilvNodes *nodes = lilv_world_find_nodes(gWorld, subject, predicate, NULL); + LilvNodes *nodes = lilv_world_find_nodes(gWorld, subject, predicate, nullptr); if (nodes) { LILV_FOREACH(nodes, i, nodes) @@ -1949,7 +1950,7 @@ bool LV2Effect::CheckOptions(const LilvNode *subject, const LilvNode *predicate, { bool supported = true; - LilvNodes *nodes = lilv_world_find_nodes(gWorld, subject, predicate, NULL); + LilvNodes *nodes = lilv_world_find_nodes(gWorld, subject, predicate, nullptr); if (nodes) { LILV_FOREACH(nodes, i, nodes) @@ -2000,17 +2001,17 @@ bool LV2Effect::CheckOptions(const LilvNode *subject, const LilvNode *predicate, LV2Wrapper *LV2Effect::InitInstance(float sampleRate) { - LV2Wrapper *wrapper = new LV2Wrapper(this); - if (wrapper == NULL) + auto *wrapper = new LV2Wrapper(this); + if (wrapper == nullptr) { - return NULL; + return nullptr; } LilvInstance *instance = wrapper->Instantiate(mPlug, sampleRate, mFeatures); if (!instance) { delete wrapper; - return NULL; + return nullptr; } wrapper->SetBlockSize(); @@ -2084,8 +2085,8 @@ bool LV2Effect::BuildFancy() #endif // Determine if the plugin has a supported UI - const LilvUI *ui = NULL; - const LilvNode *uiType = NULL; + const LilvUI *ui = nullptr; + const LilvNode *uiType = nullptr; LilvUIs *uis = lilv_plugin_get_uis(mPlug); if (uis) { @@ -2105,7 +2106,7 @@ bool LV2Effect::BuildFancy() break; } - ui = NULL; + ui = nullptr; } lilv_node_free(containerType); @@ -2113,7 +2114,7 @@ bool LV2Effect::BuildFancy() } // Check for other supported UIs - if (ui == NULL) + if (ui == nullptr) { LILV_FOREACH(uis, iter, uis) { @@ -2123,12 +2124,12 @@ bool LV2Effect::BuildFancy() uiType = node_ExternalUI; break; } - ui = NULL; + ui = nullptr; } } // No usable UI found - if (ui == NULL) + if (ui == nullptr) { lilv_uis_free(uis); return false; @@ -2173,8 +2174,8 @@ bool LV2Effect::BuildFancy() // Create the suil host mSuilHost = suil_host_new(LV2Effect::suil_port_write_func, LV2Effect::suil_port_index_func, - NULL, - NULL); + nullptr, + nullptr); if (!mSuilHost) { lilv_uis_free(uis); @@ -2190,8 +2191,8 @@ bool LV2Effect::BuildFancy() lilv_free(libPath); #endif - char *bundlePath = lilv_file_uri_parse(lilv_node_as_uri(lilv_ui_get_bundle_uri(ui)), NULL); - char *binaryPath = lilv_file_uri_parse(lilv_node_as_uri(lilv_ui_get_binary_uri(ui)), NULL); + char *bundlePath = lilv_file_uri_parse(lilv_node_as_uri(lilv_ui_get_bundle_uri(ui)), nullptr); + char *binaryPath = lilv_file_uri_parse(lilv_node_as_uri(lilv_ui_get_binary_uri(ui)), nullptr); mSuilInstance = suil_instance_new(mSuilHost, this, @@ -2215,7 +2216,7 @@ bool LV2Effect::BuildFancy() #endif suil_host_free(mSuilHost); - mSuilHost = NULL; + mSuilHost = nullptr; return false; } @@ -2232,7 +2233,7 @@ bool LV2Effect::BuildFancy() } else { - WXWidget widget = (WXWidget) suil_instance_get_widget(mSuilInstance); + auto widget = (WXWidget) suil_instance_get_widget(mSuilInstance); #if defined(__WXGTK__) // Needed by some plugins (e.g., Invada) to ensure the display is fully @@ -2257,7 +2258,7 @@ bool LV2Effect::BuildFancy() mNativeWin->SetMinSize(mNativeWinInitialSize); } - wxSizerItem *si = NULL; + wxSizerItem *si = nullptr; auto vs = std::make_unique(wxVERTICAL); if (vs) { @@ -2318,7 +2319,7 @@ bool LV2Effect::BuildPlain() wxSizer *innerSizer; wxASSERT(mParent); // To justify safenew - wxScrolledWindow *const w = safenew + auto *const w = safenew wxScrolledWindow(mParent, wxID_ANY, wxDefaultPosition, @@ -2365,15 +2366,15 @@ bool LV2Effect::BuildPlain() std::sort(mGroups.begin(), mGroups.end()); - for (size_t i = 0, groupCount = mGroups.size(); i < groupCount; i++) + for (auto & mGroup : mGroups) { - wxString label = mGroups[i]; + wxString label = mGroup; auto groupSizer = std::make_unique(wxVERTICAL, w, label); auto gridSizer = std::make_unique(numCols, 5, 5); gridSizer->AddGrowableCol(3); - for (auto & p : mGroupMap[mGroups[i]]) + for (auto & p : mGroupMap[mGroup]) { auto & port = mControlPorts[p]; @@ -2393,7 +2394,7 @@ bool LV2Effect::BuildPlain() gridSizer->Add(1, 1, 0); wxASSERT(w); // To justify safenew - wxButton *b = safenew wxButton(w, ID_Triggers + p, labelText); + auto *b = safenew wxButton(w, ID_Triggers + p, labelText); gridSizer->Add(b, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); port->mCtrl.button = b; @@ -2410,7 +2411,7 @@ bool LV2Effect::BuildPlain() if (port->mToggle) { - wxCheckBox *c = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); + auto *c = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); c->SetName(labelText); c->SetValue(port->mVal > 0); gridSizer->Add(c, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); @@ -2436,7 +2437,7 @@ bool LV2Effect::BuildPlain() s = 0; } - wxChoice *c = safenew wxChoice(w, ID_Choices + p); + auto *c = safenew wxChoice(w, ID_Choices + p); c->SetName(labelText); c->Append(port->mScaleLabels); c->SetSelection(s); @@ -2452,7 +2453,7 @@ bool LV2Effect::BuildPlain() gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); - LV2EffectMeter *m = safenew LV2EffectMeter(w, port); + auto *m = safenew LV2EffectMeter(w, port); gridSizer->Add(m, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND); port->mCtrl.meter = m; @@ -2460,7 +2461,7 @@ bool LV2Effect::BuildPlain() } else { - wxTextCtrl *t = safenew wxTextCtrl(w, ID_Texts + p, wxT("")); + auto *t = safenew wxTextCtrl(w, ID_Texts + p, wxT("")); t->SetName(labelText); gridSizer->Add(t, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); port->mText = t; @@ -2513,7 +2514,7 @@ bool LV2Effect::BuildPlain() gridSizer->Add(1, 1, 0); } - wxSlider *s = safenew wxSliderWrapper(w, ID_Sliders + p, + auto *s = safenew wxSliderWrapper(w, ID_Sliders + p, 0, 0, 1000, wxDefaultPosition, wxSize(150, -1)); @@ -2555,7 +2556,7 @@ bool LV2Effect::BuildPlain() for (size_t i = (GetType() == EffectTypeGenerate); i < cnt; i++) { wxSizer *groupSizer = innerSizer->GetItem(i)->GetSizer(); - wxFlexGridSizer *gridSizer = (wxFlexGridSizer *) groupSizer->GetItem((size_t) 0)->GetSizer(); + auto *gridSizer = (wxFlexGridSizer *) groupSizer->GetItem((size_t) 0)->GetSizer(); size_t items = gridSizer->GetChildren().GetCount(); int cols = gridSizer->GetCols(); @@ -2571,7 +2572,7 @@ bool LV2Effect::BuildPlain() for (size_t i = (GetType() == EffectTypeGenerate); i < cnt; i++) { wxSizer *groupSizer = innerSizer->GetItem(i)->GetSizer(); - wxFlexGridSizer *gridSizer = (wxFlexGridSizer *) groupSizer->GetItem((size_t) 0)->GetSizer(); + auto *gridSizer = (wxFlexGridSizer *) groupSizer->GetItem((size_t) 0)->GetSizer(); size_t items = gridSizer->GetChildren().GetCount(); int cols = gridSizer->GetCols(); @@ -2818,7 +2819,7 @@ void LV2Effect::OnIdle(wxIdleEvent &evt) { ZixRing *ring = mControlOut->mRing; - LV2_Atom *atom = (LV2_Atom *) malloc(mControlOut->mMinimumSize); + auto *atom = (LV2_Atom *) malloc(mControlOut->mMinimumSize); if (atom) { while (zix_ring_read(ring, atom, sizeof(LV2_Atom))) @@ -3004,7 +3005,7 @@ const char *LV2Effect::URID_Unmap(LV2_URID urid) } } - return NULL; + return nullptr; } // static callback @@ -3051,7 +3052,7 @@ int LV2Effect::LogVPrintf(LV2_URID type, const char *fmt, va_list ap) level = wxLOG_Message; } - char *msg = NULL; + char *msg = nullptr; int len = wxCRT_VsnprintfA(msg, 0, fmt, ap); msg = (char *) malloc(len + 1); @@ -3102,8 +3103,6 @@ void LV2Effect::ui_closed(LV2UI_Controller controller) void LV2Effect::UIClosed() { mExternalUIClosed = true; - - return; } // static callback @@ -3139,8 +3138,7 @@ void LV2Effect::SuilPortWrite(uint32_t port_index, } } - return; -} + } // static callback uint32_t LV2Effect::suil_port_index_func(SuilController controller, @@ -3191,7 +3189,7 @@ const void *LV2Effect::GetPortValue(const char *port_symbol, *size = 0; *type = 0; - return NULL; + return nullptr; } // static callback @@ -3280,11 +3278,11 @@ void LV2Effect::SizeRequest(GtkWidget *widget, GtkRequisition *requisition) LV2Wrapper::LV2Wrapper(LV2Effect *effect) : mEffect(effect) { - mInstance = NULL; - mHandle = NULL; - mOptionsInterface = NULL; - mStateInterface = NULL; - mWorkerInterface = NULL; + mInstance = nullptr; + mHandle = nullptr; + mOptionsInterface = nullptr; + mStateInterface = nullptr; + mWorkerInterface = nullptr; mWorkerSchedule = {}; mFreeWheeling = false; mLatency = 0.0; @@ -3300,7 +3298,7 @@ LV2Wrapper::~LV2Wrapper() { mStopWorker = true; - LV2Work work = {0, NULL}; + LV2Work work = {0, nullptr}; mRequests.Post(work); thread->Wait(); @@ -3313,7 +3311,7 @@ LV2Wrapper::~LV2Wrapper() } lilv_instance_free(mInstance); - mInstance = NULL; + mInstance = nullptr; } } @@ -3330,7 +3328,7 @@ LilvInstance *LV2Wrapper::Instantiate(const LilvPlugin *plugin, mWorkerSchedule.schedule_work = LV2Wrapper::schedule_work; mEffect->AddFeature(LV2_WORKER__schedule, &mWorkerSchedule); - mEffect->AddFeature(NULL, NULL); + mEffect->AddFeature(nullptr, nullptr); } #if defined(__WXMSW__) @@ -3361,12 +3359,12 @@ LilvInstance *LV2Wrapper::Instantiate(const LilvPlugin *plugin, features.pop_back(); // Re-add terminator - mEffect->AddFeature(NULL, NULL); + mEffect->AddFeature(nullptr, nullptr); } if (!mInstance) { - return NULL; + return nullptr; } mHandle = lilv_instance_get_handle(mInstance); @@ -3407,7 +3405,7 @@ LV2_Handle LV2Wrapper::GetHandle() return mHandle; } -float LV2Wrapper::GetLatency() +float LV2Wrapper::GetLatency() const { return mLatency; } @@ -3466,7 +3464,7 @@ void *LV2Wrapper::Entry() work.data); } - return (void *) 0; + return (void *) nullptr; } void LV2Wrapper::SendResponses() diff --git a/src/effects/lv2/LV2Effect.h b/src/effects/lv2/LV2Effect.h index 4a02867fc9..3a3ba88542 100644 --- a/src/effects/lv2/LV2Effect.h +++ b/src/effects/lv2/LV2Effect.h @@ -124,7 +124,7 @@ class LV2AtomPort : public LV2Port mIsMidi = false; mWantsPosition = false; mMinimumSize = 1024; - mRing = NULL; + mRing = nullptr; } virtual ~LV2AtomPort() { @@ -205,8 +205,8 @@ class LV2ControlPort : public LV2Port mEnumeration = false; mLogarithmic = false; mNotOnGui = false; - mCtrl.button = NULL; - mText = NULL; + mCtrl.button = nullptr; + mText = nullptr; }; wxString mUnits; @@ -258,7 +258,7 @@ class LV2Effect final : public wxEvtHandler, { public: LV2Effect(const LilvPlugin *plug); - virtual ~LV2Effect(); + ~LV2Effect() override; // ComponentInterface implementation @@ -296,7 +296,7 @@ class LV2Effect final : public wxEvtHandler, size_t GetTailSize() override; bool IsReady() override; - bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; + bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = nullptr) override; bool ProcessFinalize() override; size_t ProcessBlock(float **inbuf, float **outbuf, size_t size) override; @@ -345,7 +345,7 @@ class LV2Effect final : public wxEvtHandler, bool SaveParameters(const RegistryPath & group); LV2Wrapper *InitInstance(float sampleRate); - void FreeInstance(LV2Wrapper *wrapper); + static void FreeInstance(LV2Wrapper *wrapper); static uint32_t uri_to_id(LV2_URI_Map_Callback_Data callback_data, const char *map, @@ -385,7 +385,7 @@ class LV2Effect final : public wxEvtHandler, bool TransferDataToWindow() /* not override */; bool TransferDataFromWindow() /* not override */; - void SetSlider(const LV2ControlPortPtr & port); + static void SetSlider(const LV2ControlPortPtr & port); void OnTrigger(wxCommandEvent & evt); void OnToggle(wxCommandEvent & evt); @@ -596,19 +596,19 @@ class LV2Wrapper : public wxThreadHelper public: LV2Wrapper(LV2Effect *effect); - virtual ~LV2Wrapper(); + ~LV2Wrapper() override; LilvInstance *Instantiate(const LilvPlugin *plugin, double sampleRrate, std::vector> & features); - void *Entry(); + void *Entry() override; LilvInstance *GetInstance(); LV2_Handle GetHandle(); - float GetLatency(); + float GetLatency() const; void SetFreeWheeling(bool enable); diff --git a/src/effects/lv2/LoadLV2.cpp b/src/effects/lv2/LoadLV2.cpp index 91aa2e65fc..f4ebeec460 100644 --- a/src/effects/lv2/LoadLV2.cpp +++ b/src/effects/lv2/LoadLV2.cpp @@ -77,7 +77,7 @@ DECLARE_BUILTIN_MODULE(LV2sEffectBuiltin); /////////////////////////////////////////////////////////////////////////////// using UriHash = std::unordered_map; -LilvWorld *gWorld = NULL; +LilvWorld *gWorld = nullptr; LV2EffectsModule::LV2EffectsModule() { @@ -212,9 +212,7 @@ void LV2EffectsModule::Terminate() NODELIST lilv_world_free(gWorld); - gWorld = NULL; - - return; + gWorld = nullptr; } EffectFamilySymbol LV2EffectsModule::GetOptionalFamilySymbol() @@ -284,7 +282,7 @@ unsigned LV2EffectsModule::DiscoverPluginsAtPath( if (plug) { LV2Effect effect(plug); - if (effect.SetHost(NULL)) + if (effect.SetHost(nullptr)) { if (callback) callback( this, &effect ); @@ -300,7 +298,7 @@ bool LV2EffectsModule::IsPluginValid(const PluginPath & path, bool bFast) { if( bFast ) return true; - return GetPlugin(path) != NULL; + return GetPlugin(path) != nullptr; } std::unique_ptr @@ -321,7 +319,7 @@ const LilvPlugin *LV2EffectsModule::GetPlugin(const PluginPath & path) LilvNode *uri = lilv_new_uri(gWorld, path.ToUTF8()); if (!uri) { - return NULL; + return nullptr; } const LilvPlugin *plug = lilv_plugins_get_by_uri(lilv_world_get_all_plugins(gWorld), uri); diff --git a/src/effects/lv2/LoadLV2.h b/src/effects/lv2/LoadLV2.h index 4bc169728e..d8aef6e1da 100644 --- a/src/effects/lv2/LoadLV2.h +++ b/src/effects/lv2/LoadLV2.h @@ -165,7 +165,7 @@ class LV2EffectsModule final : public ModuleInterface { public: LV2EffectsModule(); - virtual ~LV2EffectsModule(); + ~LV2EffectsModule() override; // ComponentInterface implementation @@ -199,7 +199,7 @@ class LV2EffectsModule final : public ModuleInterface // LV2EffectModule implementation private: - const LilvPlugin *GetPlugin(const PluginPath & path); + static const LilvPlugin *GetPlugin(const PluginPath & path); }; extern LilvWorld *gWorld; diff --git a/src/effects/lv2/NativeWindow.h b/src/effects/lv2/NativeWindow.h index bd9098b57c..b852fd08b8 100644 --- a/src/effects/lv2/NativeWindow.h +++ b/src/effects/lv2/NativeWindow.h @@ -88,7 +88,7 @@ class NativeWindow : public wxWindow #elif defined(__WXGTK__) - virtual ~NativeWindow() + ~NativeWindow() override { } diff --git a/src/effects/lv2/zix/ring.cpp b/src/effects/lv2/zix/ring.cpp index dbb7220027..b05b0d13b7 100644 --- a/src/effects/lv2/zix/ring.cpp +++ b/src/effects/lv2/zix/ring.cpp @@ -14,9 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include +#include +#include +#include #ifdef HAVE_MLOCK # include @@ -73,7 +73,7 @@ next_power_of_two(uint32_t size) ZixRing* zix_ring_new(uint32_t size) { - ZixRing* ring = (ZixRing*)malloc(sizeof(ZixRing)); + auto* ring = (ZixRing*)malloc(sizeof(ZixRing)); ring->write_head = 0; ring->read_head = 0; ring->size = next_power_of_two(size); diff --git a/src/effects/lv2/zix/ring.h b/src/effects/lv2/zix/ring.h index 59c9877399..48ad61f319 100644 --- a/src/effects/lv2/zix/ring.h +++ b/src/effects/lv2/zix/ring.h @@ -17,7 +17,7 @@ #ifndef ZIX_RING_H #define ZIX_RING_H -#include +#include #include "common.h" diff --git a/src/effects/nyquist/LoadNyquist.cpp b/src/effects/nyquist/LoadNyquist.cpp index a07e4f81aa..23ad874bf1 100644 --- a/src/effects/nyquist/LoadNyquist.cpp +++ b/src/effects/nyquist/LoadNyquist.cpp @@ -147,9 +147,7 @@ bool NyquistEffectsModule::Initialize() void NyquistEffectsModule::Terminate() { - nyx_set_xlisp_path(NULL); - - return; + nyx_set_xlisp_path(nullptr); } EffectFamilySymbol NyquistEffectsModule::GetOptionalFamilySymbol() @@ -188,10 +186,10 @@ bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) PluginManagerInterface::DefaultRegistrationCallback); } - for (size_t i = 0; i < WXSIZEOF(kShippedEffects); i++) + for (auto & kShippedEffect : kShippedEffects) { files.clear(); - pm.FindFilesInPathList(kShippedEffects[i], pathList, files); + pm.FindFilesInPathList(kShippedEffect, pathList, files); for (size_t j = 0, cnt = files.size(); j < cnt; j++) { /* diff --git a/src/effects/nyquist/LoadNyquist.h b/src/effects/nyquist/LoadNyquist.h index a6f049daa8..6c0d25a747 100644 --- a/src/effects/nyquist/LoadNyquist.h +++ b/src/effects/nyquist/LoadNyquist.h @@ -22,7 +22,7 @@ class NyquistEffectsModule final : public ModuleInterface { public: NyquistEffectsModule(); - virtual ~NyquistEffectsModule(); + ~NyquistEffectsModule() override; // ComponentInterface implementation diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index b5a0ce1d6f..9304613c25 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -32,7 +32,7 @@ effects from this one class. #include #include -#include +#include #include #include @@ -85,11 +85,11 @@ effects from this one class. #error You need to update lib-src/libnyquist #endif -#include +#include #include #include #include -#include +#include int NyquistEffect::mReentryCount = 0; @@ -288,7 +288,7 @@ bool NyquistEffect::IsInteractive() return true; } - return mControls.size() != 0; + return !mControls.empty(); } bool NyquistEffect::IsDefault() @@ -326,9 +326,8 @@ bool NyquistEffect::DefineParams( ShuttleParams & S ) return true; } - for (size_t c = 0, cnt = mControls.size(); c < cnt; c++) + for (auto & ctrl : mControls) { - NyqControl & ctrl = mControls[c]; double d = ctrl.val; if (d == UNINITIALIZED_CONTROL && ctrl.type != NYQ_CTRL_STRING) @@ -374,9 +373,8 @@ bool NyquistEffect::GetAutomationParameters(CommandParameters & parms) return true; } - for (size_t c = 0, cnt = mControls.size(); c < cnt; c++) + for (auto & ctrl : mControls) { - NyqControl & ctrl = mControls[c]; double d = ctrl.val; if (d == UNINITIALIZED_CONTROL && ctrl.type != NYQ_CTRL_STRING) @@ -476,9 +474,8 @@ int NyquistEffect::SetLispVarsFromParameters(CommandParameters & parms, bool bTe { int badCount = 0; // First pass verifies values - for (size_t c = 0, cnt = mControls.size(); c < cnt; c++) + for (auto & ctrl : mControls) { - NyqControl & ctrl = mControls[c]; bool good = false; // This GetCtrlValue code is preserved from former code, @@ -630,7 +627,7 @@ bool NyquistEffect::CheckWhetherSkipEffect() { // If we're a prompt and we have controls, then we've already processed // the audio, so skip further processing. - return (mIsPrompt && mControls.size() > 0 && !IsBatchProcessing()); + return (mIsPrompt && !mControls.empty() && !IsBatchProcessing()); } static void RegisterFunctions(); @@ -828,7 +825,7 @@ bool NyquistEffect::Process() // (we have no idea what the length of the returned audio will be, so we have // to handle sync-lock group behavior the "old" way). mFirstInGroup = true; - Track *gtLast = NULL; + Track *gtLast = nullptr; for (; bOnePassTool || pRange->first != pRange->second; @@ -902,7 +899,7 @@ bool NyquistEffect::Process() // if available, or fix libnyquist to be locale-independent. // See also http://bugzilla.audacityteam.org/show_bug.cgi?id=642#c9 // for further info about this thread safety question. - wxString prevlocale = wxSetlocale(LC_NUMERIC, NULL); + wxString prevlocale = wxSetlocale(LC_NUMERIC, nullptr); wxSetlocale(LC_NUMERIC, wxString(wxT("C"))); nyx_init(); @@ -910,8 +907,8 @@ bool NyquistEffect::Process() nyx_capture_output(StaticOutputCallback, (void *)this); auto cleanup = finally( [&] { - nyx_capture_output(NULL, (void *)NULL); - nyx_set_os_callback(NULL, (void *)NULL); + nyx_capture_output(nullptr, (void *)nullptr); + nyx_set_os_callback(nullptr, (void *)nullptr); nyx_cleanup(); } ); @@ -1025,7 +1022,7 @@ bool NyquistEffect::ShowInterface( // We're done if the user clicked "Close", we are not the Nyquist Prompt, // or the program currently loaded into the prompt doesn't have a UI. - if (!res || !mIsPrompt || mControls.size() == 0) + if (!res || !mIsPrompt || mControls.empty()) { return res; } @@ -1325,30 +1322,30 @@ bool NyquistEffect::ProcessOne() cmd += wxT("(setf *tracenable* NIL)\n"); } - for (unsigned int j = 0; j < mControls.size(); j++) { - if (mControls[j].type == NYQ_CTRL_FLOAT || mControls[j].type == NYQ_CTRL_FLOAT_TEXT || - mControls[j].type == NYQ_CTRL_TIME) { + for (auto & mControl : mControls) { + if (mControl.type == NYQ_CTRL_FLOAT || mControl.type == NYQ_CTRL_FLOAT_TEXT || + mControl.type == NYQ_CTRL_TIME) { // We use Internat::ToString() rather than "%f" here because we // always have to use the dot as decimal separator when giving // numbers to Nyquist, whereas using "%f" will use the user's // decimal separator which may be a comma in some countries. cmd += wxString::Format(wxT("(setf %s %s)\n"), - mControls[j].var, - Internat::ToString(mControls[j].val, 14)); + mControl.var, + Internat::ToString(mControl.val, 14)); } - else if (mControls[j].type == NYQ_CTRL_INT || - mControls[j].type == NYQ_CTRL_INT_TEXT || - mControls[j].type == NYQ_CTRL_CHOICE) { + else if (mControl.type == NYQ_CTRL_INT || + mControl.type == NYQ_CTRL_INT_TEXT || + mControl.type == NYQ_CTRL_CHOICE) { cmd += wxString::Format(wxT("(setf %s %d)\n"), - mControls[j].var, - (int)(mControls[j].val)); + mControl.var, + (int)(mControl.val)); } - else if (mControls[j].type == NYQ_CTRL_STRING || mControls[j].type == NYQ_CTRL_FILE) { + else if (mControl.type == NYQ_CTRL_STRING || mControl.type == NYQ_CTRL_FILE) { cmd += wxT("(setf "); // restrict variable names to 7-bit ASCII: - cmd += mControls[j].var; + cmd += mControl.var; cmd += wxT(" \""); - cmd += EscapeString(mControls[j].valStr); // unrestricted value will become quoted UTF-8 + cmd += EscapeString(mControl.valStr); // unrestricted value will become quoted UTF-8 cmd += wxT("\")\n"); } } @@ -1516,7 +1513,7 @@ bool NyquistEffect::ProcessOne() unsigned int l; auto ltrack = * mOutputTracks->Any< LabelTrack >().begin(); if (!ltrack) { - ltrack = static_cast( + ltrack = dynamic_cast( AddToOutputTracks(std::make_shared())); } @@ -1642,7 +1639,7 @@ bool NyquistEffect::ProcessOne() wxString NyquistEffect::NyquistToWxString(const char *nyqString) { wxString str(nyqString, wxConvUTF8); - if (nyqString != NULL && nyqString[0] && str.empty()) { + if (nyqString != nullptr && nyqString[0] && str.empty()) { // invalid UTF-8 string, convert as Latin-1 str = _("[Warning: Nyquist returned invalid UTF-8 string, converted here as Latin-1]"); // TODO: internationalization of strings from Nyquist effects, at least @@ -1689,7 +1686,7 @@ std::vector NyquistEffect::ParseChoice(const wxString & text) wxT(",") ); for (auto &choice : choices) - results.push_back( { choice.Trim(true).Trim(false) } ); + results.emplace_back( choice.Trim(true).Trim(false) ); } return results; } @@ -1769,7 +1766,7 @@ void NyquistEffect::SetCommand(const wxString &cmd) { mExternal = true; - if (cmd.size()) { + if (!cmd.empty()) { ParseCommand(cmd); } } @@ -2421,7 +2418,7 @@ int NyquistEffect::StaticGetCallback(float *buffer, int channel, int64_t start, int64_t len, int64_t totlen, void *userdata) { - NyquistEffect *This = (NyquistEffect *)userdata; + auto *This = (NyquistEffect *)userdata; return This->GetCallback(buffer, channel, start, len, totlen); } @@ -2488,7 +2485,7 @@ int NyquistEffect::StaticPutCallback(float *buffer, int channel, int64_t start, int64_t len, int64_t totlen, void *userdata) { - NyquistEffect *This = (NyquistEffect *)userdata; + auto *This = (NyquistEffect *)userdata; return This->PutCallback(buffer, channel, start, len, totlen); } @@ -2606,7 +2603,7 @@ bool NyquistEffect::TransferDataToEffectWindow() val = 0; } - wxChoice *c = (wxChoice *) mUIParent->FindWindow(ID_Choice + i); + auto *c = (wxChoice *) mUIParent->FindWindow(ID_Choice + i); c->SetSelection(val); } else if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_FLOAT) @@ -2614,12 +2611,12 @@ bool NyquistEffect::TransferDataToEffectWindow() // wxTextCtrls are handled by the validators double range = ctrl.high - ctrl.low; int val = (int)(0.5 + ctrl.ticks * (ctrl.val - ctrl.low) / range); - wxSlider *s = (wxSlider *) mUIParent->FindWindow(ID_Slider + i); + auto *s = (wxSlider *) mUIParent->FindWindow(ID_Slider + i); s->SetValue(val); } else if (ctrl.type == NYQ_CTRL_TIME) { - NumericTextCtrl *n = (NumericTextCtrl *) mUIParent->FindWindow(ID_Time + i); + auto *n = (NumericTextCtrl *) mUIParent->FindWindow(ID_Time + i); n->SetValue(ctrl.val); } } @@ -2647,7 +2644,7 @@ bool NyquistEffect::TransferDataFromPromptWindow() bool NyquistEffect::TransferDataFromEffectWindow() { - if (mControls.size() == 0) + if (mControls.empty()) { return true; } @@ -2729,7 +2726,7 @@ bool NyquistEffect::TransferDataFromEffectWindow() if (ctrl->type == NYQ_CTRL_TIME) { - NumericTextCtrl *n = (NumericTextCtrl *) mUIParent->FindWindow(ID_Time + i); + auto *n = (NumericTextCtrl *) mUIParent->FindWindow(ID_Time + i); ctrl->val = n->GetValue(); } @@ -2869,7 +2866,7 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S) .MenuEnabled(true) .ReadOnly(false); - NumericTextCtrl *time = safenew + auto *time = safenew NumericTextCtrl(S.GetParent(), (ID_Time + i), NumericConverter::TIME, GetSelectionFormat(), @@ -2977,7 +2974,7 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S) // NyquistEffect implementation -bool NyquistEffect::IsOk() +bool NyquistEffect::IsOk() const { return mOK; } @@ -3097,7 +3094,7 @@ void NyquistEffect::OnTime(wxCommandEvent& evt) static double value = 0.0; NyqControl & ctrl = mControls[i]; - NumericTextCtrl *n = (NumericTextCtrl *) mUIParent->FindWindow(ID_Time + i); + auto *n = (NumericTextCtrl *) mUIParent->FindWindow(ID_Time + i); double val = n->GetValue(); // Observed that two events transmitted on each control change (Linux) @@ -3195,9 +3192,9 @@ void NyquistEffect::OnFileButton(wxCommandEvent& evt) wxArrayString selectedFiles; openFileDialog.GetPaths(selectedFiles); - for (size_t sf = 0; sf < selectedFiles.size(); sf++) { + for (const auto & selectedFile : selectedFiles) { path += "\""; - path += selectedFiles[sf]; + path += selectedFile; path += "\""; } ctrl.valStr = path; @@ -3210,7 +3207,7 @@ void NyquistEffect::OnFileButton(wxCommandEvent& evt) mUIParent->FindWindow(ID_Text + i)->GetValidator()->TransferToWindow(); } -void NyquistEffect::resolveFilePath(wxString& path, FileExtension extension /* empty string */) +void NyquistEffect::resolveFilePath(wxString& path, const FileExtension& extension /* empty string */) { #if defined(__WXMSW__) path.Replace("/", wxFileName::GetPathSeparator()); @@ -3268,7 +3265,7 @@ void NyquistEffect::resolveFilePath(wxString& path, FileExtension extension /* e } -bool NyquistEffect::validatePath(wxString path) +bool NyquistEffect::validatePath(const wxString& path) { wxFileName fname = path; wxString dir = fname.GetPath(); @@ -3302,7 +3299,7 @@ void NyquistEffect::OnText(wxCommandEvent & evt) int pos = (int)floor((ctrl.val - ctrl.low) / (ctrl.high - ctrl.low) * ctrl.ticks + 0.5); - wxSlider *slider = (wxSlider *)mUIParent->FindWindow(ID_Slider + i); + auto *slider = (wxSlider *)mUIParent->FindWindow(ID_Slider + i); slider->SetValue(pos); } } @@ -3443,7 +3440,7 @@ void * nyq_make_opaque_string( int size, unsigned char *src ){ /* xlc_aud_do -- interface to C routine aud_do */ /**/ -LVAL xlc_aud_do(void) +LVAL xlc_aud_do() { // Based on string-trim... unsigned char *leftp; diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index f9094992db..c46d6edea4 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -69,7 +69,7 @@ class SAUCEDACITY_DLL_API NyquistEffect final : public Effect * an empty string, then prompt the user for the Nyquist code to interpret. */ NyquistEffect(const wxString &fName); - virtual ~NyquistEffect(); + ~NyquistEffect() override; // ComponentInterface implementation @@ -131,16 +131,16 @@ class SAUCEDACITY_DLL_API NyquistEffect final : public Effect bool TransferDataFromPromptWindow(); bool TransferDataFromEffectWindow(); - bool IsOk(); - const TranslatableString &InitializationError() const { return mInitError; } + bool IsOk() const; + [[nodiscard]] const TranslatableString &InitializationError() const { return mInitError; } static FilePaths GetNyquistSearchPath(); static wxString NyquistToWxString(const char *nyqString); - wxString EscapeString(const wxString & inStr); + static wxString EscapeString(const wxString & inStr); static std::vector ParseChoice(const wxString & text); - FileExtensions ParseFileExtensions(const wxString & text); + static FileExtensions ParseFileExtensions(const wxString & text); FileNames::FileType ParseFileType(const wxString & text); FileNames::FileTypes ParseFileTypes(const wxString & text); @@ -180,7 +180,7 @@ class SAUCEDACITY_DLL_API NyquistEffect final : public Effect wxString *pExtraString = nullptr); static wxString UnQuote(const wxString &s, bool allowParens = true, wxString *pExtraString = nullptr); - double GetCtrlValue(const wxString &s); + static double GetCtrlValue(const wxString &s); void OnLoad(wxCommandEvent & evt); void OnSave(wxCommandEvent & evt); @@ -192,9 +192,9 @@ class SAUCEDACITY_DLL_API NyquistEffect final : public Effect void OnTime(wxCommandEvent & evt); void OnFileButton(wxCommandEvent & evt); - void resolveFilePath(wxString & path, FileExtension extension = {}); - bool validatePath(wxString path); - wxString ToTimeFormat(double t); + static void resolveFilePath(wxString & path, const FileExtension& extension = {}); + static bool validatePath(const wxString& path); + static wxString ToTimeFormat(double t); private: diff --git a/src/effects/vamp/LoadVamp.cpp b/src/effects/vamp/LoadVamp.cpp index 4ce2ee6669..d1cd6e8961 100644 --- a/src/effects/vamp/LoadVamp.cpp +++ b/src/effects/vamp/LoadVamp.cpp @@ -103,8 +103,7 @@ bool VampEffectsModule::Initialize() void VampEffectsModule::Terminate() { // Nothing to do here - return; -} + } EffectFamilySymbol VampEffectsModule::GetOptionalFamilySymbol() { @@ -134,9 +133,9 @@ PluginPaths VampEffectsModule::FindPluginPaths(PluginManagerInterface & WXUNUSED PluginLoader::PluginKeyList keys = loader->listPlugins(); - for (PluginLoader::PluginKeyList::iterator i = keys.begin(); i != keys.end(); ++i) + for (auto & key : keys) { - std::unique_ptr vp{ PluginLoader::getInstance()->loadPlugin(*i, 48000) }; // rate doesn't matter here + std::unique_ptr vp{ PluginLoader::getInstance()->loadPlugin(key, 48000) }; // rate doesn't matter here if (!vp) { continue; @@ -165,7 +164,7 @@ PluginPaths VampEffectsModule::FindPluginPaths(PluginManagerInterface & WXUNUSED int output = 0; - for (Plugin::OutputList::iterator j = outputs.begin(); j != outputs.end(); ++j) + for (auto j = outputs.begin(); j != outputs.end(); ++j) { if (j->sampleType == Plugin::OutputDescriptor::FixedSampleRate || j->sampleType == Plugin::OutputDescriptor::OneSamplePerStep || @@ -193,7 +192,7 @@ PluginPaths VampEffectsModule::FindPluginPaths(PluginManagerInterface & WXUNUSED } } - wxString path = wxString::FromUTF8(i->c_str()) + wxT("/") + name; + wxString path = wxString::FromUTF8(key.c_str()) + wxT("/") + name; names.push_back(path); ++output; @@ -287,7 +286,7 @@ std::unique_ptr VampEffectsModule::FindPlugin(const PluginPath & p hasParameters = !vp->getParameterDescriptors().empty(); - for (Plugin::OutputList::iterator j = outputs.begin(); j != outputs.end(); ++j) + for (auto j = outputs.begin(); j != outputs.end(); ++j) { if (j->sampleType == Plugin::OutputDescriptor::FixedSampleRate || j->sampleType == Plugin::OutputDescriptor::OneSamplePerStep || diff --git a/src/effects/vamp/LoadVamp.h b/src/effects/vamp/LoadVamp.h index 45ce2652be..ddc5d8bce4 100644 --- a/src/effects/vamp/LoadVamp.h +++ b/src/effects/vamp/LoadVamp.h @@ -31,7 +31,7 @@ class VampEffectsModule final : public ModuleInterface { public: VampEffectsModule(); - virtual ~VampEffectsModule(); + ~VampEffectsModule() override; // ComponentInterface implementation @@ -65,7 +65,7 @@ class VampEffectsModule final : public ModuleInterface private: // VampEffectModule implementation - std::unique_ptr FindPlugin(const PluginPath & wpath, + static std::unique_ptr FindPlugin(const PluginPath & wpath, int & output, bool & hasParameters); }; diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index 3a8e73b9cd..60b8d755cb 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -147,15 +147,15 @@ unsigned VampEffect::GetAudioInCount() bool VampEffect::GetAutomationParameters(CommandParameters & parms) { - for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++) + for (auto & mParameter : mParameters) { - wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str()); - float value = mPlugin->getParameter(mParameters[p].identifier); - float lower = mParameters[p].minValue; - float upper = mParameters[p].maxValue; + wxString key = wxString::FromUTF8(mParameter.identifier.c_str()); + float value = mPlugin->getParameter(mParameter.identifier); + float lower = mParameter.minValue; + float upper = mParameter.maxValue; - if (mParameters[p].isQuantized && - mParameters[p].quantizeStep == 1.0 && + if (mParameter.isQuantized && + mParameter.quantizeStep == 1.0 && lower == 0.0 && upper == 1.0) { @@ -163,21 +163,21 @@ bool VampEffect::GetAutomationParameters(CommandParameters & parms) parms.Write(key, val); } - else if (mParameters[p].isQuantized && - mParameters[p].quantizeStep == 1.0 && - !mParameters[p].valueNames.empty()) + else if (mParameter.isQuantized && + mParameter.quantizeStep == 1.0 && + !mParameter.valueNames.empty()) { std::vector choices; int val = 0; - for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++) + for (size_t i = 0, choiceCount = mParameter.valueNames.size(); i < choiceCount; i++) { - wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str()); - if (size_t(value - mParameters[p].minValue + 0.5) == i) + wxString choice = wxString::FromUTF8(mParameter.valueNames[i].c_str()); + if (size_t(value - mParameter.minValue + 0.5) == i) { val = i; } - choices.push_back(choice); + choices.emplace_back(choice); } parms.WriteEnum(key, val, choices.data(), choices.size()); @@ -194,15 +194,15 @@ bool VampEffect::GetAutomationParameters(CommandParameters & parms) bool VampEffect::SetAutomationParameters(CommandParameters & parms) { // First pass verifies values - for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++) + for (auto & mParameter : mParameters) { - wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str()); - float lower = mParameters[p].minValue; - float upper = mParameters[p].maxValue; + wxString key = wxString::FromUTF8(mParameter.identifier.c_str()); + float lower = mParameter.minValue; + float upper = mParameter.maxValue; bool good = false; - if (mParameters[p].isQuantized && - mParameters[p].quantizeStep == 1.0 && + if (mParameter.isQuantized && + mParameter.quantizeStep == 1.0 && lower == 0.0 && upper == 1.0) { @@ -210,17 +210,17 @@ bool VampEffect::SetAutomationParameters(CommandParameters & parms) good = parms.Read(key, &val); } - else if (mParameters[p].isQuantized && - mParameters[p].quantizeStep == 1.0 && - !mParameters[p].valueNames.empty()) + else if (mParameter.isQuantized && + mParameter.quantizeStep == 1.0 && + !mParameter.valueNames.empty()) { std::vector choices; int val; - for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++) + for (size_t i = 0, choiceCount = mParameter.valueNames.size(); i < choiceCount; i++) { - wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str()); - choices.push_back(choice); + wxString choice = wxString::FromUTF8(mParameter.valueNames[i].c_str()); + choices.emplace_back(choice); } good = parms.ReadEnum(key, &val, choices.data(), choices.size()) && val != wxNOT_FOUND; @@ -239,14 +239,14 @@ bool VampEffect::SetAutomationParameters(CommandParameters & parms) } // Second pass sets the variables - for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++) + for (auto & mParameter : mParameters) { - wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str()); - float lower = mParameters[p].minValue; - float upper = mParameters[p].maxValue; + wxString key = wxString::FromUTF8(mParameter.identifier.c_str()); + float lower = mParameter.minValue; + float upper = mParameter.maxValue; - if (mParameters[p].isQuantized && - mParameters[p].quantizeStep == 1.0 && + if (mParameter.isQuantized && + mParameter.quantizeStep == 1.0 && lower == 0.0 && upper == 1.0) { @@ -254,24 +254,24 @@ bool VampEffect::SetAutomationParameters(CommandParameters & parms) parms.Read(key, &val); - mPlugin->setParameter(mParameters[p].identifier, val ? upper : lower); + mPlugin->setParameter(mParameter.identifier, val ? upper : lower); } - else if (mParameters[p].isQuantized && - mParameters[p].quantizeStep == 1.0 && - !mParameters[p].valueNames.empty()) + else if (mParameter.isQuantized && + mParameter.quantizeStep == 1.0 && + !mParameter.valueNames.empty()) { std::vector choices; int val = 0; - for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++) + for (size_t i = 0, choiceCount = mParameter.valueNames.size(); i < choiceCount; i++) { - wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str()); - choices.push_back(choice); + wxString choice = wxString::FromUTF8(mParameter.valueNames[i].c_str()); + choices.emplace_back(choice); } parms.ReadEnum(key, &val, choices.data(), choices.size()); - mPlugin->setParameter(mParameters[p].identifier, (float) val); + mPlugin->setParameter(mParameter.identifier, (float) val); } else { @@ -279,9 +279,9 @@ bool VampEffect::SetAutomationParameters(CommandParameters & parms) parms.Read(key, &val); - if (mParameters[p].isQuantized) + if (mParameter.isQuantized) { - float qs = mParameters[p].quantizeStep; + float qs = mParameter.quantizeStep; if (qs != 0.0) { @@ -289,7 +289,7 @@ bool VampEffect::SetAutomationParameters(CommandParameters & parms) } } - mPlugin->setParameter(mParameters[p].identifier, val); + mPlugin->setParameter(mParameter.identifier, val); } } @@ -373,7 +373,7 @@ bool VampEffect::Process() // channelGroup now contains all but the first channel const WaveTrack *right = - channelGroup.size() ? *channelGroup.first++ : nullptr; + !channelGroup.empty() ? *channelGroup.first++ : nullptr; if (right) channels = 2; @@ -718,9 +718,9 @@ bool VampEffect::TransferDataFromWindow() // VampEffect implementation void VampEffect::AddFeatures(LabelTrack *ltrack, - Vamp::Plugin::FeatureSet &features) + Vamp::Plugin::FeatureSet &features) const { - for (Vamp::Plugin::FeatureList::iterator fli = features[mOutput].begin(); + for (auto fli = features[mOutput].begin(); fli != features[mOutput].end(); ++fli) { Vamp::RealTime ftime0 = fli->timestamp; @@ -731,7 +731,7 @@ void VampEffect::AddFeatures(LabelTrack *ltrack, double ltime1 = ftime1.sec + (double(ftime1.nsec) / 1000000000.0); wxString label = LAT1CTOWX(fli->label.c_str()); - if (label == wxString()) + if (label.empty()) { if (fli->values.empty()) { diff --git a/src/effects/vamp/VampEffect.h b/src/effects/vamp/VampEffect.h index 2555b0da61..d8d8239712 100644 --- a/src/effects/vamp/VampEffect.h +++ b/src/effects/vamp/VampEffect.h @@ -38,7 +38,7 @@ class VampEffect final : public Effect const PluginPath & path, int output, bool hasParameters); - virtual ~VampEffect(); + ~VampEffect() override; // ComponentInterface implementation @@ -73,7 +73,7 @@ class VampEffect final : public Effect private: // VampEffect implementation - void AddFeatures(LabelTrack *track, Vamp::Plugin::FeatureSet & features); + void AddFeatures(LabelTrack *track, Vamp::Plugin::FeatureSet & features) const; void UpdateFromPlugin(); diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 6c44162332..614e287c74 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -57,6 +57,8 @@ #include #include +#include + #include "../theme/AllThemeResources.h" #include "../Mix.h" #include "../prefs/ImportExportPrefs.h" @@ -284,7 +286,7 @@ END_EVENT_TABLE() namespace { const auto PathStart = wxT("Exporters"); -static Registry::GroupItem &sRegistry() +Registry::GroupItem &sRegistry() { static Registry::TransparentGroupItem<> registry{ PathStart }; return registry; @@ -292,9 +294,9 @@ static Registry::GroupItem &sRegistry() struct ExporterItem final : Registry::SingleItem { ExporterItem( - const Identifier &id, const Exporter::ExportPluginFactory &factory ) + const Identifier &id, Exporter::ExportPluginFactory factory ) : SingleItem{ id } - , mFactory{ factory } + , mFactory{std::move( factory )} {} Exporter::ExportPluginFactory mFactory; @@ -327,8 +329,8 @@ Exporter::Exporter( SaucedacityProject &project ) { {wxT(""), wxT("PCM,MP3,OGG,FLAC,MP2,CommandLine,FFmpeg") } }, }; - mMixerSpec = NULL; - mBook = NULL; + mMixerSpec = nullptr; + mBook = nullptr; // build the list of export plugins. for ( const auto &factory : sFactories() ) @@ -346,7 +348,7 @@ Exporter::Exporter( SaucedacityProject &project ) void Visit( SingleItem &item, const Path &path ) override { mPlugins.emplace_back( - static_cast( item ).mFactory() ); + dynamic_cast( item ).mFactory() ); } ExportPluginArray mPlugins; @@ -646,7 +648,7 @@ bool Exporter::GetFilename() mFilename.SetName(_("untitled")); while (true) { // Must reset each iteration - mBook = NULL; + mBook = nullptr; { auto useFileName = mFilename; @@ -893,7 +895,7 @@ bool Exporter::CheckMix(bool prompt /*= true*/ ) ExportMixerDialog md(&TrackList::Get( *mProject ), mSelectedOnly, exportedChannels, - NULL, + nullptr, 1, XO("Advanced Mixing Options")); if (prompt) { @@ -947,7 +949,7 @@ bool Exporter::ExportTracks() mT0, mT1, mMixerSpec.get(), - NULL, + nullptr, mSubFormat); success = @@ -958,7 +960,7 @@ bool Exporter::ExportTracks() void Exporter::CreateUserPaneCallback(wxWindow *parent, wxUIntPtr userdata) { - Exporter *self = (Exporter *) userdata; + auto *self = (Exporter *) userdata; if (self) { self->CreateUserPane(parent); @@ -998,8 +1000,6 @@ void Exporter::CreateUserPane(wxWindow *parent) S.EndHorizontalLay(); } S.EndStatic(); - - return; } void Exporter::OnFilterChanged(wxFileCtrlEvent & evt) @@ -1007,7 +1007,7 @@ void Exporter::OnFilterChanged(wxFileCtrlEvent & evt) int index = evt.GetFilterIndex(); // On GTK, this event can fire before the userpane is created - if (mBook == NULL || index < 0 || index >= (int) mBook->GetPageCount()) + if (mBook == nullptr || index < 0 || index >= (int) mBook->GetPageCount()) { return; } @@ -1043,7 +1043,7 @@ void Exporter::OnFilterChanged(wxFileCtrlEvent & evt) bool Exporter::ProcessFromTimerRecording(bool selectedOnly, double t0, double t1, - wxFileName fnFile, + const wxFileName& fnFile, int iFormat, int iSubFormat, int iFilterIndex) @@ -1083,15 +1083,15 @@ bool Exporter::ProcessFromTimerRecording(bool selectedOnly, return success; } -int Exporter::GetAutoExportFormat() { +int Exporter::GetAutoExportFormat() const { return mFormat; } -int Exporter::GetAutoExportSubFormat() { +int Exporter::GetAutoExportSubFormat() const { return mSubFormat; } -int Exporter::GetAutoExportFilterIndex() { +int Exporter::GetAutoExportFilterIndex() const { return mFormat; } @@ -1129,14 +1129,14 @@ END_EVENT_TABLE() ExportMixerPanel::ExportMixerPanel( wxWindow *parent, wxWindowID id, MixerSpec *mixerSpec, - wxArrayString trackNames, + const wxArrayString& trackNames, const wxPoint& pos, const wxSize& size): wxPanelWrapper(parent, id, pos, size) , mMixerSpec{mixerSpec} , mChannelRects{ mMixerSpec->GetMaxNumChannels() } , mTrackRects{ mMixerSpec->GetNumTracks() } { - mBitmap = NULL; + mBitmap = nullptr; mWidth = 0; mHeight = 0; mSelectedTrack = mSelectedChannel = -1; @@ -1474,7 +1474,7 @@ void ExportMixerDialog::OnSize(wxSizeEvent &event) void ExportMixerDialog::OnSlider( wxCommandEvent & WXUNUSED(event)) { - wxSlider *channels = ( wxSlider* )FindWindow( ID_SLIDER_CHANNEL ); + auto *channels = ( wxSlider* )FindWindow( ID_SLIDER_CHANNEL ); ExportMixerPanel *pnl = ( ( ExportMixerPanel* ) FindWindow( ID_MIXERPANEL ) ); mMixerSpec->SetNumChannels( channels->GetValue() ); pnl->Refresh( false ); @@ -1517,7 +1517,7 @@ TranslatableString AudacityExportMessageStr() // page as we learn more about when (if ever) these errors actually happen. // The number happens to at one time have been a line number, but all // we need from them is that they be distinct. -void ShowExportErrorDialog(wxString ErrorCode, +void ShowExportErrorDialog(const wxString& ErrorCode, TranslatableString message, const TranslatableString& caption) { diff --git a/src/export/Export.h b/src/export/Export.h index ab7ada3706..b7adbe316a 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -132,12 +132,12 @@ class SAUCEDACITY_DLL_API ExportPlugin /* not final */ bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) = 0; protected: - std::unique_ptr CreateMixer(const TrackList &tracks, + static std::unique_ptr CreateMixer(const TrackList &tracks, bool selectionOnly, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, @@ -188,7 +188,7 @@ class SAUCEDACITY_DLL_API Exporter final : public wxEvtHandler const TranslatableString &shortUndoDescription, bool force); Exporter( SaucedacityProject &project ); - virtual ~Exporter(); + ~Exporter() override; void SetFileDialogTitle( const TranslatableString & DialogTitle ); void SetDefaultFormat( const FileExtension & Format ){ mFormatName = Format;}; @@ -208,14 +208,14 @@ class SAUCEDACITY_DLL_API Exporter final : public wxEvtHandler bool ProcessFromTimerRecording(bool selectedOnly, double t0, double t1, - wxFileName fnFile, + const wxFileName& fnFile, int iFormat, int iSubFormat, int iFilterIndex); bool SetAutoExportOptions(); - int GetAutoExportFormat(); - int GetAutoExportSubFormat(); - int GetAutoExportFilterIndex(); + int GetAutoExportFormat() const; + int GetAutoExportSubFormat() const; + int GetAutoExportFilterIndex() const; wxFileName GetAutoExportFileName(); void OnExtensionChanged(wxCommandEvent &evt); void OnHelp(wxCommandEvent &evt); @@ -267,10 +267,10 @@ class ExportMixerPanel final : public wxPanelWrapper { public: ExportMixerPanel( wxWindow *parent, wxWindowID id, - MixerSpec *mixerSpec, wxArrayString trackNames, + MixerSpec *mixerSpec, const wxArrayString& trackNames, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - virtual ~ExportMixerPanel(); + ~ExportMixerPanel() override; void OnMouseEvent(wxMouseEvent & event); void OnPaint(wxPaintEvent & event); @@ -287,8 +287,8 @@ class ExportMixerPanel final : public wxPanelWrapper wxArrayString mTrackNames; int mBoxWidth, mChannelHeight, mTrackHeight; - void SetFont( wxMemoryDC &memDC, const wxString &text, int width, int height ); - double Distance( wxPoint &a, wxPoint &b ); + static void SetFont( wxMemoryDC &memDC, const wxString &text, int width, int height ); + static double Distance( wxPoint &a, wxPoint &b ); bool IsOnLine( wxPoint p, wxPoint la, wxPoint lb ); DECLARE_EVENT_TABLE() @@ -306,7 +306,7 @@ class ExportMixerDialog final : public wxDialogWrapper const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ); - virtual ~ExportMixerDialog(); + ~ExportMixerDialog() override; MixerSpec* GetMixerSpec() { return mMixerSpec.get(); } @@ -332,7 +332,7 @@ SAUCEDACITY_DLL_API TranslatableString AudacityExportMessageStr(); /// We have many Export errors that are essentially anonymous /// and are distinguished only by an error code number. /// Rather than repeat the code, we have it just once. -SAUCEDACITY_DLL_API void ShowExportErrorDialog(wxString ErrorCode, +SAUCEDACITY_DLL_API void ShowExportErrorDialog(const wxString& ErrorCode, TranslatableString message = AudacityExportMessageStr(), const TranslatableString& caption = AudacityExportCaptionStr()); diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index b5aaf05e6d..b7d3e31078 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -58,7 +58,7 @@ class ExportCLOptions final : public wxPanelWrapper { public: ExportCLOptions(wxWindow *parent, int format); - virtual ~ExportCLOptions(); + ~ExportCLOptions() override; void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; @@ -208,8 +208,6 @@ void ExportCLOptions::OnBrowse(wxCommandEvent& WXUNUSED(event)) } mCmd->SetInsertionPointEnd(); - - return; } //---------------------------------------------------------------------------- @@ -243,12 +241,12 @@ class ExportCLProcess final : public wxProcess Redirect(); } - bool IsActive() + bool IsActive() const { return mActive; } - void OnTerminate(int WXUNUSED( pid ), int status) + void OnTerminate(int WXUNUSED( pid ), int status) override { Drain(GetInputStream(), mOutput); Drain(GetErrorStream(), mOutput); @@ -257,7 +255,7 @@ class ExportCLProcess final : public wxProcess mActive = false; } - int GetStatus() + int GetStatus() const { return mStatus; } @@ -288,8 +286,8 @@ class ExportCL final : public ExportPlugin bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) override; // Optional @@ -298,7 +296,7 @@ class ExportCL final : public ExportPlugin private: void GetSettings(); - std::vector GetMetaChunk(const Tags *metadata); + static std::vector GetMetaChunk(const Tags *metadata); wxString mCmd; bool mShow; @@ -462,12 +460,12 @@ ProgressResult ExportCL::Export(SaucedacityProject *project, fmt.avgBytesPerSec = wxUINT32_SWAP_ON_BE(fmt.sampleRate * fmt.blockAlign); // Retrieve tags if not given a set - if (metadata == NULL) { + if (metadata == nullptr) { metadata = &Tags::Get(*project); } auto metachunk = GetMetaChunk(metadata); - if (metachunk.size()) { + if (!metachunk.empty()) { id3.id3ID[0] = 'i'; id3.id3ID[1] = 'd'; @@ -486,7 +484,7 @@ ProgressResult ExportCL::Export(SaucedacityProject *project, // write the headers and metadata os->Write(&riff, sizeof(riff)); os->Write(&fmt, sizeof(fmt)); - if (metachunk.size()) { + if (!metachunk.empty()) { os->Write(&id3, sizeof(id3)); os->Write(metachunk.data(), metachunk.size()); } @@ -507,7 +505,7 @@ ProgressResult ExportCL::Export(SaucedacityProject *project, mixerSpec); size_t numBytes = 0; - samplePtr mixed = NULL; + samplePtr mixed = nullptr; auto updateResult = ProgressResult::Success; { @@ -698,7 +696,7 @@ std::vector ExportCL::GetMetaChunk(const Tags *tags) id3_length_t len; - len = id3_tag_render(tp.get(), 0); + len = id3_tag_render(tp.get(), nullptr); if ((len % 2) != 0) { len++; // Length must be even. } @@ -722,7 +720,7 @@ bool ExportCL::CheckFileName(wxFileName &filename, int WXUNUSED(format)) ExtendPath ep; if (filename.GetExt().empty()) { - if (ShowWarningDialog(NULL, + if (ShowWarningDialog(nullptr, wxT("MissingExtension"), XO("You've specified a file name without an extension. Are you sure?"), true) == wxID_CANCEL) { @@ -740,7 +738,7 @@ bool ExportCL::CheckFileName(wxFileName &filename, int WXUNUSED(format)) #endif ); - if (argv.size() == 0) { + if (argv.empty()) { ShowExportErrorDialog( ":745", XO("Program name appears to be missing.")); diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 8b302bb6f7..cf8efcadc4 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -126,10 +126,10 @@ class ExportFFmpeg final : public ExportPlugin void OptionsCreate(ShuttleGui &S, int format) override; /// Check whether or not current project sample rate is compatible with the export codec - bool CheckSampleRate(int rate, int lowrate, int highrate, const int *sampRates); + static bool CheckSampleRate(int rate, int lowrate, int highrate, const int *sampRates); /// Asks user to resample the project or cancel the export procedure - int AskResample(int bitrate, int rate, int lowrate, int highrate, const int *sampRates); + static int AskResample(int bitrate, int rate, int lowrate, int highrate, const int *sampRates); /// Exports audio ///\param project Audacity project @@ -148,8 +148,8 @@ class ExportFFmpeg final : public ExportPlugin bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) override; private: @@ -158,7 +158,7 @@ class ExportFFmpeg final : public ExportPlugin bool WritePacket(AVPacketWrapper& packet); - int EncodeAudio(AVPacketWrapper& pkt, int16_t* audio_samples, int nb_samples); + int EncodeAudio(AVPacketWrapper& pkt, const int16_t* audio_samples, int nb_samples); std::shared_ptr mFFmpeg; @@ -185,8 +185,8 @@ class ExportFFmpeg final : public ExportPlugin ExportFFmpeg::ExportFFmpeg() : ExportPlugin() { - mEncFormatDesc = NULL; // describes our output file to libavformat - mEncAudioStream = NULL; // the output audio stream (may remain NULL) + mEncFormatDesc = nullptr; // describes our output file to libavformat + mEncAudioStream = nullptr; // the output audio stream (may remain NULL) #define MAX_AUDIO_PACKET_SIZE (128 * 1024) mEncAudioFifoOutBufSize = 0; @@ -209,7 +209,7 @@ ExportFFmpeg::ExportFFmpeg() auto avoformat = mFFmpeg->GuessOutputFormat(shortname.mb_str(), nullptr, nullptr); auto avcodec = mFFmpeg->CreateEncoder(mFFmpeg->GetAVCodecID(ExportFFmpegOptions::fmts[newfmt].codecid)); - if (avoformat == NULL || avcodec == NULL) + if (avoformat == nullptr || avcodec == nullptr) { ExportFFmpegOptions::fmts[newfmt].compiledIn = false; continue; @@ -364,7 +364,7 @@ bool ExportFFmpeg::Init(const char *shortname, SaucedacityProject *project, cons if (mEncAudioStream->SetParametersFromContext(*mEncAudioCodecCtx) < 0) return false; - if (metadata == NULL) + if (metadata == nullptr) metadata = &Tags::Get( *project ); // Add metadata BEFORE writing the header. @@ -613,7 +613,7 @@ bool ExportFFmpeg::InitCodecs(SaucedacityProject *project) } // Is the required audio codec compiled into libavcodec? - if (codec == NULL) + if (codec == nullptr) { AudacityMessageBox( XO( @@ -786,7 +786,7 @@ bool ExportFFmpeg::WritePacket(AVPacketWrapper& pkt) } // Returns 0 if no more output, 1 if more output, negative if error -int ExportFFmpeg::EncodeAudio(AVPacketWrapper& pkt, int16_t* audio_samples, int nb_samples) +int ExportFFmpeg::EncodeAudio(AVPacketWrapper& pkt, const int16_t* audio_samples, int nb_samples) { int i, ch, buffer_size, ret, got_output = 0; AVDataBuffer samples; @@ -807,7 +807,7 @@ int ExportFFmpeg::EncodeAudio(AVPacketWrapper& pkt, int16_t* audio_samples, int frame->SetChannelLayout(mEncAudioCodecCtx->GetChannelLayout()); buffer_size = mFFmpeg->av_samples_get_buffer_size( - NULL, mEncAudioCodecCtx->GetChannels(), nb_samples, + nullptr, mEncAudioCodecCtx->GetChannels(), nb_samples, mEncAudioCodecCtx->GetSampleFmt(), 0); if (buffer_size < 0) @@ -1015,7 +1015,7 @@ bool ExportFFmpeg::Finalize() { // Fifo is empty, flush encoder. May be called multiple times. encodeResult = - EncodeAudio(*pkt.get(), nullptr, 0); + EncodeAudio(*pkt, nullptr, 0); } if (encodeResult < 0) { @@ -1171,7 +1171,7 @@ ProgressResult ExportFFmpeg::Export(SaucedacityProject *project, if (pcmNumSamples == 0) break; - short *pcmBuffer = (short *)mixer->GetBuffer(); + auto *pcmBuffer = (short *)mixer->GetBuffer(); if (!EncodeAudioFrame( pcmBuffer, (pcmNumSamples)*sizeof(int16_t)*mChannels)) { @@ -1195,13 +1195,13 @@ ProgressResult ExportFFmpeg::Export(SaucedacityProject *project, return updateResult; } -void AddStringTagUTF8(char field[], int size, wxString value) +void AddStringTagUTF8(char field[], int size, const wxString& value) { memset(field,0,size); memcpy(field,value.ToUTF8(),(int)strlen(value.ToUTF8()) > size -1 ? size -1 : strlen(value.ToUTF8())); } -void AddStringTagANSI(char field[], int size, wxString value) +void AddStringTagANSI(char field[], int size, const wxString& value) { memset(field,0,size); memcpy(field,value.mb_str(),(int)strlen(value.mb_str()) > size -1 ? size -1 : strlen(value.mb_str())); @@ -1209,7 +1209,7 @@ void AddStringTagANSI(char field[], int size, wxString value) bool ExportFFmpeg::AddTags(const Tags *tags) { - if (tags == NULL) + if (tags == nullptr) { return false; } diff --git a/src/export/ExportFFmpegDialogs.cpp b/src/export/ExportFFmpegDialogs.cpp index 01f5e73913..36e466c6a4 100644 --- a/src/export/ExportFFmpegDialogs.cpp +++ b/src/export/ExportFFmpegDialogs.cpp @@ -781,8 +781,8 @@ END_EVENT_TABLE() ExportFFmpegCustomOptions::ExportFFmpegCustomOptions(wxWindow *parent, int WXUNUSED(format)) : wxPanelWrapper(parent, wxID_ANY), - mFormat(NULL), - mCodec(NULL) + mFormat(nullptr), + mCodec(nullptr) { ShuttleGui S(this, eIsCreatingFromPrefs); PopulateOrExchange(S); @@ -877,7 +877,7 @@ FFmpegPreset::~FFmpegPreset() FFmpegPresets::FFmpegPresets() { - mPreset = NULL; + mPreset = nullptr; mAbortImport = false; XMLFileReader xmlfile; @@ -900,7 +900,7 @@ FFmpegPresets::~FFmpegPresets() void FFmpegPresets::ImportPresets(wxString &filename) { - mPreset = NULL; + mPreset = nullptr; mAbortImport = false; FFmpegPresetMap savePresets = mPresets; @@ -912,7 +912,7 @@ void FFmpegPresets::ImportPresets(wxString &filename) } } -void FFmpegPresets::ExportPresets(wxString &filename) +void FFmpegPresets::ExportPresets(wxString &filename) const { GuardedCall( [&] { XMLFileWriter writer{ filename, XO("Error Saving FFmpeg Presets") }; @@ -936,7 +936,7 @@ void FFmpegPresets::GetPresetList(wxArrayString &list) void FFmpegPresets::DeletePreset(wxString &name) { - FFmpegPresetMap::iterator iter = mPresets.find(name); + auto iter = mPresets.find(name); if (iter != mPresets.end()) { mPresets.erase(iter); @@ -945,13 +945,13 @@ void FFmpegPresets::DeletePreset(wxString &name) FFmpegPreset *FFmpegPresets::FindPreset(wxString &name) { - FFmpegPresetMap::iterator iter = mPresets.find(name); + auto iter = mPresets.find(name); if (iter != mPresets.end()) { return &iter->second; } - return NULL; + return nullptr; } // return false if overwrite was not allowed. @@ -1012,7 +1012,7 @@ bool FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name) for (int id = FEFirstID; id < FELastID; id++) { wxWindow *wnd = dynamic_cast(parent)->FindWindowById(id,parent); - if (wnd != NULL) + if (wnd != nullptr) { switch(id) { @@ -1083,7 +1083,7 @@ void FFmpegPresets::LoadPreset(ExportFFmpegOptions *parent, wxString &name) for (int id = FEFirstID; id < FELastID; id++) { wxWindow *wnd = parent->FindWindowById(id,parent); - if (wnd != NULL) + if (wnd != nullptr) { wxString readstr; long readlong; @@ -1183,7 +1183,7 @@ bool FFmpegPresets::HandleXMLTag(const wxChar *tag, const wxChar **attrs) } if (action == wxNO) { - mPreset = NULL; + mPreset = nullptr; return false; } *mPreset = FFmpegPreset(); @@ -1231,7 +1231,7 @@ XMLTagHandler *FFmpegPresets::HandleXMLChild(const wxChar *tag) { if (mAbortImport) { - return NULL; + return nullptr; } if (!wxStrcmp(tag, wxT("preset"))) @@ -1242,10 +1242,10 @@ XMLTagHandler *FFmpegPresets::HandleXMLChild(const wxChar *tag) { return this; } - return NULL; + return nullptr; } -void FFmpegPresets::WriteXMLHeader(XMLWriter &xmlFile) const +void FFmpegPresets::WriteXMLHeader(XMLWriter &xmlFile) // may throw { xmlFile.Write(wxT(" codec = mFFmpeg->CreateEncoder(mFFmpeg->GetAVCodecID(CompatibilityList[i].codec)); // If it exists, is audio and has encoder - if (codec != NULL && codec->IsAudio() && mFFmpeg->av_codec_is_encoder(codec->GetWrappedValue())) + if (codec != nullptr && codec->IsAudio() && mFFmpeg->av_codec_is_encoder(codec->GetWrappedValue())) { // If it was selected - remember its NEW index if ((ffmpegId >= 0) && codec->GetId() == ffmpegId) @@ -2156,17 +2153,17 @@ int ExportFFmpegOptions::FetchCompatibleFormatList( wxArrayString FromList; // Find all formats compatible to this codec in compatibility list - for (int i = 0; CompatibilityList[i].fmt != NULL; i++) + for (int i = 0; CompatibilityList[i].fmt != nullptr; i++) { if (CompatibilityList[i].codec == id || (CompatibilityList[i].codec.value == AUDACITY_AV_CODEC_ID_NONE) ) { - if ((selfmt != NULL) && (*selfmt == CompatibilityList[i].fmt)) index = mShownFormatNames.size(); + if ((selfmt != nullptr) && (*selfmt == CompatibilityList[i].fmt)) index = mShownFormatNames.size(); FromList.push_back(CompatibilityList[i].fmt); mShownFormatNames.push_back(CompatibilityList[i].fmt); auto tofmt = mFFmpeg->GuessOutputFormat( wxString(CompatibilityList[i].fmt).ToUTF8(), nullptr, nullptr); - if (tofmt != NULL) + if (tofmt != nullptr) { mShownFormatLongNames.push_back(wxString::Format( wxT("%s - %s"), CompatibilityList[i].fmt, @@ -2175,9 +2172,9 @@ int ExportFFmpegOptions::FetchCompatibleFormatList( } } bool found = false; - if (selfmt != NULL) + if (selfmt != nullptr) { - for (int i = 0; CompatibilityList[i].fmt != NULL; i++) + for (int i = 0; CompatibilityList[i].fmt != nullptr; i++) { if (*selfmt == CompatibilityList[i].fmt) { @@ -2196,9 +2193,9 @@ int ExportFFmpegOptions::FetchCompatibleFormatList( { wxString ofmtname = wxString::FromUTF8(ofmt->GetName()); found = false; - for (unsigned int i = 0; i < FromList.size(); i++) + for (const auto & i : FromList) { - if (ofmtname == FromList[i]) + if (ofmtname == i) { found = true; break; @@ -2206,7 +2203,7 @@ int ExportFFmpegOptions::FetchCompatibleFormatList( } if (!found) { - if ((selfmt != NULL) && + if ((selfmt != nullptr) && (*selfmt == wxString::FromUTF8(ofmt->GetName()))) index = mShownFormatNames.size(); @@ -2227,7 +2224,7 @@ int ExportFFmpegOptions::FetchCompatibleFormatList( /// void ExportFFmpegOptions::OnDeletePreset(wxCommandEvent& WXUNUSED(event)) { - wxComboBox *preset = dynamic_cast(FindWindowById(FEPresetID,this)); + auto *preset = dynamic_cast(FindWindowById(FEPresetID,this)); wxString presetname = preset->GetValue(); if (presetname.empty()) { @@ -2261,7 +2258,7 @@ void ExportFFmpegOptions::OnSavePreset(wxCommandEvent& WXUNUSED(event)) // Return false if failed to save. bool ExportFFmpegOptions::SavePreset(bool bCheckForOverwrite) { - wxComboBox *preset = dynamic_cast(FindWindowById(FEPresetID,this)); + auto *preset = dynamic_cast(FindWindowById(FEPresetID,this)); wxString name = preset->GetValue(); if (name.empty()) { @@ -2287,7 +2284,7 @@ bool ExportFFmpegOptions::SavePreset(bool bCheckForOverwrite) /// void ExportFFmpegOptions::OnLoadPreset(wxCommandEvent& WXUNUSED(event)) { - wxComboBox *preset = dynamic_cast(FindWindowById(FEPresetID,this)); + auto *preset = dynamic_cast(FindWindowById(FEPresetID,this)); wxString presetname = preset->GetValue(); mShownFormatNames = mFormatNames; @@ -2416,7 +2413,7 @@ bool ExportFFmpegOptions::ReportIfBadCombination() // However, the list updating now seems to be working correctly // making it impossible to select illegal combinations bool bFound = false; - for (int i = 0; CompatibilityList[i].fmt != NULL; i++) + for (int i = 0; CompatibilityList[i].fmt != nullptr; i++) { if (*selfmt == CompatibilityList[i].fmt) { @@ -2464,20 +2461,20 @@ void ExportFFmpegOptions::EnableDisableControls(AVCodecWrapper *cdc, wxString *s codec = true; } else if ( - cdc != NULL && + cdc != nullptr && apptable[i].codec == mFFmpeg->GetAudacityCodecID(cdc->GetId())) { codec = true; } if (wxString::FromUTF8(apptable[i].format) == wxT("any")) format = true; - else if (selfmt != NULL && + else if (selfmt != nullptr && *selfmt == wxString::FromUTF8(apptable[i].format)) format = true; if (codec && format) { handled = apptable[i].control; wxWindow *item = FindWindowById(apptable[i].control,this); - if (item != NULL) item->Enable(apptable[i].enable); + if (item != nullptr) item->Enable(apptable[i].enable); } } } @@ -2485,20 +2482,20 @@ void ExportFFmpegOptions::EnableDisableControls(AVCodecWrapper *cdc, wxString *s void ExportFFmpegOptions::DoOnFormatList() { - wxString *selfmt = NULL; - wxString *selfmtlong = NULL; + wxString *selfmt = nullptr; + wxString *selfmtlong = nullptr; FindSelectedFormat(&selfmt, &selfmtlong); - if (selfmt == NULL) + if (selfmt == nullptr) { return; } - wxString *selcdc = NULL; - wxString *selcdclong = NULL; + wxString *selcdc = nullptr; + wxString *selcdclong = nullptr; FindSelectedCodec(&selcdc, &selcdclong); - auto fmt = mFFmpeg->GuessOutputFormat(selfmt->ToUTF8(),NULL,NULL); - if (fmt == NULL) + auto fmt = mFFmpeg->GuessOutputFormat(selfmt->ToUTF8(),nullptr,nullptr); + if (fmt == nullptr) { //This shouldn't really happen mFormatName->SetLabel(wxString(_("Failed to guess format"))); @@ -2530,7 +2527,6 @@ void ExportFFmpegOptions::DoOnFormatList() EnableDisableControls(cdc.get(), selfmt); Layout(); Fit(); - return; } void ExportFFmpegOptions::DoOnCodecList() @@ -2580,7 +2576,6 @@ void ExportFFmpegOptions::DoOnCodecList() EnableDisableControls(cdc.get(), selfmt); Layout(); Fit(); - return; } /// @@ -2617,8 +2612,6 @@ void ExportFFmpegOptions::OnOK(wxCommandEvent& WXUNUSED(event)) gPrefs->Flush(); EndModal(wxID_OK); - - return; } void ExportFFmpegOptions::OnGetURL(wxCommandEvent & WXUNUSED(event)) diff --git a/src/export/ExportFFmpegDialogs.h b/src/export/ExportFFmpegDialogs.h index 414fd36c9d..8d2206addf 100644 --- a/src/export/ExportFFmpegDialogs.h +++ b/src/export/ExportFFmpegDialogs.h @@ -74,9 +74,9 @@ class ExportFFmpegAC3Options final : public wxPanelWrapper public: ExportFFmpegAC3Options(wxWindow *parent, int format); - virtual ~ExportFFmpegAC3Options(); + ~ExportFFmpegAC3Options() override; - void PopulateOrExchange(ShuttleGui & S); + static void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -95,9 +95,9 @@ class ExportFFmpegAACOptions final : public wxPanelWrapper public: ExportFFmpegAACOptions(wxWindow *parent, int format); - virtual ~ExportFFmpegAACOptions(); + ~ExportFFmpegAACOptions() override; - void PopulateOrExchange(ShuttleGui & S); + static void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; }; @@ -107,9 +107,9 @@ class ExportFFmpegAMRNBOptions final : public wxPanelWrapper public: ExportFFmpegAMRNBOptions(wxWindow *parent, int format); - virtual ~ExportFFmpegAMRNBOptions(); + ~ExportFFmpegAMRNBOptions() override; - void PopulateOrExchange(ShuttleGui & S); + static void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -124,9 +124,9 @@ class ExportFFmpegOPUSOptions final : public wxPanelWrapper public: ExportFFmpegOPUSOptions(wxWindow *parent, int format); - ~ExportFFmpegOPUSOptions(); + ~ExportFFmpegOPUSOptions() override; - void PopulateOrExchange(ShuttleGui & S); + static void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -158,9 +158,9 @@ class ExportFFmpegWMAOptions final : public wxPanelWrapper public: ExportFFmpegWMAOptions(wxWindow *parent, int format); - ~ExportFFmpegWMAOptions(); + ~ExportFFmpegWMAOptions() override; - void PopulateOrExchange(ShuttleGui & S); + static void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -177,7 +177,7 @@ class ExportFFmpegCustomOptions final : public wxPanelWrapper public: ExportFFmpegCustomOptions(wxWindow *parent, int format); - ~ExportFFmpegCustomOptions(); + ~ExportFFmpegCustomOptions() override; void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; @@ -209,7 +209,7 @@ class ExportFFmpegOptions final : public wxDialogWrapper public: ExportFFmpegOptions(wxWindow *parent); - ~ExportFFmpegOptions(); + ~ExportFFmpegOptions() override; void PopulateOrExchange(ShuttleGui & S); void OnOK(wxCommandEvent& event); void OnGetURL(wxCommandEvent& event); @@ -320,7 +320,7 @@ class FFmpegPresets : XMLTagHandler { public: FFmpegPresets(); - ~FFmpegPresets(); + ~FFmpegPresets() override; void GetPresetList(wxArrayString &list); void LoadPreset(ExportFFmpegOptions *parent, wxString &name); @@ -330,11 +330,11 @@ class FFmpegPresets : XMLTagHandler FFmpegPreset *FindPreset(wxString &name); void ImportPresets(wxString &filename); - void ExportPresets(wxString &filename); + void ExportPresets(wxString &filename) const; bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override; XMLTagHandler *HandleXMLChild(const wxChar *tag) override; - void WriteXMLHeader(XMLWriter &xmlFile) const; + static void WriteXMLHeader(XMLWriter &xmlFile) ; void WriteXML(XMLWriter &xmlFile) const; private: diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index eff0a1fa96..c54b0da133 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -53,9 +53,9 @@ class ExportFLACOptions final : public wxPanelWrapper public: ExportFLACOptions(wxWindow *parent, int format); - virtual ~ExportFLACOptions(); + ~ExportFLACOptions() override; - void PopulateOrExchange(ShuttleGui & S); + static void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; }; @@ -136,8 +136,6 @@ void ExportFLACOptions::PopulateOrExchange(ShuttleGui & S) S.EndHorizontalLay(); } S.EndVerticalLay(); - - return; } /// @@ -221,8 +219,8 @@ class ExportFLAC final : public ExportPlugin bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) override; private: @@ -450,7 +448,7 @@ void ExportFLAC::OptionsCreate(ShuttleGui &S, int format) bool ExportFLAC::GetMetadata(SaucedacityProject *project, const Tags *tags) { // Retrieve tags if needed - if (tags == NULL) + if (tags == nullptr) tags = &Tags::Get( *project ); mMetadata.reset(::FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)); diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index 30bff3b430..3f5d3e969d 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -127,9 +127,9 @@ class ExportMP2Options final : public wxPanelWrapper { public: ExportMP2Options(wxWindow *parent, int format); - virtual ~ExportMP2Options(); + ~ExportMP2Options() override; - void PopulateOrExchange(ShuttleGui & S); + static void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; }; @@ -216,15 +216,15 @@ class ExportMP2 final : public ExportPlugin bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) override; private: int AddTags(SaucedacityProject *project, ArrayOf &buffer, bool *endOfFile, const Tags *tags); #ifdef USE_LIBID3TAG - void AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name); + static void AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name); #endif }; @@ -273,7 +273,7 @@ ProgressResult ExportMP2::Export(SaucedacityProject *project, } // Put ID3 tags at beginning of file - if (metadata == NULL) + if (metadata == nullptr) metadata = &Tags::Get( *project ); FileIO outFile(fName, FileIO::Output); @@ -324,7 +324,7 @@ ProgressResult ExportMP2::Export(SaucedacityProject *project, if (pcmNumSamples == 0) break; - short *pcmBuffer = (short *)mixer->GetBuffer(); + auto *pcmBuffer = (short *)mixer->GetBuffer(); int mp2BufferNumBytes = twolame_encode_buffer_interleaved( encodeOptions, @@ -447,7 +447,7 @@ int ExportMP2::AddTags( id3_length_t len; - len = id3_tag_render(tp.get(), 0); + len = id3_tag_render(tp.get(), nullptr); buffer.reinit(len); len = id3_tag_render(tp.get(), (id3_byte_t *)buffer.get()); diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index d7489d5153..5784d3348c 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -229,7 +229,7 @@ class ExportMP3Options final : public wxPanelWrapper public: ExportMP3Options(wxWindow *parent, int format); - virtual ~ExportMP3Options(); + ~ExportMP3Options() override; void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; @@ -331,7 +331,7 @@ static EnumSetting< MP3ChannelMode > MP3ChannelModeSetting{ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) { bool mono = false; - gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0); + gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, false); const TranslatableStrings *choices = nullptr; const std::vector< int > *codes = nullptr; @@ -588,7 +588,7 @@ class FindDialog final : public wxDialogWrapper #ifndef DISABLE_DYNAMIC_LOADING_LAME - FindDialog(wxWindow *parent, wxString path, wxString name, + FindDialog(wxWindow *parent, const wxString& path, const wxString& name, FileNames::FileTypes types) : wxDialogWrapper(parent, wxID_ANY, /* i18n-hint: LAME is the name of an MP3 converter and should not be translated*/ @@ -650,9 +650,7 @@ class FindDialog final : public wxDialogWrapper Fit(); SetMinSize(GetSize()); Center(); - - return; - } + } void OnBrowse(wxCommandEvent & WXUNUSED(event)) { @@ -715,9 +713,9 @@ END_EVENT_TABLE() #ifndef DISABLE_DYNAMIC_LOADING_LAME -typedef lame_global_flags *lame_init_t(void); +typedef lame_global_flags *lame_init_t(); typedef int lame_init_params_t(lame_global_flags*); -typedef const char* get_lame_version_t(void); +typedef const char* get_lame_version_t(); typedef int CDECL lame_encode_buffer_ieee_float_t( lame_t gfp, @@ -814,7 +812,7 @@ class MP3Exporter #ifndef DISABLE_DYNAMIC_LOADING_LAME bool FindLibrary(wxWindow *parent); bool LoadLibrary(wxWindow *parent, AskUser askuser); - bool ValidLibraryLoaded(); + bool ValidLibraryLoaded() const; #endif // DISABLE_DYNAMIC_LOADING_LAME /* These global settings keep state over the life of the object */ @@ -826,22 +824,22 @@ class MP3Exporter /* Virtual methods that must be supplied by library interfaces */ /* initialize the library interface */ - bool InitLibrary(wxString libpath); - bool InitLibraryInternal(); - bool InitLibraryExternal(wxString libpath); + bool InitLibrary(const wxString& libpath); + static bool InitLibraryInternal(); + bool InitLibraryExternal(const wxString& libpath); void FreeLibrary(); /* get library info */ wxString GetLibraryVersion(); - wxString GetLibraryName(); - wxString GetLibraryPath(); - FileNames::FileTypes GetLibraryTypes(); + static wxString GetLibraryName(); + static wxString GetLibraryPath(); + static FileNames::FileTypes GetLibraryTypes(); /* returns the number of samples PER CHANNEL to send for each call to EncodeBuffer */ int InitializeStream(unsigned channels, int sampleRate); /* In bytes. must be called AFTER InitializeStream */ - int GetOutBufferSize(); + int GetOutBufferSize() const; /* returns the number of bytes written. input is interleaved if stereo*/ int EncodeBuffer(float inbuffer[], unsigned char outbuffer[]); @@ -938,7 +936,7 @@ MP3Exporter::MP3Exporter() mLibraryLoaded = false; #endif // DISABLE_DYNAMIC_LOADING_LAME mEncoding = false; - mGF = NULL; + mGF = nullptr; #ifndef DISABLE_DYNAMIC_LOADING_LAME if (gPrefs) { @@ -1058,7 +1056,7 @@ bool MP3Exporter::LoadLibrary(wxWindow *parent, AskUser askuser) return true; } -bool MP3Exporter::ValidLibraryLoaded() +bool MP3Exporter::ValidLibraryLoaded() const { return mLibraryLoaded; } @@ -1086,7 +1084,7 @@ void MP3Exporter::SetChannel(int mode) mChannel = mode; } -bool MP3Exporter::InitLibrary(wxString libpath) +bool MP3Exporter::InitLibrary(const wxString& libpath) { return mLibIsExternal ? InitLibraryExternal(libpath) : InitLibraryInternal(); } @@ -1143,7 +1141,7 @@ bool MP3Exporter::InitLibraryInternal() } -bool MP3Exporter::InitLibraryExternal(wxString libpath) +bool MP3Exporter::InitLibraryExternal(const wxString& libpath) { wxLogMessage(wxT("Loading LAME from %s"), libpath); @@ -1253,7 +1251,7 @@ bool MP3Exporter::InitLibraryExternal(wxString libpath) #endif // DISABLE_DYNAMIC_LOADING_LAME mGF = lame_init(); - if (mGF == NULL) { + if (mGF == nullptr) { return false; } @@ -1264,14 +1262,12 @@ void MP3Exporter::FreeLibrary() { if (mGF) { lame_close(mGF); - mGF = NULL; + mGF = nullptr; } #ifndef DISABLE_DYNAMIC_LOADING_LAME lame_lib.Unload(); #endif // DISABLE_DYNAMIC_LOADING_LAME - - return; } wxString MP3Exporter::GetLibraryVersion() @@ -1387,7 +1383,7 @@ int MP3Exporter::InitializeStream(unsigned channels, int sampleRate) return mSamplesPerChunk; } -int MP3Exporter::GetOutBufferSize() +int MP3Exporter::GetOutBufferSize() const { if (!mEncoding) return -1; @@ -1482,7 +1478,7 @@ bool MP3Exporter::PutInfoTag(wxFFile & f, wxFileOffset off) mGF = NULL; } #endif - else if (lame_mp3_tags_fid != NULL) { + else if (lame_mp3_tags_fid != nullptr) { lame_mp3_tags_fid(mGF, f.fp()); } } @@ -1708,16 +1704,16 @@ class ExportMP3 final : public ExportPlugin bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) override; private: - int AskResample(int bitrate, int rate, int lowrate, int highrate); + static int AskResample(int bitrate, int rate, int lowrate, int highrate); unsigned long AddTags(SaucedacityProject *project, ArrayOf &buffer, bool *endOfFile, const Tags *tags); #ifdef USE_LIBID3TAG - void AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name); + static void AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name); #endif int SetNumExportChannels() override; }; @@ -1753,7 +1749,7 @@ bool ExportMP3::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(form int ExportMP3::SetNumExportChannels() { bool mono; - gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0); + gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, false); return (mono)? 1 : -1; } @@ -1884,7 +1880,7 @@ ProgressResult ExportMP3::Export(SaucedacityProject *project, } // Put ID3 tags at beginning of file - if (metadata == NULL) + if (metadata == nullptr) metadata = &Tags::Get( *project ); // Open file for writing @@ -1955,7 +1951,7 @@ ProgressResult ExportMP3::Export(SaucedacityProject *project, break; } - float *mixed = (float *)mixer->GetBuffer(); + auto *mixed = (float *)mixer->GetBuffer(); if ((int)blockLen < inSamples) { if (channels > 1) { @@ -2169,7 +2165,7 @@ unsigned long ExportMP3::AddTags(SaucedacityProject *WXUNUSED(project), ArrayOf< unsigned long len; - len = id3_tag_render(tp.get(), 0); + len = id3_tag_render(tp.get(), nullptr); buffer.reinit(len); len = id3_tag_render(tp.get(), (id3_byte_t *)buffer.get()); diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index 390bd1ef9e..0260173613 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -144,7 +144,7 @@ ExportMultipleDialog::ExportMultipleDialog(SaucedacityProject *project) this->CountTracksAndLabels(); - mBook = NULL; + mBook = nullptr; ShuttleGui S(this, eIsCreatingFromPrefs); @@ -776,7 +776,7 @@ ProgressResult ExportMultipleDialog::ExportMultipleByLabel(bool byName, wxString name; // used to hold file name whilst we mess with it wxString title; // un-messed-with title of file for tagging with - const LabelStruct *info = NULL; + const LabelStruct *info = nullptr; /* Examine all labels a first time, sort out all data but don't do any * exporting yet (so this run is quick but interactive) */ while( l < mNumLabels ) { @@ -838,7 +838,7 @@ ProgressResult ExportMultipleDialog::ExportMultipleByLabel(bool byName, // copy project metadata to start with setting.filetags = Tags::Get( *mProject ); setting.filetags.LoadDefaults(); - if (exportSettings.size()) { + if (!exportSettings.empty()) { setting.filetags = exportSettings.back().filetags; } // over-ride with values @@ -982,7 +982,7 @@ ProgressResult ExportMultipleDialog::ExportMultipleByTrack(bool byName, // copy project metadata to start with setting.filetags = Tags::Get( *mProject ); setting.filetags.LoadDefaults(); - if (exportSettings.size()) { + if (!exportSettings.empty()) { setting.filetags = exportSettings.back().filetags; } // over-ride with values @@ -1130,7 +1130,7 @@ ProgressResult ExportMultipleDialog::DoExport(std::unique_ptr &p selectedOnly, t0, t1, - NULL, + nullptr, &tags, mSubFormatIndex); diff --git a/src/export/ExportMultiple.h b/src/export/ExportMultiple.h index b08b5c7425..3973cd8c1a 100644 --- a/src/export/ExportMultiple.h +++ b/src/export/ExportMultiple.h @@ -37,9 +37,9 @@ class SAUCEDACITY_DLL_API ExportMultipleDialog final : public wxDialogWrapper using ProgressResult = GenericUI::ProgressResult; ExportMultipleDialog(SaucedacityProject *parent); - virtual ~ExportMultipleDialog(); + ~ExportMultipleDialog() override; - int ShowModal(); + int ShowModal() override; private: @@ -184,7 +184,7 @@ class SuccessDialog final : public wxDialogWrapper class MouseEvtHandler final : public wxEvtHandler { public: - void OnMouse(wxMouseEvent& event); + void OnMouse(wxMouseEvent& event); private: DECLARE_EVENT_TABLE() }; diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index 5051b4b434..d9c96d3480 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -49,7 +49,7 @@ class ExportOGGOptions final : public wxPanelWrapper public: ExportOGGOptions(wxWindow *parent, int format); - virtual ~ExportOGGOptions(); + ~ExportOGGOptions() override; void PopulateOrExchange(ShuttleGui & S); bool TransferDataToWindow() override; @@ -142,13 +142,13 @@ class ExportOGG final : public ExportPlugin bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) override; private: - bool FillComment(SaucedacityProject *project, vorbis_comment *comment, const Tags *metadata); + static bool FillComment(SaucedacityProject *project, vorbis_comment *comment, const Tags *metadata); }; ExportOGG::ExportOGG() @@ -239,7 +239,7 @@ ProgressResult ExportOGG::Export(SaucedacityProject *project, // Set up packet->stream encoder. According to encoder example, // a random serial number makes it more likely that you can make // chained streams with concatenation. - srand(time(NULL)); + srand(time(nullptr)); if (ogg_stream_init(&stream, rand())) { AudacityMessageBox( XO("Unable to export - problem creating stream") ); return ProgressResult::Cancelled; @@ -301,7 +301,7 @@ ProgressResult ExportOGG::Export(SaucedacityProject *project, else { for (size_t i = 0; i < numChannels; i++) { - float *temp = (float *)mixer->GetBuffer(i); + auto *temp = (float *)mixer->GetBuffer(i); memcpy(vorbis_buffer[i], temp, sizeof(float)*SAMPLES_PER_RUN); } @@ -318,7 +318,7 @@ ProgressResult ExportOGG::Export(SaucedacityProject *project, while (!err && vorbis_analysis_blockout(&dsp, &block) == 1) { // analysis, assume we want to use bitrate management - err = vorbis_analysis(&block, NULL); + err = vorbis_analysis(&block, nullptr); if (!err) err = vorbis_bitrate_addblock(&block); @@ -379,7 +379,7 @@ void ExportOGG::OptionsCreate(ShuttleGui &S, int format) bool ExportOGG::FillComment(SaucedacityProject *project, vorbis_comment *comment, const Tags *metadata) { // Retrieve tags from project if not over-ridden - if (metadata == NULL) + if (metadata == nullptr) metadata = &Tags::Get( *project ); vorbis_comment_init(comment); diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index 559a329f1d..68c385913f 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -115,7 +115,7 @@ class ExportPCMOptions final : public wxPanelWrapper public: ExportPCMOptions(wxWindow *parent, int format); - virtual ~ExportPCMOptions(); + ~ExportPCMOptions() override; void PopulateOrExchange(ShuttleGui & S); @@ -247,9 +247,9 @@ void ExportPCMOptions::OnHeaderChoice(wxCommandEvent & evt) // Repopulate the encoding choices mEncodingChoice->Clear(); - for (int i = 0, num = mEncodingNames.size(); i < num; ++i) + for (auto & mEncodingName : mEncodingNames) { - mEncodingChoice->AppendString(mEncodingNames[i].StrippedTranslation()); + mEncodingChoice->AppendString(mEncodingName.StrippedTranslation()); } // Select the desired encoding @@ -395,8 +395,8 @@ class ExportPCM final : public ExportPlugin bool selectedOnly, double t0, double t1, - MixerSpec *mixerSpec = NULL, - const Tags *metadata = NULL, + MixerSpec *mixerSpec = nullptr, + const Tags *metadata = nullptr, int subformat = 0) override; // optional wxString GetFormat(int index) override; @@ -404,10 +404,10 @@ class ExportPCM final : public ExportPlugin unsigned GetMaxChannels(int index) override; private: - void ReportTooBigError(wxWindow * pParent); - ArrayOf AdjustString(const wxString & wxStr, int sf_format); + static void ReportTooBigError(wxWindow * pParent); + static ArrayOf AdjustString(const wxString & wxStr, int sf_format); bool AddStrings(SaucedacityProject *project, SNDFILE *sf, const Tags *tags, int sf_format); - bool AddID3Chunk( + static bool AddID3Chunk( const wxFileNameWrapper &fName, const Tags *tags, int sf_format); }; @@ -418,12 +418,12 @@ ExportPCM::ExportPCM() int selformat; // the index of the format we are setting up at the moment // Add the "special" formats first - for (size_t i = 0; i < WXSIZEOF(kFormats); ++i) + for (const auto & kFormat : kFormats) { selformat = AddFormat() - 1; - AddExtension(sf_header_extension(kFormats[i].format), selformat); - SetFormat(kFormats[i].name, selformat); - SetDescription(kFormats[i].desc, selformat); + AddExtension(sf_header_extension(kFormat.format), selformat); + SetFormat(kFormat.name, selformat); + SetDescription(kFormat.desc, selformat); SetCanMetaData(true, selformat); SetMaxChannels(255, selformat); } @@ -569,7 +569,7 @@ ProgressResult ExportPCM::Export(SaucedacityProject *project, // libsndfile can't (under Windows). sf.reset(SFCall(sf_open_fd, f.fd(), SFM_WRITE, &info, FALSE)); //add clipping for integer formats. We allow floats to clip. - sf_command(sf.get(), SFC_SET_CLIPPING, NULL, sf_subtype_is_integer(sf_format)?SF_TRUE:SF_FALSE) ; + sf_command(sf.get(), SFC_SET_CLIPPING, nullptr, sf_subtype_is_integer(sf_format)?SF_TRUE:SF_FALSE) ; } if (!sf) { @@ -577,7 +577,7 @@ ProgressResult ExportPCM::Export(SaucedacityProject *project, return ProgressResult::Cancelled; } // Retrieve tags if not given a set - if (metadata == NULL) + if (metadata == nullptr) metadata = &Tags::Get( *project ); // Install the meta data at the beginning of the file (except for @@ -970,13 +970,13 @@ bool ExportPCM::AddID3Chunk( id3_length_t len; - len = id3_tag_render(tp.get(), 0); + len = id3_tag_render(tp.get(), nullptr); if (len == 0) return true; if ((len % 2) != 0) len++; // Length must be even. ArrayOf buffer { len, true }; - if (buffer == NULL) + if (buffer == nullptr) return false; // Zero all locations, for ending odd UTF16 content diff --git a/src/ffmpeg/FFmpeg.cpp b/src/ffmpeg/FFmpeg.cpp index 89f766c460..bfdbb3a541 100644 --- a/src/ffmpeg/FFmpeg.cpp +++ b/src/ffmpeg/FFmpeg.cpp @@ -176,9 +176,7 @@ class FindFFmpegDialog final : public wxDialogWrapper Fit(); SetMinSize(GetSize()); Center(); - - return; - } + } void OnBrowse(wxCommandEvent & WXUNUSED(event)) { diff --git a/src/ffmpeg/FFmpegNotFoundDialog.cpp b/src/ffmpeg/FFmpegNotFoundDialog.cpp index a952b6a1fa..7e16950389 100644 --- a/src/ffmpeg/FFmpegNotFoundDialog.cpp +++ b/src/ffmpeg/FFmpegNotFoundDialog.cpp @@ -44,8 +44,6 @@ void FFmpegNotFoundDialog::PopulateOrExchange(ShuttleGui & S) Fit(); SetMinSize(GetSize()); Center(); - - return; } void FFmpegNotFoundDialog::OnOk(wxCommandEvent & WXUNUSED(event)) diff --git a/src/import/FormatClassifier.cpp b/src/import/FormatClassifier.cpp index c101653fbf..7257bab8ad 100644 --- a/src/import/FormatClassifier.cpp +++ b/src/import/FormatClassifier.cpp @@ -80,7 +80,7 @@ FormatClassifier::FormatClassT FormatClassifier::GetResultFormat() return mResultFormat; } -int FormatClassifier::GetResultFormatLibSndfile() +int FormatClassifier::GetResultFormatLibSndfile() const { int format = SF_FORMAT_RAW; @@ -122,7 +122,7 @@ int FormatClassifier::GetResultFormatLibSndfile() return format; } -unsigned FormatClassifier::GetResultChannels() +unsigned FormatClassifier::GetResultChannels() const { return mResultChannels; } @@ -266,7 +266,7 @@ void FormatClassifier::ConvertSamples(void* in, float* out, FormatClassT format) } } -void FormatClassifier::Add(float* in1, float* in2, size_t len) +void FormatClassifier::Add(float* in1, const float* in2, size_t len) { for (unsigned int n = 0; n < len; n++) { @@ -291,7 +291,7 @@ void FormatClassifier::Div(float* in, float div, size_t len) } -void FormatClassifier::Abs(float* in, float* out, size_t len) +void FormatClassifier::Abs(const float* in, float* out, size_t len) { for (unsigned int n = 0; n < len; n++) { @@ -306,7 +306,7 @@ void FormatClassifier::Abs(float* in, float* out, size_t len) } } -float FormatClassifier::Mean(float* in, size_t len) +float FormatClassifier::Mean(const float* in, size_t len) { float mean = 0.0f; @@ -326,7 +326,7 @@ float FormatClassifier::Max(float* in, size_t len) return Max(in, len, &dummyidx); } -float FormatClassifier::Max(float* in, size_t len, size_t* maxidx) +float FormatClassifier::Max(const float* in, size_t len, size_t* maxidx) { float max = -FLT_MAX; *maxidx = 0; diff --git a/src/import/FormatClassifier.h b/src/import/FormatClassifier.h index 03a7585f41..7652449331 100644 --- a/src/import/FormatClassifier.h +++ b/src/import/FormatClassifier.h @@ -96,20 +96,20 @@ class FormatClassifier ~FormatClassifier(); FormatClassT GetResultFormat(); - int GetResultFormatLibSndfile(); - unsigned GetResultChannels(); + int GetResultFormatLibSndfile() const; + unsigned GetResultChannels() const; private: void Run(); void ReadSignal(FormatClassT format, size_t stride); void ConvertSamples(void* in, float* out, FormatClassT format); - void Add(float* in1, float* in2, size_t len); - void Sub(float* in, float subt, size_t len); - void Div(float* in, float div, size_t len); - void Abs(float* in, float* out, size_t len); - float Mean(float* in, size_t len); + static void Add(float* in1, const float* in2, size_t len); + static void Sub(float* in, float subt, size_t len); + static void Div(float* in, float div, size_t len); + static void Abs(const float* in, float* out, size_t len); + static float Mean(const float* in, size_t len); float Max(float* in, size_t len); - float Max(float* in, size_t len, size_t* maxidx); + static float Max(const float* in, size_t len, size_t* maxidx); template void ToFloat(T* in, float* out, size_t len); }; diff --git a/src/import/Import.cpp b/src/import/Import.cpp index a4e4a95cd0..7449214888 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -86,9 +86,9 @@ ImportPluginList &Importer::sImportPluginList() } namespace { -static const auto PathStart = wxT("Importers"); +const auto PathStart = wxT("Importers"); -static Registry::GroupItem &sRegistry() +Registry::GroupItem &sRegistry() { static Registry::TransparentGroupItem<> registry{ PathStart }; return registry; @@ -153,7 +153,7 @@ bool Importer::Initialize() void Visit( SingleItem &item, const Path &path ) override { sImportPluginList().push_back( - static_cast( item ).mpPlugin.get() ); + dynamic_cast( item ).mpPlugin.get() ); } } visitor; @@ -348,9 +348,9 @@ void Importer::ReadImportItems() for (const auto &importPlugin : sImportPluginList()) { bool found = false; - for (size_t i = 0; i < new_item->filter_objects.size(); i++) + for (auto & filter_object : new_item->filter_objects) { - if (importPlugin == new_item->filter_objects[i]) + if (importPlugin == filter_object) { found = true; break; @@ -526,17 +526,17 @@ bool Importer::Import( SaucedacityProject &project, ExtImportItem *item = uItem.get(); bool matches_ext = false, matches_mime = false; wxLogDebug(wxT("Testing extensions")); - for (size_t j = 0; j < item->extensions.size(); j++) + for (const auto & extension : item->extensions) { - wxLogDebug(wxT("%s"), item->extensions[j].Lower()); - if (wxMatchWild (item->extensions[j].Lower(),fName.Lower(), false)) + wxLogDebug(wxT("%s"), extension.Lower()); + if (wxMatchWild (extension.Lower(),fName.Lower(), false)) { wxLogDebug(wxT("Match!")); matches_ext = true; break; } } - if (item->extensions.size() == 0) + if (item->extensions.empty()) { wxLogDebug(wxT("Match! (empty list)")); matches_ext = true; @@ -554,7 +554,7 @@ bool Importer::Import( SaucedacityProject &project, break; } } - if (item->mime_types.size() == 0) + if (item->mime_types.empty()) { wxLogDebug(wxT("Match! (empty list)")); matches_mime = true; @@ -608,13 +608,13 @@ bool Importer::Import( SaucedacityProject &project, // Try to open the file with this plugin (probe it) wxLogMessage(wxT("Opening with %s"),plugin->GetPluginStringID()); auto inFile = plugin->Open(fName, pProj); - if ( (inFile != NULL) && (inFile->GetStreamCount() > 0) ) + if ( (inFile != nullptr) && (inFile->GetStreamCount() > 0) ) { wxLogMessage(wxT("Open(%s) succeeded"), fName); // File has more than one stream - display stream selector if (inFile->GetStreamCount() > 1) { - ImportStreamDialog ImportDlg(inFile.get(), NULL, -1, XO("Select stream(s) to import")); + ImportStreamDialog ImportDlg(inFile.get(), nullptr, -1, XO("Select stream(s) to import")); if (ImportDlg.ShowModal() == wxID_CANCEL) { @@ -650,7 +650,7 @@ bool Importer::Import( SaucedacityProject &project, // But correct that and proceed anyway tracks.erase( iter, end ); } - if (tracks.size() > 0) + if (!tracks.empty()) { // success! return true; diff --git a/src/import/Import.h b/src/import/Import.h index ebd0981571..875cf44ead 100644 --- a/src/import/Import.h +++ b/src/import/Import.h @@ -118,7 +118,7 @@ class SAUCEDACITY_DLL_API Importer { * Constructs a list of types, for use by file opening dialogs, that includes * all supported file types */ - FileNames::FileTypes + static FileNames::FileTypes GetFileTypes( const FileNames::FileType &extraType = {} ); /** @@ -155,7 +155,7 @@ class SAUCEDACITY_DLL_API Importer { * @str string and appends string-tokens to a list @list. * @mod defines tokenizer's behaviour. */ - void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod = wxTOKEN_RET_EMPTY_ALL); + static void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod = wxTOKEN_RET_EMPTY_ALL); /** * Returns a pointer to internal items array. @@ -167,7 +167,7 @@ class SAUCEDACITY_DLL_API Importer { * Allocates NEW ExtImportItem, fills it with default data * and returns a pointer to it. */ - std::unique_ptr CreateDefaultImportItem(); + static std::unique_ptr CreateDefaultImportItem(); // if false, the import failed and errorMessage will be set. bool Import( SaucedacityProject &project, @@ -198,7 +198,7 @@ class ImportStreamDialog final : public wxDialogWrapper const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ); - virtual ~ImportStreamDialog(); + ~ImportStreamDialog() override; private: ImportFileHandle *mFile; diff --git a/src/import/ImportAUP.cpp b/src/import/ImportAUP.cpp index 9af79ac5f2..b8552267ab 100644 --- a/src/import/ImportAUP.cpp +++ b/src/import/ImportAUP.cpp @@ -75,7 +75,7 @@ class AUPImportPlugin final : public ImportPlugin { public: AUPImportPlugin(); - ~AUPImportPlugin(); + ~AUPImportPlugin() override; wxString GetPluginStringID() override; @@ -91,7 +91,7 @@ class AUPImportFileHandle final : public ImportFileHandle, public: AUPImportFileHandle(const FilePath &name, SaucedacityProject *project); - ~AUPImportFileHandle(); + ~AUPImportFileHandle() override; TranslatableString GetFileDescription() override; @@ -351,7 +351,7 @@ ProgressResult AUPImportFileHandle::Import(WaveTrackFactory *WXUNUSED(trackFacto wxASSERT( mUpdateResult == ProgressResult::Success ); sampleCount processed = 0; - for (auto fi : mFiles) + for (const auto& fi : mFiles) { mUpdateResult = mProgress->Update(processed.as_long_long(), mTotalSamples.as_long_long()); if (mUpdateResult != ProgressResult::Success) @@ -538,7 +538,7 @@ void AUPImportFileHandle::HandleXMLEndTag(const wxChar *tag) mHandlers.pop_back(); - if (mHandlers.size()) + if (!mHandlers.empty()) { node = mHandlers.back(); mParentTag = node.parent; @@ -665,7 +665,7 @@ bool AUPImportFileHandle::HandleProject(XMLTagHandler *&handler) wxString strValue = value; -#define set(f, v) (mProjectAttrs.have ## f = true, mProjectAttrs.f = v) +#define set(f, v) (mProjectAttrs.have ## f = true, mProjectAttrs.f = (v)) // ViewInfo if (!wxStrcmp(attr, wxT("vpos"))) @@ -1028,19 +1028,19 @@ bool AUPImportFileHandle::HandleWaveClip(XMLTagHandler *&handler) if (mParentTag.IsSameAs(wxT("wavetrack"))) { - WaveTrack *wavetrack = static_cast(node.handler); + auto *wavetrack = dynamic_cast(node.handler); handler = wavetrack->CreateClip(); } else if (mParentTag.IsSameAs(wxT("waveclip"))) { // Nested wave clips are cut lines - WaveClip *waveclip = static_cast(node.handler); + auto *waveclip = dynamic_cast(node.handler); handler = waveclip->HandleXMLChild(mCurrentTag); } - mClip = static_cast(handler); + mClip = dynamic_cast(handler); mClips.push_back(mClip); return true; @@ -1056,7 +1056,7 @@ bool AUPImportFileHandle::HandleEnvelope(XMLTagHandler *&handler) // envelope as well. (See HandleTimeTrack and HandleControlPoint) if (node.handler) { - TimeTrack *timetrack = static_cast(node.handler); + auto *timetrack = dynamic_cast(node.handler); handler = timetrack->GetEnvelope(); } @@ -1070,7 +1070,7 @@ bool AUPImportFileHandle::HandleEnvelope(XMLTagHandler *&handler) // Nested wave clips are cut lines else if (mParentTag.IsSameAs(wxT("waveclip"))) { - WaveClip *waveclip = static_cast(node.handler); + auto *waveclip = dynamic_cast(node.handler); handler = waveclip->GetEnvelope(); } @@ -1088,7 +1088,7 @@ bool AUPImportFileHandle::HandleControlPoint(XMLTagHandler *&handler) // control points as well. (See HandleTimeTrack and HandleEnvelope) if (node.handler) { - Envelope *envelope = static_cast(node.handler); + auto *envelope = dynamic_cast(node.handler); handler = envelope->HandleXMLChild(mCurrentTag); } @@ -1101,7 +1101,7 @@ bool AUPImportFileHandle::HandleSequence(XMLTagHandler *&handler) { struct node node = mHandlers.back(); - WaveClip *waveclip = static_cast(node.handler); + auto *waveclip = dynamic_cast(node.handler); // Earlier versions of Audacity had a single implied waveclip, so for // these versions, we get or create the only clip in the track. @@ -1612,7 +1612,7 @@ bool AUPImportFileHandle::AddSamples(const FilePath &blockFilename, // read 16-bit data directly. This is a pretty common // case, as most audio files are 16-bit. SampleBuffer temp(cnt * channels, int16Sample); - short *tmpptr = (short *) temp.ptr(); + auto *tmpptr = (short *) temp.ptr(); framesRead = SFCall(sf_readf_short, sf, tmpptr, cnt); if (framesRead != cnt) @@ -1646,7 +1646,7 @@ bool AUPImportFileHandle::AddSamples(const FilePath &blockFilename, // scaling, and pass us normalized data as floats. We can // then convert to whatever format we want. SampleBuffer tmpbuf(cnt * channels, floatSample); - float *tmpptr = (float *) tmpbuf.ptr(); + auto *tmpptr = (float *) tmpbuf.ptr(); framesRead = SFCall(sf_readf_float, sf, tmpptr, cnt); if (framesRead != cnt) diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp index 80011db1c4..5e7f6ea2a1 100644 --- a/src/import/ImportFFmpeg.cpp +++ b/src/import/ImportFFmpeg.cpp @@ -172,7 +172,7 @@ class FFmpegImportPlugin final : public ImportPlugin { } - ~FFmpegImportPlugin() { } + ~FFmpegImportPlugin() override { } wxString GetPluginStringID() override { return wxT("libav"); } TranslatableString GetPluginFormatDescription() override; @@ -200,7 +200,7 @@ class FFmpegImportFileHandle final : public ImportFileHandle public: FFmpegImportFileHandle(const FilePath & name); - ~FFmpegImportFileHandle(); + ~FFmpegImportFileHandle() override; ///! Format initialization ///\return true if successful, false otherwise @@ -377,7 +377,7 @@ bool FFmpegImportFileHandle::InitCodecs() auto codec = mFFmpeg->CreateDecoder(id); auto name = mFFmpeg->avcodec_get_name(id); - if (codec == NULL) + if (codec == nullptr) { wxLogError( wxT("FFmpeg : CreateDecoder() failed. Index[%02d], Codec[%02x - %s]"), diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index 8534051641..79d154f637 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -100,7 +100,7 @@ class MyFLACFile final : public FLAC::Decoder::File set_metadata_respond(FLAC__METADATA_TYPE_STREAMINFO); } - bool get_was_error() const + [[nodiscard]] bool get_was_error() const { return mWasError; } @@ -125,7 +125,7 @@ class FLACImportPlugin final : public ImportPlugin { } - ~FLACImportPlugin() { } + ~FLACImportPlugin() override { } wxString GetPluginStringID() override { return wxT("libflac"); } TranslatableString GetPluginFormatDescription() override; @@ -139,7 +139,7 @@ class FLACImportFileHandle final : public ImportFileHandle friend class MyFLACFile; public: FLACImportFileHandle(const FilePath & name); - ~FLACImportFileHandle(); + ~FLACImportFileHandle() override; bool Init(); diff --git a/src/import/ImportLOF.cpp b/src/import/ImportLOF.cpp index 45fcce5aa9..d73e2739cf 100644 --- a/src/import/ImportLOF.cpp +++ b/src/import/ImportLOF.cpp @@ -110,7 +110,7 @@ class LOFImportPlugin final : public ImportPlugin { } - ~LOFImportPlugin() { } + ~LOFImportPlugin() override { } wxString GetPluginStringID() override { return wxT("lof"); } TranslatableString GetPluginFormatDescription() override; @@ -124,7 +124,7 @@ class LOFImportFileHandle final : public ImportFileHandle public: LOFImportFileHandle( SaucedacityProject *pProject, const FilePath & name, std::unique_ptr &&file); - ~LOFImportFileHandle(); + ~LOFImportFileHandle() override; TranslatableString GetFileDescription() override; ByteCount GetFileUncompressedBytes() override; @@ -451,7 +451,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln) // t is now the last track in the project, unless the import of // all tracks failed, in which case it will be null. In that // case we return because we cannot offset a non-existent track. - if (t == NULL) + if (t == nullptr) return; #ifdef USE_MIDI if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false) || diff --git a/src/import/ImportMIDI.h b/src/import/ImportMIDI.h index 20aee9315e..a5c38cef0b 100644 --- a/src/import/ImportMIDI.h +++ b/src/import/ImportMIDI.h @@ -50,18 +50,18 @@ class MIDIParser { private: - int check_aborted(void); + int check_aborted(); - int Mf_getc(void); + int Mf_getc(); void Mf_error(char *); void Mf_on(int, int, int); void Mf_off(int, int, int); void Mf_header(int, int, int); void Mf_tempo(int); - void Mf_starttrack(void) {} - void Mf_endtrack(void) {} - void Mf_eot(void) {} + void Mf_starttrack() {} + void Mf_endtrack() {} + void Mf_eot() {} void Mf_pressure(int, int, int) {} void Mf_controller(int, int, int) {} void Mf_pitchbend(int, int, int) {} @@ -86,17 +86,17 @@ class MIDIParser { int abort_flag; - long readvarinum(void); - long read32bit(void); - int read16bit(void); - void msgenlarge(void); - char *msg(void); - int readheader(void); - void readtrack(void); - void sysex(void); - void msginit(void); - int egetc(void); - int msgleng(void); + long readvarinum(); + long read32bit(); + int read16bit(); + void msgenlarge(); + char *msg(); + int readheader(); + void readtrack(); + void sysex(); + void msginit(); + int egetc(); + int msgleng(); int readmt(char *, int); long to32bit(int, int, int, int); diff --git a/src/import/ImportMP3.cpp b/src/import/ImportMP3.cpp index 2f5e12e71c..9e82c4a02f 100644 --- a/src/import/ImportMP3.cpp +++ b/src/import/ImportMP3.cpp @@ -89,7 +89,7 @@ class MP3ImportPlugin final : public ImportPlugin { public: MP3ImportPlugin(); - ~MP3ImportPlugin(); + ~MP3ImportPlugin() override; wxString GetPluginStringID() override; TranslatableString GetPluginFormatDescription() override; @@ -102,7 +102,7 @@ class MP3ImportFileHandle final : public ImportFileHandle { public: MP3ImportFileHandle(const FilePath &filename); - ~MP3ImportFileHandle(); + ~MP3ImportFileHandle() override; TranslatableString GetFileDescription() override; ByteCount GetFileUncompressedBytes() override; @@ -141,7 +141,7 @@ class MP3ImportFileHandle final : public ImportFileHandle static mad_flow error_cb(void *that, struct mad_stream *stream, struct mad_frame *frame); - mad_flow ErrorCB(struct mad_stream *stream, struct mad_frame *frame); + mad_flow ErrorCB(struct mad_stream *stream, struct mad_frame *frame) const; private: mad_decoder mDecoder; @@ -265,7 +265,7 @@ ProgressResult MP3ImportFileHandle::Import(WaveTrackFactory *trackFactory, mPadding = 0; // Initialize decoder - mad_decoder_init(&mDecoder, this, input_cb, 0, filter_cb, output_cb, error_cb, 0); + mad_decoder_init(&mDecoder, this, input_cb, nullptr, filter_cb, output_cb, error_cb, nullptr); // Send the decoder on its way! auto res = mad_decoder_run(&mDecoder, MAD_DECODER_MODE_SYNC); @@ -375,8 +375,7 @@ void MP3ImportFileHandle::CheckTags() CheckID3V2Tags(true); } - return; -} + } void MP3ImportFileHandle::CheckAPETags(bool atEnd) { @@ -658,7 +657,7 @@ bool MP3ImportFileHandle::FillBuffer() void MP3ImportFileHandle::LoadID3(Tags *tags) { #ifdef USE_LIBID3TAG - struct id3_file *id3file = NULL; + struct id3_file *id3file = nullptr; auto cleanup = finally([&] { if (id3file) @@ -792,7 +791,7 @@ void MP3ImportFileHandle::LoadID3(Tags *tags) } // Now get the tag value - const id3_ucs4_t *ustr = NULL; + const id3_ucs4_t *ustr = nullptr; if (n == TAG_COMMENTS) { @@ -1078,7 +1077,7 @@ mad_flow MP3ImportFileHandle::error_cb(void *that, } enum mad_flow MP3ImportFileHandle::ErrorCB(struct mad_stream *stream, - struct mad_frame *frame) + struct mad_frame *frame) const { // You always get a LOSTSYNC error at EOF, so just ignore it if (stream->error == MAD_ERROR_LOSTSYNC && mFilePos == mFileLen) diff --git a/src/import/ImportOGG.cpp b/src/import/ImportOGG.cpp index 31f9a5f540..bbb4f54dac 100644 --- a/src/import/ImportOGG.cpp +++ b/src/import/ImportOGG.cpp @@ -87,7 +87,7 @@ class OggImportPlugin final : public ImportPlugin { } - ~OggImportPlugin() { } + ~OggImportPlugin() override { } wxString GetPluginStringID() override { return wxT("liboggvorbis"); } TranslatableString GetPluginFormatDescription() override; @@ -120,7 +120,7 @@ class OggImportFileHandle final : public ImportFileHandle } } - ~OggImportFileHandle(); + ~OggImportFileHandle() override; TranslatableString GetFileDescription() override; ByteCount GetFileUncompressedBytes() override; @@ -181,7 +181,7 @@ std::unique_ptr OggImportPlugin::Open( return nullptr; } - int err = ov_open(file->fp(), vorbisFile.get(), NULL, 0); + int err = ov_open(file->fp(), vorbisFile.get(), nullptr, 0); if (err < 0) { TranslatableString message; diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 2e37a2a5ec..d3aae9b194 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -76,7 +76,7 @@ class PCMImportPlugin final : public ImportPlugin { } - ~PCMImportPlugin() { } + ~PCMImportPlugin() override { } wxString GetPluginStringID() override { return wxT("libsndfile"); } TranslatableString GetPluginFormatDescription() override; @@ -89,7 +89,7 @@ class PCMImportFileHandle final : public ImportFileHandle { public: PCMImportFileHandle(const FilePath &name, SFFile &&file, SF_INFO info); - ~PCMImportFileHandle(); + ~PCMImportFileHandle() override; TranslatableString GetFileDescription() override; ByteCount GetFileUncompressedBytes() override; @@ -140,7 +140,7 @@ std::unique_ptr PCMImportPlugin::Open( // ImportPCM to not handle .mp3. Of course, this will still fail for mp3s // that are mislabeled with a .wav or other extension. // So, in the future we may want to write a simple parser to detect mp3s here. - return NULL; + return nullptr; } #endif @@ -329,8 +329,8 @@ ProgressResult PCMImportFileHandle::Import(WaveTrackFactory *trackFactory, SampleBuffer srcbuffer, buffer; wxASSERT(mInfo.channels >= 0); - while (NULL == srcbuffer.Allocate(maxBlock * mInfo.channels, mFormat).ptr() || - NULL == buffer.Allocate(maxBlock, mFormat).ptr()) + while (nullptr == srcbuffer.Allocate(maxBlock * mInfo.channels, mFormat).ptr() || + nullptr == buffer.Allocate(maxBlock, mFormat).ptr()) { maxBlock /= 2; if (maxBlock < 1) @@ -539,7 +539,7 @@ ProgressResult PCMImportFileHandle::Import(WaveTrackFactory *trackFactory, n = UTF8CTOWX(frame->description).BeforeFirst(wxT('/')); } - const id3_ucs4_t *ustr = NULL; + const id3_ucs4_t *ustr = nullptr; if (n == TAG_COMMENTS) { ustr = id3_field_getfullstring(&frame->fields[3]); diff --git a/src/import/ImportPlugin.h b/src/import/ImportPlugin.h index 003ca38bf6..10dceaed37 100644 --- a/src/import/ImportPlugin.h +++ b/src/import/ImportPlugin.h @@ -46,6 +46,7 @@ but little else. #define __AUDACITY_IMPORTER__ #include +#include // Saucedacity libraries #include @@ -151,7 +152,7 @@ class SAUCEDACITY_DLL_API ImportFileHandle /* not final */ protected: //! Build a wave track with appropriate format, which will not be narrower than the specified one - std::shared_ptr NewWaveTrack( WaveTrackFactory &trackFactory, + static std::shared_ptr NewWaveTrack( WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate); FilePath mFilename; @@ -164,8 +165,8 @@ class UnusableImportPlugin { public: UnusableImportPlugin( - const TranslatableString &formatName, FileExtensions extensions): - mFormatName(formatName), + TranslatableString formatName, FileExtensions extensions): + mFormatName(std::move(formatName)), mExtensions( std::move( extensions ) ) { } diff --git a/src/import/ImportRaw.cpp b/src/import/ImportRaw.cpp index 552c35dcfa..63568b7094 100644 --- a/src/import/ImportRaw.cpp +++ b/src/import/ImportRaw.cpp @@ -64,7 +64,7 @@ class ImportRawDialog final : public wxDialogWrapper { ImportRawDialog(wxWindow * parent, int encoding, unsigned channels, int offset, double rate); - ~ImportRawDialog(); + ~ImportRawDialog() override; void OnOK(wxCommandEvent & event); void OnCancel(wxCommandEvent & event); @@ -163,7 +163,7 @@ void ImportRaw(const SaucedacityProject &project, wxWindow *parent, const wxStri if (!sndFile){ char str[1000]; - sf_error_str((SNDFILE *)NULL, str, 1000); + sf_error_str((SNDFILE *)nullptr, str, 1000); wxPrintf("%s\n", str); throw FileException{ FileException::Cause::Open, fileName }; diff --git a/src/import/MultiFormatReader.cpp b/src/import/MultiFormatReader.cpp index 12fb7ca9e7..94ec00c0f2 100644 --- a/src/import/MultiFormatReader.cpp +++ b/src/import/MultiFormatReader.cpp @@ -38,11 +38,11 @@ MachineEndianness::MachineEndianness() MultiFormatReader::MultiFormatReader(const char* filename) - : mpFid(NULL) + : mpFid(nullptr) { mpFid = fopen(filename, "rb"); - if (mpFid == NULL) + if (mpFid == nullptr) { throw std::runtime_error("Error opening file"); } @@ -50,7 +50,7 @@ MultiFormatReader::MultiFormatReader(const char* filename) MultiFormatReader::~MultiFormatReader() { - if (mpFid != NULL) + if (mpFid != nullptr) { fclose(mpFid); } @@ -58,7 +58,7 @@ MultiFormatReader::~MultiFormatReader() void MultiFormatReader::Reset() { - if (mpFid != NULL) + if (mpFid != nullptr) { rewind(mpFid); } @@ -110,7 +110,7 @@ size_t MultiFormatReader::ReadSamples(void* buffer, size_t len, size_t stride, size_t MultiFormatReader::Read(void* buffer, size_t size, size_t len, size_t stride) { size_t actRead = 0; - uint8_t* pWork = (uint8_t*) buffer; + auto* pWork = (uint8_t*) buffer; if (stride > 1) { @@ -135,7 +135,7 @@ size_t MultiFormatReader::Read(void* buffer, size_t size, size_t len, size_t str void MultiFormatReader::SwapBytes(void* buffer, size_t size, size_t len) { - uint8_t* pResBuffer = (uint8_t*) buffer; + auto* pResBuffer = (uint8_t*) buffer; uint8_t* pCurBuffer; if (size > 8) diff --git a/src/import/RawAudioGuess.cpp b/src/import/RawAudioGuess.cpp index 7319a1e157..06b287528b 100644 --- a/src/import/RawAudioGuess.cpp +++ b/src/import/RawAudioGuess.cpp @@ -74,7 +74,7 @@ static float JumpStat(float *data, size_t len) return avg; } -static float SecondDStat(float *data, size_t len) +static float SecondDStat(const float *data, size_t len) { float v1=0, v2=0; float a1=0, a2=0; @@ -107,7 +107,7 @@ static void ExtractFloats(bool doublePrec, bool bigendian, bool stereo, size_t offset, - char *rawData, size_t dataSize, + const char *rawData, size_t dataSize, float *data1, float *data2, size_t *len1, size_t *len2) { size_t rawCount = 0; @@ -216,7 +216,7 @@ static void Extract(bool bits16, "Error:_Importing_raw_audio" }; - size_t dataSize = (size_t)dataSizeIn; + auto dataSize = (size_t)dataSizeIn; if (bits16) { if (sign && bigendian) @@ -547,12 +547,12 @@ static int Guess8Bit(unsigned numTests, const ArrayOf rawData[], size_t da for (unsigned test = 0; test < numTests; test++) { float signL, signR, unsignL, unsignR; - Extract(0, 1, 1, 0, /* 8-bit signed stereo */ + Extract(false, true, true, false, /* 8-bit signed stereo */ false, rawData[test].get(), dataSize, data1.get(), data2.get(), &len1, &len2); signL = JumpStat(data1.get(), len1); signR = JumpStat(data2.get(), len2); - Extract(0, 0, 1, 0, /* 8-bit unsigned stereo */ + Extract(false, false, true, false, /* 8-bit unsigned stereo */ false, rawData[test].get(), dataSize, data1.get(), data2.get(), &len1, &len2); unsignL = JumpStat(data1.get(), len1); @@ -591,11 +591,11 @@ static int Guess8Bit(unsigned numTests, const ArrayOf rawData[], size_t da for (unsigned test = 0; test < numTests; test++) { float leftChannel, rightChannel, combinedChannel; - Extract(0, guessSigned, 1, 0, 0, rawData[test].get(), dataSize, data1.get(), + Extract(false, guessSigned, true, false, false, rawData[test].get(), dataSize, data1.get(), data2.get(), &len1, &len2); leftChannel = JumpStat(data1.get(), len1); rightChannel = JumpStat(data2.get(), len2); - Extract(0, guessSigned, 0, 0, 0, rawData[test].get(), dataSize, data1.get(), + Extract(false, guessSigned, false, false, false, rawData[test].get(), dataSize, data1.get(), data2.get(), &len1, &len2); combinedChannel = JumpStat(data1.get(), len1); @@ -622,7 +622,7 @@ static int Guess8Bit(unsigned numTests, const ArrayOf rawData[], size_t da for (unsigned test = 0; test < numTests; test++) { float redundant; - Extract(0, guessSigned, 0, 0, 0, rawData[test].get(), dataSize, + Extract(false, guessSigned, false, false, false, rawData[test].get(), dataSize, data1.get(), data2.get(), &len1, &len2); redundant = RedundantStereo(data1.get(), len1); @@ -703,12 +703,12 @@ static int Guess16Bit(unsigned numTests, const ArrayOf rawData[], /* Test signed/unsigned of the MSB */ - Extract(0, 1, 1, 0, /* 8-bit signed stereo */ - 0, rawData2.get(), dataSize / 2, data1.get(), data2.get(), &len1, &len2); + Extract(false, true, true, false, /* 8-bit signed stereo */ + false, rawData2.get(), dataSize / 2, data1.get(), data2.get(), &len1, &len2); signL = JumpStat(data1.get(), len1); signR = JumpStat(data2.get(), len2); - Extract(0, 0, 1, 0, /* 8-bit unsigned stereo */ - 0, rawData2.get(), dataSize / 2, data1.get(), data2.get(), &len1, &len2); + Extract(false, false, true, false, /* 8-bit unsigned stereo */ + false, rawData2.get(), dataSize / 2, data1.get(), data2.get(), &len1, &len2); unsignL = JumpStat(data1.get(), len1); unsignR = JumpStat(data2.get(), len2); @@ -748,11 +748,11 @@ static int Guess16Bit(unsigned numTests, const ArrayOf rawData[], for (size_t i = 0; i < dataSize / 2; i++) rawData2[i] = rawData[test][2 * i + (evenMSB ? 0 : 1)]; - Extract(0, guessSigned, 1, 0, 0, + Extract(false, guessSigned, true, false, false, rawData2.get(), dataSize / 2, data1.get(), data2.get(), &len1, &len2); leftChannel = JumpStat(data1.get(), len1); rightChannel = JumpStat(data2.get(), len2); - Extract(0, guessSigned, 0, 0, 0, + Extract(false, guessSigned, false, false, false, rawData2.get(), dataSize / 2, data1.get(), data2.get(), &len1, &len2); combinedChannel = JumpStat(data1.get(), len1); @@ -785,7 +785,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf rawData[], for (size_t i = 0; i < dataSize / 2; i++) rawData2[i] = rawData[test][2 * i + (evenMSB ? 0 : 1)]; - Extract(0, guessSigned, 0, 0, 0, rawData2.get(), dataSize / 2, + Extract(false, guessSigned, false, false, false, rawData2.get(), dataSize / 2, data1.get(), data2.get(), &len1, &len2); redundant = RedundantStereo(data1.get(), len1); @@ -820,7 +820,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf rawData[], */ guessBigEndian = evenMSB; - guessOffset = 0; + guessOffset = false; #if RAW_GUESS_DEBUG wxFprintf(af, "evenMSB: %d BE: %d\n", evenMSB, guessBigEndian); @@ -843,7 +843,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf rawData[], rawData[test][2 * i + (evenMSB ? 0 : 1)]; former = 0.0; - Extract(1, guessSigned, guessStereo, guessBigEndian, guessOffset, + Extract(true, guessSigned, guessStereo, guessBigEndian, guessOffset, rawData[test].get(), dataSize-4, data1.get(), data2.get(), &len1, &len2); offs=(!guessBigEndian); @@ -857,7 +857,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf rawData[], } latter = 0.0; - Extract(1, guessSigned, guessStereo, !guessBigEndian, + Extract(true, guessSigned, guessStereo, !guessBigEndian, !guessOffset, rawData[test].get(), dataSize, data1.get(), data2.get(), &len1, &len2); @@ -962,7 +962,7 @@ static int GuessIntFormats(unsigned numTests, const ArrayOf rawData[], siz for (unsigned test = 0; test < numTests; test++) { float even, odd; - Extract(0, 1, 1, 0, /* 8-bit signed stereo */ + Extract(false, true, true, false, /* 8-bit signed stereo */ false, rawData[test].get(), dataSize, data1.get(), data2.get(), &len1, &len2); even = AmpStat(data1.get(), len1); diff --git a/src/import/SpecPowerMeter.cpp b/src/import/SpecPowerMeter.cpp index d94ac5f655..e79308c9b4 100644 --- a/src/import/SpecPowerMeter.cpp +++ b/src/import/SpecPowerMeter.cpp @@ -51,7 +51,7 @@ float SpecPowerCalculation::CalcPower(float* sig, float fc, float bw) } // Calc the FFT - FFT(mSigLen, 0, sig, mSigI.get(), mSigFR.get(), mSigFI.get()); + FFT(mSigLen, false, sig, mSigI.get(), mSigFR.get(), mSigFI.get()); // Calc the in-band power pwr = CalcBinPower(mSigFR.get(), mSigFI.get(), loBin, hiBin); @@ -59,7 +59,7 @@ float SpecPowerCalculation::CalcPower(float* sig, float fc, float bw) return pwr; } -float SpecPowerCalculation::CalcBinPower(float* sig_f_r, float* sig_f_i, int loBin, int hiBin) +float SpecPowerCalculation::CalcBinPower(const float* sig_f_r, const float* sig_f_i, int loBin, int hiBin) { float pwr = 0.0f; @@ -71,7 +71,7 @@ float SpecPowerCalculation::CalcBinPower(float* sig_f_r, float* sig_f_i, int loB return pwr; } -int SpecPowerCalculation::Freq2Bin(float fc) +int SpecPowerCalculation::Freq2Bin(float fc) const { int bin; diff --git a/src/import/SpecPowerMeter.h b/src/import/SpecPowerMeter.h index c11a6e8184..21db6e0b0c 100644 --- a/src/import/SpecPowerMeter.h +++ b/src/import/SpecPowerMeter.h @@ -24,8 +24,8 @@ class SpecPowerCalculation Floats mSigFR; Floats mSigFI; - float CalcBinPower(float* sig_f_r, float* sig_f_i, int loBin, int hiBin); - int Freq2Bin(float fc); + static float CalcBinPower(const float* sig_f_r, const float* sig_f_i, int loBin, int hiBin); + int Freq2Bin(float fc) const; public: SpecPowerCalculation(size_t sigLen); ~SpecPowerCalculation(); diff --git a/src/menus/TransportMenus.cpp b/src/menus/TransportMenus.cpp index 2c4b49ba02..4a45b6e81d 100644 --- a/src/menus/TransportMenus.cpp +++ b/src/menus/TransportMenus.cpp @@ -229,7 +229,7 @@ bool DoStopPlaying(const CommandContext &context) //stop playing the other project if (iter != finish) { - auto otherProject = *iter; + const auto& otherProject = *iter; auto &otherToolbar = ControlToolBar::Get(*otherProject); auto &otherProjectAudioManager = ProjectAudioManager::Get(*otherProject); diff --git a/src/prefs/BatchPrefs.cpp b/src/prefs/BatchPrefs.cpp index cb4f03ddc0..f372f1907a 100644 --- a/src/prefs/BatchPrefs.cpp +++ b/src/prefs/BatchPrefs.cpp @@ -81,7 +81,6 @@ void BatchPrefs::PopulateOrExchange( ShuttleGui & S ) S.EndStatic(); S.EndHorizontalLay(); S.EndScroller(); - return; } /// Send changed values back to Prefs, and update Audacity. diff --git a/src/prefs/BatchPrefs.h b/src/prefs/BatchPrefs.h index a4e1a3dad7..b898c55ff5 100644 --- a/src/prefs/BatchPrefs.h +++ b/src/prefs/BatchPrefs.h @@ -24,7 +24,7 @@ class BatchPrefs final : public PrefsPanel { public: BatchPrefs(wxWindow * parent, wxWindowID winid); - ~BatchPrefs(); + ~BatchPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; ManualPageID HelpPageName() override; diff --git a/src/prefs/DevicePrefs.cpp b/src/prefs/DevicePrefs.cpp index 747b06e65f..21d67b1234 100644 --- a/src/prefs/DevicePrefs.cpp +++ b/src/prefs/DevicePrefs.cpp @@ -116,7 +116,7 @@ void DevicePrefs::GetNamesAndLabels() int nDevices = Pa_GetDeviceCount(); for (int i = 0; i < nDevices; i++) { const PaDeviceInfo *info = Pa_GetDeviceInfo(i); - if ((info!=NULL)&&(info->maxOutputChannels > 0 || info->maxInputChannels > 0)) { + if ((info!=nullptr)&&(info->maxOutputChannels > 0 || info->maxInputChannels > 0)) { wxString name = wxSafeConvertMB2WX(Pa_GetHostApiInfo(info->hostApi)->name); if (!make_iterator_range(mHostNames) .contains( Verbatim( name ) )) { @@ -214,7 +214,7 @@ void DevicePrefs::PopulateOrExchange(ShuttleGui & S) void DevicePrefs::OnHost(wxCommandEvent & e) { // Bail if we have no hosts - if (mHostNames.size() < 1) + if (mHostNames.empty()) return; // Find the index for the host API selected @@ -239,7 +239,7 @@ void DevicePrefs::OnHost(wxCommandEvent & e) // FIXME: TRAP_ERR PaErrorCode not handled. nDevices can be negative number. if (nDevices == 0) { mHost->Clear(); - mHost->Append(_("No audio interfaces"), (void *) NULL); + mHost->Append(_("No audio interfaces"), (void *) nullptr); mHost->SetSelection(0); } @@ -286,12 +286,12 @@ void DevicePrefs::OnHost(wxCommandEvent & e) /* deal with not having any devices at all */ if (mPlay->GetCount() == 0) { playnames.push_back(_("No devices found")); - mPlay->Append(playnames[0], (void *) NULL); + mPlay->Append(playnames[0], (void *) nullptr); mPlay->SetSelection(0); } if (mRecord->GetCount() == 0) { recordnames.push_back(_("No devices found")); - mRecord->Append(recordnames[0], (void *) NULL); + mRecord->Append(recordnames[0], (void *) nullptr); mRecord->SetSelection(0); } @@ -333,8 +333,8 @@ void DevicePrefs::OnDevice(wxCommandEvent & WXUNUSED(event)) int sel = mChannels->GetSelection(); int cnt = 0; - DeviceSourceMap *inMap = (DeviceSourceMap *) mRecord->GetClientData(ndx); - if (inMap != NULL) { + auto *inMap = (DeviceSourceMap *) mRecord->GetClientData(ndx); + if (inMap != nullptr) { cnt = inMap->numChannels; } @@ -391,7 +391,7 @@ bool DevicePrefs::Commit() { ShuttleGui S(this, eIsSavingToPrefs); PopulateOrExchange(S); - DeviceSourceMap *map = NULL; + DeviceSourceMap *map = nullptr; if (mPlay->GetCount() > 0) { map = (DeviceSourceMap *) mPlay->GetClientData( @@ -400,7 +400,7 @@ bool DevicePrefs::Commit() if (map) AudioIOPlaybackDevice.Write(map->deviceString); - map = NULL; + map = nullptr; if (mRecord->GetCount() > 0) { map = (DeviceSourceMap *) mRecord->GetClientData(mRecord->GetSelection()); } diff --git a/src/prefs/DevicePrefs.h b/src/prefs/DevicePrefs.h index 543071410c..be9f2f10b6 100644 --- a/src/prefs/DevicePrefs.h +++ b/src/prefs/DevicePrefs.h @@ -25,7 +25,7 @@ class DevicePrefs final : public PrefsPanel { public: DevicePrefs(wxWindow * parent, wxWindowID winid); - virtual ~DevicePrefs(); + ~DevicePrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/DirectoriesPrefs.cpp b/src/prefs/DirectoriesPrefs.cpp index 124747d34b..9347020196 100644 --- a/src/prefs/DirectoriesPrefs.cpp +++ b/src/prefs/DirectoriesPrefs.cpp @@ -53,12 +53,12 @@ class FilesystemValidator : public wxValidator mMessage = message; } - virtual wxObject* Clone() const wxOVERRIDE + [[nodiscard]] wxObject* Clone() const wxOVERRIDE { return safenew FilesystemValidator(mMessage); } - virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE + bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE { wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl); if (!tc) { @@ -72,12 +72,12 @@ class FilesystemValidator : public wxValidator return true; } - virtual bool TransferToWindow() wxOVERRIDE + bool TransferToWindow() wxOVERRIDE { return true; } - virtual bool TransferFromWindow() wxOVERRIDE + bool TransferFromWindow() wxOVERRIDE { return true; } @@ -145,8 +145,8 @@ END_EVENT_TABLE() DirectoriesPrefs::DirectoriesPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: Directories, also called directories, in computer file systems */ : PrefsPanel(parent, winid, XO("Directories")), - mFreeSpace(NULL), - mTempText(NULL) + mFreeSpace(nullptr), + mTempText(nullptr) { Populate(); } @@ -322,7 +322,7 @@ void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt) // (that doesn't exist) -- hence the constructor calls if (tmpDirPath != wxFileName(DefaultTempDir(), wxT("")) && tmpDirPath != wxFileName(mTempText->GetValue(), wxT("")) && - (dirsInPath.size() == 0 || + (dirsInPath.empty() || dirsInPath[dirsInPath.size()-1] != newDirName)) { tmpDirPath.AppendDir(newDirName); @@ -342,7 +342,7 @@ void DirectoriesPrefs::OnTempText(wxCommandEvent & WXUNUSED(evt)) FilePath path = mTempText->GetValue(); wxLongLong space; - wxGetDiskSpace(path, NULL, &space); + wxGetDiskSpace(path, nullptr, &space); label = wxDirExists(path) ? Internat::FormatSize(space) @@ -355,7 +355,7 @@ void DirectoriesPrefs::OnTempText(wxCommandEvent & WXUNUSED(evt)) void DirectoriesPrefs::OnBrowse(wxCommandEvent &evt) { long id = evt.GetId() - ButtonsStart; - wxTextCtrl *tc = (wxTextCtrl *) FindWindow(id + TextsStart); + auto *tc = (wxTextCtrl *) FindWindow(id + TextsStart); wxString location = tc->GetValue(); diff --git a/src/prefs/DirectoriesPrefs.h b/src/prefs/DirectoriesPrefs.h index d8348a4a6c..734f6a7d60 100644 --- a/src/prefs/DirectoriesPrefs.h +++ b/src/prefs/DirectoriesPrefs.h @@ -25,7 +25,7 @@ class DirectoriesPrefs final : public PrefsPanel { public: DirectoriesPrefs(wxWindow * parent, wxWindowID winid); - ~DirectoriesPrefs(); + ~DirectoriesPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/EffectsPrefs.cpp b/src/prefs/EffectsPrefs.cpp index 6e06f91da8..08d318140a 100644 --- a/src/prefs/EffectsPrefs.cpp +++ b/src/prefs/EffectsPrefs.cpp @@ -134,7 +134,7 @@ struct Entry { TranslatableString prompt; wxString setting; }; -static const std::vector< Entry > &GetModuleData() +const std::vector< Entry > &GetModuleData() { struct ModuleData : public std::vector< Entry > { ModuleData() { diff --git a/src/prefs/EffectsPrefs.h b/src/prefs/EffectsPrefs.h index d7f285fdd5..fb05dc3a31 100644 --- a/src/prefs/EffectsPrefs.h +++ b/src/prefs/EffectsPrefs.h @@ -26,7 +26,7 @@ class EffectsPrefs final : public PrefsPanel { public: EffectsPrefs(wxWindow * parent, wxWindowID winid); - ~EffectsPrefs(); + ~EffectsPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/ExtImportPrefs.cpp b/src/prefs/ExtImportPrefs.cpp index 0c4ab4aaa2..3cc447e61d 100644 --- a/src/prefs/ExtImportPrefs.cpp +++ b/src/prefs/ExtImportPrefs.cpp @@ -62,8 +62,8 @@ END_EVENT_TABLE() ExtImportPrefs::ExtImportPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: Title of dialog governing "Extended", or "advanced," * audio file import options */ -: PrefsPanel(parent, winid, XO("Extended Import")), RuleTable(NULL), - PluginList(NULL), mCreateTable (false), mDragFocus (NULL), +: PrefsPanel(parent, winid, XO("Extended Import")), RuleTable(nullptr), + PluginList(nullptr), mCreateTable (false), mDragFocus (nullptr), mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1) { Populate(); @@ -120,7 +120,7 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay (wxEXPAND, 1); { bool fillRuleTable = false; - if (RuleTable == NULL) + if (RuleTable == nullptr) { RuleTable = safenew Grid(S.GetParent(),EIPRuleTable); @@ -259,7 +259,7 @@ void ExtImportPrefs::SwapPluginRows (int row1, int row2) ImportPlugin *ip1, *ip2; auto &items = Importer::Get().GetImportItems(); - ExtImportItem *item = NULL; + ExtImportItem *item = nullptr; if( last_selected >= 0 ) item = items[last_selected].get(); @@ -380,10 +380,10 @@ void ExtImportPrefs::OnPluginBeginDrag(wxListEvent& WXUNUSED(event)) dragtext2->SetText(wxT("")); dragSource.SetData(*dragtext2); mDragFocus = PluginList; - if( mDragFocus == NULL ) + if( mDragFocus == nullptr ) return; wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove); - mDragFocus = NULL; + mDragFocus = nullptr; switch (result) { case wxDragCopy: @@ -487,7 +487,7 @@ void ExtImportPrefs::DoOnRuleTableSelect (int toprow) PluginList->SetItemData (i, -1); shift = 1; } - if (item->filter_objects[i] != NULL) + if (item->filter_objects[i] != nullptr) { PluginList->InsertItem (i + shift, item->filter_objects[i]->GetPluginFormatDescription().Translation()); @@ -538,12 +538,12 @@ void ExtImportPrefs::OnRuleTableEdit (wxGridEvent& event) break; } - for (size_t i = 0; i < vals.size(); i++) + for (auto & val : vals) { - wxString trimmed = vals[i]; + wxString trimmed = val; trimmed.Trim().Trim(false); - if (trimmed != vals[i]) + if (trimmed != val) { if (!askedAboutSpaces) { @@ -559,11 +559,11 @@ Audacity to trim spaces for you?"), } if (fixSpaces != wxYES) { - trimmed = vals[i]; + trimmed = val; } else { - vals[i] = trimmed; + val = trimmed; } } switch (col) @@ -594,7 +594,7 @@ Audacity to trim spaces for you?"), void ExtImportPrefs::AddItemToTable (int index, const ExtImportItem *item) { wxString extensions, mime_types; - if (item->extensions.size() > 0) + if (!item->extensions.empty()) { extensions.Append (item->extensions[0]); for (unsigned int i = 1; i < item->extensions.size(); i++) @@ -603,7 +603,7 @@ void ExtImportPrefs::AddItemToTable (int index, const ExtImportItem *item) extensions.Append (item->extensions[i]); } } - if (item->mime_types.size() > 0) + if (!item->mime_types.empty()) { mime_types.Append (item->mime_types[0]); for (unsigned int i = 1; i < item->mime_types.size(); i++) @@ -706,7 +706,7 @@ void ExtImportPrefs::OnRuleTableCellClick (wxGridEvent& event) dragSource.SetData(*dragtext1); mDragFocus = RuleTable; wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove); - mDragFocus = NULL; + mDragFocus = nullptr; switch (result) { case wxDragCopy: /* copy the data */ @@ -723,7 +723,7 @@ void ExtImportPrefs::OnRuleTableCellClick (wxGridEvent& event) ExtImportPrefsDropTarget::ExtImportPrefsDropTarget(wxDataObject *dataObject) : wxDropTarget(dataObject) { - mPrefs = NULL; + mPrefs = nullptr; } ExtImportPrefsDropTarget::~ExtImportPrefsDropTarget () @@ -766,7 +766,7 @@ long wxCustomFindItem(wxListCtrl *list, int x, int y) bool ExtImportPrefsDropTarget::OnDrop(wxCoord x, wxCoord y) { - if (mPrefs == NULL) + if (mPrefs == nullptr) return false; wxListCtrl *PluginList = mPrefs->GetPluginList(); Grid *RuleTable = mPrefs->GetRuleTable(); @@ -782,7 +782,7 @@ bool ExtImportPrefsDropTarget::OnDrop(wxCoord x, wxCoord y) long item = wxCustomFindItem (PluginList, x, y); #else int flags = 0; - long item = PluginList->HitTest (wxPoint (x, y), flags, NULL); + long item = PluginList->HitTest (wxPoint (x, y), flags, nullptr); #endif if (item < 0) return false; @@ -800,7 +800,7 @@ wxDragResult ExtImportPrefsDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult ExtImportPrefsDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult WXUNUSED(def)) { - if (mPrefs == NULL) + if (mPrefs == nullptr) return wxDragNone; wxListCtrl *PluginList = mPrefs->GetPluginList(); Grid *RuleTable = mPrefs->GetRuleTable(); @@ -826,7 +826,7 @@ wxDragResult ExtImportPrefsDropTarget::OnDragOver(wxCoord x, wxCoord y, long item = wxCustomFindItem (PluginList, x, y); #else int flags = 0; - long item = PluginList->HitTest (wxPoint (x, y), flags, NULL); + long item = PluginList->HitTest (wxPoint (x, y), flags, nullptr); #endif if (item < 0) return wxDragNone; diff --git a/src/prefs/ExtImportPrefs.h b/src/prefs/ExtImportPrefs.h index 7b0ccc35cf..6dd0901712 100644 --- a/src/prefs/ExtImportPrefs.h +++ b/src/prefs/ExtImportPrefs.h @@ -35,12 +35,12 @@ class ExtImportPrefsDropTarget final : public wxDropTarget public: // Takes ownership of the argument ExtImportPrefsDropTarget(wxDataObject* dataObject = nullptr); - ~ExtImportPrefsDropTarget (); - wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def); - bool OnDrop(wxCoord x, wxCoord y); - wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); - wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); - void OnLeave(); + ~ExtImportPrefsDropTarget () override; + wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) override; + bool OnDrop(wxCoord x, wxCoord y) override; + wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def) override; + wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def) override; + void OnLeave() override; void SetPrefs (ExtImportPrefs *prefs); private: ExtImportPrefs *mPrefs; @@ -50,7 +50,7 @@ class ExtImportPrefs final : public PrefsPanel { public: ExtImportPrefs(wxWindow * parent, wxWindowID winid); - ~ExtImportPrefs(); + ~ExtImportPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/GUIPrefs.h b/src/prefs/GUIPrefs.h index 29fd822952..8aa161d63e 100644 --- a/src/prefs/GUIPrefs.h +++ b/src/prefs/GUIPrefs.h @@ -26,7 +26,7 @@ class SAUCEDACITY_DLL_API GUIPrefs final : public PrefsPanel { public: GUIPrefs(wxWindow * parent, wxWindowID winid); - ~GUIPrefs(); + ~GUIPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/GUISettings.h b/src/prefs/GUISettings.h index 73498de374..edc5d1d5ae 100644 --- a/src/prefs/GUISettings.h +++ b/src/prefs/GUISettings.h @@ -20,7 +20,7 @@ Paul Licameli #ifndef __WXMAC__ #define RTL_WORKAROUND( pWnd ) \ if ( gPrefs->Read( "/GUI/RtlWorkaround", true) ) \ - pWnd->SetLayoutDirection(wxLayout_LeftToRight); + (pWnd)->SetLayoutDirection(wxLayout_LeftToRight); #else #define RTL_WORKAROUND( pWnd ) #endif diff --git a/src/prefs/ImportExportPrefs.h b/src/prefs/ImportExportPrefs.h index 5fa6c5a4c8..5bd9550e68 100644 --- a/src/prefs/ImportExportPrefs.h +++ b/src/prefs/ImportExportPrefs.h @@ -31,7 +31,7 @@ class SAUCEDACITY_DLL_API ImportExportPrefs final : public PrefsPanel static EnumSetting< bool > AllegroStyleSetting; ImportExportPrefs(wxWindow * parent, wxWindowID winid); - ~ImportExportPrefs(); + ~ImportExportPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index 95ac164224..6520552239 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -91,9 +91,9 @@ KeyConfigPrefs::KeyConfigPrefs( const CommandID &name) /* i18n-hint: as in computer keyboard (not musical!) */ : PrefsPanel(parent, winid, XO("Keyboard")), - mView(NULL), - mKey(NULL), - mFilter(NULL), + mView(nullptr), + mKey(nullptr), + mFilter(nullptr), mFilterTimer(this, FilterTimerID), mFilterPending(false) , mProject{ pProject } @@ -387,7 +387,7 @@ bool KeyConfigPrefs::ContainsIllegalDups( for (size_t i{ 0 }; i < mKeys.size(); i++) { - if (mKeys[i] == EMPTY_SHORTCUT || mKeys[i] == NO_SHORTCUT) + if (mKeys[i].empty() || mKeys[i] == NO_SHORTCUT) continue; if (seen.count(mKeys[i]) == 0) @@ -397,7 +397,7 @@ bool KeyConfigPrefs::ContainsIllegalDups( IndexesArray checkMe{ seen.at(mKeys[i]) }; for (int index : checkMe) { - if (mDefaultKeys[i] == EMPTY_SHORTCUT || + if (mDefaultKeys[i].empty() || mDefaultKeys[i] != mDefaultKeys[index]) { fMatching = mManager->GetPrefixedLabelFromName(mNames[i]); @@ -430,7 +430,7 @@ TranslatableString KeyConfigPrefs::MergeWithExistingKeys( if (k == index) continue; else if (toAdd[index] == mKeys[k] && - (mDefaultKeys[k] == EMPTY_SHORTCUT || + (mDefaultKeys[k].empty() || mDefaultKeys[k] != mDefaultKeys[index])) return (int)k; @@ -443,7 +443,7 @@ TranslatableString KeyConfigPrefs::MergeWithExistingKeys( { if (mKeys[i] != NO_SHORTCUT) continue; - else if (toAdd[i] == EMPTY_SHORTCUT) + else if (toAdd[i].empty()) mManager->SetKeyFromIndex(i, noKey); else { @@ -556,7 +556,7 @@ void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event)) TranslatableString message{ XO("Loaded %d keyboard shortcuts\n").Format(mManager->GetNumberOfKeysRead()) }; - if (disabledShortcuts.Translation() != ("")) + if (!disabledShortcuts.Translation().empty()) message += XO("\nThe following commands are not mentioned in the imported file, " "but have their shortcuts removed because of the conflict with other new shortcuts:\n") + disabledShortcuts; @@ -607,9 +607,9 @@ void KeyConfigPrefs::FilterKeys( std::vector & arr ) const auto &MaxListOnly = CommandManager::ExcludedList(); // Remove items that are in MaxList. - for (size_t i = 0; i < arr.size(); i++) { - if( std::binary_search(MaxListOnly.begin(), MaxListOnly.end(), arr[i]) ) - arr[i] = {}; + for (auto & i : arr) { + if( std::binary_search(MaxListOnly.begin(), MaxListOnly.end(), i) ) + i = {}; } } @@ -631,7 +631,7 @@ void KeyConfigPrefs::OnImportDefaults(wxCommandEvent & event) void KeyConfigPrefs::OnHotkeyKeyDown(wxKeyEvent & e) { - wxTextCtrl *t = (wxTextCtrl *)e.GetEventObject(); + auto *t = (wxTextCtrl *)e.GetEventObject(); // Make sure we can navigate away from the hotkey textctrl. // On Linux and OSX, it can get stuck, but it doesn't hurt @@ -682,7 +682,7 @@ void KeyConfigPrefs::OnFilterTimer(wxTimerEvent & WXUNUSED(e)) void KeyConfigPrefs::OnFilterKeyDown(wxKeyEvent & e) { - wxTextCtrl *t = (wxTextCtrl *)e.GetEventObject(); + auto *t = (wxTextCtrl *)e.GetEventObject(); int keycode = e.GetKeyCode(); // Make sure we can navigate away from the hotkey textctrl. @@ -785,7 +785,7 @@ void KeyConfigPrefs::OnSet(wxCommandEvent & WXUNUSED(event)) if (mNames[i] == newCommand) return; - if (newComDefaultKey == EMPTY_SHORTCUT || + if (newComDefaultKey.empty() || mDefaultKeys[i] != newComDefaultKey) { oldCommands.push_back(mNames[i]); @@ -932,8 +932,7 @@ void KeyConfigPrefs::Cancel() mManager->SetKeyFromIndex(i, mKeys[i]); } - return; -} + } PrefsPanel::Factory KeyConfigPrefsFactory( const CommandID &name ) diff --git a/src/prefs/KeyConfigPrefs.h b/src/prefs/KeyConfigPrefs.h index cfa11e1710..4693b0f94e 100644 --- a/src/prefs/KeyConfigPrefs.h +++ b/src/prefs/KeyConfigPrefs.h @@ -52,7 +52,7 @@ class KeyConfigPrefs final : public PrefsPanel TranslatableString & sMatching) const; TranslatableString MergeWithExistingKeys( const std::vector &toAdd); - void FilterKeys( std::vector & arr ); + static void FilterKeys( std::vector & arr ); CommandID NameFromKey(const NormalizedKeyString & key); void SetKeyForSelected(const NormalizedKeyString & key); diff --git a/src/prefs/LibraryPrefs.h b/src/prefs/LibraryPrefs.h index 2d9ff15549..083fa52494 100644 --- a/src/prefs/LibraryPrefs.h +++ b/src/prefs/LibraryPrefs.h @@ -28,7 +28,7 @@ class LibraryPrefs final : public PrefsPanel { public: LibraryPrefs(wxWindow * parent, wxWindowID winid); - ~LibraryPrefs(); + ~LibraryPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index ec93529281..36bd7727d5 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -144,7 +144,7 @@ void ModulePrefs::PopulateOrExchange(ShuttleGui & S) ); S.EndMultiColumn(); } - if( mModules.size() < 1 ) + if( mModules.empty() ) { S.AddFixedText( XO("No modules were found") ); } diff --git a/src/prefs/ModulePrefs.h b/src/prefs/ModulePrefs.h index b2bc3ad75f..551fe1b2db 100644 --- a/src/prefs/ModulePrefs.h +++ b/src/prefs/ModulePrefs.h @@ -27,7 +27,7 @@ class ModulePrefs final : public PrefsPanel { public: ModulePrefs(wxWindow * parent, wxWindowID winid); - ~ModulePrefs(); + ~ModulePrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/MousePrefs.h b/src/prefs/MousePrefs.h index ff3e5b0d28..929d59ae9d 100644 --- a/src/prefs/MousePrefs.h +++ b/src/prefs/MousePrefs.h @@ -23,7 +23,7 @@ class MousePrefs final : public PrefsPanel { public: MousePrefs(wxWindow * parent, wxWindowID winid); - ~MousePrefs(); + ~MousePrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/PlaybackPrefs.h b/src/prefs/PlaybackPrefs.h index a5666ee8c8..73090ac815 100644 --- a/src/prefs/PlaybackPrefs.h +++ b/src/prefs/PlaybackPrefs.h @@ -24,7 +24,7 @@ class PlaybackPrefs final : public PrefsPanel { public: PlaybackPrefs(wxWindow * parent, wxWindowID winid); - virtual ~PlaybackPrefs(); + ~PlaybackPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index 835f99d2dc..3eede484b5 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -383,11 +383,11 @@ class wxTreebookExt final : public wxTreebook { public: wxTreebookExt( wxWindow *parent, - wxWindowID id, const TranslatableString &titlePrefix) + wxWindowID id, TranslatableString titlePrefix) : wxTreebook( parent, id ) - , mTitlePrefix(titlePrefix) + , mTitlePrefix(std::move(titlePrefix)) {;}; - ~wxTreebookExt(){;}; + ~wxTreebookExt() override{;}; int ChangeSelection(size_t n) override; int SetSelection(size_t n) override; const TranslatableString mTitlePrefix; @@ -397,8 +397,8 @@ class wxTreebookExt final : public wxTreebook int wxTreebookExt::ChangeSelection(size_t n) { int i = wxTreebook::ChangeSelection(n); wxString Temp = GetPageText( n ); - static_cast(GetParent())->SetTitle( Temp ); - static_cast(GetParent())->SetName( Temp ); + dynamic_cast(GetParent())->SetTitle( Temp ); + dynamic_cast(GetParent())->SetName( Temp ); return i; }; @@ -406,10 +406,10 @@ int wxTreebookExt::SetSelection(size_t n) { int i = wxTreebook::SetSelection(n); auto Temp = mTitlePrefix.Translation() + wxT(" ") + GetPageText( n ); - static_cast(GetParent())->SetTitle( Temp ); - static_cast(GetParent())->SetName( Temp ); + dynamic_cast(GetParent())->SetTitle( Temp ); + dynamic_cast(GetParent())->SetName( Temp ); - PrefsPanel *const panel = static_cast(GetPage(n)); + auto *const panel = dynamic_cast(GetPage(n)); const bool showHelp = (!panel->HelpPageName().empty()); const bool showPreview = panel->ShowsPreviewButton(); wxWindow *const helpButton = wxWindow::FindWindowById(wxID_HELP, GetParent()); @@ -446,16 +446,16 @@ int wxTreebookExt::SetSelection(size_t n) PrefsDialog::PrefsDialog( wxWindow * parent, SaucedacityProject *pProject, - const TranslatableString &titlePrefix, + TranslatableString titlePrefix, PrefsPanel::Factories &factories) : wxDialogWrapper(parent, wxID_ANY, XO("Saucedacity Preferences"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , mFactories(factories) -, mTitlePrefix(titlePrefix) +, mTitlePrefix(std::move(titlePrefix)) { - wxASSERT(factories.size() > 0); + wxASSERT(!factories.empty()); const bool uniquePage = (factories.size() == 1); SetLayoutDirection(wxLayout_LeftToRight); @@ -463,7 +463,7 @@ PrefsDialog::PrefsDialog( S.StartVerticalLay(true); { - wxASSERT(factories.size() > 0); + wxASSERT(!factories.empty()); if (!uniquePage) { mCategories = safenew wxTreebookExt(S.GetParent(), wxID_ANY, mTitlePrefix); #if wxUSE_ACCESSIBILITY @@ -502,7 +502,7 @@ PrefsDialog::PrefsDialog( } } if (node.nChildren > 0) - stack.push_back(IntPair(iPage, node.nChildren)); + stack.emplace_back(iPage, node.nChildren); } } } @@ -643,7 +643,7 @@ void PrefsDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) PrefsPanel * PrefsDialog::GetCurrentPanel() { if( mCategories) - return static_cast(mCategories->GetCurrentPage()); + return dynamic_cast(mCategories->GetCurrentPage()); else { wxASSERT( mUniquePage ); @@ -668,7 +668,7 @@ void PrefsDialog::ShuttleAll( ShuttleGui & S) if (mCategories) { for (size_t i = 0; i < mCategories->GetPageCount(); i++) { S.ResetId(); - PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i); + auto *panel = (PrefsPanel *)mCategories->GetPage(i); panel->PopulateOrExchange( S ); } } @@ -694,7 +694,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event)) // Validate all pages first if (mCategories) { for (size_t i = 0; i < mCategories->GetPageCount(); i++) { - PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i); + auto *panel = (PrefsPanel *)mCategories->GetPage(i); // The dialog doesn't end until all the input is valid if (!panel->Validate()) { @@ -715,7 +715,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event)) // Reverse order - so Track Name is updated before language change // A workaround for Bug 1661 for (int i = (int)mCategories->GetPageCount()-1; i>= 0; i--) { - PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i); + auto *panel = (PrefsPanel *)mCategories->GetPage(i); panel->Preview(); panel->Commit(); @@ -815,6 +815,8 @@ void PrefsDialog::RecordExpansionState() } #include + +#include #include "../Menus.h" #include "../Project.h" @@ -833,7 +835,7 @@ void DoReloadPreferences( SaucedacityProject &project ) // LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with // rebuilding the menus while the PrefsDialog is still in the modal // state. - for (auto p : AllProjects{}) { + for (const auto& p : AllProjects{}) { MenuManager::Get(*p).RebuildMenuBar(*p); } } diff --git a/src/prefs/PrefsDialog.h b/src/prefs/PrefsDialog.h index 21acd43e94..1db75e62f7 100644 --- a/src/prefs/PrefsDialog.h +++ b/src/prefs/PrefsDialog.h @@ -35,10 +35,10 @@ class SAUCEDACITY_DLL_API PrefsDialog /* not final */ : public wxDialogWrapper public: PrefsDialog(wxWindow * parent, SaucedacityProject *pProject, // may be null - const TranslatableString &titlePrefix = XO("Preferences:"), + TranslatableString titlePrefix = XO("Preferences:"), PrefsPanel::Factories &factories = PrefsPanel::DefaultFactories()); - virtual ~PrefsDialog(); + ~PrefsDialog() override; // Defined this so a protected virtual can be invoked after the constructor int ShowModal() override; @@ -55,7 +55,7 @@ class SAUCEDACITY_DLL_API PrefsDialog /* not final */ : public wxDialogWrapper // Accessor to help implementations of SavePreferredPage(), // such as by saving a preference after DoModal() returns - int GetSelectedPage() const; + [[nodiscard]] int GetSelectedPage() const; protected: // Decide which page to open first; return -1 for undecided @@ -84,7 +84,7 @@ class SAUCEDACITY_DLL_API GlobalPrefsDialog final : public PrefsDialog wxWindow * parent, SaucedacityProject *pProject, PrefsPanel::Factories &factories = PrefsPanel::DefaultFactories()); - virtual ~GlobalPrefsDialog(); + ~GlobalPrefsDialog() override; long GetPreferredPage() override; void SavePreferredPage() override; }; diff --git a/src/prefs/PrefsPanel.cpp b/src/prefs/PrefsPanel.cpp index 2c13f4e099..c03ac6d219 100644 --- a/src/prefs/PrefsPanel.cpp +++ b/src/prefs/PrefsPanel.cpp @@ -10,11 +10,12 @@ Paul Licameli split from PrefsDialog.cpp #include "PrefsPanel.h" #include +#include namespace { const auto PathStart = wxT("Preferences"); -static Registry::GroupItem &sRegistry() +Registry::GroupItem &sRegistry() { static Registry::TransparentGroupItem<> registry{ PathStart }; return registry; @@ -25,9 +26,9 @@ struct PrefsItem final : Registry::ConcreteGroupItem { bool expanded{ false }; PrefsItem( const wxString &name, - const PrefsPanel::Factory &factory_, bool expanded_ ) + PrefsPanel::Factory factory_, bool expanded_ ) : ConcreteGroupItem{ name } - , factory{ factory_ }, expanded{ expanded_ } + , factory{std::move( factory_ )}, expanded{ expanded_ } {} }; diff --git a/src/prefs/PrefsPanel.h b/src/prefs/PrefsPanel.h index d5eee8238c..a238afa0f4 100644 --- a/src/prefs/PrefsPanel.h +++ b/src/prefs/PrefsPanel.h @@ -28,6 +28,7 @@ MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs. #define __AUDACITY_PREFS_PANEL__ #include +#include // Saucedacity libraries #include @@ -62,10 +63,10 @@ class SAUCEDACITY_DLL_API PrefsPanel /* not final */ size_t nChildren{ 0 }; bool expanded{ false }; - PrefsNode(const Factory &factory_, + PrefsNode(Factory factory_, unsigned nChildren_ = 0, bool expanded_ = true) - : factory(factory_), nChildren(nChildren_), expanded(expanded_) + : factory(std::move(factory_)), nChildren(nChildren_), expanded(expanded_) {} }; @@ -98,16 +99,16 @@ class SAUCEDACITY_DLL_API PrefsPanel /* not final */ SetName(title); // Provide audible label } - virtual ~PrefsPanel(); + ~PrefsPanel() override; // NEW virtuals virtual void Preview() {} // Make tentative changes virtual bool Commit() = 0; // used to be called "Apply" - virtual PluginPath GetPath(); - virtual VendorSymbol GetVendor(); - virtual wxString GetVersion(); + PluginPath GetPath() override; + VendorSymbol GetVendor() override; + wxString GetVersion() override; //virtual ComponentInterfaceSymbol GetSymbol(); //virtual wxString GetDescription(); diff --git a/src/prefs/QualityPrefs.h b/src/prefs/QualityPrefs.h index 081d989b81..89ae4c3189 100644 --- a/src/prefs/QualityPrefs.h +++ b/src/prefs/QualityPrefs.h @@ -29,7 +29,7 @@ class SAUCEDACITY_DLL_API QualityPrefs final : public PrefsPanel { public: QualityPrefs(wxWindow * parent, wxWindowID winid); - virtual ~QualityPrefs(); + ~QualityPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/RecordingPrefs.h b/src/prefs/RecordingPrefs.h index a4c7ac1364..5bd0d2eb39 100644 --- a/src/prefs/RecordingPrefs.h +++ b/src/prefs/RecordingPrefs.h @@ -36,7 +36,7 @@ class RecordingPrefs final : public PrefsPanel { public: RecordingPrefs(wxWindow * parent, wxWindowID winid); - virtual ~RecordingPrefs(); + ~RecordingPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/SpectrogramSettings.cpp b/src/prefs/SpectrogramSettings.cpp index 2bb7cc1e7b..b8fd285f8f 100644 --- a/src/prefs/SpectrogramSettings.cpp +++ b/src/prefs/SpectrogramSettings.cpp @@ -327,7 +327,7 @@ void SpectrogramSettings::LoadPrefs() InvalidateCaches(); } -void SpectrogramSettings::SavePrefs() +void SpectrogramSettings::SavePrefs() const { gPrefs->Write(wxT("/Spectrum/MinFreq"), minFreq); gPrefs->Write(wxT("/Spectrum/MaxFreq"), maxFreq); @@ -542,7 +542,7 @@ namespace void SpectrogramSettings::CacheWindows() const { - if (hFFT == NULL || window == NULL) { + if (hFFT == nullptr || window == nullptr) { double scale; auto factor = ZeroPaddingFactor(); @@ -590,7 +590,7 @@ void SpectrogramSettings::ConvertToActualWindowSizes() #endif } -float SpectrogramSettings::findBin( float frequency, float binUnit ) const +float SpectrogramSettings::findBin( float frequency, float binUnit ) { float linearBin = frequency / binUnit; if (linearBin < 0) diff --git a/src/prefs/SpectrogramSettings.h b/src/prefs/SpectrogramSettings.h index 4201acc620..ebbeec099d 100644 --- a/src/prefs/SpectrogramSettings.h +++ b/src/prefs/SpectrogramSettings.h @@ -75,7 +75,7 @@ class SAUCEDACITY_DLL_API SpectrogramSettings : public PrefsListener SpectrogramSettings(); SpectrogramSettings(const SpectrogramSettings &other); SpectrogramSettings& operator= (const SpectrogramSettings &other); - ~SpectrogramSettings(); + ~SpectrogramSettings() override; bool IsDefault() const { @@ -84,7 +84,7 @@ class SAUCEDACITY_DLL_API SpectrogramSettings : public PrefsListener bool Validate(bool quiet); void LoadPrefs(); - void SavePrefs(); + void SavePrefs() const; void UpdatePrefs() override; @@ -96,7 +96,7 @@ class SAUCEDACITY_DLL_API SpectrogramSettings : public PrefsListener // Need to be told what the bin unit is, as this structure does not know // the rate - float findBin( float frequency, float binUnit ) const; + static float findBin( float frequency, float binUnit ) ; // If "bins" is false, units are Hz NumberScale GetScale( float minFreq, float maxFreq ) const; diff --git a/src/prefs/SpectrumPrefs.cpp b/src/prefs/SpectrumPrefs.cpp index 769e39ffaf..dadbcc29ab 100644 --- a/src/prefs/SpectrumPrefs.cpp +++ b/src/prefs/SpectrumPrefs.cpp @@ -136,8 +136,8 @@ void SpectrumPrefs::PopulatePaddingChoices(size_t windowSize) // If it is not NULL, we rebuild the control by hand. // I don't yet know an easier way to do this with ShuttleGUI functions. // PRL - wxChoice *const pPaddingSizeControl = - static_cast(wxWindow::FindWindowById(ID_PADDING_SIZE, this)); + auto *const pPaddingSizeControl = + dynamic_cast(wxWindow::FindWindowById(ID_PADDING_SIZE, this)); if (pPaddingSizeControl) { mZeroPaddingChoice = pPaddingSizeControl->GetSelection(); @@ -174,7 +174,7 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S) // { - mDefaultsCheckbox = 0; + mDefaultsCheckbox = nullptr; if (mWt) { /* i18n-hint: use is a verb */ mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(XXO("&Use Preferences"), mDefaulted); @@ -534,8 +534,8 @@ void SpectrumPrefs::OnWindowSize(wxCommandEvent &evt) { // Restrict choice of zero padding, so that product of window // size and padding may not exceed the largest window size. - wxChoice *const pWindowSizeControl = - static_cast(wxWindow::FindWindowById(ID_WINDOW_SIZE, this)); + auto *const pWindowSizeControl = + dynamic_cast(wxWindow::FindWindowById(ID_WINDOW_SIZE, this)); size_t windowSize = 1 << (pWindowSizeControl->GetSelection() + SpectrogramSettings::LogMinWindowSize); PopulatePaddingChoices(windowSize); diff --git a/src/prefs/SpectrumPrefs.h b/src/prefs/SpectrumPrefs.h index cc05c9b399..de62257f65 100644 --- a/src/prefs/SpectrumPrefs.h +++ b/src/prefs/SpectrumPrefs.h @@ -43,7 +43,7 @@ class SpectrumPrefs final : public PrefsPanel public: SpectrumPrefs(wxWindow * parent, wxWindowID winid, SaucedacityProject *pProject, WaveTrack *wt); - virtual ~SpectrumPrefs(); + ~SpectrumPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; @@ -108,5 +108,5 @@ class SpectrumPrefs final : public PrefsPanel /// A PrefsPanel::Factory that creates one SpectrumPrefs panel. /// This factory can be parametrized by a single track, to change settings /// non-globally -extern PrefsPanel::Factory SpectrumPrefsFactory( WaveTrack *wt = 0 ); +extern PrefsPanel::Factory SpectrumPrefsFactory( WaveTrack *wt = nullptr ); #endif diff --git a/src/prefs/ThemePrefs.cpp b/src/prefs/ThemePrefs.cpp index f8c210cb15..29c8d52bc9 100644 --- a/src/prefs/ThemePrefs.cpp +++ b/src/prefs/ThemePrefs.cpp @@ -71,7 +71,7 @@ ThemePrefs::ThemePrefs(wxWindow * parent, wxWindowID winid) Populate(); } -ThemePrefs::~ThemePrefs(void) +ThemePrefs::~ThemePrefs() { } diff --git a/src/prefs/ThemePrefs.h b/src/prefs/ThemePrefs.h index 0aa171901c..d2ca2e7159 100644 --- a/src/prefs/ThemePrefs.h +++ b/src/prefs/ThemePrefs.h @@ -31,7 +31,7 @@ class ThemePrefs final : public PrefsPanel { public: ThemePrefs(wxWindow * parent, wxWindowID winid); - ~ThemePrefs(void); + ~ThemePrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/TracksBehaviorsPrefs.h b/src/prefs/TracksBehaviorsPrefs.h index 3a8e54abe1..e51f370295 100644 --- a/src/prefs/TracksBehaviorsPrefs.h +++ b/src/prefs/TracksBehaviorsPrefs.h @@ -25,7 +25,7 @@ class SAUCEDACITY_DLL_API TracksBehaviorsPrefs final : public PrefsPanel { public: TracksBehaviorsPrefs(wxWindow * parent, wxWindowID winid); - ~TracksBehaviorsPrefs(); + ~TracksBehaviorsPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/TracksPrefs.h b/src/prefs/TracksPrefs.h index 2eeba36d75..0391d5544f 100644 --- a/src/prefs/TracksPrefs.h +++ b/src/prefs/TracksPrefs.h @@ -28,7 +28,7 @@ class SAUCEDACITY_DLL_API TracksPrefs final : public PrefsPanel { public: TracksPrefs(wxWindow * parent, wxWindowID winid); - ~TracksPrefs(); + ~TracksPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/WarningsPrefs.h b/src/prefs/WarningsPrefs.h index 77bf93e56f..1a2868db6d 100644 --- a/src/prefs/WarningsPrefs.h +++ b/src/prefs/WarningsPrefs.h @@ -25,7 +25,7 @@ class WarningsPrefs final : public PrefsPanel { public: WarningsPrefs(wxWindow * parent, wxWindowID winid); - ~WarningsPrefs(); + ~WarningsPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; diff --git a/src/prefs/WaveformPrefs.cpp b/src/prefs/WaveformPrefs.cpp index fa37a9e54c..0939446f0a 100644 --- a/src/prefs/WaveformPrefs.cpp +++ b/src/prefs/WaveformPrefs.cpp @@ -99,7 +99,7 @@ void WaveformPrefs::PopulateOrExchange(ShuttleGui & S) // S.StartStatic(XO("Track Settings")); { - mDefaultsCheckbox = 0; + mDefaultsCheckbox = nullptr; if (mWt) { /* i18n-hint: use is a verb */ mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(XXO("&Use Preferences"), mDefaulted); diff --git a/src/prefs/WaveformPrefs.h b/src/prefs/WaveformPrefs.h index 491f3ed52f..808296f5d2 100644 --- a/src/prefs/WaveformPrefs.h +++ b/src/prefs/WaveformPrefs.h @@ -27,7 +27,7 @@ class WaveformPrefs final : public PrefsPanel public: WaveformPrefs(wxWindow * parent, wxWindowID winid, SaucedacityProject *pProject, WaveTrack *wt); - virtual ~WaveformPrefs(); + ~WaveformPrefs() override; ComponentInterfaceSymbol GetSymbol() override; TranslatableString GetDescription() override; ManualPageID HelpPageName() override; diff --git a/src/prefs/WaveformSettings.h b/src/prefs/WaveformSettings.h index f35e603989..3b66b5eec3 100644 --- a/src/prefs/WaveformSettings.h +++ b/src/prefs/WaveformSettings.h @@ -35,9 +35,9 @@ class SAUCEDACITY_DLL_API WaveformSettings : public PrefsListener WaveformSettings(); WaveformSettings(const WaveformSettings &other); WaveformSettings& operator= (const WaveformSettings &other); - ~WaveformSettings(); + ~WaveformSettings() override; - bool IsDefault() const + [[nodiscard]] bool IsDefault() const { return this == &defaults(); } @@ -68,6 +68,6 @@ class SAUCEDACITY_DLL_API WaveformSettings : public PrefsListener int dBRange; // Convenience - bool isLinear() const { return stLinear == scaleType; } + [[nodiscard]] bool isLinear() const { return stLinear == scaleType; } }; #endif diff --git a/src/shuttle/Shuttle.cpp b/src/shuttle/Shuttle.cpp index da7dfbc998..f4c83ae114 100644 --- a/src/shuttle/Shuttle.cpp +++ b/src/shuttle/Shuttle.cpp @@ -326,7 +326,7 @@ bool ShuttleParams::ShouldSet(){ if( !pOptionalFlag ) return true; bool result = *pOptionalFlag; - pOptionalFlag = NULL; + pOptionalFlag = nullptr; return result; } // These are functions to override. They do nothing. @@ -421,7 +421,7 @@ bool ShuttleSetAutomation::CouldGet( const wxString &key ){ return true; bool result = mpEap->HasEntry( key ); *pOptionalFlag = result; - pOptionalFlag = NULL; + pOptionalFlag = nullptr; return result; } diff --git a/src/shuttle/Shuttle.h b/src/shuttle/Shuttle.h index 1b1cb72503..135121564f 100644 --- a/src/shuttle/Shuttle.h +++ b/src/shuttle/Shuttle.h @@ -37,7 +37,7 @@ class Shuttle /* not final */ { virtual bool TransferLongLong( const wxString & Name, wxLongLong_t & iValue, const wxLongLong_t &iDefault ); virtual bool TransferString( const wxString & Name, wxString & strValue, const wxString &strDefault ); virtual bool TransferEnum( const wxString & Name, int & iValue, - const int nChoices, const wxString * pFirstStr); + int nChoices, const wxString * pFirstStr); virtual bool TransferWrappedType( const wxString & Name, WrappedType & W ); // We expect the ExchangeWithMaster function to change from one type of // archive to another. @@ -49,7 +49,7 @@ class ShuttleCli final : public Shuttle public: wxString mParams; ShuttleCli() {} - virtual ~ShuttleCli() {} + ~ShuttleCli() override {} bool ExchangeWithMaster(const wxString & Name) override; }; @@ -65,20 +65,20 @@ class SAUCEDACITY_DLL_API ShuttleParams /* not final */ wxString mParams; bool *pOptionalFlag; CommandParameters * mpEap; - ShuttleParams() { mpEap = NULL; pOptionalFlag = NULL; } + ShuttleParams() { mpEap = nullptr; pOptionalFlag = nullptr; } virtual ~ShuttleParams() {} bool ShouldSet(); - virtual ShuttleParams & Optional( bool & WXUNUSED(var) ){ pOptionalFlag = NULL;return *this;}; + virtual ShuttleParams & Optional( bool & WXUNUSED(var) ){ pOptionalFlag = nullptr;return *this;}; virtual ShuttleParams & OptionalY( bool & var ){ return Optional( var );}; virtual ShuttleParams & OptionalN( bool & var ){ return Optional( var );}; - virtual void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false ); - virtual void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin=0, const int vmax=100000, const int vscl=1 ); - virtual void Define( int & var, const wxChar * key, const int vdefault, const int vmin=0, const int vmax=100000, const int vscl=1 ); - virtual void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl=1.0f ); - virtual void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl=1.0f ); - virtual void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl=1.0f ); - virtual void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin = {}, const wxString vmax = {}, const wxString vscl = {} ); - virtual void DefineEnum( int &var, const wxChar * key, const int vdefault, + virtual void Define( bool & var, const wxChar * key, bool vdefault, bool vmin=false, bool vmax=false, bool vscl=false ); + virtual void Define( size_t & var, const wxChar * key, int vdefault, int vmin=0, int vmax=100000, int vscl=1 ); + virtual void Define( int & var, const wxChar * key, int vdefault, int vmin=0, int vmax=100000, int vscl=1 ); + virtual void Define( float & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl=1.0f ); + virtual void Define( double & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl=1.0f ); + virtual void Define( double & var, const wxChar * key, double vdefault, double vmin, double vmax, double vscl=1.0f ); + virtual void Define( wxString &var, const wxChar * key, wxString vdefault, wxString vmin = {}, wxString vmax = {}, wxString vscl = {} ); + virtual void DefineEnum( int &var, const wxChar * key, int vdefault, const EnumValueSymbol strings[], size_t nStrings ); }; @@ -89,14 +89,14 @@ class SAUCEDACITY_DLL_API ShuttleGetAutomation final : public ShuttleParams { public: ShuttleParams & Optional( bool & var ) override; - void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override; - void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override; - void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override; - void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override; - void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override; - void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override; - void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override; - void DefineEnum( int &var, const wxChar * key, const int vdefault, + void Define( bool & var, const wxChar * key, bool vdefault, bool vmin, bool vmax, bool vscl ) override; + void Define( int & var, const wxChar * key, int vdefault, int vmin, int vmax, int vscl ) override; + void Define( size_t & var, const wxChar * key, int vdefault, int vmin, int vmax, int vscl ) override; + void Define( float & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl ) override; + void Define( double & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl ) override; + void Define( double & var, const wxChar * key, double vdefault, double vmin, double vmax, double vscl ) override; + void Define( wxString &var, const wxChar * key, wxString vdefault, wxString vmin, wxString vmax, wxString vscl ) override; + void DefineEnum( int &var, const wxChar * key, int vdefault, const EnumValueSymbol strings[], size_t nStrings ) override; }; @@ -113,14 +113,14 @@ class SAUCEDACITY_DLL_API ShuttleSetAutomation final : public ShuttleParams bool CouldGet(const wxString &key); void SetForValidating( CommandParameters * pEap){ mpEap=pEap; bOK=true;bWrite=false;}; void SetForWriting(CommandParameters * pEap){ mpEap=pEap;bOK=true;bWrite=true;}; - void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override; - void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override; - void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override; - void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override; - void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override; - void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override; - void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override; - void DefineEnum( int &var, const wxChar * key, const int vdefault, + void Define( bool & var, const wxChar * key, bool vdefault, bool vmin, bool vmax, bool vscl ) override; + void Define( int & var, const wxChar * key, int vdefault, int vmin, int vmax, int vscl ) override; + void Define( size_t & var, const wxChar * key, int vdefault, int vmin, int vmax, int vscl ) override; + void Define( float & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl ) override; + void Define( double & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl ) override; + void Define( double & var, const wxChar * key, double vdefault, double vmin, double vmax, double vscl ) override; + void Define( wxString &var, const wxChar * key, wxString vdefault, wxString vmin, wxString vmax, wxString vscl ) override; + void DefineEnum( int &var, const wxChar * key, int vdefault, const EnumValueSymbol strings[], size_t nStrings ) override; }; @@ -132,9 +132,9 @@ class ShuttleDefaults final : public ShuttleParams { public: wxString Result; - virtual ShuttleParams & Optional( bool & var )override{ var = true; pOptionalFlag = NULL;return *this;}; - virtual ShuttleParams & OptionalY( bool & var )override{ var = true; pOptionalFlag = NULL;return *this;}; - virtual ShuttleParams & OptionalN( bool & var )override{ var = false;pOptionalFlag = NULL;return *this;}; + ShuttleParams & Optional( bool & var )override{ var = true; pOptionalFlag = nullptr;return *this;}; + ShuttleParams & OptionalY( bool & var )override{ var = true; pOptionalFlag = nullptr;return *this;}; + ShuttleParams & OptionalN( bool & var )override{ var = false;pOptionalFlag = nullptr;return *this;}; void Define( bool & var, const wxChar * WXUNUSED(key), const bool vdefault, const bool WXUNUSED(vmin), const bool WXUNUSED(vmax), const bool WXUNUSED(vscl) ) diff --git a/src/shuttle/ShuttleGetDefinition.cpp b/src/shuttle/ShuttleGetDefinition.cpp index b1e41f4cd7..4c4d4a8a0b 100644 --- a/src/shuttle/ShuttleGetDefinition.cpp +++ b/src/shuttle/ShuttleGetDefinition.cpp @@ -14,8 +14,8 @@ #include bool ShuttleGetDefinition::IsOptional(){ - bool result = pOptionalFlag !=NULL; - pOptionalFlag = NULL; + bool result = pOptionalFlag !=nullptr; + pOptionalFlag = nullptr; return result; } diff --git a/src/shuttle/ShuttleGetDefinition.h b/src/shuttle/ShuttleGetDefinition.h index 461901c8a6..86599b201e 100644 --- a/src/shuttle/ShuttleGetDefinition.h +++ b/src/shuttle/ShuttleGetDefinition.h @@ -25,14 +25,14 @@ class SAUCEDACITY_DLL_API ShuttleGetDefinition final wxString Result; bool IsOptional(); ShuttleParams & Optional( bool & var ) override; - void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override; - void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override; - void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override; - void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override; - void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override; - void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override; - void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override; - void DefineEnum( int &var, const wxChar * key, const int vdefault, + void Define( bool & var, const wxChar * key, bool vdefault, bool vmin, bool vmax, bool vscl ) override; + void Define( int & var, const wxChar * key, int vdefault, int vmin, int vmax, int vscl ) override; + void Define( size_t & var, const wxChar * key, int vdefault, int vmin, int vmax, int vscl ) override; + void Define( float & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl ) override; + void Define( double & var, const wxChar * key, float vdefault, float vmin, float vmax, float vscl ) override; + void Define( double & var, const wxChar * key, double vdefault, double vmin, double vmax, double vscl ) override; + void Define( wxString &var, const wxChar * key, wxString vdefault, wxString vmin, wxString vmax, wxString vscl ) override; + void DefineEnum( int &var, const wxChar * key, int vdefault, const EnumValueSymbol strings[], size_t nStrings ) override; }; diff --git a/src/shuttle/ShuttleGui.cpp b/src/shuttle/ShuttleGui.cpp index 284b2150fc..05e46a8a07 100644 --- a/src/shuttle/ShuttleGui.cpp +++ b/src/shuttle/ShuttleGui.cpp @@ -129,7 +129,7 @@ ShuttleGuiBase::ShuttleGuiBase( wxWindow * pParent, teShuttleMode ShuttleMode, bool vertical, wxSize minSize ) : mpDlg{ pParent } { - wxASSERT( (pParent != NULL ) || ( ShuttleMode != eIsCreating)); + wxASSERT( (pParent != nullptr ) || ( ShuttleMode != eIsCreating)); mpbOptionalFlag = nullptr; mpParent = pParent; mShuttleMode = ShuttleMode; @@ -142,10 +142,10 @@ ShuttleGuiBase::~ShuttleGuiBase() void ShuttleGuiBase::Init(bool vertical, wxSize minSize) { - mpShuttle = NULL; - mpSizer = NULL; - mpWind = NULL; - mpSubSizer = NULL; + mpShuttle = nullptr; + mpSizer = nullptr; + mpWind = nullptr; + mpSubSizer = nullptr; mRadioSettingName = wxT(""); mRadioCount = -1; @@ -946,9 +946,9 @@ wxStaticBox * ShuttleGuiBase::StartStatic(const TranslatableString &Str, int iPr { UseUpId(); if( mShuttleMode != eIsCreating ) - return NULL; + return nullptr; auto translated = Str.Translation(); - wxStaticBox * pBox = safenew wxStaticBoxWrapper( + auto * pBox = safenew wxStaticBoxWrapper( GetParent(), miId, translated ); pBox->SetLabel( translated ); if (Str.empty()) { @@ -1121,9 +1121,9 @@ wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const TranslatableString & Name ) { if( mShuttleMode != eIsCreating ) - return NULL; + return nullptr; // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx); - auto pNotebook = static_cast< wxBookCtrlBase* >( mpParent ); + auto pNotebook = dynamic_cast< wxBookCtrlBase* >( mpParent ); wxNotebookPage * pPage = safenew wxPanelWrapper(GetParent()); const auto translated = Name.Translation(); pPage->SetName(translated); @@ -1162,7 +1162,7 @@ class InvisiblePanel final : public wxPanelWrapper wxPanelWrapper( parent, id, pos, size, style ) { }; - ~InvisiblePanel(){;}; + ~InvisiblePanel() override{;}; void OnPaint( wxPaintEvent &event ); void OnErase(wxEraseEvent &/*evt*/){;}; DECLARE_EVENT_TABLE() @@ -1390,7 +1390,7 @@ wxSpinCtrl * ShuttleGuiBase::DoTieSpinCtrl( return AddSpinCtrl( Prompt, WrappedRef.ReadAsInt(), max, min ); UseUpId(); - wxSpinCtrl * pSpinCtrl=NULL; + wxSpinCtrl * pSpinCtrl=nullptr; wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg); pSpinCtrl = wxDynamicCast(pWnd, wxSpinCtrl); @@ -1428,7 +1428,7 @@ wxTextCtrl * ShuttleGuiBase::DoTieTextBox( return AddTextBox( Prompt, WrappedRef.ReadAsString(), nChars ); UseUpId(); - wxTextCtrl * pTextBox=NULL; + wxTextCtrl * pTextBox=nullptr; wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg); pTextBox = wxDynamicCast(pWnd, wxTextCtrl); @@ -1466,7 +1466,7 @@ wxTextCtrl * ShuttleGuiBase::DoTieNumericTextBox( return AddNumericTextBox( Prompt, WrappedRef.ReadAsString(), nChars ); UseUpId(); - wxTextCtrl * pTextBox=NULL; + wxTextCtrl * pTextBox=nullptr; wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg); pTextBox = wxDynamicCast(pWnd, wxTextCtrl); @@ -1503,7 +1503,7 @@ wxSlider * ShuttleGuiBase::DoTieSlider( // The Add function does a UseUpId(), so don't do it here in that case. if( mShuttleMode != eIsCreating ) UseUpId(); - wxSlider * pSlider=NULL; + wxSlider * pSlider=nullptr; switch( mShuttleMode ) { case eIsCreating: @@ -1549,7 +1549,7 @@ wxChoice * ShuttleGuiBase::TieChoice( if( mShuttleMode != eIsCreating ) UseUpId(); - wxChoice * pChoice=NULL; + wxChoice * pChoice=nullptr; switch( mShuttleMode ) { case eIsCreating: @@ -1603,7 +1603,7 @@ wxRadioButton * ShuttleGuiBase::TieRadioButton() mRadioCount++; UseUpId(); - wxRadioButton * pRadioButton = NULL; + wxRadioButton * pRadioButton = nullptr; switch( mShuttleMode ) { @@ -1895,7 +1895,7 @@ wxCheckBox * ShuttleGuiBase::TieCheckBox( const TranslatableString &Prompt, const BoolSetting &Setting) { - wxCheckBox * pCheck=NULL; + wxCheckBox * pCheck=nullptr; auto Value = Setting.GetDefault(); WrappedType WrappedRef( Value ); @@ -1912,7 +1912,7 @@ wxCheckBox * ShuttleGuiBase::TieCheckBoxOnRight( const TranslatableString &Prompt, const BoolSetting & Setting) { - wxCheckBox * pCheck=NULL; + wxCheckBox * pCheck=nullptr; auto Value = Setting.GetDefault(); WrappedType WrappedRef( Value ); @@ -1931,7 +1931,7 @@ wxSlider * ShuttleGuiBase::TieSlider( const int max, const int min) { - wxSlider * pSlider=NULL; + wxSlider * pSlider=nullptr; auto Value = Setting.GetDefault(); WrappedType WrappedRef( Value ); @@ -1950,7 +1950,7 @@ wxSpinCtrl * ShuttleGuiBase::TieSpinCtrl( const int max, const int min) { - wxSpinCtrl * pSpinCtrl=NULL; + wxSpinCtrl * pSpinCtrl=nullptr; auto Value = Setting.GetDefault(); WrappedType WrappedRef( Value ); @@ -1968,7 +1968,7 @@ wxTextCtrl * ShuttleGuiBase::TieTextBox( const StringSetting & Setting, const int nChars) { - wxTextCtrl * pText=(wxTextCtrl*)NULL; + auto * pText=(wxTextCtrl*)nullptr; auto Value = Setting.GetDefault(); WrappedType WrappedRef( Value ); @@ -1986,7 +1986,7 @@ wxTextCtrl * ShuttleGuiBase::TieIntegerTextBox( const IntSetting &Setting, const int nChars) { - wxTextCtrl * pText=(wxTextCtrl*)NULL; + auto * pText=(wxTextCtrl*)nullptr; auto Value = Setting.GetDefault(); WrappedType WrappedRef( Value ); @@ -2004,7 +2004,7 @@ wxTextCtrl * ShuttleGuiBase::TieNumericTextBox( const DoubleSetting & Setting, const int nChars) { - wxTextCtrl * pText=(wxTextCtrl*)NULL; + auto * pText=(wxTextCtrl*)nullptr; auto Value = Setting.GetDefault(); WrappedType WrappedRef( Value ); @@ -2033,7 +2033,7 @@ wxChoice *ShuttleGuiBase::TieChoice( const auto &Choices = symbols.GetMsgids(); const auto &InternalChoices = symbols.GetInternals(); - wxChoice * pChoice=(wxChoice*)NULL; + auto * pChoice=(wxChoice*)nullptr; int TempIndex=0; // int TempIndex = TranslateToIndex( Default, InternalChoices ); @@ -2230,7 +2230,7 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt) PushSizer(); } - mpWind = NULL; + mpWind = nullptr; miProp = 0; miSizerProp =0; } @@ -2274,17 +2274,17 @@ long ShuttleGuiBase::GetStyle( long style ) // ONLY if the value it is to be set to is non NULL. void SetIfCreated( wxChoice * &Var, wxChoice * Val ) { - if( Val != NULL ) + if( Val != nullptr ) Var = Val; }; void SetIfCreated( wxTextCtrl * &Var, wxTextCtrl * Val ) { - if( Val != NULL ) + if( Val != nullptr ) Var = Val; }; void SetIfCreated( wxStaticText *&Var, wxStaticText * Val ) { - if( Val != NULL ) + if( Val != nullptr ) Var = Val; }; @@ -2337,7 +2337,7 @@ ShuttleGui & ShuttleGui::Optional( bool &bVar ){ std::unique_ptr CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra) { - wxASSERT(parent != NULL); // To justify safenew + wxASSERT(parent != nullptr); // To justify safenew int margin; { @@ -2354,11 +2354,11 @@ std::unique_ptr CreateStdButtonSizer(wxWindow *parent, long buttons, wx #endif } - wxButton *b = NULL; + wxButton *b = nullptr; auto bs = std::make_unique(); const auto makeButton = - [parent]( wxWindowID id, const wxString label = {} ) { + [parent]( wxWindowID id, const wxString& label = {} ) { auto result = safenew wxButton( parent, id, label ); result->SetName( result->GetLabel() ); return result; @@ -2511,7 +2511,7 @@ void ShuttleGui::AddStandardButtons(long buttons, wxWindow *extra) wxSizerItem * ShuttleGui::AddSpace( int width, int height, int prop ) { if( mShuttleMode != eIsCreating ) - return NULL; + return nullptr; // SetProportions(0); // return mpSizer->Add( width, height, miProp); diff --git a/src/shuttle/ShuttleGui.h b/src/shuttle/ShuttleGui.h index 7ecafa3c84..6fe3ba2b02 100644 --- a/src/shuttle/ShuttleGui.h +++ b/src/shuttle/ShuttleGui.h @@ -270,7 +270,7 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ SliderTextCtrl* AddSliderTextCtrl( const TranslatableString &Prompt, double pos, double Max, double Min = 0, - int precision = 2, double* value = NULL, double scale = 0, double offset = 0); + int precision = 2, double* value = nullptr, double scale = 0, double offset = 0); // Pass the same initValue to the sequence of calls to AddRadioButton and // AddRadioButtonToGroup. @@ -302,10 +302,10 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ const wxString &Value); wxTextCtrl * AddTextBox( const TranslatableString &Caption, - const wxString &Value, const int nChars); + const wxString &Value, int nChars); wxTextCtrl * AddNumericTextBox( const TranslatableString &Caption, - const wxString &Value, const int nChars); + const wxString &Value, int nChars); wxTextCtrl * AddTextWindow(const wxString &Value); wxListBox * AddListBox(const wxArrayStringEx &choices); @@ -405,19 +405,19 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ bool DoStep( int iStep ); int TranslateToIndex( const wxString &Value, const wxArrayStringEx &Choices ); - wxString TranslateFromIndex( const int nIn, const wxArrayStringEx &Choices ); + wxString TranslateFromIndex( int nIn, const wxArrayStringEx &Choices ); //-- Tie functions both add controls and also read/write to them. wxTextCtrl * TieTextBox( - const TranslatableString &Caption, wxString & Value, const int nChars=0); + const TranslatableString &Caption, wxString & Value, int nChars=0); wxTextCtrl * TieTextBox( - const TranslatableString &Prompt, int &Selected, const int nChars=0); + const TranslatableString &Prompt, int &Selected, int nChars=0); wxTextCtrl * TieTextBox( - const TranslatableString &Prompt, double &Value, const int nChars=0); + const TranslatableString &Prompt, double &Value, int nChars=0); - wxTextCtrl * TieNumericTextBox( const TranslatableString &Prompt, int &Value, const int nChars=0); - wxTextCtrl * TieNumericTextBox( const TranslatableString &Prompt, double &Value, const int nChars=0); + wxTextCtrl * TieNumericTextBox( const TranslatableString &Prompt, int &Value, int nChars=0); + wxTextCtrl * TieNumericTextBox( const TranslatableString &Prompt, double &Value, int nChars=0); wxCheckBox * TieCheckBox( const TranslatableString &Prompt, bool & Var ); wxCheckBox * TieCheckBoxOnRight( const TranslatableString & Prompt, bool & Var ); @@ -430,23 +430,23 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ wxSlider * TieSlider( const TranslatableString &Prompt, - int &pos, const int max, const int min = 0); + int &pos, int max, int min = 0); wxSlider * TieSlider( const TranslatableString &Prompt, - double &pos, const double max, const double min = 0.0); + double &pos, double max, double min = 0.0); wxSlider * TieSlider( const TranslatableString &Prompt, - float &pos, const float fMin, const float fMax); + float &pos, float fMin, float fMax); wxSlider * TieVSlider( const TranslatableString &Prompt, - float &pos, const float fMin, const float fMax); + float &pos, float fMin, float fMax); // Must be called between a StartRadioButtonGroup / EndRadioButtonGroup pair, // and as many times as there are values in the enumeration. wxRadioButton * TieRadioButton(); wxSpinCtrl * TieSpinCtrl( const TranslatableString &Prompt, - int &Value, const int max, const int min = 0 ); + int &Value, int max, int min = 0 ); //-- Variants of the standard Tie functions which do two step exchange in one go @@ -479,28 +479,28 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ virtual wxTextCtrl * TieTextBox( const TranslatableString &Prompt, const StringSetting &Setting, - const int nChars); + int nChars); virtual wxTextCtrl * TieIntegerTextBox( const TranslatableString & Prompt, const IntSetting &Setting, - const int nChars); + int nChars); virtual wxTextCtrl * TieNumericTextBox( const TranslatableString & Prompt, const DoubleSetting &Setting, - const int nChars); + int nChars); virtual wxSlider * TieSlider( const TranslatableString & Prompt, const IntSetting &Setting, - const int max, - const int min = 0); + int max, + int min = 0); virtual wxSpinCtrl * TieSpinCtrl( const TranslatableString &Prompt, const IntSetting &Setting, - const int max, - const int min); + int max, + int min); //-- End of variants. void SetBorder( int Border ) {miBorder = Border;}; - int GetBorder() const noexcept; + [[nodiscard]] int GetBorder() const noexcept; void SetSizerProportion( int iProp ) {miSizerProp = iProp;}; void SetStretchyCol( int i ); void SetStretchyRow( int i ); @@ -510,7 +510,7 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ { // This assertion justifies the use of safenew in many places where GetParent() // is used to construct a window - wxASSERT(mpParent != NULL); + wxASSERT(mpParent != nullptr); return mpParent; } ShuttleGuiBase & Prop( int iProp ); @@ -534,7 +534,7 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ long GetStyle( long Style ); private: - void DoInsertListColumns( + static void DoInsertListColumns( wxListCtrl *pListCtrl, long listControlStyles, std::initializer_list columns ); @@ -573,15 +573,15 @@ class SAUCEDACITY_DLL_API ShuttleGuiBase /* not final */ wxCheckBox * DoTieCheckBoxOnRight( const TranslatableString & Prompt, WrappedType & WrappedRef ); wxTextCtrl * DoTieTextBox( const TranslatableString &Prompt, - WrappedType & WrappedRef, const int nChars); + WrappedType & WrappedRef, int nChars); wxTextCtrl * DoTieNumericTextBox( - const TranslatableString &Prompt, WrappedType & WrappedRef, const int nChars); + const TranslatableString &Prompt, WrappedType & WrappedRef, int nChars); wxCheckBox * DoTieCheckBox( const TranslatableString &Prompt, WrappedType & WrappedRef ); wxSlider * DoTieSlider( const TranslatableString &Prompt, - WrappedType & WrappedRef, const int max, const int min = 0 ); + WrappedType & WrappedRef, int max, int min = 0 ); wxSpinCtrl * DoTieSpinCtrl( const TranslatableString &Prompt, - WrappedType & WrappedRef, const int max, const int min = 0 ); + WrappedType & WrappedRef, int max, int min = 0 ); std::vector mRadioSymbols; wxString mRadioSettingName; /// The setting controlled by a group. @@ -637,7 +637,7 @@ enum SAUCEDACITY_DLL_API std::unique_ptr CreateStdButtonSizer( wxWindow *parent, long buttons = eOkButton | eCancelButton, - wxWindow *extra = NULL ); + wxWindow *extra = nullptr ); // ShuttleGui extends ShuttleGuiBase with Audacity specific extensions. class SAUCEDACITY_DLL_API ShuttleGui /* not final */ : public ShuttleGuiBase @@ -648,7 +648,7 @@ class SAUCEDACITY_DLL_API ShuttleGui /* not final */ : public ShuttleGuiBase bool vertical = true, // Choose layout direction of topmost level sizer wxSize minSize = { 250, 100 } ); - ~ShuttleGui(void); + ~ShuttleGui() override; public: ShuttleGui & Optional( bool & bVar ); ShuttleGui & Id(int id ); @@ -751,7 +751,7 @@ class SAUCEDACITY_DLL_API ShuttleGui /* not final */ : public ShuttleGuiBase // The first of these buttons, if any, that is included will be default: // Apply, Yes, OK void AddStandardButtons( - long buttons = eOkButton | eCancelButton, wxWindow *extra = NULL ); + long buttons = eOkButton | eCancelButton, wxWindow *extra = nullptr ); wxSizerItem * AddSpace( int width, int height, int prop = 0 ); wxSizerItem * AddSpace( int size ) { return AddSpace( size, size ); }; diff --git a/src/shuttle/ShuttlePrefs.h b/src/shuttle/ShuttlePrefs.h index 573a93f700..669db1dfc7 100644 --- a/src/shuttle/ShuttlePrefs.h +++ b/src/shuttle/ShuttlePrefs.h @@ -19,7 +19,7 @@ class ShuttlePrefs final : public Shuttle public: // constructors and destructors ShuttlePrefs(){;}; - virtual ~ShuttlePrefs() {}; + ~ShuttlePrefs() override {}; public: bool TransferBool( const wxString & Name, bool & bValue, const bool & bDefault ) override; diff --git a/src/theme/FlowPacker.cpp b/src/theme/FlowPacker.cpp index c7ac9d475f..a26bb22ee5 100644 --- a/src/theme/FlowPacker.cpp +++ b/src/theme/FlowPacker.cpp @@ -80,17 +80,17 @@ void FlowPacker::GetNextPosition( int xSize, int ySize ) mComponentHeight = ySize; } -wxRect FlowPacker::Rect() +wxRect FlowPacker::Rect() const { return wxRect( mxPos, myPos, mComponentWidth, mComponentHeight); } -wxRect FlowPacker::RectInner() +wxRect FlowPacker::RectInner() const { return Rect().Deflate( mBorderWidth, mBorderWidth ); } -void FlowPacker::RectMid( int &x, int &y ) +void FlowPacker::RectMid( int &x, int &y ) const { x = mxPos + mComponentWidth/2; y = myPos + mComponentHeight/2; diff --git a/src/theme/FlowPacker.h b/src/theme/FlowPacker.h index 3eeefceca9..7ac7ca8002 100644 --- a/src/theme/FlowPacker.h +++ b/src/theme/FlowPacker.h @@ -31,9 +31,9 @@ class SAUCEDACITY_DLL_API FlowPacker void GetNextPosition( int xSize, int ySize ); void SetNewGroup( int iGroupSize ); void SetColourGroup( ); - wxRect Rect(); - wxRect RectInner(); - void RectMid( int &x, int &y ); + [[nodiscard]] wxRect Rect() const; + wxRect RectInner() const; + void RectMid( int &x, int &y ) const; // These 4 should become private again... int mFlags; diff --git a/src/theme/SourceOutputStream.h b/src/theme/SourceOutputStream.h index 29c40f7329..c0ff57959a 100644 --- a/src/theme/SourceOutputStream.h +++ b/src/theme/SourceOutputStream.h @@ -38,7 +38,7 @@ class SourceOutputStream final : public wxOutputStream SourceOutputStream(){}; int OpenFile(const FilePath & Filename); - virtual ~SourceOutputStream(); + ~SourceOutputStream() override; protected: size_t OnSysWrite(const void *buffer, size_t bufsize) override; diff --git a/src/theme/Theme.cpp b/src/theme/Theme.cpp index f346a289a1..bf5a260c27 100644 --- a/src/theme/Theme.cpp +++ b/src/theme/Theme.cpp @@ -86,12 +86,12 @@ static const unsigned char HiContrastImageCacheAsData[] = { // theTheme is a global variable. SAUCEDACITY_DLL_API Theme theTheme; -Theme::Theme(void) +Theme::Theme() { mbInitialised=false; } -Theme::~Theme(void) +Theme::~Theme() { } @@ -135,13 +135,13 @@ void Theme::RegisterColours() { } -ThemeBase::ThemeBase(void) +ThemeBase::ThemeBase() { bRecolourOnLoad = false; bIsUsingSystemTextColour = false; } -ThemeBase::~ThemeBase(void) +ThemeBase::~ThemeBase() { } @@ -309,7 +309,7 @@ void ThemeBase::RegisterImage( int &iIndex, const wxImage &Image, const wxString TempImage.ConvertAlphaToMask(); mBitmaps.push_back( wxBitmap( TempImage ) ); #else - mBitmaps.push_back( wxBitmap( Image ) ); + mBitmaps.emplace_back( Image ); #endif mBitmapNames.push_back( Name ); @@ -558,7 +558,7 @@ void ThemeBase::WriteImageDefs( ) wxFFile File( FileNames::ThemeImageDefsAsCee(), wxT("wb") ); if( !File.IsOpened() ) return; - teResourceFlags PrevFlags = (teResourceFlags)-1; + auto PrevFlags = (teResourceFlags)-1; for(i = 0; i < (int)mImages.size(); i++) { wxImage &SrcImage = mImages[i]; diff --git a/src/theme/Theme.h b/src/theme/Theme.h index 28060677ec..4da7153ba7 100644 --- a/src/theme/Theme.h +++ b/src/theme/Theme.h @@ -33,11 +33,11 @@ class ChoiceSetting; class SAUCEDACITY_DLL_API ThemeBase /* not final */ { public: - ThemeBase(void); + ThemeBase(); ThemeBase ( const ThemeBase & ) = delete; ThemeBase &operator =( const ThemeBase & ) = delete; public: - virtual ~ThemeBase(void); + virtual ~ThemeBase(); public: virtual void EnsureInitialised()=0; @@ -45,7 +45,7 @@ class SAUCEDACITY_DLL_API ThemeBase /* not final */ void RegisterImage( int &iIndex, const wxImage &Image, const wxString & Name ); void RegisterColour( int &iIndex, const wxColour &Clr, const wxString & Name ); - teThemeType GetFallbackThemeType(); + static teThemeType GetFallbackThemeType(); teThemeType ThemeTypeOfTypeName( const wxString & Name ); void CreateImageCache(bool bBinarySave = true); bool ReadImageCache( teThemeType type = themeFromFile, bool bOkIfNotFound=false); @@ -55,11 +55,11 @@ class SAUCEDACITY_DLL_API ThemeBase /* not final */ void WriteImageDefs( ); void WriteImageMap( ); static bool LoadPreferredTheme(); - bool IsUsingSystemTextColour(){ return bIsUsingSystemTextColour;}; + [[nodiscard]] bool IsUsingSystemTextColour() const{ return bIsUsingSystemTextColour;}; void RecolourBitmap( int iIndex, wxColour From, wxColour To ); void RecolourTheme(); - int ColourDistance( wxColour & From, wxColour & To ); + static int ColourDistance( wxColour & From, wxColour & To ); wxColour & Colour( int iIndex ); wxBitmap & Bitmap( int iIndex ); wxImage & Image( int iIndex ); @@ -77,9 +77,9 @@ class SAUCEDACITY_DLL_API ThemeBase /* not final */ void SetFlags( int flags ){ mFlow.mFlags = flags;}; // Utility function that combines a bitmap and a mask, both in XPM format. - wxImage MaskedImage( char const ** pXpm, char const ** pMask ); + static wxImage MaskedImage( char const ** pXpm, char const ** pMask ); // Utility function that takes a 32 bit bitmap and makes it into an image. - wxImage MakeImageWithAlpha( wxBitmap & Bmp ); + static wxImage MakeImageWithAlpha( wxBitmap & Bmp ); protected: // wxImage, wxBitmap copy cheaply using reference counting @@ -97,9 +97,9 @@ class SAUCEDACITY_DLL_API ThemeBase /* not final */ class SAUCEDACITY_DLL_API Theme final : public ThemeBase { public: - Theme(void); + Theme(); public: - ~Theme(void); + ~Theme() override; public: void EnsureInitialised() override; void RegisterImages(); diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index b38560cb36..87a730aecc 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -129,14 +129,14 @@ ControlToolBar::~ControlToolBar() ControlToolBar *ControlToolBar::Find( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return static_cast( + return dynamic_cast( toolManager.GetToolBar(TransportBarID) ); } ControlToolBar &ControlToolBar::Get( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return *static_cast( + return *dynamic_cast( toolManager.GetToolBar(TransportBarID) ); } @@ -247,7 +247,7 @@ void ControlToolBar::RegenerateTooltips() #if wxUSE_TOOLTIPS for (long iWinID = ID_PAUSE_BUTTON; iWinID < BUTTON_COUNT; iWinID++) { - auto pCtrl = static_cast(this->FindWindow(iWinID)); + auto pCtrl = dynamic_cast(this->FindWindow(iWinID)); CommandID name; switch (iWinID) { @@ -287,12 +287,12 @@ void ControlToolBar::RegenerateTooltips() { bool bPreferNewTrack; gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false); // For the shortcut tooltip. - commands.push_back( { + commands.emplace_back( wxT("Record2ndChoice"), !bPreferNewTrack ? XO("Record New Track") : XO("Append Record") - } ); + ); } break; case ID_PAUSE_BUTTON: @@ -301,13 +301,13 @@ void ControlToolBar::RegenerateTooltips() break; case ID_FF_BUTTON: // With shift - commands.push_back( { - wxT("SelEnd"), XO("Select to End") } ); + commands.emplace_back( + wxT("SelEnd"), XO("Select to End") ); break; case ID_REW_BUTTON: // With shift - commands.push_back( { - wxT("SelStart"), XO("Select to Start") } ); + commands.emplace_back( + wxT("SelStart"), XO("Select to Start") ); break; } ToolBar::SetButtonToolTip( diff --git a/src/toolbars/ControlToolBar.h b/src/toolbars/ControlToolBar.h index 7661ea8410..5e1afc94be 100644 --- a/src/toolbars/ControlToolBar.h +++ b/src/toolbars/ControlToolBar.h @@ -34,7 +34,7 @@ class SAUCEDACITY_DLL_API ControlToolBar final : public ToolBar { public: ControlToolBar( SaucedacityProject &project ); - virtual ~ControlToolBar(); + ~ControlToolBar() override; static ControlToolBar *Find( SaucedacityProject &project ); static ControlToolBar &Get( SaucedacityProject &project ); diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index 7b2297a025..df47291c2e 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -88,7 +88,7 @@ DeviceToolBar::~DeviceToolBar() DeviceToolBar &DeviceToolBar::Get( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return *static_cast( toolManager.GetToolBar(DeviceBarID) ); + return *dynamic_cast( toolManager.GetToolBar(DeviceBarID) ); } const DeviceToolBar &DeviceToolBar::Get( const SaucedacityProject &project ) @@ -108,10 +108,10 @@ void DeviceToolBar::Create(wxWindow *parent) void DeviceToolBar::DeinitChildren() { - mInput = NULL; - mOutput = NULL; - mInputChannels = NULL; - mHost = NULL; + mInput = nullptr; + mOutput = nullptr; + mInputChannels = nullptr; + mHost = nullptr; } void DeviceToolBar::Populate() @@ -219,7 +219,7 @@ void DeviceToolBar::OnFocus(wxFocusEvent &event) void DeviceToolBar::OnCaptureKey(wxCommandEvent &event) { - wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject(); + auto *kevent = (wxKeyEvent *)event.GetEventObject(); int keyCode = kevent->GetKeyCode(); // Pass UP/DOWN/LEFT/RIGHT through for input/output choice @@ -233,8 +233,6 @@ void DeviceToolBar::OnCaptureKey(wxCommandEvent &event) return; } event.Skip(); - - return; } void DeviceToolBar::UpdatePrefs() @@ -266,18 +264,18 @@ void DeviceToolBar::UpdatePrefs() mInput->SetStringSelection(desc); FillInputChannels(); } else if (mInput->GetStringSelection() != desc && mInput->GetCount()) { - for (size_t i = 0; i < inMaps.size(); i++) { - if (inMaps[i].hostString == hostName && - MakeDeviceSourceString(&inMaps[i]) == mInput->GetString(0)) { + for (const auto & inMap : inMaps) { + if (inMap.hostString == hostName && + MakeDeviceSourceString(&inMap) == mInput->GetString(0)) { // use the default. It should exist but check just in case, falling back on the 0 index. - DeviceSourceMap *defaultMap = DeviceManager::Instance()->GetDefaultInputDevice(inMaps[i].hostIndex); + DeviceSourceMap *defaultMap = DeviceManager::Instance()->GetDefaultInputDevice(inMap.hostIndex); if (defaultMap) { mInput->SetStringSelection(MakeDeviceSourceString(defaultMap)); - SetDevices(defaultMap, NULL); + SetDevices(defaultMap, nullptr); } else { //use the first item (0th index) if we have no familiar devices mInput->SetSelection(0); - SetDevices(&inMaps[i], NULL); + SetDevices(&inMap, nullptr); } break; } @@ -296,18 +294,18 @@ void DeviceToolBar::UpdatePrefs() mOutput->SetStringSelection(desc); } else if (mOutput->GetStringSelection() != desc && mOutput->GetCount()) { - for (size_t i = 0; i < outMaps.size(); i++) { - if (outMaps[i].hostString == hostName && - MakeDeviceSourceString(&outMaps[i]) == mOutput->GetString(0)) { + for (const auto & outMap : outMaps) { + if (outMap.hostString == hostName && + MakeDeviceSourceString(&outMap) == mOutput->GetString(0)) { // use the default. It should exist but check just in case, falling back on the 0 index. - DeviceSourceMap *defaultMap = DeviceManager::Instance()->GetDefaultOutputDevice(outMaps[i].hostIndex); + DeviceSourceMap *defaultMap = DeviceManager::Instance()->GetDefaultOutputDevice(outMap.hostIndex); if (defaultMap) { mOutput->SetStringSelection(MakeDeviceSourceString(defaultMap)); - SetDevices(NULL, defaultMap); + SetDevices(nullptr, defaultMap); } else { //use the first item (0th index) if we have no familiar devices mOutput->SetSelection(0); - SetDevices(NULL, &outMaps[i]); + SetDevices(nullptr, &outMap); } break; } @@ -418,7 +416,7 @@ void DeviceToolBar::FillHosts() mHost->Clear(); mHost->Append(hosts); - if (hosts.size() == 0) { + if (hosts.empty()) { mHost->Enable(false); } @@ -458,10 +456,10 @@ void DeviceToolBar::FillHostDevices() // If no host was found based on the prefs device host, load the first available one if (foundHostIndex == -1) { - if (outMaps.size()) { + if (!outMaps.empty()) { foundHostIndex = outMaps[0].hostIndex; } - else if (inMaps.size()) { + else if (!inMaps.empty()) { foundHostIndex = inMaps[0].hostIndex; } } @@ -637,8 +635,8 @@ void DeviceToolBar::ChangeDevice(bool isInput) return; } - SetDevices(isInput ? &maps[newIndex] : NULL, - isInput ? NULL : &maps[newIndex]); + SetDevices(isInput ? &maps[newIndex] : nullptr, + isInput ? nullptr : &maps[newIndex]); } void DeviceToolBar::OnChoice(wxCommandEvent &event) diff --git a/src/toolbars/DeviceToolBar.h b/src/toolbars/DeviceToolBar.h index c8543fa888..ddf284d534 100644 --- a/src/toolbars/DeviceToolBar.h +++ b/src/toolbars/DeviceToolBar.h @@ -26,7 +26,7 @@ class DeviceToolBar final : public ToolBar { public: DeviceToolBar( SaucedacityProject &project ); - virtual ~DeviceToolBar(); + ~DeviceToolBar() override; static DeviceToolBar &Get( SaucedacityProject &project ); static const DeviceToolBar &Get( const SaucedacityProject &project ); @@ -67,7 +67,7 @@ class DeviceToolBar final : public ToolBar { void SetDevices(const DeviceSourceMap *in, const DeviceSourceMap *out); void SetNames(); void RegenerateTooltips() override; - void ShowComboDialog(wxChoice *combo, const TranslatableString &title); + static void ShowComboDialog(wxChoice *combo, const TranslatableString &title); wxChoice *mInput; wxChoice *mOutput; diff --git a/src/toolbars/EditToolBar.h b/src/toolbars/EditToolBar.h index 1a0b9bbcc8..0933e429fd 100644 --- a/src/toolbars/EditToolBar.h +++ b/src/toolbars/EditToolBar.h @@ -73,7 +73,7 @@ class EditToolBar final : public ToolBar { public: EditToolBar( SaucedacityProject &project ); - virtual ~EditToolBar(); + ~EditToolBar() override; void Create(wxWindow *parent) override; diff --git a/src/toolbars/MeterToolBar.cpp b/src/toolbars/MeterToolBar.cpp index 63ed30ab4d..a5f2ea0b00 100644 --- a/src/toolbars/MeterToolBar.cpp +++ b/src/toolbars/MeterToolBar.cpp @@ -62,9 +62,9 @@ MeterToolBar::MeterToolBar(SaucedacityProject &project, int type) } else { mWhichMeters = kWithPlayMeter | kWithRecordMeter; } - mSizer = NULL; - mPlayMeter = NULL; - mRecordMeter = NULL; + mSizer = nullptr; + mPlayMeter = nullptr; + mRecordMeter = nullptr; } MeterToolBar::~MeterToolBar() @@ -192,8 +192,8 @@ void MeterToolBar::OnSize( wxSizeEvent & event) //WXUNUSED(event) ) width = sz.x; height = sz.y; int nMeters = - ((mRecordMeter ==NULL) ? 0:1) + - ((mPlayMeter ==NULL) ? 0:1); + ((mRecordMeter ==nullptr) ? 0:1) + + ((mPlayMeter ==nullptr) ? 0:1); bool bHorizontal = ( width > height ); bool bEndToEnd = ( nMeters > 1 ) && wxMin( width, height ) < (60 * nMeters); diff --git a/src/toolbars/MeterToolBar.h b/src/toolbars/MeterToolBar.h index d1ff580341..4aa3f1728c 100644 --- a/src/toolbars/MeterToolBar.h +++ b/src/toolbars/MeterToolBar.h @@ -34,7 +34,7 @@ class MeterToolBar final : public ToolBar { public: MeterToolBar(SaucedacityProject &project, int type); - virtual ~MeterToolBar(); + ~MeterToolBar() override; void Create(wxWindow *parent) override; @@ -53,7 +53,7 @@ class MeterToolBar final : public ToolBar { wxSize GetDockedSize() override { return GetSmartDockedSize(); }; - virtual void SetDocked(ToolDock *dock, bool pushed)override; + void SetDocked(ToolDock *dock, bool pushed)override; private: void RegenerateTooltips() override; diff --git a/src/toolbars/ScrubbingToolBar.cpp b/src/toolbars/ScrubbingToolBar.cpp index ad13cdeefe..524f434756 100644 --- a/src/toolbars/ScrubbingToolBar.cpp +++ b/src/toolbars/ScrubbingToolBar.cpp @@ -70,7 +70,7 @@ ScrubbingToolBar::~ScrubbingToolBar() ScrubbingToolBar &ScrubbingToolBar::Get( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return *static_cast( toolManager.GetToolBar(ScrubbingBarID) ); + return *dynamic_cast( toolManager.GetToolBar(ScrubbingBarID) ); } const ScrubbingToolBar &ScrubbingToolBar::Get( const SaucedacityProject &project ) diff --git a/src/toolbars/ScrubbingToolBar.h b/src/toolbars/ScrubbingToolBar.h index d26fece4d3..aeb1962006 100644 --- a/src/toolbars/ScrubbingToolBar.h +++ b/src/toolbars/ScrubbingToolBar.h @@ -41,7 +41,7 @@ class ScrubbingToolBar final : public ToolBar { public: ScrubbingToolBar( SaucedacityProject &project ); - virtual ~ScrubbingToolBar(); + ~ScrubbingToolBar() override; static ScrubbingToolBar &Get( SaucedacityProject &project ); static const ScrubbingToolBar &Get( const SaucedacityProject &project ); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index ad3c5476a2..324acb48a4 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -111,13 +111,13 @@ END_EVENT_TABLE() SelectionBar::SelectionBar( SaucedacityProject &project ) : ToolBar(project, SelectionBarID, XO("Selection"), wxT("Selection")), - mListener(NULL), mRate(0.0), + mListener(nullptr), mRate(0.0), mStart(0.0), mEnd(0.0), mLength(0.0), mCenter(0.0), mAudio(0.0), mDrive1( StartTimeID), mDrive2( EndTimeID ), mSelectionMode(0), - mStartTime(NULL), mCenterTime(NULL), mLengthTime(NULL), mEndTime(NULL), - mAudioTime(NULL), - mChoice(NULL) + mStartTime(nullptr), mCenterTime(nullptr), mLengthTime(nullptr), mEndTime(nullptr), + mAudioTime(nullptr), + mChoice(nullptr) { // Make sure we have a valid rate as the NumericTextCtrl()s // created in Populate() @@ -139,7 +139,7 @@ SelectionBar::~SelectionBar() SelectionBar &SelectionBar::Get( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return *static_cast( toolManager.GetToolBar(SelectionBarID) ); + return *dynamic_cast( toolManager.GetToolBar(SelectionBarID) ); } const SelectionBar &SelectionBar::Get( const SaucedacityProject &project ) @@ -157,7 +157,7 @@ void SelectionBar::Create(wxWindow * parent) AuStaticText * SelectionBar::AddTitle( const TranslatableString & Title, wxSizer * pSizer ){ const auto translated = Title.Translation(); - AuStaticText * pTitle = safenew AuStaticText(this, translated ); + auto * pTitle = safenew AuStaticText(this, translated ); pTitle->SetBackgroundColour( theTheme.Colour( clrMedium )); pTitle->SetForegroundColour( theTheme.Colour( clrTrackPanelText ) ); pSizer->Add( pTitle, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 ); @@ -194,7 +194,7 @@ void SelectionBar::Populate() // Inner sizers have space on right only. // This choice makes for a nice border and internal spacing and places clear responsibility // on each sizer as to what spacings it creates. - wxFlexGridSizer *mainSizer = safenew wxFlexGridSizer(SIZER_COLS, 1, 1); + auto *mainSizer = safenew wxFlexGridSizer(SIZER_COLS, 1, 1); Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5); // Top row (mostly labels) @@ -522,12 +522,12 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt) // ReCreateButtons() will get rid of our sizers and controls // so reset pointers first. for( i=0;i<5;i++) - *Ctrls[i]=NULL; + *Ctrls[i]=nullptr; - mChoice = NULL; - mRateBox = NULL; - mRateText = NULL; - mSnapTo = NULL; + mChoice = nullptr; + mRateBox = nullptr; + mRateText = nullptr; + mSnapTo = nullptr; ToolBar::ReCreateButtons(); @@ -776,7 +776,7 @@ void SelectionBar::OnFocus(wxFocusEvent &event) void SelectionBar::OnCaptureKey(wxCommandEvent &event) { - wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject(); + auto *kevent = (wxKeyEvent *)event.GetEventObject(); wxWindow *w = FindFocus(); int keyCode = kevent->GetKeyCode(); diff --git a/src/toolbars/SelectionBar.h b/src/toolbars/SelectionBar.h index 797d106fb2..5d6da2c6ee 100644 --- a/src/toolbars/SelectionBar.h +++ b/src/toolbars/SelectionBar.h @@ -47,7 +47,7 @@ class SAUCEDACITY_DLL_API SelectionBar final : public ToolBar { public: SelectionBar( SaucedacityProject &project ); - virtual ~SelectionBar(); + ~SelectionBar() override; static SelectionBar &Get( SaucedacityProject &project ); static const SelectionBar &Get( const SaucedacityProject &project ); diff --git a/src/toolbars/SpectralSelectionBar.cpp b/src/toolbars/SpectralSelectionBar.cpp index b9a0a315db..cf7d6582ae 100644 --- a/src/toolbars/SpectralSelectionBar.cpp +++ b/src/toolbars/SpectralSelectionBar.cpp @@ -98,10 +98,10 @@ static const wxString preferencePath SpectralSelectionBar::SpectralSelectionBar( SaucedacityProject &project ) : ToolBar( project, SpectralSelectionBarID, XO("Spectral Selection"), wxT("SpectralSelection") ) -, mListener(NULL), mbCenterAndWidth(true) +, mListener(nullptr), mbCenterAndWidth(true) , mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0) -, mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL) -, mChoice(NULL) +, mCenterCtrl(nullptr), mWidthCtrl(nullptr), mLowCtrl(nullptr), mHighCtrl(nullptr) +, mChoice(nullptr) { } @@ -113,7 +113,7 @@ SpectralSelectionBar::~SpectralSelectionBar() SpectralSelectionBar &SpectralSelectionBar::Get( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return *static_cast( + return *dynamic_cast( toolManager.GetToolBar(SpectralSelectionBarID) ); } @@ -141,7 +141,7 @@ void SpectralSelectionBar::Populate() ? mListener->SSBL_GetBandwidthSelectionFormatName() : NumericFormatSymbol{}; - wxFlexGridSizer *mainSizer = safenew wxFlexGridSizer(1, 1, 1); + auto *mainSizer = safenew wxFlexGridSizer(1, 1, 1); Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5); // @@ -389,8 +389,8 @@ void SpectralSelectionBar::OnUpdate(wxCommandEvent &evt) // ReCreateButtons() will get rid of our sizers and controls // so reset pointers first. - mCenterCtrl = mWidthCtrl = NULL; - mLowCtrl = mHighCtrl = NULL; + mCenterCtrl = mWidthCtrl = nullptr; + mLowCtrl = mHighCtrl = nullptr; ReCreateButtons(); ValuesToControls(); diff --git a/src/toolbars/SpectralSelectionBar.h b/src/toolbars/SpectralSelectionBar.h index 67cf80eb7a..0137e1c16b 100644 --- a/src/toolbars/SpectralSelectionBar.h +++ b/src/toolbars/SpectralSelectionBar.h @@ -30,7 +30,7 @@ class SpectralSelectionBar final : public ToolBar { public: SpectralSelectionBar( SaucedacityProject &project ); - virtual ~SpectralSelectionBar(); + ~SpectralSelectionBar() override; static SpectralSelectionBar &Get( SaucedacityProject &project ); static const SpectralSelectionBar &Get( const SaucedacityProject &project ); diff --git a/src/toolbars/SpectralSelectionBarListener.h b/src/toolbars/SpectralSelectionBarListener.h index 6d423b9b31..671bc72e4c 100644 --- a/src/toolbars/SpectralSelectionBarListener.h +++ b/src/toolbars/SpectralSelectionBarListener.h @@ -21,7 +21,7 @@ class SAUCEDACITY_DLL_API SpectralSelectionBarListener /* not final */ { SpectralSelectionBarListener(){} virtual ~SpectralSelectionBarListener(){} - virtual double SSBL_GetRate() const = 0; + [[nodiscard]] virtual double SSBL_GetRate() const = 0; virtual const NumericFormatSymbol & SSBL_GetFrequencySelectionFormatName() = 0; virtual void SSBL_SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName) = 0; diff --git a/src/toolbars/TimeToolBar.cpp b/src/toolbars/TimeToolBar.cpp index 3b305b01dc..9814b52fea 100644 --- a/src/toolbars/TimeToolBar.cpp +++ b/src/toolbars/TimeToolBar.cpp @@ -50,8 +50,8 @@ END_EVENT_TABLE() TimeToolBar::TimeToolBar(SaucedacityProject &project) : ToolBar(project, TimeBarID, XO("Time"), wxT("Time"), true), - mListener(NULL), - mAudioTime(NULL) + mListener(nullptr), + mAudioTime(nullptr) { project.Bind(EVT_PROJECT_SETTINGS_CHANGE, &TimeToolBar::OnSettingsChanged, this); } @@ -63,7 +63,7 @@ TimeToolBar::~TimeToolBar() TimeToolBar &TimeToolBar::Get(SaucedacityProject &project) { auto &toolManager = ToolManager::Get(project); - return *static_cast(toolManager.GetToolBar(TimeBarID)); + return *dynamic_cast(toolManager.GetToolBar(TimeBarID)); } const TimeToolBar &TimeToolBar::Get(const SaucedacityProject &project) diff --git a/src/toolbars/TimeToolBar.h b/src/toolbars/TimeToolBar.h index 54e538447e..2d33b59ef1 100644 --- a/src/toolbars/TimeToolBar.h +++ b/src/toolbars/TimeToolBar.h @@ -23,7 +23,7 @@ class TimeToolBar final : public ToolBar { public: TimeToolBar(SaucedacityProject &project); - virtual ~TimeToolBar(); + ~TimeToolBar() override; static TimeToolBar &Get(SaucedacityProject &project); static const TimeToolBar &Get(const SaucedacityProject &project); diff --git a/src/toolbars/ToolBar.cpp b/src/toolbars/ToolBar.cpp index 45ad571296..effcf04184 100644 --- a/src/toolbars/ToolBar.cpp +++ b/src/toolbars/ToolBar.cpp @@ -73,12 +73,12 @@ class ToolBarResizer final : public wxWindow { public: ToolBarResizer(ToolBar *mBar); - virtual ~ToolBarResizer(); + ~ToolBarResizer() override; // We don't need or want to accept focus. // Note that AcceptsFocusFromKeyboard() is overridden rather than // AcceptsFocus(), so that resize can be cancelled by ESC - bool AcceptsFocusFromKeyboard() const override {return false;} + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override {return false;} private: void OnErase(wxEraseEvent & event); @@ -343,13 +343,13 @@ ToolBar::ToolBar( SaucedacityProject &project, mResizable = resizable; // Initialize everything - mParent = NULL; - mHSizer = NULL; + mParent = nullptr; + mHSizer = nullptr; mVisible = false; mPositioned = false; - mGrabber = NULL; - mResizer = NULL; + mGrabber = nullptr; + mResizer = nullptr; SetId(mType); } @@ -388,7 +388,7 @@ wxString ToolBar::GetSection() // // Returns the toolbar type // -int ToolBar::GetType() +int ToolBar::GetType() const { return mType; } @@ -521,12 +521,12 @@ void ToolBar::ReCreateButtons() // SetSizer(NULL) detaches mHSizer and deletes it. // Do not use Detach() here, as that attempts to detach mHSizer from itself! - SetSizer( NULL ); + SetSizer( nullptr ); // Get rid of any children we may have DestroyChildren(); - mGrabber = NULL; - mResizer = NULL; + mGrabber = nullptr; + mResizer = nullptr; SetLayoutDirection(wxLayout_LeftToRight); // Refresh the background before populating @@ -622,8 +622,7 @@ void ToolBar::UpdatePrefs() } #endif - return; -} + } // // Return the pointer to the ToolBock where this bar lives @@ -651,7 +650,7 @@ void ToolBar::SetDocked( ToolDock *dock, bool pushed ) if (mResizer) { - mResizer->Show(dock != NULL); + mResizer->Show(dock != nullptr); Layout(); } } @@ -863,7 +862,7 @@ AButton * ToolBar::MakeButton(wxWindow *parent, wxImagePtr disable2 (OverlayImage(eUp, eDisabled, xoff, yoff)); wxASSERT(parent); // to justify safenew - AButton * button = + auto * button = safenew AButton(parent, id, placement, size, *up2, *hilite2, *down2, *downHi2, *disable2, processdownevents); diff --git a/src/toolbars/ToolBar.h b/src/toolbars/ToolBar.h index f4d018ff8f..78bcb63ddd 100644 --- a/src/toolbars/ToolBar.h +++ b/src/toolbars/ToolBar.h @@ -105,9 +105,9 @@ class SAUCEDACITY_DLL_API ToolBar /* not final */ ToolBar( SaucedacityProject &project, int type, const TranslatableString & label, const wxString & section, bool resizable = false); - virtual ~ToolBar(); + ~ToolBar() override; - bool AcceptsFocus() const override { return false; }; + [[nodiscard]] bool AcceptsFocus() const override { return false; }; virtual void SetToDefaultSize(); //NEW virtuals: @@ -117,7 +117,7 @@ class SAUCEDACITY_DLL_API ToolBar /* not final */ void UpdatePrefs() override; virtual void RegenerateTooltips() = 0; - int GetType(); + int GetType() const; TranslatableString GetTitle(); TranslatableString GetLabel(); wxString GetSection(); @@ -132,10 +132,10 @@ class SAUCEDACITY_DLL_API ToolBar /* not final */ // NEW virtual: virtual bool Expose(bool show = true); - bool IsResizable() const; - bool IsVisible() const; - bool IsDocked() const; - bool IsPositioned(){ return mPositioned; }; + [[nodiscard]] bool IsResizable() const; + [[nodiscard]] bool IsVisible() const; + [[nodiscard]] bool IsDocked() const; + bool IsPositioned() const{ return mPositioned; }; void SetVisible( bool bVisible ); void SetPositioned(){ mPositioned = true;}; @@ -187,7 +187,7 @@ class SAUCEDACITY_DLL_API ToolBar /* not final */ virtual void ResizingDone() {}; protected: - void SetButton(bool down, AButton *button); + static void SetButton(bool down, AButton *button); static void MakeMacRecoloredImage(teBmps eBmpOut, teBmps eBmpIn); static void MakeRecoloredImage(teBmps eBmpOut, teBmps eBmpIn); @@ -198,21 +198,21 @@ class SAUCEDACITY_DLL_API ToolBar /* not final */ int proportion = 0, int flag = wxALIGN_TOP, int border = 0, - wxObject *userData = NULL); + wxObject *userData = nullptr); // Takes ownership of sizer void Add(wxSizer *sizer, int proportion = 0, int flag = 0, int border = 0, - wxObject *userData = NULL); + wxObject *userData = nullptr); void Add(int width, int height, int proportion = 0, int flag = 0, int border = 0, - wxObject *userData = NULL); + wxObject *userData = nullptr); void AddSpacer(int size = 14); void AddStretchSpacer(int prop = 1); @@ -223,7 +223,7 @@ class SAUCEDACITY_DLL_API ToolBar /* not final */ void Updated(); /// Returns the width in pixels of the resizer element - int GetResizeGrabberWidth(); + static int GetResizeGrabberWidth(); virtual void Populate() = 0; virtual void Repaint(wxDC *dc) = 0; diff --git a/src/toolbars/ToolDock.cpp b/src/toolbars/ToolDock.cpp index 5a71534960..96341f3247 100644 --- a/src/toolbars/ToolDock.cpp +++ b/src/toolbars/ToolDock.cpp @@ -682,7 +682,7 @@ void ToolDock::LayoutToolBars() return false; } - virtual void FinalRect + void FinalRect (const wxRect &rect, ToolBarConfiguration::Position) override { diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h index f117319b30..061527b8b5 100644 --- a/src/toolbars/ToolDock.h +++ b/src/toolbars/ToolDock.h @@ -140,7 +140,7 @@ class ToolBarConfiguration } else { auto b = children.begin(); - mIters.push_back( Triple { b, b, children.end() } ); + mIters.emplace_back( b, b, children.end() ); } } @@ -167,7 +167,7 @@ class ToolBarConfiguration } // This may be called on the end iterator, and then returns empty - std::vector GetPath() const + [[nodiscard]] std::vector GetPath() const { std::vector path; path.reserve(mIters.size()); @@ -199,7 +199,7 @@ class ToolBarConfiguration auto &forest = conf.mForest; if (!forest.empty()) { auto b = forest.begin(); - mIters.push_back( Triple { b, b, forest.end() } ); + mIters.emplace_back( b, b, forest.end() ); mPlace.pTree = &*b; } } @@ -228,7 +228,7 @@ class ToolBarConfiguration }; Iterator begin() { return Iterator { *this }; } - Iterator end() const { return Iterator {}; } + static Iterator end() { return Iterator {}; } Position Find(const ToolBar *bar) const; @@ -267,7 +267,7 @@ class ToolBarConfiguration private: - void Remove(Forest &forest, Forest::iterator iter); + static void Remove(Forest &forest, Forest::iterator iter); void RemoveNulls(Forest &forest); struct Tree @@ -293,9 +293,9 @@ class ToolDock final : public wxPanelWrapper public: ToolDock( wxEvtHandler *manager, wxWindow *parent, int dockid ); - ~ToolDock(); + ~ToolDock() override; - bool AcceptsFocus() const override { return false; }; + [[nodiscard]] bool AcceptsFocus() const override { return false; }; void LoadConfig(); void LayoutToolBars(); diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index a7323d13b1..25397923f5 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -130,7 +130,7 @@ ToolFrame::ToolFrame Layout(); // Inform toolbar of change - bar->SetDocked( NULL, true ); + bar->SetDocked( nullptr, true ); // Make sure resizable floaters don't get any smaller than initial size if( bar->IsResizable() ) @@ -381,9 +381,9 @@ ToolManager::ToolManager( SaucedacityProject *parent ) mParent = parent; mLastPos.x = mBarPos.x = -1; mLastPos.y = mBarPos.y = -1; - mDragWindow = NULL; - mDragDock = NULL; - mDragBar = NULL; + mDragWindow = nullptr; + mDragDock = nullptr; + mDragBar = nullptr; // Create the down arrow pt[ 0 ].x = 0; @@ -409,7 +409,7 @@ ToolManager::ToolManager( SaucedacityProject *parent ) // Create the indicator frame // parent is null but FramePtr ensures destruction - mIndicator = FramePtr{ safenew wxFrame( NULL, + mIndicator = FramePtr{ safenew wxFrame( nullptr, wxID_ANY, wxEmptyString, wxDefaultPosition, @@ -502,8 +502,8 @@ void ToolManager::Destroy() mTopDock = mBotDock = nullptr; // indicate that it has been destroyed - for ( size_t ii = 0; ii < ToolBarCount; ++ii ) - mBars[ii].reset(); + for (auto & mBar : mBars) + mBar.reset(); mIndicator.reset(); } @@ -591,7 +591,7 @@ void ToolManager::Reset() if( bar->IsDocked() ) { bar->GetDock()->Undock( bar ); - floater = NULL; + floater = nullptr; } else { @@ -645,7 +645,7 @@ void ToolManager::Reset() // Next condition will always (?) be true, as the reset configuration is // with no floating toolbars. - if( dock != NULL ) + if( dock != nullptr ) { // when we dock, we reparent, so bar is no longer a child of floater. dock->Dock( bar, false, position ); @@ -659,7 +659,7 @@ void ToolManager::Reset() // Maybe construct a NEW floater // this happens if we have just been bounced out of a dock. - if( floater == NULL ) { + if( floater == nullptr ) { wxASSERT(mParent); floater = safenew ToolFrame( mParent, this, bar, wxPoint(-1,-1) ); bar->Reparent( floater ); @@ -672,7 +672,7 @@ void ToolManager::Reset() // they won't overlap too much. floater->CentreOnParent( ); floater->Move( floater->GetPosition() + wxSize( ndx * 10 - 200, ndx * 10 )); - bar->SetDocked( NULL, false ); + bar->SetDocked( nullptr, false ); Expose( ndx, false ); } @@ -699,7 +699,7 @@ int ToolManager::FilterEvent(wxEvent &event) // the last one of our own that is not a grabber. if (event.GetEventType() == wxEVT_KILL_FOCUS) { - auto &focusEvent = static_cast(event); + auto &focusEvent = dynamic_cast(event); auto window = focusEvent.GetWindow(); auto top = wxGetTopLevelParent(window); if(auto toolFrame = dynamic_cast(top)) @@ -888,7 +888,7 @@ void ToolManager::ReadConfig() // Construct a NEW floater wxASSERT(mParent); - ToolFrame *f = safenew ToolFrame( mParent, this, bar, wxPoint( x, y ) ); + auto *f = safenew ToolFrame( mParent, this, bar, wxPoint( x, y ) ); // Set the width and height if( width[ ndx ] != -1 && height[ ndx ] != -1 ) @@ -906,7 +906,7 @@ void ToolManager::ReadConfig() bar->GetParent()->SetMinSize(msz); // Inform toolbar of change - bar->SetDocked( NULL, false ); + bar->SetDocked( nullptr, false ); // Show or hide it Expose( ndx, show[ ndx ] ); @@ -930,9 +930,9 @@ void ToolManager::ReadConfig() d->LoadConfig(); // Add all unordered toolbars - for( int ord = 0; ord < (int) unordered[ dock ].size(); ord++ ) + for(int ord : unordered[ dock ]) { - ToolBar *t = mBars[ unordered[ dock ][ ord ] ].get(); + ToolBar *t = mBars[ ord ].get(); // Dock it d->Dock( t, false ); @@ -1193,7 +1193,7 @@ void ToolManager::OnMouse( wxMouseEvent & event ) else { // Calling SetDocked() to force the grabber button to popup - mDragBar->SetDocked( NULL, false ); + mDragBar->SetDocked( nullptr, false ); } DoneDragging(); @@ -1243,7 +1243,7 @@ void ToolManager::OnMouse( wxMouseEvent & event ) // To find which dock, rather than test against pos, test against the whole dragger rect. // This means it is enough to overlap the dock to dock with it. wxRect barRect = mDragWindow->GetRect(); - ToolDock *dock = NULL; + ToolDock *dock = nullptr; if( tr.Intersects( barRect ) ) dock = mTopDock; else if( br.Intersects( barRect ) ) @@ -1383,8 +1383,7 @@ void ToolManager::OnTimer( wxTimerEvent & event ) #endif } - return; -} + } // // Handle Indicator paint events @@ -1395,7 +1394,7 @@ void ToolManager::OnTimer( wxTimerEvent & event ) void ToolManager::OnIndicatorPaint( wxPaintEvent & event ) { // TODO: Better to use a bitmap than a triangular region. - wxWindow *w = (wxWindow *)event.GetEventObject(); + auto *w = (wxWindow *)event.GetEventObject(); wxPaintDC dc( w ); // TODO: Better (faster) to use the existing spare brush. wxBrush brush( theTheme.Colour( clrTrackPanelText ) ); @@ -1428,7 +1427,7 @@ void ToolManager::UndockBar( wxPoint mp ) mp -= mDragOffset; // Inform toolbar of change - mDragBar->SetDocked( NULL, true ); + mDragBar->SetDocked( nullptr, true ); mDragBar->SetPositioned(); // Construct a NEW floater @@ -1520,7 +1519,7 @@ void ToolManager::HandleEscapeKey() // Floater remains, and returns to where it begain auto parent = mDragBar->GetParent(); parent->SetPosition(mPrevPosition); - mDragBar->SetDocked(NULL, false); + mDragBar->SetDocked(nullptr, false); } DoneDragging(); @@ -1545,10 +1544,10 @@ void ToolManager::DoneDragging() // Hide the indicator mIndicator->Hide(); - mDragWindow = NULL; - mDragDock = NULL; - mDragBar = NULL; - mPrevDock = NULL; + mDragWindow = nullptr; + mDragDock = nullptr; + mDragBar = nullptr; + mPrevDock = nullptr; mPrevSlot = { ToolBarConfiguration::UnspecifiedPosition }; mPrevConfiguration.Clear(); mLastPos.x = mBarPos.x = -1; diff --git a/src/toolbars/ToolManager.h b/src/toolbars/ToolManager.h index 289b682a43..da61593f44 100644 --- a/src/toolbars/ToolManager.h +++ b/src/toolbars/ToolManager.h @@ -64,7 +64,7 @@ class SAUCEDACITY_DLL_API ToolManager final ToolManager( SaucedacityProject *parent ); ToolManager( const ToolManager & ) = delete; ToolManager &operator=( const ToolManager & ) = delete; - ~ToolManager(); + ~ToolManager() override; void CreateWindows(); @@ -78,12 +78,12 @@ class SAUCEDACITY_DLL_API ToolManager final void Expose( int type, bool show ); - ToolBar *GetToolBar( int type ) const; + [[nodiscard]] ToolBar *GetToolBar( int type ) const; ToolDock *GetTopDock(); - const ToolDock *GetTopDock() const; + [[nodiscard]] const ToolDock *GetTopDock() const; ToolDock *GetBotDock(); - const ToolDock *GetBotDock() const; + [[nodiscard]] const ToolDock *GetBotDock() const; void Reset(); static void OnResetToolBars(const CommandContext &context); @@ -168,7 +168,7 @@ class ToolFrame final : public wxFrame ToolFrame( SaucedacityProject *parent, ToolManager *manager, ToolBar *bar, wxPoint pos ); - ~ToolFrame(); + ~ToolFrame() override; ToolBar *GetBar() { return mBar; } void ClearBar() { mBar = nullptr; } diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index 896b2e2ebb..0c15adce48 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -104,7 +104,7 @@ ToolsToolBar::~ToolsToolBar() ToolsToolBar &ToolsToolBar::Get( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return *static_cast( toolManager.GetToolBar(ToolsBarID) ); + return *dynamic_cast( toolManager.GetToolBar(ToolsBarID) ); } const ToolsToolBar &ToolsToolBar::Get( const SaucedacityProject &project ) @@ -161,8 +161,7 @@ void ToolsToolBar::RegenerateTooltips() #endif // wxSafeYield(); - return; -} + } void ToolsToolBar::UpdatePrefs() { @@ -255,7 +254,7 @@ bool ToolsToolBar::IsDown(int tool) const return mTool[tool]->IsDown(); } -int ToolsToolBar::GetDownTool() +int ToolsToolBar::GetDownTool() const { int tool; @@ -277,7 +276,7 @@ void ToolsToolBar::OnTool(wxCommandEvent & evt) else mTool[i]->PopUp(); - for ( auto pProject : AllProjects{} ) + for ( const auto& pProject : AllProjects{} ) ProjectWindow::Get( *pProject ).RedrawProject(); gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"), diff --git a/src/toolbars/ToolsToolBar.h b/src/toolbars/ToolsToolBar.h index f8639c0768..cf8959b57d 100644 --- a/src/toolbars/ToolsToolBar.h +++ b/src/toolbars/ToolsToolBar.h @@ -37,7 +37,7 @@ class ToolsToolBar final : public ToolBar { public: ToolsToolBar( SaucedacityProject &project ); - virtual ~ToolsToolBar(); + ~ToolsToolBar() override; static ToolsToolBar &Get( SaucedacityProject &project ); static const ToolsToolBar &Get( const SaucedacityProject &project ); @@ -49,9 +49,9 @@ class ToolsToolBar final : public ToolBar { void SetCurrentTool(int tool); //These interrogate the state of the buttons or controls. - int GetCurrentTool() const; - bool IsDown(int tool) const; - int GetDownTool(); + [[nodiscard]] int GetCurrentTool() const; + [[nodiscard]] bool IsDown(int tool) const; + int GetDownTool() const; void Populate() override; void Repaint(wxDC * WXUNUSED(dc)) override {}; diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index 3f3e2d3380..b16ca5fc14 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -112,7 +112,7 @@ TranscriptionToolBar::~TranscriptionToolBar() TranscriptionToolBar &TranscriptionToolBar::Get( SaucedacityProject &project ) { auto &toolManager = ToolManager::Get( project ); - return *static_cast( toolManager.GetToolBar(TranscriptionBarID) ); + return *dynamic_cast( toolManager.GetToolBar(TranscriptionBarID) ); } const TranscriptionToolBar &TranscriptionToolBar::Get( const SaucedacityProject &project ) @@ -380,7 +380,7 @@ void TranscriptionToolBar::OnFocus(wxFocusEvent &event) void TranscriptionToolBar::OnCaptureKey(wxCommandEvent &event) { - wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject(); + auto *kevent = (wxKeyEvent *)event.GetEventObject(); int keyCode = kevent->GetKeyCode(); // Pass LEFT/RIGHT/UP/DOWN/PAGEUP/PAGEDOWN through for input/output sliders @@ -391,8 +391,6 @@ void TranscriptionToolBar::OnCaptureKey(wxCommandEvent &event) } event.Skip(); - - return; } //This handles key-stroke events???? diff --git a/src/toolbars/TranscriptionToolBar.h b/src/toolbars/TranscriptionToolBar.h index a7dac61199..116c1720e1 100644 --- a/src/toolbars/TranscriptionToolBar.h +++ b/src/toolbars/TranscriptionToolBar.h @@ -63,7 +63,7 @@ class TranscriptionToolBar final : public ToolBar { public: TranscriptionToolBar( SaucedacityProject &project ); - virtual ~TranscriptionToolBar(); + ~TranscriptionToolBar() override; static TranscriptionToolBar &Get( SaucedacityProject &project ); static const TranscriptionToolBar &Get( const SaucedacityProject &project ); @@ -114,7 +114,7 @@ class TranscriptionToolBar final : public ToolBar { void SetEnabled(bool enabled); void SetPlaying(bool down, bool looped, bool cutPreview); - double GetPlaySpeed() const { return mPlaySpeed / 100.0; } + [[nodiscard]] double GetPlaySpeed() const { return mPlaySpeed / 100.0; } private: @@ -128,7 +128,7 @@ class TranscriptionToolBar final : public ToolBar { teBmps eFore, teBmps eDisabled, int id, unsigned altIdx); void GetSamples(const WaveTrack *t, sampleCount *s0, sampleCount *slen); - void SetButton(bool newstate, AButton *button); + static void SetButton(bool newstate, AButton *button); void RegenerateTooltips() override; AButton *mButtons[TTBNumButtons]; diff --git a/src/tracks/labeltrack/ui/LabelDefaultClickHandle.cpp b/src/tracks/labeltrack/ui/LabelDefaultClickHandle.cpp index 5aee789b74..9997978983 100644 --- a/src/tracks/labeltrack/ui/LabelDefaultClickHandle.cpp +++ b/src/tracks/labeltrack/ui/LabelDefaultClickHandle.cpp @@ -39,8 +39,8 @@ void LabelDefaultClickHandle::SaveState( SaucedacityProject *pProject ) for (auto lt : tracks.Any()) { auto &view = LabelTrackView::Get( *lt ); - pairs.push_back( std::make_pair( - lt->SharedPointer(), view.SaveFlags() ) ); + pairs.emplace_back( + lt->SharedPointer(), view.SaveFlags() ); } } diff --git a/src/tracks/labeltrack/ui/LabelDefaultClickHandle.h b/src/tracks/labeltrack/ui/LabelDefaultClickHandle.h index c2635d422e..353e51035e 100644 --- a/src/tracks/labeltrack/ui/LabelDefaultClickHandle.h +++ b/src/tracks/labeltrack/ui/LabelDefaultClickHandle.h @@ -22,7 +22,7 @@ class LabelDefaultClickHandle /* not final */ : public UIHandle { public: LabelDefaultClickHandle(); - virtual ~LabelDefaultClickHandle(); + ~LabelDefaultClickHandle() override; LabelDefaultClickHandle &operator= (const LabelDefaultClickHandle&) = default; diff --git a/src/tracks/labeltrack/ui/LabelGlyphHandle.cpp b/src/tracks/labeltrack/ui/LabelGlyphHandle.cpp index 6b4325362d..33f48e3cd8 100644 --- a/src/tracks/labeltrack/ui/LabelGlyphHandle.cpp +++ b/src/tracks/labeltrack/ui/LabelGlyphHandle.cpp @@ -27,6 +27,8 @@ Paul Licameli split from TrackPanel.cpp #include #include +#include + LabelTrackHit::LabelTrackHit( const std::shared_ptr &pLT ) : mpLT{ pLT } { @@ -65,10 +67,10 @@ void LabelTrackHit::OnLabelPermuted( LabelTrackEvent &e ) } LabelGlyphHandle::LabelGlyphHandle -(const std::shared_ptr &pLT, - const wxRect &rect, const std::shared_ptr &pHit) - : mpHit{ pHit } - , mpLT{ pLT } +(std::shared_ptr pLT, + const wxRect &rect, std::shared_ptr pHit) + : mpHit{std::move( pHit )} + , mpLT{std::move( pLT )} , mRect{ rect } { } @@ -333,7 +335,7 @@ bool LabelGlyphHandle::HandleGlyphDragRelease // Do this after, for its effect on TrackPanel's memory of last selected // track (which affects shift-click actions) - selectionState.SelectTrack(*pTrack.get(), true, true); + selectionState.SelectTrack(*pTrack, true, true); // PRL: bug1659 -- make selection change undo correctly updated = !ProjectAudioIO::Get(project).IsAudioActive(); diff --git a/src/tracks/labeltrack/ui/LabelGlyphHandle.h b/src/tracks/labeltrack/ui/LabelGlyphHandle.h index 31d1a74f64..edf4880e6b 100644 --- a/src/tracks/labeltrack/ui/LabelGlyphHandle.h +++ b/src/tracks/labeltrack/ui/LabelGlyphHandle.h @@ -50,8 +50,8 @@ class LabelGlyphHandle final : public LabelDefaultClickHandle { public: explicit LabelGlyphHandle - (const std::shared_ptr &pLT, - const wxRect &rect, const std::shared_ptr &pHit); + (std::shared_ptr pLT, + const wxRect &rect, std::shared_ptr pHit); LabelGlyphHandle &operator=(const LabelGlyphHandle&) = default; @@ -60,7 +60,7 @@ class LabelGlyphHandle final : public LabelDefaultClickHandle const wxMouseState &state, const std::shared_ptr &pLT, const wxRect &rect); - virtual ~LabelGlyphHandle(); + ~LabelGlyphHandle() override; void Enter(bool forward, SaucedacityProject *) override; diff --git a/src/tracks/labeltrack/ui/LabelTextHandle.cpp b/src/tracks/labeltrack/ui/LabelTextHandle.cpp index faf71c058e..41109a1ca2 100644 --- a/src/tracks/labeltrack/ui/LabelTextHandle.cpp +++ b/src/tracks/labeltrack/ui/LabelTextHandle.cpp @@ -213,8 +213,7 @@ void LabelTextHandle::HandleTextDragRelease( } } - return; -} + } UIHandle::Result LabelTextHandle::Drag (const TrackPanelMouseEvent &evt, SaucedacityProject *pProject) diff --git a/src/tracks/labeltrack/ui/LabelTextHandle.h b/src/tracks/labeltrack/ui/LabelTextHandle.h index 25c77ea448..c97775b20c 100644 --- a/src/tracks/labeltrack/ui/LabelTextHandle.h +++ b/src/tracks/labeltrack/ui/LabelTextHandle.h @@ -33,10 +33,10 @@ class LabelTextHandle final : public LabelDefaultClickHandle explicit LabelTextHandle ( const std::shared_ptr &pLT, int labelNum ); - virtual ~LabelTextHandle(); + ~LabelTextHandle() override; - std::shared_ptr GetTrack() const { return mpLT.lock(); } - int GetLabelNum() const { return mLabelNum; } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpLT.lock(); } + [[nodiscard]] int GetLabelNum() const { return mLabelNum; } void Enter(bool forward, SaucedacityProject *) override; diff --git a/src/tracks/labeltrack/ui/LabelTrackControls.h b/src/tracks/labeltrack/ui/LabelTrackControls.h index cd3144a7ad..923647a91e 100644 --- a/src/tracks/labeltrack/ui/LabelTrackControls.h +++ b/src/tracks/labeltrack/ui/LabelTrackControls.h @@ -11,6 +11,8 @@ Paul Licameli split from TrackPanel.cpp #ifndef __AUDACITY_LABEL_TRACK_CONTROLS__ #define __AUDACITY_LABEL_TRACK_CONTROLS__ +#include + #include "../../ui/CommonTrackControls.h" // to inherit class LabelTrackControls final : public CommonTrackControls @@ -21,8 +23,8 @@ class LabelTrackControls final : public CommonTrackControls public: explicit LabelTrackControls( std::shared_ptr pTrack ) - : CommonTrackControls( pTrack ) {} - ~LabelTrackControls(); + : CommonTrackControls( std::move(pTrack) ) {} + ~LabelTrackControls() override; std::vector HitTest (const TrackPanelMouseState &state, diff --git a/src/tracks/labeltrack/ui/LabelTrackShifter.cpp b/src/tracks/labeltrack/ui/LabelTrackShifter.cpp index ced784f4fc..e6b7bc0fd3 100644 --- a/src/tracks/labeltrack/ui/LabelTrackShifter.cpp +++ b/src/tracks/labeltrack/ui/LabelTrackShifter.cpp @@ -31,12 +31,12 @@ class LabelTrackShifter final : public TrackShifter { mpTrack->Unbind( EVT_LABELTRACK_DELETION, &LabelTrackShifter::OnLabelDeleted, this ); } - Track &GetTrack() const override { return *mpTrack; } + [[nodiscard]] Track &GetTrack() const override { return *mpTrack; } static inline size_t& GetIndex(TrackInterval &interval) { auto pExtra = - static_cast( interval.Extra() ); + dynamic_cast( interval.Extra() ); return pExtra->index; } @@ -205,7 +205,7 @@ class LabelTrackShifter final : public TrackShifter { } auto update = [=]( TrackInterval &interval ){ - auto pExtra = static_cast(interval.Extra()); + auto pExtra = dynamic_cast(interval.Extra()); auto &index = pExtra->index; if ( index >= present ) ++ index; @@ -230,7 +230,7 @@ class LabelTrackShifter final : public TrackShifter { } auto update = [=]( TrackInterval &interval ){ - auto pExtra = static_cast(interval.Extra()); + auto pExtra = dynamic_cast(interval.Extra()); auto &index = pExtra->index; if ( index > former ) -- index; diff --git a/src/tracks/labeltrack/ui/LabelTrackVRulerControls.h b/src/tracks/labeltrack/ui/LabelTrackVRulerControls.h index b31cb3e292..7563ad9c4e 100644 --- a/src/tracks/labeltrack/ui/LabelTrackVRulerControls.h +++ b/src/tracks/labeltrack/ui/LabelTrackVRulerControls.h @@ -25,7 +25,7 @@ class LabelTrackVRulerControls final : public TrackVRulerControls explicit LabelTrackVRulerControls( const std::shared_ptr &pTrackView ) : TrackVRulerControls( pTrackView ) {} - ~LabelTrackVRulerControls(); + ~LabelTrackVRulerControls() override; private: diff --git a/src/tracks/labeltrack/ui/LabelTrackView.cpp b/src/tracks/labeltrack/ui/LabelTrackView.cpp index 797d8cb4d1..9cf2eabe09 100644 --- a/src/tracks/labeltrack/ui/LabelTrackView.cpp +++ b/src/tracks/labeltrack/ui/LabelTrackView.cpp @@ -157,12 +157,12 @@ void LabelTrackView::CopyTo( Track &track ) const LabelTrackView &LabelTrackView::Get( LabelTrack &track ) { - return static_cast< LabelTrackView& >( TrackView::Get( track ) ); + return dynamic_cast< LabelTrackView& >( TrackView::Get( track ) ); } const LabelTrackView &LabelTrackView::Get( const LabelTrack &track ) { - return static_cast< const LabelTrackView& >( TrackView::Get( track ) ); + return dynamic_cast< const LabelTrackView& >( TrackView::Get( track ) ); } std::shared_ptr LabelTrackView::FindLabelTrack() @@ -706,7 +706,7 @@ void getXPos( const LabelStruct &ls, wxDC & dc, int * xPos1, int cursorPos) { int partWidth; // Calculate the width of the substring and add it to Xpos - dc.GetTextExtent(ls.title.Left(cursorPos), &partWidth, NULL); + dc.GetTextExtent(ls.title.Left(cursorPos), &partWidth, nullptr); *xPos1 += partWidth; } } @@ -906,7 +906,7 @@ void LabelTrackView::Draw { // Calculate the width of the substring and add it to Xpos int partWidth; - dc.GetTextExtent(labelStruct.title.Left(mCurrentCursorPos), &partWidth, NULL); + dc.GetTextExtent(labelStruct.title.Left(mCurrentCursorPos), &partWidth, nullptr); xPos += partWidth; } @@ -961,10 +961,10 @@ int LabelTrackView::FindCursorPosition(int labelIndex, wxCoord xPos) } subString = title.Left(charIndex); // Get the width of substring - dc.GetTextExtent(subString, &partWidth, NULL); + dc.GetTextExtent(subString, &partWidth, nullptr); // Get the width of the last character - dc.GetTextExtent(subString.Right(1), &oneWidth, NULL); + dc.GetTextExtent(subString.Right(1), &oneWidth, nullptr); bound = labelStruct.xText + partWidth - oneWidth * 0.5; if (xPos <= bound) @@ -1025,7 +1025,7 @@ void LabelTrackView::calculateFontHeight(wxDC & dc) int charLeading; // Calculate the width of the substring and add it to Xpos - dc.GetTextExtent(wxT("(Test String)|[yp]"), NULL, &mFontHeight, &charDescent, &charLeading); + dc.GetTextExtent(wxT("(Test String)|[yp]"), nullptr, &mFontHeight, &charDescent, &charLeading); // The cursor will have height charHeight. We don't include the descender as // part of the height because for phonetic fonts this leads to cursors which are @@ -1166,9 +1166,9 @@ bool LabelTrackView::PasteSelectedText( } // Convert control characters to blanks - for (int i = 0; i < (int)text.length(); i++) { - if (wxIscntrl(text[i])) { - text[i] = wxT(' '); + for (auto && i : text) { + if (wxIscntrl(i)) { + i = wxT(' '); } } } diff --git a/src/tracks/labeltrack/ui/LabelTrackView.h b/src/tracks/labeltrack/ui/LabelTrackView.h index abc1c5b862..8d5bfa8fa8 100644 --- a/src/tracks/labeltrack/ui/LabelTrackView.h +++ b/src/tracks/labeltrack/ui/LabelTrackView.h @@ -67,7 +67,7 @@ class SAUCEDACITY_DLL_API LabelTrackView final : public CommonTrackView const wxString &title = {}, int restoreFocus = -1); - std::vector GetMenuItems(const wxRect&, const wxPoint*, SaucedacityProject*); + std::vector GetMenuItems(const wxRect&, const wxPoint*, SaucedacityProject*) override; private: void BindTo( LabelTrack *pParent ); @@ -106,7 +106,7 @@ class SAUCEDACITY_DLL_API LabelTrackView final : public CommonTrackView bool IsTextSelected( SaucedacityProject &project ) const; private: - void CreateCustomGlyphs(); + static void CreateCustomGlyphs(); public: static wxFont GetFont(const wxString &faceName, int size = DefaultFontSize); @@ -136,7 +136,7 @@ class SAUCEDACITY_DLL_API LabelTrackView final : public CommonTrackView Index &operator ++(); Index &operator --(); - bool IsModified() const; + [[nodiscard]] bool IsModified() const; void SetModified(bool modified); private: diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackAffordanceControls.h b/src/tracks/playabletrack/notetrack/ui/NoteTrackAffordanceControls.h index b6438cc13e..2545030844 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackAffordanceControls.h +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackAffordanceControls.h @@ -25,5 +25,5 @@ class SAUCEDACITY_DLL_API NoteTrackAffordanceControls : public CommonTrackCell void Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass) override; - bool IsSelected() const; + [[nodiscard]] bool IsSelected() const; }; diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h b/src/tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h index 20db4dd55d..c99bb6a6b6 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h @@ -31,15 +31,15 @@ class NoteTrackButtonHandle : public UIHandle NoteTrackButtonHandle &operator=(const NoteTrackButtonHandle&) = default; - virtual ~NoteTrackButtonHandle(); + ~NoteTrackButtonHandle() override; static UIHandlePtr HitTest (std::weak_ptr &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr &pTrack); - std::shared_ptr GetTrack() const { return mpTrack.lock(); } - int GetChannel() const { return mChannel; } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpTrack.lock(); } + [[nodiscard]] int GetChannel() const { return mChannel; } static UIHandle::Result NeedChangeHighlight (const NoteTrackButtonHandle &oldState, diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.cpp b/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.cpp index 7107fe1f9b..4d42ace6eb 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.cpp +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.cpp @@ -49,11 +49,11 @@ std::vector NoteTrackControls::HitTest auto track = std::static_pointer_cast(FindTrack()); auto result = [&]{ UIHandlePtr result; - if (NULL != (result = MuteButtonHandle::HitTest( + if (nullptr != (result = MuteButtonHandle::HitTest( mMuteHandle, state, rect, pProject, track))) return result; - if (NULL != (result = SoloButtonHandle::HitTest( + if (nullptr != (result = SoloButtonHandle::HitTest( mSoloHandle, state, rect, pProject, track))) return result; #ifdef EXPERIMENTAL_MIDI_OUT @@ -115,7 +115,7 @@ enum { /// Scrolls the note track up or down by an octave void NoteTrackMenuTable::OnChangeOctave(wxCommandEvent &event) { - NoteTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); wxASSERT(event.GetId() == OnUpOctaveID || event.GetId() == OnDownOctaveID); @@ -183,7 +183,7 @@ void SliderDrawFunction { wxRect sliderRect = rect; TrackInfo::GetSliderHorizontalBounds( rect.GetTopLeft(), sliderRect ); - auto nt = static_cast( pTrack ); + auto nt = dynamic_cast( pTrack ); Selector( sliderRect, nt, captured, pParent )->OnPaint(*dc, highlight); } @@ -217,7 +217,7 @@ void MidiControlsDrawFunction wxRect midiRect = rect; GetMidiControlsHorizontalBounds(rect, midiRect); NoteTrack::DrawLabelControls - ( static_cast(pTrack), dc, midiRect, channel ); + ( dynamic_cast(pTrack), dc, midiRect, channel ); } } diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.h b/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.h index 7160887c57..53259ebd4c 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.h +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackControls.h @@ -11,6 +11,8 @@ Paul Licameli split from TrackPanel.cpp #ifndef __AUDACITY_NOTE_TRACK_CONTROLS__ #define __AUDACITY_NOTE_TRACK_CONTROLS__ +#include + #include "../../ui/PlayableTrackControls.h" // to inherit class wxEvent; class LWSlider; @@ -44,8 +46,8 @@ class NoteTrackControls : public NoteTrackControlsBase public: explicit NoteTrackControls( std::shared_ptr pTrack ) - : NoteTrackControlsBase( pTrack ) {} - ~NoteTrackControls(); + : NoteTrackControlsBase( std::move(pTrack) ) {} + ~NoteTrackControls() override; std::vector HitTest (const TrackPanelMouseState &state, diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackShifter.cpp b/src/tracks/playabletrack/notetrack/ui/NoteTrackShifter.cpp index 25dc7f38ab..aef4359f47 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackShifter.cpp +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackShifter.cpp @@ -15,7 +15,7 @@ class NoteTrackShifter final : public TrackShifter { InitIntervals(); } ~NoteTrackShifter() override {} - Track &GetTrack() const override { return *mpTrack; } + [[nodiscard]] Track &GetTrack() const override { return *mpTrack; } HitTestResult HitTest( double time, const ViewInfo &viewInfo, HitTestParams* ) override @@ -38,7 +38,7 @@ class NoteTrackShifter final : public TrackShifter { // Ensure that t0 is still within the data. // This corrects for any rounding errors. - double AdjustT0(double t0) const override + [[nodiscard]] double AdjustT0(double t0) const override { auto& track = GetTrack(); if (t0 < track.GetStartTime()) diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.cpp b/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.cpp index 22131bc848..544a930562 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.cpp +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.cpp @@ -72,7 +72,7 @@ unsigned NoteTrackVRulerControls::HandleWheelRotation return RefreshNone; auto steps = evt.steps; - const auto nt = static_cast(pTrack.get()); + const auto nt = dynamic_cast(pTrack.get()); if (event.CmdDown() && !event.ShiftDown()) { if (steps > 0) diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.h b/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.h index 3f39e1d631..156c64684f 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.h +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackVRulerControls.h @@ -24,7 +24,7 @@ class NoteTrackVRulerControls final : public TrackVRulerControls explicit NoteTrackVRulerControls( const std::shared_ptr &pTrackView ) : TrackVRulerControls( pTrackView ) {} - ~NoteTrackVRulerControls(); + ~NoteTrackVRulerControls() override; std::vector HitTest (const TrackPanelMouseState &state, diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.cpp b/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.cpp index cc8cb30cc7..44502b8394 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.cpp +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.cpp @@ -167,7 +167,7 @@ class NoteTrackVRulerMenuTable NoteTrackVRulerMenuTable() : PopupMenuTable{ "NoteTrackVRuler" } {}; - virtual ~NoteTrackVRulerMenuTable() {} + ~NoteTrackVRulerMenuTable() override {} DECLARE_POPUP_MENU(NoteTrackVRulerMenuTable); public: @@ -315,7 +315,7 @@ UIHandle::Result NoteTrackVZoomHandle::Release *pProject, pTrack.get(), mRect, RefreshNone, event.m_y }; - PopupMenuTable *const pTable = + auto *const pTable = (PopupMenuTable *) &NoteTrackVRulerMenuTable::Instance(); auto pMenu = PopupMenuTable::BuildMenu(pParent, pTable, &data); diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.h b/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.h index 44ab6a981d..1cc8a38b2b 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.h +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.h @@ -34,7 +34,7 @@ class NoteTrackVZoomHandle : public UIHandle virtual ~NoteTrackVZoomHandle(); - std::shared_ptr GetTrack() const { return mpTrack.lock(); } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpTrack.lock(); } void Enter(bool forward, SaucedacityProject *) override; diff --git a/src/tracks/playabletrack/notetrack/ui/NoteTrackView.cpp b/src/tracks/playabletrack/notetrack/ui/NoteTrackView.cpp index 8f82bd94b9..379dd89bd3 100644 --- a/src/tracks/playabletrack/notetrack/ui/NoteTrackView.cpp +++ b/src/tracks/playabletrack/notetrack/ui/NoteTrackView.cpp @@ -148,7 +148,7 @@ const char *IsShape(Alg_note_ptr note) } parameters = parameters->next; } - return NULL; + return nullptr; } // returns value of attr, or default if not found @@ -208,7 +208,7 @@ const char *LookupStringAttribute(Alg_note_ptr note, Alg_attribute attr, const c } // returns value of attr, or default if not found -const char *LookupAtomAttribute(Alg_note_ptr note, Alg_attribute attr, char *def) +const char *LookupAtomAttribute(Alg_note_ptr note, Alg_attribute attr, const char *def) { Alg_parameters_ptr parameters = note->parameters; while (parameters) { @@ -472,16 +472,16 @@ void DrawNoteTrack(TrackPanelDrawingContext &context, iterator.begin(); //for every event Alg_event_ptr evt; - while (0 != (evt = iterator.next())) { + while (nullptr != (evt = iterator.next())) { if (evt->get_type() == 'n') { // 'n' means a note - Alg_note_ptr note = (Alg_note_ptr) evt; + auto note = (Alg_note_ptr) evt; // if the note's channel is visible if (track->IsVisibleChan(evt->chan)) { double xx = note->time + track->GetOffset(); double x1 = xx + note->dur; if (xx < h1 && x1 > h) { // omit if outside box - const char *shape = NULL; - if (note->loud > 0.0 || 0 == (shape = IsShape(note))) { + const char *shape = nullptr; + if (note->loud > 0.0 || nullptr == (shape = IsShape(note))) { wxRect nr; // "note rectangle" nr.y = data.PitchToY(note->pitch); nr.height = data.GetPitchHeight(1); @@ -652,8 +652,8 @@ void DrawNoteTrack(TrackPanelDrawingContext &context, //// if no color specified, copy color from brush //else dc.SetTextBackground(dc.GetPen().GetColour()); - const char *font = LookupAtomAttribute(note, fonta, NULL); - const char *weight = LookupAtomAttribute(note, weighta, NULL); + const char *font = LookupAtomAttribute(note, fonta, nullptr); + const char *weight = LookupAtomAttribute(note, weighta, nullptr); int size = LookupIntAttribute(note, sizei, 8); const char *justify = LookupStringAttribute(note, justifys, "ld"); wxFont wxfont; diff --git a/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp b/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp index 3e37929169..112e42b5df 100644 --- a/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp +++ b/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp @@ -31,11 +31,12 @@ Paul Licameli split from TrackPanel.cpp #include "../../../../../images/Cursors.h" #include +#include StretchHandle::StretchHandle -( const std::shared_ptr &pTrack, const StretchState &stretchState ) - : mpTrack{ pTrack } - , mStretchState{ stretchState } +( std::shared_ptr pTrack, StretchState stretchState ) + : mpTrack{std::move( pTrack )} + , mStretchState{std::move( stretchState )} {} HitTestPreview StretchHandle::HitPreview( StretchEnum stretchMode, bool unsafe ) @@ -53,7 +54,7 @@ HitTestPreview StretchHandle::HitPreview( StretchEnum stretchMode, bool unsafe ) return { {}, &*disabledCursor }; } else { - wxCursor *pCursor = NULL; + wxCursor *pCursor = nullptr; switch (stretchMode) { default: wxASSERT(false); @@ -170,7 +171,7 @@ UIHandle::Result StretchHandle::Click if (event.LeftDClick() || !event.LeftDown() || - evt.pCell == NULL) + evt.pCell == nullptr) return Cancelled; @@ -203,7 +204,7 @@ UIHandle::Result StretchHandle::Drag Track *clickedTrack=nullptr; if (evt.pCell) clickedTrack = - static_cast(evt.pCell.get())->FindTrack().get(); + dynamic_cast(evt.pCell.get())->FindTrack().get(); if (clickedTrack == nullptr && mpTrack != nullptr) clickedTrack = mpTrack.get(); @@ -289,7 +290,7 @@ void StretchHandle::Stretch(SaucedacityProject *pProject, int mouseXCoordinate, { auto &viewInfo = ViewInfo::Get( *pProject ); - if (pTrack == NULL && mpTrack != NULL) + if (pTrack == nullptr && mpTrack != nullptr) pTrack = mpTrack.get(); if (pTrack) pTrack->TypeSwitch( [&](NoteTrack *pNt) { diff --git a/src/tracks/playabletrack/notetrack/ui/StretchHandle.h b/src/tracks/playabletrack/notetrack/ui/StretchHandle.h index e49580b8ef..255e383491 100644 --- a/src/tracks/playabletrack/notetrack/ui/StretchHandle.h +++ b/src/tracks/playabletrack/notetrack/ui/StretchHandle.h @@ -56,8 +56,8 @@ class StretchHandle : public UIHandle public: explicit StretchHandle - ( const std::shared_ptr &pTrack, - const StretchState &stretchState ); + ( std::shared_ptr pTrack, + StretchState stretchState ); StretchHandle &operator=(const StretchHandle&) = default; @@ -66,7 +66,7 @@ class StretchHandle : public UIHandle const TrackPanelMouseState &state, const SaucedacityProject *pProject, const std::shared_ptr &pTrack ); - virtual ~StretchHandle(); + ~StretchHandle() override; Result Click (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) override; diff --git a/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.h b/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.h index 831f3f616a..a79fabdc4e 100644 --- a/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.h +++ b/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.h @@ -24,7 +24,7 @@ class SAUCEDACITY_DLL_API MuteButtonHandle final : public ButtonHandle MuteButtonHandle &operator=(const MuteButtonHandle&) = default; - virtual ~MuteButtonHandle(); + ~MuteButtonHandle() override; protected: Result CommitChanges @@ -55,7 +55,7 @@ class SAUCEDACITY_DLL_API SoloButtonHandle final : public ButtonHandle SoloButtonHandle &operator=(const SoloButtonHandle&) = default; - virtual ~SoloButtonHandle(); + ~SoloButtonHandle() override; protected: Result CommitChanges diff --git a/src/tracks/playabletrack/ui/PlayableTrackControls.cpp b/src/tracks/playabletrack/ui/PlayableTrackControls.cpp index 62df970701..0cc66319fe 100644 --- a/src/tracks/playabletrack/ui/PlayableTrackControls.cpp +++ b/src/tracks/playabletrack/ui/PlayableTrackControls.cpp @@ -164,7 +164,7 @@ void PlayableTrackControls::GetMuteSoloRect (const wxRect & rect, wxRect & dest, bool solo, bool bHasSoloButton, const Track *pTrack) { - auto &trackControl = static_cast( + auto &trackControl = dynamic_cast( TrackControls::Get( *pTrack ) ); auto resultsM = TrackInfo::CalcItemY( trackControl.GetTCPLines(), TCPLine::kItemMute ); auto resultsS = TrackInfo::CalcItemY( trackControl.GetTCPLines(), TCPLine::kItemSolo ); diff --git a/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp index b05f5cbc5a..db79b31b0f 100644 --- a/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp @@ -11,6 +11,8 @@ Paul Licameli split from TrackPanel.cpp #include "CutlineHandle.h" +#include + #include "../../../../HitTestResult.h" #include "../../../../ProjectAudioIO.h" #include "../../../../ProjectHistory.h" @@ -23,8 +25,8 @@ Paul Licameli split from TrackPanel.cpp #include "../../../../../images/Cursors.h" CutlineHandle::CutlineHandle -( const std::shared_ptr &pTrack, WaveTrackLocation location ) - : mpTrack{ pTrack } +( std::shared_ptr pTrack, WaveTrackLocation location ) + : mpTrack{std::move( pTrack )} , mLocation{ location } { } diff --git a/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.h b/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.h index fbd8bca8cd..2460f7fdc1 100644 --- a/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.h +++ b/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.h @@ -25,7 +25,7 @@ class CutlineHandle final : public UIHandle public: explicit CutlineHandle - ( const std::shared_ptr &pTrack, + ( std::shared_ptr pTrack, WaveTrackLocation location ); CutlineHandle &operator=(const CutlineHandle&) = default; @@ -38,7 +38,7 @@ class CutlineHandle final : public UIHandle const SaucedacityProject *pProject, const std::shared_ptr &pTrack); - virtual ~CutlineHandle(); + ~CutlineHandle() override; const WaveTrackLocation &GetLocation() { return mLocation; } std::shared_ptr GetTrack() { return mpTrack; } diff --git a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp index 003b7d55d0..e2faa9e1d0 100644 --- a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp @@ -12,6 +12,7 @@ Paul Licameli split from TrackPanel.cpp #include "SampleHandle.h" #include +#include #include #include "../../../../Envelope.h" @@ -34,8 +35,8 @@ static const int SMOOTHING_BRUSH_RADIUS = 5; static const double SMOOTHING_PROPORTION_MAX = 0.7; static const double SMOOTHING_PROPORTION_MIN = 0.0; -SampleHandle::SampleHandle( const std::shared_ptr &pTrack ) - : mClickedTrack{ pTrack } +SampleHandle::SampleHandle( std::shared_ptr pTrack ) + : mClickedTrack{std::move( pTrack )} { } diff --git a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h index 863b30da82..e07b56cede 100644 --- a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h +++ b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h @@ -28,7 +28,7 @@ class SampleHandle final : public UIHandle (const wxMouseState &state, const SaucedacityProject *pProject, bool unsafe); public: - explicit SampleHandle( const std::shared_ptr &pTrack ); + explicit SampleHandle( std::shared_ptr pTrack ); SampleHandle &operator=(const SampleHandle&) = default; @@ -40,9 +40,9 @@ class SampleHandle final : public UIHandle const wxMouseState &state, const wxRect &rect, const SaucedacityProject *pProject, const std::shared_ptr &pTrack); - virtual ~SampleHandle(); + ~SampleHandle() override; - std::shared_ptr GetTrack() const { return mClickedTrack; } + [[nodiscard]] std::shared_ptr GetTrack() const { return mClickedTrack; } void Enter(bool forward, SaucedacityProject *) override; diff --git a/src/tracks/playabletrack/wavetrack/ui/SpectrumVRulerControls.cpp b/src/tracks/playabletrack/wavetrack/ui/SpectrumVRulerControls.cpp index 86b1450f94..cae03b8f91 100644 --- a/src/tracks/playabletrack/wavetrack/ui/SpectrumVRulerControls.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/SpectrumVRulerControls.cpp @@ -52,7 +52,7 @@ unsigned SpectrumVRulerControls::HandleWheelRotation( const auto pTrack = FindTrack(); if (!pTrack) return RefreshNone; - const auto wt = static_cast(pTrack.get()); + const auto wt = dynamic_cast(pTrack.get()); return DoHandleWheelRotation( evt, pProject, wt ); } diff --git a/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.cpp index 656b09c093..8d023a6d3e 100644 --- a/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.cpp @@ -281,7 +281,7 @@ BeginSection( "Scales" ); POPUP_MENU_FN( OnSpectrumScaleType ), []( PopupMenuHandler &handler, wxMenu &menu, int id ){ WaveTrack *const wt = - static_cast( handler ) + dynamic_cast( handler ) .mpData->pTrack; if ( id == OnFirstSpectrumScaleID + diff --git a/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.h b/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.h index 0950270ed9..f0d07406a8 100644 --- a/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.h +++ b/src/tracks/playabletrack/wavetrack/ui/SpectrumVZoomHandle.h @@ -34,7 +34,7 @@ class SpectrumVZoomHandle final : public UIHandle ~SpectrumVZoomHandle() override; - std::shared_ptr GetTrack() const { return mpTrack.lock(); } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpTrack.lock(); } void Enter(bool forward, SaucedacityProject*) override; @@ -80,7 +80,7 @@ class SpectrumVRulerMenuTable : public WaveTrackVRulerMenuTable SpectrumVRulerMenuTable() : WaveTrackVRulerMenuTable{ "SpectrumVRuler" } {} - virtual ~SpectrumVRulerMenuTable() {} + ~SpectrumVRulerMenuTable() override {} DECLARE_POPUP_MENU(SpectrumVRulerMenuTable); public: diff --git a/src/tracks/playabletrack/wavetrack/ui/SpectrumView.cpp b/src/tracks/playabletrack/wavetrack/ui/SpectrumView.cpp index a85b0b9e69..726c263bb7 100644 --- a/src/tracks/playabletrack/wavetrack/ui/SpectrumView.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/SpectrumView.cpp @@ -57,7 +57,7 @@ std::vector SpectrumView::DetailedHitTest( void SpectrumView::DoSetMinimized( bool minimized ) { - auto wt = static_cast( FindTrack().get() ); + auto wt = dynamic_cast( FindTrack().get() ); #ifdef EXPERIMENTAL_HALF_WAVE bool bHalfWave; @@ -93,7 +93,7 @@ std::shared_ptr SpectrumView::DoGetVRulerControls() namespace { -static inline float findValue +inline float findValue (const float *spectrum, float bin0, float bin1, unsigned nBins, bool autocorrelation, int gain, int range) { @@ -258,8 +258,8 @@ void DrawClipSpectrum(TrackPanelDrawingContext &context, const auto half = settings.GetFFTLength() / 2; const double binUnit = rate / (2 * half); - const float *freq = 0; - const sampleCount *where = 0; + const float *freq = nullptr; + const sampleCount *where = nullptr; bool updated; { const double pps = averagePixelsPerSample * rate; @@ -549,7 +549,7 @@ void DrawClipSpectrum(TrackPanelDrawingContext &context, // in the loop above, and must be fetched from fft cache float* uncached; if (!zoomInfo.InFisheye(xx, -leftOffset)) { - uncached = 0; + uncached = nullptr; } else { int specIndex = (xx - fisheyeLeft) * nBins; @@ -658,7 +658,7 @@ void SpectrumView::Draw( // If both channels are visible, we will duplicate this effort, but that // matters little. for( auto channel: - TrackList::Channels(static_cast(FindTrack().get())) ) + TrackList::Channels(dynamic_cast(FindTrack().get())) ) channel->UpdateLocationsCache(); const auto wt = std::static_pointer_cast( @@ -713,7 +713,7 @@ struct SpectrogramSettingsHandler : PopupMenuHandler { return instance; } - void OnSpectrogramSettings(wxCommandEvent &); + void OnSpectrogramSettings(wxCommandEvent &) const; void InitUserData(void *pUserData) override { @@ -726,7 +726,7 @@ struct SpectrogramSettingsHandler : PopupMenuHandler { } }; -void SpectrogramSettingsHandler::OnSpectrogramSettings(wxCommandEvent &) +void SpectrogramSettingsHandler::OnSpectrogramSettings(wxCommandEvent &) const { class ViewSettingsDialog final : public PrefsDialog { @@ -762,7 +762,7 @@ void SpectrogramSettingsHandler::OnSpectrogramSettings(wxCommandEvent &) return; } - WaveTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); PrefsPanel::Factories factories; // factories.push_back(WaveformPrefsFactory( pTrack )); diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.cpp index 0a2f1a0ad7..a1b6018c42 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.cpp @@ -9,6 +9,8 @@ **********************************************************************/ #include "WaveClipTrimHandle.h" + +#include #include "ProjectAudioIO.h" #include "RefreshCode.h" @@ -56,8 +58,8 @@ HitTestPreview WaveClipTrimHandle::HitPreview(const SaucedacityProject*, bool un }; } -WaveClipTrimHandle::WaveClipTrimHandle(const std::pair& range, const std::vector>& clips, Border targetBorder) - : mRange(range), mClips(clips), mTargetBorder(targetBorder) +WaveClipTrimHandle::WaveClipTrimHandle(std::pair range, std::vector> clips, Border targetBorder) + : mRange(std::move(range)), mClips(std::move(clips)), mTargetBorder(targetBorder) { } @@ -88,7 +90,7 @@ UIHandlePtr WaveClipTrimHandle::HitAnywhere(std::weak_ptr& h if (!WaveTrackView::ClipDetailsVisible(*clip, zoomInfo, rect)) continue; - auto clipRect = ClipParameters::GetClipRect(*clip.get(), zoomInfo, rect); + auto clipRect = ClipParameters::GetClipRect(*clip, zoomInfo, rect); if (std::abs(px - clipRect.GetLeft()) <= BoundaryThreshold) { diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.h b/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.h index f8a5e29bbe..d6c224f410 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.h +++ b/src/tracks/playabletrack/wavetrack/ui/WaveClipTrimHandle.h @@ -35,7 +35,7 @@ class WaveClipTrimHandle : public UIHandle static HitTestPreview HitPreview(const SaucedacityProject*, bool unsafe); public: - WaveClipTrimHandle(const std::pair& range, const std::vector>& clips, Border targetBorder); + WaveClipTrimHandle(std::pair range, std::vector> clips, Border targetBorder); static UIHandlePtr HitAnywhere(std::weak_ptr& holder, WaveTrack* waveTrack, @@ -48,15 +48,15 @@ class WaveClipTrimHandle : public UIHandle HitTestPreview Preview(const TrackPanelMouseState& mouseState, SaucedacityProject* pProject) override; - virtual Result Click + Result Click (const TrackPanelMouseEvent& event, SaucedacityProject* pProject) override; - virtual Result Drag + Result Drag (const TrackPanelMouseEvent& event, SaucedacityProject* pProject) override; - virtual Result Release + Result Release (const TrackPanelMouseEvent& event, SaucedacityProject* pProject, wxWindow* pParent) override; - virtual Result Cancel(SaucedacityProject* pProject) override; + Result Cancel(SaucedacityProject* pProject) override; }; diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp index 93f665fad0..3fbc397f4d 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp @@ -13,6 +13,8 @@ #include #include +#include + #include "../../../../theme/AllThemeResources.h" #include "../../../../commands/CommandContext.h" #include "../../../../commands/CommandFlag.h" @@ -81,11 +83,11 @@ class WaveClipTitleEditHandle final : public UIHandle std::shared_ptr mHelper; public: - WaveClipTitleEditHandle(const std::shared_ptr& helper) - : mHelper(helper) + WaveClipTitleEditHandle(std::shared_ptr helper) + : mHelper(std::move(helper)) { } - ~WaveClipTitleEditHandle() + ~WaveClipTitleEditHandle() override { } @@ -238,7 +240,7 @@ void WaveTrackAffordanceControls::Draw(TrackPanelDrawingContext& context, const for (const auto& clip : waveTrack->GetClips()) { auto affordanceRect - = ClipParameters::GetClipRect(*clip.get(), zoomInfo, rect); + = ClipParameters::GetClipRect(*clip, zoomInfo, rect); if(!WaveTrackView::ClipDetailsVisible(*clip, zoomInfo, rect)) { @@ -513,7 +515,7 @@ unsigned WaveTrackAffordanceControls::OnAffordanceClick(const TrackPanelMouseEve { if (auto lock = mEditedClip.lock()) { - auto affordanceRect = ClipParameters::GetClipRect(*lock.get(), viewInfo, event.rect); + auto affordanceRect = ClipParameters::GetClipRect(*lock, viewInfo, event.rect); if (!affordanceRect.Contains(event.event.GetPosition())) return ExitTextEditing(); } @@ -522,7 +524,7 @@ unsigned WaveTrackAffordanceControls::OnAffordanceClick(const TrackPanelMouseEve { if (event.event.LeftDClick()) { - auto affordanceRect = ClipParameters::GetClipRect(*lock.get(), viewInfo, event.rect); + auto affordanceRect = ClipParameters::GetClipRect(*lock, viewInfo, event.rect); if (affordanceRect.Contains(event.event.GetPosition()) && StartEditClipName(project)) { diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.cpp index b043736b6c..99cf724432 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.cpp @@ -9,6 +9,8 @@ **********************************************************************/ #include "WaveTrackAffordanceHandle.h" + +#include #include "WaveTrackAffordanceControls.h" #include "WaveTrackView.h" #include "ViewInfo.h" @@ -18,8 +20,8 @@ #include "../../../../TrackPanelMouseEvent.h" #include "../../../../ProjectHistory.h" -WaveTrackAffordanceHandle::WaveTrackAffordanceHandle(const std::shared_ptr& track, const std::shared_ptr& target) - : AffordanceHandle(track), mTarget(target) +WaveTrackAffordanceHandle::WaveTrackAffordanceHandle(const std::shared_ptr& track, std::shared_ptr target) + : AffordanceHandle(track), mTarget(std::move(target)) { } UIHandle::Result WaveTrackAffordanceHandle::Click(const TrackPanelMouseEvent& event, SaucedacityProject* project) diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.h b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.h index 8179c13c9e..efa99cfdf4 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.h +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceHandle.h @@ -19,7 +19,7 @@ class WaveTrackAffordanceHandle final : public AffordanceHandle { std::shared_ptr mTarget; public: - WaveTrackAffordanceHandle(const std::shared_ptr& track, const std::shared_ptr& target); + WaveTrackAffordanceHandle(const std::shared_ptr& track, std::shared_ptr target); Result Click(const TrackPanelMouseEvent& event, SaucedacityProject* project) override; diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp index 3af683173f..49ed6a052c 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp @@ -60,19 +60,19 @@ std::vector WaveTrackControls::HitTest std::vector results; auto result = [&]{ UIHandlePtr result; - if (NULL != (result = MuteButtonHandle::HitTest( + if (nullptr != (result = MuteButtonHandle::HitTest( mMuteHandle, state, rect, pProject, track))) return result; - if (NULL != (result = SoloButtonHandle::HitTest( + if (nullptr != (result = SoloButtonHandle::HitTest( mSoloHandle, state, rect, pProject, track))) return result; - if (NULL != (result = GainSliderHandle::HitTest( + if (nullptr != (result = GainSliderHandle::HitTest( mGainHandle, state, rect, track))) return result; - if (NULL != (result = PanSliderHandle::HitTest( + if (nullptr != (result = PanSliderHandle::HitTest( mPanHandle, state, rect, track))) return result; @@ -89,7 +89,7 @@ std::vector WaveTrackControls::HitTest WaveTrack &WaveTrackPopupMenuTable::FindWaveTrack() const { - return *static_cast< WaveTrack* >( mpData->pTrack ); + return *dynamic_cast< WaveTrack* >( mpData->pTrack ); }; enum { @@ -170,14 +170,14 @@ struct FormatMenuTable : PopupMenuTable void DestroyMenu() override { - mpData = NULL; + mpData = nullptr; } PlayableTrackControls::InitMenuData *mpData{}; static int IdOfFormat(int format); - void OnFormatChange(wxCommandEvent & event); + void OnFormatChange(wxCommandEvent & event) const; }; FormatMenuTable &FormatMenuTable::Instance() @@ -228,11 +228,11 @@ int FormatMenuTable::IdOfFormat(int format) /// Handles the selection from the Format submenu of the /// track menu. -void FormatMenuTable::OnFormatChange(wxCommandEvent & event) +void FormatMenuTable::OnFormatChange(wxCommandEvent & event) const { int id = event.GetId(); wxASSERT(id >= On16BitID && id <= OnFloatID); - const auto pTrack = static_cast(mpData->pTrack); + const auto pTrack = dynamic_cast(mpData->pTrack); sampleFormat newFormat = int16Sample; @@ -314,13 +314,13 @@ struct RateMenuTable : PopupMenuTable void DestroyMenu() override { - mpData = NULL; + mpData = nullptr; } PlayableTrackControls::InitMenuData *mpData{}; static int IdOfRate(int rate); - void SetRate(WaveTrack * pTrack, double rate); + void SetRate(WaveTrack * pTrack, double rate) const; void OnRateChange(wxCommandEvent & event); void OnRateOther(wxCommandEvent & event); @@ -382,7 +382,7 @@ int RateMenuTable::IdOfRate(int rate) /// Sets the sample rate for a track, and if it is linked to /// another track, that one as well. -void RateMenuTable::SetRate(WaveTrack * pTrack, double rate) +void RateMenuTable::SetRate(WaveTrack * pTrack, double rate) const { SaucedacityProject *const project = &mpData->project; for (auto channel : TrackList::Channels(pTrack)) @@ -403,7 +403,7 @@ void RateMenuTable::OnRateChange(wxCommandEvent & event) { int id = event.GetId(); wxASSERT(id >= OnRate8ID && id <= OnRate384ID); - const auto pTrack = static_cast(mpData->pTrack); + const auto pTrack = dynamic_cast(mpData->pTrack); SetRate(pTrack, gRates[id - OnRate8ID]); @@ -413,7 +413,7 @@ void RateMenuTable::OnRateChange(wxCommandEvent & event) void RateMenuTable::OnRateOther(wxCommandEvent &) { - const auto pTrack = static_cast(mpData->pTrack); + const auto pTrack = dynamic_cast(mpData->pTrack); int newRate; @@ -557,14 +557,14 @@ BEGIN_POPUP_MENU(WaveTrackMenuTable) static const auto isMono = []( PopupMenuHandler &handler ) -> bool { auto &track = - static_cast< WaveTrackMenuTable& >( handler ).FindWaveTrack(); + dynamic_cast< WaveTrackMenuTable& >( handler ).FindWaveTrack(); return 1 == TrackList::Channels( &track ).size(); }; static const auto isUnsafe = []( PopupMenuHandler &handler ) -> bool { auto &project = - static_cast< WaveTrackMenuTable& >( handler ).mpData->project; + dynamic_cast< WaveTrackMenuTable& >( handler ).mpData->project; return RealtimeEffectManager::Get().RealtimeIsActive() && ProjectAudioIO::Get( project ).IsAudioActive(); }; @@ -579,7 +579,7 @@ BEGIN_POPUP_MENU(WaveTrackMenuTable) POPUP_MENU_FN( OnMultiView ), table, []( PopupMenuHandler &handler, wxMenu &menu, int id ){ - auto &table = static_cast< WaveTrackMenuTable& >( handler ); + auto &table = dynamic_cast< WaveTrackMenuTable& >( handler ); auto &track = table.FindWaveTrack(); const auto &view = WaveTrackView::Get( track ); menu.Check( id, view.GetMultiView() ); @@ -605,7 +605,7 @@ BEGIN_POPUP_MENU(WaveTrackMenuTable) (std::find( begin, allTypes.end(), type ) - begin); }; - auto &table = static_cast< WaveTrackMenuTable& >( handler ); + auto &table = dynamic_cast< WaveTrackMenuTable& >( handler ); auto &track = table.FindWaveTrack(); const auto &view = WaveTrackView::Get( track ); @@ -670,9 +670,9 @@ BEGIN_POPUP_MENU(WaveTrackMenuTable) bool canMakeStereo = !isUnsafe( handler ) && isMono( handler ); if ( canMakeStereo ) { SaucedacityProject &project = - static_cast< WaveTrackMenuTable& >( handler ).mpData->project; + dynamic_cast< WaveTrackMenuTable& >( handler ).mpData->project; auto &tracks = TrackList::Get( project ); - auto &table = static_cast< WaveTrackMenuTable& >( handler ); + auto &table = dynamic_cast< WaveTrackMenuTable& >( handler ); auto &track = table.FindWaveTrack(); auto next = * ++ tracks.Find(&track); canMakeStereo = @@ -688,7 +688,7 @@ BEGIN_POPUP_MENU(WaveTrackMenuTable) POPUP_MENU_FN( OnSwapChannels ), []( PopupMenuHandler &handler, wxMenu &menu, int id ){ auto &track = - static_cast< WaveTrackMenuTable& >( handler ).FindWaveTrack(); + dynamic_cast< WaveTrackMenuTable& >( handler ).FindWaveTrack(); bool isStereo = 2 == TrackList::Channels( &track ).size(); menu.Enable( id, isStereo && !isUnsafe( handler ) ); @@ -722,7 +722,7 @@ END_POPUP_MENU() void WaveTrackMenuTable::OnMultiView(wxCommandEvent & event) { - const auto pTrack = static_cast(mpData->pTrack); + const auto pTrack = dynamic_cast(mpData->pTrack); const auto &view = WaveTrackView::Get( *pTrack ); bool multi = !view.GetMultiView(); const auto &displays = view.GetDisplays(); @@ -745,7 +745,7 @@ void WaveTrackMenuTable::OnSetDisplay(wxCommandEvent & event) int idInt = event.GetId(); wxASSERT(idInt >= OnSetDisplayId && idInt <= lastDisplayId); - const auto pTrack = static_cast(mpData->pTrack); + const auto pTrack = dynamic_cast(mpData->pTrack); auto id = AllTypes()[ idInt - OnSetDisplayId ].id; @@ -822,10 +822,10 @@ void WaveTrackMenuTable::OnMergeStereo(wxCommandEvent &) SaucedacityProject *const project = &mpData->project; auto &tracks = TrackList::Get( *project ); - WaveTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); wxASSERT(pTrack); - auto partner = static_cast< WaveTrack * > + auto partner = dynamic_cast< WaveTrack * > ( *tracks.Find( pTrack ).advance( 1 ) ); bool bBothMinimizedp = @@ -867,7 +867,7 @@ void WaveTrackMenuTable::OnMergeStereo(wxCommandEvent &) /// Split a stereo track (or more-than-stereo?) into two (or more) tracks... void WaveTrackMenuTable::SplitStereo(bool stereo) { - WaveTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); wxASSERT(pTrack); SaucedacityProject *const project = &mpData->project; auto channels = TrackList::Channels( pTrack ); @@ -901,7 +901,7 @@ void WaveTrackMenuTable::OnSwapChannels(wxCommandEvent &) { SaucedacityProject *const project = &mpData->project; - WaveTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); const auto linkType = pTrack->GetLinkType(); auto channels = TrackList::Channels( pTrack ); if (channels.size() != 2) @@ -933,7 +933,7 @@ void WaveTrackMenuTable::OnSwapChannels(wxCommandEvent &) void WaveTrackMenuTable::OnSplitStereo(wxCommandEvent &) { SplitStereo(true); - WaveTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); SaucedacityProject *const project = &mpData->project; ProjectHistory::Get( *project ).PushState( /* i18n-hint: The string names a track */ @@ -948,7 +948,7 @@ void WaveTrackMenuTable::OnSplitStereo(wxCommandEvent &) void WaveTrackMenuTable::OnSplitStereoMono(wxCommandEvent &) { SplitStereo(false); - WaveTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); SaucedacityProject *const project = &mpData->project; ProjectHistory::Get( *project ).PushState( /* i18n-hint: The string names a track */ @@ -995,7 +995,7 @@ void SliderDrawFunction { wxRect sliderRect = rect; TrackInfo::GetSliderHorizontalBounds( rect.GetTopLeft(), sliderRect ); - auto wt = static_cast( pTrack ); + auto wt = dynamic_cast( pTrack ); Selector( sliderRect, wt, captured, pParent )->OnPaint(*dc, highlight); } @@ -1047,7 +1047,7 @@ void Status1DrawFunction const wxRect &rect, const Track *pTrack ) { auto dc = &context.dc; - auto wt = static_cast(pTrack); + auto wt = dynamic_cast(pTrack); /// Returns the string to be displayed in the track label /// indicating whether the track is mono, left, right, or @@ -1076,7 +1076,7 @@ void Status2DrawFunction const wxRect &rect, const Track *pTrack ) { auto dc = &context.dc; - auto wt = static_cast(pTrack); + auto wt = dynamic_cast(pTrack); auto format = wt ? wt->GetSampleFormat() : floatSample; auto s = GetSampleFormatStr(format); StatusDrawFunction( s, dc, rect ); diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.h b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.h index e13010d08e..363fc8cb93 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.h +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.h @@ -11,6 +11,8 @@ Paul Licameli split from TrackPanel.cpp #ifndef __AUDACITY_WAVE_TRACK_CONTROLS__ #define __AUDACITY_WAVE_TRACK_CONTROLS__ +#include + #include "../../ui/PlayableTrackControls.h" // to inherit class CellularPanel; @@ -31,8 +33,8 @@ class SAUCEDACITY_DLL_API WaveTrackControls final : public PlayableTrackControls public: explicit WaveTrackControls( std::shared_ptr pTrack ) - : PlayableTrackControls( pTrack ) {} - ~WaveTrackControls(); + : PlayableTrackControls( std::move(pTrack) ) {} + ~WaveTrackControls() override; std::vector HitTest (const TrackPanelMouseState &state, @@ -74,7 +76,7 @@ struct SAUCEDACITY_DLL_API WaveTrackPopupMenuTable : public PopupMenuTable { using PopupMenuTable::PopupMenuTable; PlayableTrackControls::InitMenuData *mpData{}; - WaveTrack &FindWaveTrack () const; + [[nodiscard]] WaveTrack &FindWaveTrack () const; int ReserveId() { return mNextId++; } protected: int mNextId = 0; diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackShifter.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackShifter.cpp index 7bad824c40..49cbb99f2b 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackShifter.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackShifter.cpp @@ -101,7 +101,7 @@ class WaveTrackShifter final : public TrackShifter { std::vector< WaveClip * > movingClips; for ( auto &interval : MovingIntervals() ) { auto data = - static_cast( interval.Extra() ); + dynamic_cast( interval.Extra() ); movingClips.push_back(data->GetClip().get()); } double newAmount = 0; @@ -112,7 +112,7 @@ class WaveTrackShifter final : public TrackShifter { Intervals Detach() override { for ( auto &interval: mMoving ) { - auto pData = static_cast( interval.Extra() ); + auto pData = dynamic_cast( interval.Extra() ); auto pClip = pData->GetClip().get(); // interval will still hold the clip, so ignore the return: (void) mpTrack->RemoveAndReturnClip(pClip); @@ -126,10 +126,10 @@ class WaveTrackShifter final : public TrackShifter { double &desiredOffset, double tolerance) override { bool ok = true; - auto pOtherWaveTrack = static_cast(&otherTrack); + auto pOtherWaveTrack = dynamic_cast(&otherTrack); for ( auto &interval: intervals ) { auto pData = - static_cast( interval.Extra() ); + dynamic_cast( interval.Extra() ); auto pClip = pData->GetClip().get(); ok = pOtherWaveTrack->CanInsertClip( pClip, desiredOffset, tolerance ); @@ -142,7 +142,7 @@ class WaveTrackShifter final : public TrackShifter { bool Attach( Intervals intervals ) override { for (auto &interval : intervals) { - auto pData = static_cast( interval.Extra() ); + auto pData = dynamic_cast( interval.Extra() ); auto pClip = pData->GetClip(); if ( !mpTrack->AddClip( pClip ) ) return false; @@ -168,7 +168,7 @@ class WaveTrackShifter final : public TrackShifter { { for ( auto &interval : MovingIntervals() ) { auto data = - static_cast( interval.Extra() ); + dynamic_cast( interval.Extra() ); data->GetClip()->Offset( offset ); } } @@ -181,7 +181,7 @@ class WaveTrackShifter final : public TrackShifter { if (MovingIntervals().empty()) return t0; else { - auto data = static_cast(MovingIntervals()[0].Extra()); + auto data = dynamic_cast(MovingIntervals()[0].Extra()); auto& clip = data->GetClip(); if (t0 < clip->GetPlayStartTime()) t0 = clip->GetPlayStartTime(); diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.cpp index 4a29ea5292..d17d1bd1e8 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.cpp @@ -103,7 +103,7 @@ UIHandlePtr GainSliderHandle::HitTest auto sliderFn = []( SaucedacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) { return WaveTrackControls::GainSlider - (sliderRect, static_cast( pTrack ), true, + (sliderRect, dynamic_cast( pTrack ), true, &TrackPanel::Get( *pProject )); }; auto result = @@ -212,7 +212,7 @@ UIHandlePtr PanSliderHandle::HitTest auto sliderFn = []( SaucedacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) { return WaveTrackControls::PanSlider - (sliderRect, static_cast( pTrack ), true, + (sliderRect, dynamic_cast( pTrack ), true, &TrackPanel::Get( *pProject )); }; auto result = std::make_shared( diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.h b/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.h index c6c5de7b58..836b858d4b 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.h +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.h @@ -20,7 +20,7 @@ class GainSliderHandle final : public SliderHandle { GainSliderHandle(const GainSliderHandle&) = delete; - std::shared_ptr GetWaveTrack() const; + [[nodiscard]] std::shared_ptr GetWaveTrack() const; public: explicit GainSliderHandle @@ -29,7 +29,7 @@ class GainSliderHandle final : public SliderHandle GainSliderHandle &operator=(const GainSliderHandle&) = default; - virtual ~GainSliderHandle(); + ~GainSliderHandle() override; protected: float GetValue() override; @@ -56,7 +56,7 @@ class PanSliderHandle final : public SliderHandle { PanSliderHandle(const PanSliderHandle&) = delete; - std::shared_ptr GetWaveTrack() const; + [[nodiscard]] std::shared_ptr GetWaveTrack() const; public: explicit PanSliderHandle @@ -65,7 +65,7 @@ class PanSliderHandle final : public SliderHandle PanSliderHandle &operator=(const PanSliderHandle&) = default; - virtual ~PanSliderHandle(); + ~PanSliderHandle() override; protected: float GetValue() override; diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp index c7462e5abd..3bbcac874c 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp @@ -104,7 +104,7 @@ struct SubViewAdjuster mFirstSubView = first - begin; } - size_t NVisible() const + [[nodiscard]] size_t NVisible() const { return mPermutation.size() - mFirstSubView; } bool ModifyPermutation( bool top ) @@ -156,7 +156,7 @@ struct SubViewAdjuster std::pair< size_t, bool > HitTest( WaveTrackSubView &subView, - wxCoord yy, wxCoord top, wxCoord height ) + wxCoord yy, wxCoord top, wxCoord height ) const { const auto index = FindIndex( subView ); auto size = mPermutation.size(); @@ -201,7 +201,7 @@ struct SubViewAdjuster { auto pView = mwView.lock(); if ( pView ) { - auto pTrack = static_cast< WaveTrack* >( pView->FindTrack().get() ); + auto pTrack = dynamic_cast< WaveTrack* >( pView->FindTrack().get() ); for ( auto pChannel : TrackList::Channels( pTrack ) ) WaveTrackView::Get( *pChannel ).RestorePlacements( rollback ? mOrigPlacements : mNewPlacements ); @@ -505,11 +505,11 @@ class SubViewRearrangeHandle : public UIHandle return RefreshNone; } - bool Clicked() const { return !mHeights.empty(); } + [[nodiscard]] bool Clicked() const { return !mHeights.empty(); } enum DragChoice_t{ Upward, Downward, Neutral }; - DragChoice_t DragChoice( const TrackPanelMouseEvent &event ) const + [[nodiscard]] DragChoice_t DragChoice( const TrackPanelMouseEvent &event ) const { // Disregard x coordinate -- so the mouse need not be in any sub-view, // just in the correct range of y coordinates @@ -827,7 +827,7 @@ auto WaveTrackSubView::GetMenuItems( -> std::vector { const WaveClip *pClip = nullptr; - auto pTrack = static_cast( FindTrack().get() ); + auto pTrack = dynamic_cast( FindTrack().get() ); double time = 0.0; if ( pTrack && pPosition ) { auto &viewInfo = ViewInfo::Get(*pProject); @@ -852,7 +852,7 @@ auto WaveTrackSubView::GetMenuItems( WaveTrackView &WaveTrackView::Get( WaveTrack &track ) { - return static_cast< WaveTrackView& >( TrackView::Get( track ) ); + return dynamic_cast< WaveTrackView& >( TrackView::Get( track ) ); } const WaveTrackView &WaveTrackView::Get( const WaveTrack &track ) @@ -1039,7 +1039,7 @@ void WaveTrackView::DoSetDisplay(Display display, bool exclusive) size_t ii = 0; std::vector< std::pair< WaveTrackViewConstants::Display, size_t > > pairs; WaveTrackSubViews::ForEach( [&pairs, &ii]( WaveTrackSubView &subView ){ - pairs.push_back( { subView.SubViewType().id, ii++ } ); + pairs.emplace_back( subView.SubViewType().id, ii++ ); } ); std::sort( pairs.begin(), pairs.end() ); @@ -1195,7 +1195,7 @@ auto WaveTrackView::GetSubViews(const wxRect* rect) -> Refinement unsigned WaveTrackView::CaptureKey(wxKeyEvent& event, ViewInfo& viewInfo, wxWindow* pParent, SaucedacityProject* project) { unsigned result{ RefreshCode::RefreshNone }; - auto pTrack = static_cast(FindTrack().get()); + auto pTrack = dynamic_cast(FindTrack().get()); for (auto pChannel : TrackList::Channels(pTrack)) { event.Skip(false); auto &waveTrackView = WaveTrackView::Get(*pChannel); diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveformVRulerControls.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveformVRulerControls.cpp index 5ee502371e..7477c1ec51 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveformVRulerControls.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveformVRulerControls.cpp @@ -53,7 +53,7 @@ unsigned WaveformVRulerControls::HandleWheelRotation( const auto pTrack = FindTrack(); if (!pTrack) return RefreshNone; - const auto wt = static_cast(pTrack.get()); + const auto wt = dynamic_cast(pTrack.get()); return DoHandleWheelRotation( evt, pProject, wt ); } diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.cpp index 96c33563fd..6585a0c106 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.cpp @@ -283,7 +283,7 @@ BEGIN_POPUP_MENU(WaveformVRulerMenuTable) POPUP_MENU_FN( OnWaveformScaleType ), []( PopupMenuHandler &handler, wxMenu &menu, int id ){ const auto pData = - static_cast< WaveformVRulerMenuTable& >( handler ).mpData; + dynamic_cast< WaveformVRulerMenuTable& >( handler ).mpData; WaveTrack *const wt = pData->pTrack; if ( id == OnFirstWaveformScaleID + diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.h b/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.h index 758d2a9c58..9d8e3ccdff 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.h +++ b/src/tracks/playabletrack/wavetrack/ui/WaveformVZoomHandle.h @@ -34,7 +34,7 @@ class WaveformVZoomHandle final : public UIHandle ~WaveformVZoomHandle() override; - std::shared_ptr GetTrack() const { return mpTrack.lock(); } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpTrack.lock(); } void Enter( bool forward, SaucedacityProject * ) override; @@ -80,7 +80,7 @@ class WaveformVRulerMenuTable : public WaveTrackVRulerMenuTable WaveformVRulerMenuTable() : WaveTrackVRulerMenuTable{ "WaveFormVRuler" } {} - virtual ~WaveformVRulerMenuTable() {} + ~WaveformVRulerMenuTable() override {} DECLARE_POPUP_MENU(WaveformVRulerMenuTable); public: diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveformView.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveformView.cpp index dad2ca0615..ad3d0970a2 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveformView.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveformView.cpp @@ -63,16 +63,16 @@ std::vector WaveformView::DetailedHitTest( // If Tools toolbar were eliminated, we would keep these // The priority of these, in case more than one might apply at one // point, seems arbitrary - if (NULL != (result = EnvelopeHandle::WaveTrackHitTest( + if (nullptr != (result = EnvelopeHandle::WaveTrackHitTest( view.mEnvelopeHandle, st.state, st.rect, pProject, pTrack ))) results.push_back(result); - if (NULL != (result = TimeShiftHandle::HitTest( + if (nullptr != (result = TimeShiftHandle::HitTest( view.mTimeShiftHandle, st.state, st.rect, pTrack ))) // This is the hit test on the "grips" drawn left and // right in Multi only results.push_back(result); - if (NULL != (result = SampleHandle::HitTest( + if (nullptr != (result = SampleHandle::HitTest( view.mSampleHandle, st.state, st.rect, pProject, pTrack ))) results.push_back(result); @@ -108,7 +108,7 @@ std::vector WaveformView::DetailedHitTest( void WaveformView::DoSetMinimized( bool minimized ) { - auto wt = static_cast( FindTrack().get() ); + auto wt = dynamic_cast( FindTrack().get() ); #ifdef EXPERIMENTAL_HALF_WAVE bool bHalfWave; @@ -313,9 +313,8 @@ void FindWavePortions const int right = std::max(left, (int)(it->position)); const int width = right - left; if (width > 0) - portions.push_back( - WavePortion(left, rect.y, width, rect.height, - prev->averageZoom, prev->inFisheye) + portions.emplace_back(left, rect.y, width, rect.height, + prev->averageZoom, prev->inFisheye ); left = right; } @@ -809,8 +808,8 @@ void DrawClipWaveform(TrackPanelDrawingContext &context, rectPortion.Intersect(mid); wxASSERT(rectPortion.width >= 0); - float *useMin = 0, *useMax = 0, *useRms = 0; - int *useBl = 0; + float *useMin = nullptr, *useMax = nullptr, *useRms = nullptr; + int *useBl = nullptr; WaveDisplay fisheyeDisplay(rectPortion.width); int skipped = 0, skippedLeft = 0, skippedRight = 0; if (portion.inFisheye) { @@ -1027,7 +1026,7 @@ void WaveformView::Draw( // If both channels are visible, we will duplicate this effort, but that // matters little. for( auto channel: - TrackList::Channels(static_cast(FindTrack().get())) ) + TrackList::Channels(dynamic_cast(FindTrack().get())) ) channel->UpdateLocationsCache(); const auto wt = std::static_pointer_cast( @@ -1086,13 +1085,13 @@ struct WaveColorMenuTable : PopupMenuTable void DestroyMenu() override { - mpData = NULL; + mpData = nullptr; } PlayableTrackControls::InitMenuData *mpData{}; - int IdOfWaveColor(int WaveColor); - void OnWaveColorChange(wxCommandEvent & event); + int IdOfWaveColor(int WaveColor) const; + void OnWaveColorChange(wxCommandEvent & event) const; int OnInstrument1ID, OnInstrument2ID, OnInstrument3ID, OnInstrument4ID; }; @@ -1119,9 +1118,9 @@ const TranslatableString GetWaveColorStr(int colorIndex) BEGIN_POPUP_MENU(WaveColorMenuTable) static const auto fn = []( PopupMenuHandler &handler, wxMenu &menu, int id ){ - auto &me = static_cast( handler ); + auto &me = dynamic_cast( handler ); auto pData = me.mpData; - const auto &track = *static_cast(pData->pTrack); + const auto &track = *dynamic_cast(pData->pTrack); auto &project = pData->project; bool unsafe = ProjectAudioIO::Get( project ).IsAudioActive(); @@ -1150,16 +1149,16 @@ BEGIN_POPUP_MENU(WaveColorMenuTable) END_POPUP_MENU() /// Converts a WaveColor enumeration to a wxWidgets menu item Id. -int WaveColorMenuTable::IdOfWaveColor(int WaveColor) +int WaveColorMenuTable::IdOfWaveColor(int WaveColor) const { return OnInstrument1ID + WaveColor;} /// Handles the selection from the WaveColor submenu of the /// track menu. -void WaveColorMenuTable::OnWaveColorChange(wxCommandEvent & event) +void WaveColorMenuTable::OnWaveColorChange(wxCommandEvent & event) const { int id = event.GetId(); wxASSERT(id >= OnInstrument1ID && id <= OnInstrument4ID); - const auto pTrack = static_cast(mpData->pTrack); + const auto pTrack = dynamic_cast(mpData->pTrack); int newWaveColor = id - OnInstrument1ID; diff --git a/src/tracks/timetrack/ui/TimeTrackControls.cpp b/src/tracks/timetrack/ui/TimeTrackControls.cpp index 550c0e4a85..a5d8d2b52c 100644 --- a/src/tracks/timetrack/ui/TimeTrackControls.cpp +++ b/src/tracks/timetrack/ui/TimeTrackControls.cpp @@ -56,7 +56,7 @@ void TimeTrackMenuTable::DestroyMenu() void TimeTrackMenuTable::OnSetTimeTrackRange(wxCommandEvent & /*event*/) { - TimeTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); if (pTrack) { long lower = (long)(pTrack->GetRangeLower() * 100.0 + 0.5); long upper = (long)(pTrack->GetRangeUpper() * 100.0 + 0.5); @@ -94,7 +94,7 @@ void TimeTrackMenuTable::OnSetTimeTrackRange(wxCommandEvent & /*event*/) void TimeTrackMenuTable::OnTimeTrackLin(wxCommandEvent & /*event*/) { - TimeTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); pTrack->SetDisplayLog(false); SaucedacityProject *const project = &mpData->project; ProjectHistory::Get( *project ) @@ -106,7 +106,7 @@ void TimeTrackMenuTable::OnTimeTrackLin(wxCommandEvent & /*event*/) void TimeTrackMenuTable::OnTimeTrackLog(wxCommandEvent & /*event*/) { - TimeTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); pTrack->SetDisplayLog(true); SaucedacityProject *const project = &mpData->project; ProjectHistory::Get( *project ) @@ -118,7 +118,7 @@ void TimeTrackMenuTable::OnTimeTrackLog(wxCommandEvent & /*event*/) void TimeTrackMenuTable::OnTimeTrackLogInt(wxCommandEvent & /*event*/) { - TimeTrack *const pTrack = static_cast(mpData->pTrack); + auto *const pTrack = dynamic_cast(mpData->pTrack); SaucedacityProject *const project = &mpData->project; if (pTrack->GetInterpolateLog()) { pTrack->SetInterpolateLog(false); @@ -135,8 +135,8 @@ void TimeTrackMenuTable::OnTimeTrackLogInt(wxCommandEvent & /*event*/) BEGIN_POPUP_MENU(TimeTrackMenuTable) static const auto findTrack = []( PopupMenuHandler &handler ){ - return static_cast( - static_cast( handler ).mpData->pTrack ); + return dynamic_cast( + dynamic_cast( handler ).mpData->pTrack ); }; BeginSection( "Scales" ); diff --git a/src/tracks/timetrack/ui/TimeTrackControls.h b/src/tracks/timetrack/ui/TimeTrackControls.h index 211c0b6d2e..49b4e54b84 100644 --- a/src/tracks/timetrack/ui/TimeTrackControls.h +++ b/src/tracks/timetrack/ui/TimeTrackControls.h @@ -11,6 +11,8 @@ Paul Licameli split from TrackPanel.cpp #ifndef __AUDACITY_TIME_TRACK_CONTROLS__ #define __AUDACITY_TIME_TRACK_CONTROLS__ +#include + #include "../../ui/CommonTrackControls.h" // to inherit class TimeTrackControls final : public CommonTrackControls @@ -21,8 +23,8 @@ class TimeTrackControls final : public CommonTrackControls public: explicit TimeTrackControls( std::shared_ptr pTrack ) - : CommonTrackControls( pTrack ) {} - ~TimeTrackControls(); + : CommonTrackControls( std::move(pTrack) ) {} + ~TimeTrackControls() override; std::vector HitTest (const TrackPanelMouseState &state, diff --git a/src/tracks/timetrack/ui/TimeTrackVRulerControls.h b/src/tracks/timetrack/ui/TimeTrackVRulerControls.h index 0de77f0590..cf3acae5ad 100644 --- a/src/tracks/timetrack/ui/TimeTrackVRulerControls.h +++ b/src/tracks/timetrack/ui/TimeTrackVRulerControls.h @@ -26,7 +26,7 @@ class TimeTrackVRulerControls final : public TrackVRulerControls explicit TimeTrackVRulerControls( const std::shared_ptr &pTrackView ) : TrackVRulerControls( pTrackView ) {} - ~TimeTrackVRulerControls(); + ~TimeTrackVRulerControls() override; std::vector HitTest( const TrackPanelMouseState &state, diff --git a/src/tracks/ui/AffordanceHandle.h b/src/tracks/ui/AffordanceHandle.h index ee57992c63..a077012506 100644 --- a/src/tracks/ui/AffordanceHandle.h +++ b/src/tracks/ui/AffordanceHandle.h @@ -20,7 +20,7 @@ class SAUCEDACITY_DLL_API AffordanceHandle : public TimeShiftHandle void Enter(bool forward, SaucedacityProject* pProject) override; HitTestPreview Preview(const TrackPanelMouseState& mouseState, SaucedacityProject* pProject) override; - AffordanceHandle(const std::shared_ptr& track); + explicit AffordanceHandle(const std::shared_ptr& track); Result Click(const TrackPanelMouseEvent& evt, SaucedacityProject* pProject) override; Result Release(const TrackPanelMouseEvent& event, SaucedacityProject* pProject, wxWindow* pParent) override; diff --git a/src/tracks/ui/BackgroundCell.cpp b/src/tracks/ui/BackgroundCell.cpp index e6fbac4661..d0f097feb1 100644 --- a/src/tracks/ui/BackgroundCell.cpp +++ b/src/tracks/ui/BackgroundCell.cpp @@ -44,7 +44,7 @@ class BackgroundHandle : public UIHandle return { {}, &arrowCursor }; } - virtual ~BackgroundHandle() + ~BackgroundHandle() override {} Result Click diff --git a/src/tracks/ui/BackgroundCell.h b/src/tracks/ui/BackgroundCell.h index ba27e7ccf7..b71f49e46f 100644 --- a/src/tracks/ui/BackgroundCell.h +++ b/src/tracks/ui/BackgroundCell.h @@ -35,7 +35,7 @@ class BackgroundCell final : mpProject(pProject) {} - virtual ~BackgroundCell(); + ~BackgroundCell() override; protected: std::vector HitTest diff --git a/src/tracks/ui/ButtonHandle.h b/src/tracks/ui/ButtonHandle.h index eea6de4e7c..ee16ff6d84 100644 --- a/src/tracks/ui/ButtonHandle.h +++ b/src/tracks/ui/ButtonHandle.h @@ -27,8 +27,8 @@ class SAUCEDACITY_DLL_API ButtonHandle /* not final */ : public UIHandle ButtonHandle(const ButtonHandle&) = delete; public: - std::shared_ptr GetTrack() const { return mpTrack.lock(); } - bool IsClicked() const { return mIsClicked; } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpTrack.lock(); } + [[nodiscard]] bool IsClicked() const { return mIsClicked; } protected: explicit ButtonHandle @@ -36,7 +36,7 @@ class SAUCEDACITY_DLL_API ButtonHandle /* not final */ : public UIHandle ButtonHandle &operator=(const ButtonHandle&) = default; - virtual ~ButtonHandle(); + ~ButtonHandle() override; // This NEW abstract virtual simplifies the duties of further subclasses. // This class will decide whether to refresh the clicked cell for button state @@ -49,25 +49,25 @@ class SAUCEDACITY_DLL_API ButtonHandle /* not final */ : public UIHandle virtual TranslatableString Tip( const wxMouseState &state, SaucedacityProject &project) const = 0; - void Enter(bool forward, SaucedacityProject *) final override; + void Enter(bool forward, SaucedacityProject *) final ; Result Click (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) - final override; + final ; Result Drag (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) - final override; + final ; HitTestPreview Preview (const TrackPanelMouseState &state, SaucedacityProject *pProject) - final override; + final ; Result Release (const TrackPanelMouseEvent &event, SaucedacityProject *pProject, - wxWindow *pParent) final override; + wxWindow *pParent) final ; - Result Cancel(SaucedacityProject *pProject) final override; + Result Cancel(SaucedacityProject *pProject) final ; std::weak_ptr mpTrack; wxRect mRect; diff --git a/src/tracks/ui/CommonTrackControls.cpp b/src/tracks/ui/CommonTrackControls.cpp index 0b08f312f1..d9ad66826e 100644 --- a/src/tracks/ui/CommonTrackControls.cpp +++ b/src/tracks/ui/CommonTrackControls.cpp @@ -44,24 +44,24 @@ std::vector CommonTrackControls::HitTest auto sThis = shared_from_this(); - if (NULL != (result = CloseButtonHandle::HitTest( + if (nullptr != (result = CloseButtonHandle::HitTest( mCloseHandle, state, rect, this))) results.push_back(result); - if (NULL != (result = MenuButtonHandle::HitTest( + if (nullptr != (result = MenuButtonHandle::HitTest( mMenuHandle, state, rect, sThis))) results.push_back(result); - if (NULL != (result = MinimizeButtonHandle::HitTest( + if (nullptr != (result = MinimizeButtonHandle::HitTest( mMinimizeHandle, state, rect, this))) results.push_back(result); - if (NULL != (result = SelectButtonHandle::HitTest( + if (nullptr != (result = SelectButtonHandle::HitTest( mSelectButtonHandle, state, rect, this))) results.push_back(result); if (results.empty()) { - if (NULL != (result = TrackSelectHandle::HitAnywhere( + if (nullptr != (result = TrackSelectHandle::HitAnywhere( mSelectHandle, FindTrack()))) results.push_back(result); } @@ -124,7 +124,7 @@ void TrackMenuTable::InitUserData(void *pUserData) BEGIN_POPUP_MENU(TrackMenuTable) static const auto enableIfCanMove = [](bool up){ return [up]( PopupMenuHandler &handler, wxMenu &menu, int id ){ - auto pData = static_cast( handler ).mpData; + auto pData = dynamic_cast( handler ).mpData; const auto &tracks = TrackList::Get( pData->project ); Track *const pTrack = pData->pTrack; menu.Enable( id, diff --git a/src/tracks/ui/CommonTrackControls.h b/src/tracks/ui/CommonTrackControls.h index adf18b2ae8..323efc6d33 100644 --- a/src/tracks/ui/CommonTrackControls.h +++ b/src/tracks/ui/CommonTrackControls.h @@ -49,7 +49,7 @@ class SAUCEDACITY_DLL_API CommonTrackControls /* not final */ : public TrackCont protected: // An override is supplied for derived classes to call through but it is // still marked pure virtual - virtual std::vector HitTest + std::vector HitTest (const TrackPanelMouseState &state, const SaucedacityProject *) override = 0; diff --git a/src/tracks/ui/CommonTrackPanelCell.h b/src/tracks/ui/CommonTrackPanelCell.h index 943ee46942..1dc376ed21 100644 --- a/src/tracks/ui/CommonTrackPanelCell.h +++ b/src/tracks/ui/CommonTrackPanelCell.h @@ -37,14 +37,14 @@ class SAUCEDACITY_DLL_API CommonTrackPanelCell /* not final */ CommonTrackPanelCell() {} - virtual ~CommonTrackPanelCell() = 0; + ~CommonTrackPanelCell() override = 0; // Default to the arrow cursor HitTestPreview DefaultPreview (const TrackPanelMouseState &, const SaucedacityProject *) override; std::shared_ptr FindTrack() { return DoFindTrack(); } - std::shared_ptr FindTrack() const + [[nodiscard]] std::shared_ptr FindTrack() const { return const_cast(this)->DoFindTrack(); } struct MenuItem { @@ -100,7 +100,7 @@ class SAUCEDACITY_DLL_API CommonTrackCell /* not final */ public: explicit CommonTrackCell( const std::shared_ptr &pTrack ); - ~CommonTrackCell(); + ~CommonTrackCell() override; // Copy state, for undo/redo purposes // The default does nothing diff --git a/src/tracks/ui/CommonTrackView.h b/src/tracks/ui/CommonTrackView.h index bca96dfada..c9c5436ddf 100644 --- a/src/tracks/ui/CommonTrackView.h +++ b/src/tracks/ui/CommonTrackView.h @@ -29,11 +29,11 @@ class SAUCEDACITY_DLL_API CommonTrackView /* not final */ : public TrackView // Do not further override this... std::vector HitTest (const TrackPanelMouseState &, const SaucedacityProject *pProject) - final override; + final ; void TimeShiftHitTest(); - virtual int GetMinimizedHeight() const override; + int GetMinimizedHeight() const override; protected: // Rather override this for subclasses: diff --git a/src/tracks/ui/EditCursorOverlay.h b/src/tracks/ui/EditCursorOverlay.h index 6aa6306cbd..a0e782d6e8 100644 --- a/src/tracks/ui/EditCursorOverlay.h +++ b/src/tracks/ui/EditCursorOverlay.h @@ -26,7 +26,7 @@ class EditCursorOverlay final EditCursorOverlay(SaucedacityProject *project, bool isMaster = true); private: - unsigned SequenceNumber() const override; + [[nodiscard]] unsigned SequenceNumber() const override; std::pair DoGetRectangle(wxSize size) override; void Draw(OverlayPanel &panel, wxDC &dc) override; diff --git a/src/tracks/ui/EnvelopeHandle.h b/src/tracks/ui/EnvelopeHandle.h index 3200823ca0..e3af494e42 100644 --- a/src/tracks/ui/EnvelopeHandle.h +++ b/src/tracks/ui/EnvelopeHandle.h @@ -39,7 +39,7 @@ class SAUCEDACITY_DLL_API EnvelopeHandle final : public UIHandle public: explicit EnvelopeHandle( Envelope *pEnvelope ); - virtual ~EnvelopeHandle(); + ~EnvelopeHandle() override; static UIHandlePtr HitAnywhere (std::weak_ptr &holder, Envelope *envelope, @@ -53,7 +53,7 @@ class SAUCEDACITY_DLL_API EnvelopeHandle final : public UIHandle const wxMouseState &state, const wxRect &rect, const SaucedacityProject *pProject, const std::shared_ptr &wt); - Envelope *GetEnvelope() const { return mEnvelope; } + [[nodiscard]] Envelope *GetEnvelope() const { return mEnvelope; } void Enter(bool forward, SaucedacityProject *) override; diff --git a/src/tracks/ui/PlayIndicatorOverlay.h b/src/tracks/ui/PlayIndicatorOverlay.h index 16d2ffa774..756b0fc16f 100644 --- a/src/tracks/ui/PlayIndicatorOverlay.h +++ b/src/tracks/ui/PlayIndicatorOverlay.h @@ -27,12 +27,12 @@ class PlayIndicatorOverlayBase { public: PlayIndicatorOverlayBase(SaucedacityProject *project, bool isMaster); - virtual ~PlayIndicatorOverlayBase(); + ~PlayIndicatorOverlayBase() override; void Update(int newIndicatorX) { mNewIndicatorX = newIndicatorX; } private: - unsigned SequenceNumber() const override; + [[nodiscard]] unsigned SequenceNumber() const override; std::pair DoGetRectangle(wxSize size) override; void Draw(OverlayPanel &panel, wxDC &dc) override; diff --git a/src/tracks/ui/ScrubUI.cpp b/src/tracks/ui/ScrubUI.cpp index 86bd1384e1..980660c1f0 100644 --- a/src/tracks/ui/ScrubUI.cpp +++ b/src/tracks/ui/ScrubUI.cpp @@ -36,13 +36,13 @@ class ScrubbingOverlay final ScrubbingOverlay(SaucedacityProject *project); private: - unsigned SequenceNumber() const override; + [[nodiscard]] unsigned SequenceNumber() const override; std::pair DoGetRectangle(wxSize size) override; void Draw(OverlayPanel &panel, wxDC &dc) override; void OnTimer(wxCommandEvent &event); - const Scrubber &GetScrubber() const; + [[nodiscard]] const Scrubber &GetScrubber() const; Scrubber &GetScrubber(); SaucedacityProject *mProject; @@ -229,7 +229,7 @@ struct ScrubForwarder mScrubber = Scrubber::Get( project ).shared_from_this(); } - ~ScrubForwarder() + ~ScrubForwarder() override { if ( mWindow ) mWindow->PopEventHandler(); diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index 26a9d65893..6bf581161b 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -261,7 +261,7 @@ namespace { bool seek; bool (Scrubber::*StatusTest)() const; - const TranslatableString &GetStatus() const { return status; } + [[nodiscard]] const TranslatableString &GetStatus() const { return status; } }; using MenuItems = std::vector< MenuItem >; const MenuItems &menuItems() @@ -893,7 +893,7 @@ bool Scrubber::Scrubs() const return (HasMark() || IsScrubbing()) && !ChoseSeeking(); } -bool Scrubber::ShouldDrawScrubSpeed() +bool Scrubber::ShouldDrawScrubSpeed() const { return IsScrubbing() && !mPaused && ( @@ -1021,7 +1021,7 @@ void Scrubber::OnSeek(const CommandContext&) #if 1 namespace { - static const wxChar *scrubEnabledPrefName = wxT("/QuickPlay/ScrubbingEnabled"); + const wxChar *scrubEnabledPrefName = wxT("/QuickPlay/ScrubbingEnabled"); bool ReadScrubEnabledPref() { @@ -1206,7 +1206,7 @@ void Scrubber::OnKeyboardScrubForwards(const CommandContext &context) namespace { -static const auto finder = +const auto finder = [](SaucedacityProject &project) -> CommandHandlerObject& { return Scrubber::Get( project ); }; diff --git a/src/tracks/ui/Scrubbing.h b/src/tracks/ui/Scrubbing.h index 399302a52d..c878fe5868 100644 --- a/src/tracks/ui/Scrubbing.h +++ b/src/tracks/ui/Scrubbing.h @@ -51,7 +51,7 @@ class SAUCEDACITY_DLL_API Scrubber final Scrubber(SaucedacityProject *project); Scrubber( const Scrubber & ) = delete; Scrubber &operator=( const Scrubber & ) = delete; - ~Scrubber(); + ~Scrubber() override; static bool ShouldScrubPinned(); @@ -108,7 +108,7 @@ class SAUCEDACITY_DLL_API Scrubber final void Cancel() { mCancelled = true; } - bool ShouldDrawScrubSpeed(); + bool ShouldDrawScrubSpeed() const; double FindScrubSpeed(bool seeking, double time) const; double GetMaxScrubSpeed() const { return mOptions.maxSpeed; } diff --git a/src/tracks/ui/SelectHandle.cpp b/src/tracks/ui/SelectHandle.cpp index d72cebf20e..d694b1bc73 100644 --- a/src/tracks/ui/SelectHandle.cpp +++ b/src/tracks/ui/SelectHandle.cpp @@ -56,7 +56,7 @@ enum { bool SelectHandle::IsClicked() const { - return mSelectionStateChanger.get() != NULL; + return mSelectionStateChanger != nullptr; } namespace @@ -104,7 +104,7 @@ namespace template inline void SetIfNotNull(T * pValue, const T Value) { - if (pValue == NULL) + if (pValue == nullptr) return; *pValue = Value; } @@ -174,7 +174,7 @@ namespace (const ViewInfo &viewInfo, wxCoord xx, wxCoord yy, const TrackView *pTrackView, const wxRect &rect, bool mayDragWidth, bool onlyWithinSnapDistance, - double *pPinValue = NULL) + double *pPinValue = nullptr) { // Choose one of four boundaries to adjust, or the center frequency. // May choose frequencies only if in a spectrogram view and @@ -208,8 +208,8 @@ namespace isSpectralSelectionView(pTrackView)) { // Spectral selection track is always wave auto pTrack = pTrackView->FindTrack(); - const WaveTrack *const wt = - static_cast(pTrack.get()); + const auto *const wt = + dynamic_cast(pTrack.get()); const wxInt64 bottomSel = (f0 >= 0) ? FrequencyToPosition(wt, f0, rect.y, rect.height) : rect.y + rect.height; @@ -648,13 +648,13 @@ UIHandle::Result SelectHandle::Click // Drag frequency only, not time: mSelStartValid = false; AdjustFreqSelection( - static_cast(pTrack), + dynamic_cast(pTrack), viewInfo, event.m_y, mRect.y, mRect.height); break; } case SBCenter: { - const auto wt = static_cast(pTrack); + const auto wt = dynamic_cast(pTrack); HandleCenterFrequencyClick(viewInfo, true, wt, value); break; } @@ -699,7 +699,7 @@ UIHandle::Result SelectHandle::Click // Do not adjust time boundaries mSelStartValid = false; AdjustFreqSelection( - static_cast(pTrack), + dynamic_cast(pTrack), viewInfo, event.m_y, mRect.y, mRect.height); // For persistence of the selection change: ProjectHistory::Get( *pProject ).ModifyState(false); @@ -746,7 +746,7 @@ UIHandle::Result SelectHandle::Click break; case SBCenter: { - const auto wt = static_cast(pTrack); + const auto wt = dynamic_cast(pTrack); HandleCenterFrequencyClick(viewInfo, false, wt, value); startNewSelection = false; break; @@ -834,7 +834,7 @@ UIHandle::Result SelectHandle::Drag if (evt.pCell) { if ( auto clickedTrack = - static_cast(evt.pCell.get())->FindTrack() ) { + dynamic_cast(evt.pCell.get())->FindTrack() ) { // Handle which tracks are selected Track *sTrack = pTrack.get(); Track *eTrack = clickedTrack.get(); @@ -854,7 +854,7 @@ UIHandle::Result SelectHandle::Drag #endif if ( TrackList::Get( *pProject ).Lock(mFreqSelTrack) == pTrack ) AdjustFreqSelection( - static_cast(pTrack.get()), + dynamic_cast(pTrack.get()), viewInfo, y, mRect.y, mRect.height); #endif @@ -1205,7 +1205,7 @@ void SelectHandle::AdjustSelection } void SelectHandle::AssignSelection -(ViewInfo &viewInfo, double selend, Track *pTrack) +(ViewInfo &viewInfo, double selend, Track *pTrack) const { double sel0, sel1; if (mSelStart < selend) { @@ -1399,7 +1399,7 @@ void SelectHandle::MoveSnappingFreqSelection pTrack->GetSelected() && isSpectralSelectionView(pTrackView)) { // Spectral selection track is always wave - WaveTrack *const wt = static_cast(pTrack); + auto *const wt = dynamic_cast(pTrack); // PRL: // What would happen if center snapping selection began in one spectrogram track, // then continues inside another? We do not then recalculate @@ -1412,7 +1412,7 @@ void SelectHandle::MoveSnappingFreqSelection PositionToFrequency(wt, false, mouseYCoordinate, trackTopEdge, trackHeight); const double snappedFrequency = - mFrequencySnapper->FindPeak(frequency, NULL); + mFrequencySnapper->FindPeak(frequency, nullptr); const double maxRatio = findMaxRatio(snappedFrequency, rate); double ratio = 2.0; // An arbitrary octave on each side, at most { @@ -1469,12 +1469,12 @@ void SelectHandle::SnapCenterOnce if (up) { while (snappedFrequency <= centerFrequency && bin < limitingBin) - snappedFrequency = analyst.FindPeak(++bin * binFrequency, NULL); + snappedFrequency = analyst.FindPeak(++bin * binFrequency, nullptr); } else { while (snappedFrequency >= centerFrequency && bin > limitingBin) - snappedFrequency = analyst.FindPeak(--bin * binFrequency, NULL); + snappedFrequency = analyst.FindPeak(--bin * binFrequency, nullptr); } // PRL: added these two lines with the big TrackPanel refactor diff --git a/src/tracks/ui/SelectHandle.h b/src/tracks/ui/SelectHandle.h index 49513a231e..d33e43b5b1 100644 --- a/src/tracks/ui/SelectHandle.h +++ b/src/tracks/ui/SelectHandle.h @@ -46,15 +46,15 @@ class SAUCEDACITY_DLL_API SelectHandle : public UIHandle SelectHandle &operator=(const SelectHandle&) = default; - virtual ~SelectHandle(); + ~SelectHandle() override; - bool IsClicked() const; + [[nodiscard]] bool IsClicked() const; void SetUseSnap(bool use, SaucedacityProject *pProject); void Enter(bool forward, SaucedacityProject *pProject) override; - bool HasSnap() const; - bool HasEscape() const override; + [[nodiscard]] bool HasSnap() const; + [[nodiscard]] bool HasEscape() const override; bool Escape(SaucedacityProject *pProject) override; @@ -88,7 +88,7 @@ class SAUCEDACITY_DLL_API SelectHandle : public UIHandle (SaucedacityProject *pProject, ViewInfo &viewInfo, int mouseXCoordinate, int trackLeftEdge, Track *pTrack); - void AssignSelection(ViewInfo &viewInfo, double selend, Track *pTrack); + void AssignSelection(ViewInfo &viewInfo, double selend, Track *pTrack) const; void StartFreqSelection (ViewInfo &viewInfo, int mouseYCoordinate, int trackTopEdge, diff --git a/src/tracks/ui/SliderHandle.h b/src/tracks/ui/SliderHandle.h index fc144f16a3..758ab24e84 100644 --- a/src/tracks/ui/SliderHandle.h +++ b/src/tracks/ui/SliderHandle.h @@ -32,11 +32,11 @@ class SAUCEDACITY_DLL_API SliderHandle /* not final */ : public UIHandle SliderHandle &operator=(const SliderHandle&) = default; - std::shared_ptr GetTrack() const { return mpTrack.lock(); } - bool IsClicked() const { return mIsClicked; } + [[nodiscard]] std::shared_ptr GetTrack() const { return mpTrack.lock(); } + [[nodiscard]] bool IsClicked() const { return mIsClicked; } protected: - virtual ~SliderHandle(); + ~SliderHandle() override; // These NEW abstract virtuals simplify the duties of further subclasses. // This class will decide whether to refresh the clicked cell for slider state @@ -55,21 +55,21 @@ class SAUCEDACITY_DLL_API SliderHandle /* not final */ : public UIHandle Result Click (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) - final override; + final ; Result Drag (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) - final override; + final ; HitTestPreview Preview (const TrackPanelMouseState &state, SaucedacityProject *pProject) - final override; + final ; Result Release (const TrackPanelMouseEvent &event, SaucedacityProject *pProject, - wxWindow *pParent) final override; + wxWindow *pParent) final ; - Result Cancel(SaucedacityProject *pProject) final override; + Result Cancel(SaucedacityProject *pProject) final ; // Derived class is expected to set these two before Click(): std::weak_ptr mpTrack; diff --git a/src/tracks/ui/TextEditHelper.cpp b/src/tracks/ui/TextEditHelper.cpp index 3192c79e13..993ec61141 100644 --- a/src/tracks/ui/TextEditHelper.cpp +++ b/src/tracks/ui/TextEditHelper.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include "../../ProjectWindow.h" #include "../../RefreshCode.h" @@ -41,9 +43,9 @@ bool TextEditHelper::IsGoodEditKeyCode(int keyCode) (keyCode > WXK_WINDOWS_MENU); } -TextEditHelper::TextEditHelper(const std::weak_ptr& delegate, const wxString& text, const wxFont& font) +TextEditHelper::TextEditHelper(std::weak_ptr delegate, const wxString& text, const wxFont& font) : mFont(font), - mDelegate(delegate), + mDelegate(std::move(delegate)), mText(text), mInitialCursorPos(0) { @@ -89,7 +91,7 @@ void TextEditHelper::SelectAll() mCurrentCursorPos = mText.Length(); } -bool TextEditHelper::IsSelectionEmpty() +bool TextEditHelper::IsSelectionEmpty() const { return mCurrentCursorPos == mInitialCursorPos; } @@ -491,10 +493,10 @@ int TextEditHelper::FindCursorIndex(const wxPoint& point) } subString = mText.Left(charIndex); // Get the width of substring - dc.GetTextExtent(subString, &partWidth, NULL); + dc.GetTextExtent(subString, &partWidth, nullptr); // Get the width of the last character - dc.GetTextExtent(subString.Right(1), &oneWidth, NULL); + dc.GetTextExtent(subString.Right(1), &oneWidth, nullptr); if (layout == wxLayout_RightToLeft) { @@ -658,9 +660,9 @@ bool TextEditHelper::PasteSelectedText(SaucedacityProject& project) } // Convert control characters to blanks - for (int i = 0; i < (int)text.length(); i++) { - if (wxIscntrl(text[i])) { - text[i] = wxT(' '); + for (auto && i : text) { + if (wxIscntrl(i)) { + i = wxT(' '); } } } diff --git a/src/tracks/ui/TextEditHelper.h b/src/tracks/ui/TextEditHelper.h index 47ce5157f4..2c95d672ff 100644 --- a/src/tracks/ui/TextEditHelper.h +++ b/src/tracks/ui/TextEditHelper.h @@ -64,7 +64,7 @@ class TextEditHelper public: static bool IsGoodEditKeyCode(int keyCode); - TextEditHelper(const std::weak_ptr& delegate, const wxString& text, const wxFont& font); + TextEditHelper(std::weak_ptr delegate, const wxString& text, const wxFont& font); ~TextEditHelper() { @@ -76,12 +76,12 @@ class TextEditHelper void Cancel(SaucedacityProject* project); void Finish(SaucedacityProject* project); - std::pair GetSelection() const; + [[nodiscard]] std::pair GetSelection() const; void SetSelection(int from, int to); void SelectAll(); - bool IsSelectionEmpty(); + bool IsSelectionEmpty() const; - bool CaptureKey(int keyCode, int mods); + static bool CaptureKey(int keyCode, int mods); bool OnKeyDown(int keyCode, int mods, SaucedacityProject* project); bool OnChar(int charCode, SaucedacityProject* project); @@ -97,7 +97,7 @@ class TextEditHelper bool GetCharPositionX(int index, int* outX); - const wxRect& GetBBox() const; + [[nodiscard]] const wxRect& GetBBox() const; protected: diff --git a/src/tracks/ui/TimeShiftHandle.cpp b/src/tracks/ui/TimeShiftHandle.cpp index a8c4b7fd76..80c0c0db17 100644 --- a/src/tracks/ui/TimeShiftHandle.cpp +++ b/src/tracks/ui/TimeShiftHandle.cpp @@ -131,7 +131,7 @@ TrackShifter::TrackShifter() = default; TrackShifter::~TrackShifter() = default; void TrackShifter::UnfixIntervals( - std::function< bool( const TrackInterval& ) > pred ) + const std::function< bool( const TrackInterval& ) >& pred ) { for ( auto iter = mFixed.begin(); iter != mFixed.end(); ) { if ( pred( *iter) ) { @@ -184,7 +184,7 @@ bool TrackShifter::MayMigrateTo(Track &) return false; } -bool TrackShifter::CommonMayMigrateTo(Track &otherTrack) +bool TrackShifter::CommonMayMigrateTo(Track &otherTrack) const { auto &track = GetTrack(); @@ -378,7 +378,7 @@ void ClipMoveState::Init( // Iterate over all unfixed intervals in all tracks // that do propagation and are in sync lock groups ... for ( auto &pair : state.shifters ) { - auto &shifter = *pair.second.get(); + auto &shifter = *pair.second; if (!shifter.SyncLocks()) continue; auto &track = shifter.GetTrack(); @@ -865,7 +865,7 @@ UIHandle::Result TimeShiftHandle::Drag const wxMouseEvent &event = evt.event; auto &viewInfo = ViewInfo::Get( *pProject ); - TrackView *trackView = dynamic_cast(evt.pCell.get()); + auto *trackView = dynamic_cast(evt.pCell.get()); Track *track = trackView ? trackView->FindTrack().get() : nullptr; // Uncommenting this permits drag to continue to work even over the controls area diff --git a/src/tracks/ui/TimeShiftHandle.h b/src/tracks/ui/TimeShiftHandle.h index 77a38220bb..568f4548c8 100644 --- a/src/tracks/ui/TimeShiftHandle.h +++ b/src/tracks/ui/TimeShiftHandle.h @@ -38,7 +38,7 @@ class SAUCEDACITY_DLL_API TrackShifter { virtual ~TrackShifter() = 0; //! There is always an associated track - virtual Track &GetTrack() const = 0; + [[nodiscard]] virtual Track &GetTrack() const = 0; //! Possibilities for HitTest on the clicked track enum class HitTestResult { @@ -69,14 +69,14 @@ class SAUCEDACITY_DLL_API TrackShifter { using Intervals = std::vector; //! Return special intervals of the track that will not move - const Intervals &FixedIntervals() const { return mFixed; } + [[nodiscard]] const Intervals &FixedIntervals() const { return mFixed; } //! Return special intervals of the track that may move - const Intervals &MovingIntervals() const { return mMoving; } + [[nodiscard]] const Intervals &MovingIntervals() const { return mMoving; } //! Change intervals satisfying a predicate from fixed to moving void UnfixIntervals( - std::function< bool( const TrackInterval& ) > pred ); + const std::function< bool( const TrackInterval& ) >& pred ); //! Change all intervals from fixed to moving void UnfixAll(); @@ -152,7 +152,7 @@ class SAUCEDACITY_DLL_API TrackShifter { // This function is used by the keyboard interface for time shifting. // It adjusts t0 after the move to take into account // any rounding errors if this is necessary. - virtual double AdjustT0(double t0) const; + [[nodiscard]] virtual double AdjustT0(double t0) const; protected: /*! Unfix any of the intervals that intersect the given one; may be useful to override `SelectInterval()` */ @@ -161,13 +161,13 @@ class SAUCEDACITY_DLL_API TrackShifter { /*! May be useful to override `MayMigrateTo()`, if certain other needed overrides are given. Returns true, iff: tracks have same type, and corresponding positions in their channel groups, which have same size */ - bool CommonMayMigrateTo( Track &otherTrack ); + bool CommonMayMigrateTo( Track &otherTrack ) const; //! Derived class constructor can initialize all intervals reported by the track as fixed, none moving /*! This can't be called by the base class constructor, when GetTrack() isn't yet callable */ void InitIntervals(); - bool AllFixed() const { + [[nodiscard]] bool AllFixed() const { return mAllFixed && mMoving.empty(); } @@ -184,7 +184,7 @@ class CoarseTrackShifter final : public TrackShifter { public: CoarseTrackShifter( Track &track ); ~CoarseTrackShifter() override; - Track &GetTrack() const override { return *mpTrack; } + [[nodiscard]] Track &GetTrack() const override { return *mpTrack; } HitTestResult HitTest( double, const ViewInfo&, HitTestParams* ) override; @@ -288,7 +288,7 @@ class SAUCEDACITY_DLL_API TimeShiftHandle : public UIHandle const wxMouseState &state, const wxRect &rect, const std::shared_ptr &pTrack); - virtual ~TimeShiftHandle(); + ~TimeShiftHandle() override; void Enter(bool forward, SaucedacityProject *) override; diff --git a/src/tracks/ui/TrackButtonHandles.cpp b/src/tracks/ui/TrackButtonHandles.cpp index ae3154379d..335c060ba4 100644 --- a/src/tracks/ui/TrackButtonHandles.cpp +++ b/src/tracks/ui/TrackButtonHandles.cpp @@ -73,7 +73,7 @@ UIHandlePtr MinimizeButtonHandle::HitTest TrackInfo::GetMinimizeRect(rect, buttonRect); if (buttonRect.Contains(state.m_x, state.m_y)) { - auto pTrack = static_cast(pCell)->FindTrack(); + auto pTrack = dynamic_cast(pCell)->FindTrack(); auto result = std::make_shared( pTrack, buttonRect ); result = AssignUIHandlePtr(holder, result); return result; @@ -128,7 +128,7 @@ UIHandlePtr SelectButtonHandle::HitTest TrackInfo::GetSelectButtonRect(rect, buttonRect); if (buttonRect.Contains(state.m_x, state.m_y)) { - auto pTrack = static_cast(pCell)->FindTrack(); + auto pTrack = dynamic_cast(pCell)->FindTrack(); auto result = std::make_shared( pTrack, buttonRect ); result = AssignUIHandlePtr(holder, result); return result; @@ -194,7 +194,7 @@ UIHandlePtr CloseButtonHandle::HitTest TrackInfo::GetCloseBoxRect(rect, buttonRect); if (buttonRect.Contains(state.m_x, state.m_y)) { - auto pTrack = static_cast(pCell)->FindTrack(); + auto pTrack = dynamic_cast(pCell)->FindTrack(); auto result = std::make_shared( pTrack, buttonRect ); result = AssignUIHandlePtr(holder, result); return result; @@ -224,7 +224,7 @@ UIHandle::Result MenuButtonHandle::CommitChanges if (!pCell) return RefreshCode::Cancelled; auto pTrack = - static_cast(pCell.get())->FindTrack(); + dynamic_cast(pCell.get())->FindTrack(); if (!pTrack) return RefreshCode::Cancelled; trackPanel.CallAfter( @@ -255,7 +255,7 @@ UIHandlePtr MenuButtonHandle::HitTest TrackInfo::GetTitleBarRect(rect, buttonRect); if (buttonRect.Contains(state.m_x, state.m_y)) { - auto pTrack = static_cast(pCell.get())->FindTrack(); + auto pTrack = dynamic_cast(pCell.get())->FindTrack(); auto result = std::make_shared( pCell, pTrack, buttonRect ); result = AssignUIHandlePtr(holder, result); return result; diff --git a/src/tracks/ui/TrackButtonHandles.h b/src/tracks/ui/TrackButtonHandles.h index 8258d5041b..e47de2e930 100644 --- a/src/tracks/ui/TrackButtonHandles.h +++ b/src/tracks/ui/TrackButtonHandles.h @@ -33,7 +33,7 @@ class MinimizeButtonHandle final : public ButtonHandle MinimizeButtonHandle &operator=(const MinimizeButtonHandle&) = default; - virtual ~MinimizeButtonHandle(); + ~MinimizeButtonHandle() override; static UIHandlePtr HitTest (std::weak_ptr &holder, @@ -59,7 +59,7 @@ class SelectButtonHandle final : public ButtonHandle SelectButtonHandle &operator=(const SelectButtonHandle&) = default; - virtual ~SelectButtonHandle(); + ~SelectButtonHandle() override; static UIHandlePtr HitTest (std::weak_ptr &holder, @@ -87,7 +87,7 @@ class CloseButtonHandle final : public ButtonHandle CloseButtonHandle &operator=(const CloseButtonHandle&) = default; - virtual ~CloseButtonHandle(); + ~CloseButtonHandle() override; static UIHandlePtr HitTest (std::weak_ptr &holder, @@ -115,7 +115,7 @@ class MenuButtonHandle final : public ButtonHandle MenuButtonHandle &operator=(const MenuButtonHandle&) = default; - virtual ~MenuButtonHandle(); + ~MenuButtonHandle() override; static UIHandlePtr HitTest (std::weak_ptr &holder, diff --git a/src/tracks/ui/TrackControls.cpp b/src/tracks/ui/TrackControls.cpp index b7da1d0ac3..f7b184f01e 100644 --- a/src/tracks/ui/TrackControls.cpp +++ b/src/tracks/ui/TrackControls.cpp @@ -13,7 +13,7 @@ Paul Licameli split from TrackPanel.cpp #include "../../Track.h" -TrackControls::TrackControls( std::shared_ptr pTrack ) +TrackControls::TrackControls( const std::shared_ptr& pTrack ) : CommonTrackCell{ pTrack } { } diff --git a/src/tracks/ui/TrackControls.h b/src/tracks/ui/TrackControls.h index 407357e1b3..cbc2a0ce6c 100644 --- a/src/tracks/ui/TrackControls.h +++ b/src/tracks/ui/TrackControls.h @@ -23,9 +23,9 @@ class SAUCEDACITY_DLL_API TrackControls /* not final */ : public CommonTrackCell static const TrackControls &Get( const Track &track ); explicit - TrackControls( std::shared_ptr pTrack ); + TrackControls( const std::shared_ptr& pTrack ); - virtual ~TrackControls() = 0; + ~TrackControls() override = 0; }; #include "AttachedVirtualFunction.h" diff --git a/src/tracks/ui/TrackSelectHandle.cpp b/src/tracks/ui/TrackSelectHandle.cpp index d135d3faee..11ca4ed6a5 100644 --- a/src/tracks/ui/TrackSelectHandle.cpp +++ b/src/tracks/ui/TrackSelectHandle.cpp @@ -24,6 +24,8 @@ Paul Licameli split from TrackPanel.cpp #include #include +#include + #include "../../../images/Cursors.h" #if defined(__WXMAC__) @@ -48,8 +50,8 @@ namespace { } } -TrackSelectHandle::TrackSelectHandle( const std::shared_ptr &pTrack ) - : mpTrack( pTrack ) +TrackSelectHandle::TrackSelectHandle( std::shared_ptr pTrack ) + : mpTrack(std::move( pTrack )) {} UIHandlePtr TrackSelectHandle::HitAnywhere diff --git a/src/tracks/ui/TrackSelectHandle.h b/src/tracks/ui/TrackSelectHandle.h index 458808d33a..f4d2ce9be2 100644 --- a/src/tracks/ui/TrackSelectHandle.h +++ b/src/tracks/ui/TrackSelectHandle.h @@ -21,7 +21,7 @@ class TrackSelectHandle final : public UIHandle TrackSelectHandle(const TrackSelectHandle&) = delete; public: - explicit TrackSelectHandle( const std::shared_ptr &pTrack ); + explicit TrackSelectHandle( std::shared_ptr pTrack ); TrackSelectHandle &operator=(const TrackSelectHandle&) = default; @@ -29,7 +29,7 @@ class TrackSelectHandle final : public UIHandle (std::weak_ptr &holder, const std::shared_ptr &pTrack); - virtual ~TrackSelectHandle(); + ~TrackSelectHandle() override; Result Click (const TrackPanelMouseEvent &event, SaucedacityProject *pProject) override; diff --git a/src/tracks/ui/TrackVRulerControls.h b/src/tracks/ui/TrackVRulerControls.h index 4f89a0c057..2b3c2569a2 100644 --- a/src/tracks/ui/TrackVRulerControls.h +++ b/src/tracks/ui/TrackVRulerControls.h @@ -27,7 +27,7 @@ class SAUCEDACITY_DLL_API TrackVRulerControls /* not final */ explicit TrackVRulerControls( const std::shared_ptr &pTrackView ); - virtual ~TrackVRulerControls() = 0; + ~TrackVRulerControls() override = 0; static TrackVRulerControls &Get( TrackView& ); static const TrackVRulerControls &Get( const TrackView& ); diff --git a/src/tracks/ui/TrackView.cpp b/src/tracks/ui/TrackView.cpp index e0b41fa91b..10330e4255 100644 --- a/src/tracks/ui/TrackView.cpp +++ b/src/tracks/ui/TrackView.cpp @@ -218,7 +218,7 @@ struct TrackPositioner final : ClientData::Base, wxEvtHandler } }; -static const SaucedacityProject::AttachedObjects::RegisteredFactory key{ +const SaucedacityProject::AttachedObjects::RegisteredFactory key{ []( SaucedacityProject &project ){ return std::make_shared< TrackPositioner >( project ); } diff --git a/src/tracks/ui/TrackView.h b/src/tracks/ui/TrackView.h index 311de8a525..653c5b1943 100644 --- a/src/tracks/ui/TrackView.h +++ b/src/tracks/ui/TrackView.h @@ -30,7 +30,7 @@ class SAUCEDACITY_DLL_API TrackView /* not final */ : public CommonTrackCell explicit TrackView( const std::shared_ptr &pTrack ); - virtual ~TrackView() = 0; + ~TrackView() override = 0; // some static conveniences, useful for summation over track iterator // ranges diff --git a/src/tracks/ui/ZoomHandle.h b/src/tracks/ui/ZoomHandle.h index 92edb6615f..4d30386232 100644 --- a/src/tracks/ui/ZoomHandle.h +++ b/src/tracks/ui/ZoomHandle.h @@ -32,7 +32,7 @@ class ZoomHandle final : public UIHandle static UIHandlePtr HitTest (std::weak_ptr &holder, const wxMouseState &state); - virtual ~ZoomHandle(); + ~ZoomHandle() override; bool HandlesRightClick() override; @@ -63,7 +63,7 @@ class ZoomHandle final : public UIHandle TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass ) override; - bool IsDragZooming() const; + [[nodiscard]] bool IsDragZooming() const; int mZoomStart{}, mZoomEnd{}; wxRect mRect{}; diff --git a/src/ui/AccessibleLinksFormatter.cpp b/src/ui/AccessibleLinksFormatter.cpp index ea46ed2cf9..e544cab38e 100644 --- a/src/ui/AccessibleLinksFormatter.cpp +++ b/src/ui/AccessibleLinksFormatter.cpp @@ -39,10 +39,10 @@ AccessibleLinksFormatter::AccessibleLinksFormatter(TranslatableString message) } AccessibleLinksFormatter& AccessibleLinksFormatter::FormatLink( - wxString placeholder, TranslatableString value, std::string targetURL) + const wxString& placeholder, TranslatableString value, std::string targetURL) { mFormatArguments.push_back({ - std::move(placeholder), + placeholder, std::move(value), {}, std::move(targetURL) @@ -52,11 +52,11 @@ AccessibleLinksFormatter& AccessibleLinksFormatter::FormatLink( } AccessibleLinksFormatter& AccessibleLinksFormatter::FormatLink( - wxString placeholder, TranslatableString value, + const wxString& placeholder, TranslatableString value, LinkClickedHandler handler) { mFormatArguments.push_back({ - std::move(placeholder), + placeholder, std::move(value), std::move(handler), {} @@ -172,7 +172,7 @@ void AccessibleLinksFormatter::Populate(ShuttleGui& S) const } std::vector -AccessibleLinksFormatter::ProcessArguments(wxString translatedMessage) const +AccessibleLinksFormatter::ProcessArguments(const wxString& translatedMessage) const { std::vector result; result.reserve(mFormatArguments.size()); diff --git a/src/ui/AccessibleLinksFormatter.h b/src/ui/AccessibleLinksFormatter.h index e4e60d283d..759bae99a0 100644 --- a/src/ui/AccessibleLinksFormatter.h +++ b/src/ui/AccessibleLinksFormatter.h @@ -44,11 +44,11 @@ class AccessibleLinksFormatter final //! Replace placeholder with a link, that will open URL in default browser. AccessibleLinksFormatter& FormatLink( - wxString placeholder, TranslatableString value, std::string targetURL); + const wxString& placeholder, TranslatableString value, std::string targetURL); //! Replace placeholder with a link, that will call a callback provided. AccessibleLinksFormatter& FormatLink( - wxString placeholder, TranslatableString value, + const wxString& placeholder, TranslatableString value, LinkClickedHandler handler); //! Generate the UI. @@ -72,8 +72,8 @@ class AccessibleLinksFormatter final /* Find the positions of the placeholders and sort * arguments according to the positions. */ - std::vector - ProcessArguments(wxString translatedMessage) const; + [[nodiscard]] std::vector + ProcessArguments(const wxString& translatedMessage) const; TranslatableString mMessage; std::vector mFormatArguments; diff --git a/src/widgets/AButton.cpp b/src/widgets/AButton.cpp index 048bee74b2..d707f55c95 100644 --- a/src/widgets/AButton.cpp +++ b/src/widgets/AButton.cpp @@ -135,8 +135,8 @@ class AButton::Listener final : public wxEventFilter { public: - Listener (AButton *button); - ~Listener(); + explicit Listener (AButton *button); + ~Listener() override; int FilterEvent(wxEvent &event) override; @@ -195,11 +195,11 @@ AButton::AButton(wxWindow * parent, wxWindowID id, const wxPoint & pos, const wxSize & size, - ImageRoll up, - ImageRoll over, - ImageRoll down, - ImageRoll overDown, - ImageRoll dis, + const ImageRoll& up, + const ImageRoll& over, + const ImageRoll& down, + const ImageRoll& overDown, + const ImageRoll& dis, bool toggle): wxWindow() { @@ -218,11 +218,11 @@ void AButton::Init(wxWindow * parent, wxWindowID id, const wxPoint & pos, const wxSize & size, - ImageRoll up, - ImageRoll over, - ImageRoll down, - ImageRoll overDown, - ImageRoll dis, + const ImageRoll& up, + const ImageRoll& over, + const ImageRoll& down, + const ImageRoll& overDown, + const ImageRoll& dis, bool toggle) { // Bug in wxWidgets 2.8.12: by default pressing Enter on an AButton is interpreted as @@ -286,11 +286,11 @@ void AButton::SetFocusFromKbd() } void AButton::SetAlternateImages(unsigned idx, - wxImage up, - wxImage over, - wxImage down, - wxImage overDown, - wxImage dis) + const wxImage& up, + const wxImage& over, + const wxImage& down, + const wxImage& overDown, + const wxImage& dis) { if (1 + idx > mImages.size()) mImages.resize(1 + idx); @@ -302,11 +302,11 @@ void AButton::SetAlternateImages(unsigned idx, } void AButton::SetAlternateImages(unsigned idx, - ImageRoll up, - ImageRoll over, - ImageRoll down, - ImageRoll overDown, - ImageRoll dis) + const ImageRoll& up, + const ImageRoll& over, + const ImageRoll& down, + const ImageRoll& overDown, + const ImageRoll& dis) { if (1 + idx > mImages.size()) mImages.resize(1 + idx); @@ -339,7 +339,7 @@ void AButton::SetFocusRect(wxRect & r) mForceFocusRect = true; } -AButton::AButtonState AButton::GetState() +AButton::AButtonState AButton::GetState() const { AButtonState state; @@ -558,12 +558,12 @@ void AButton::OnKillFocus(wxFocusEvent & WXUNUSED(event)) Refresh( false ); } -bool AButton::WasShiftDown() +bool AButton::WasShiftDown() const { return mWasShiftDown; } -bool AButton::WasControlDown() +bool AButton::WasControlDown() const { return mWasControlDown; } diff --git a/src/widgets/AButton.h b/src/widgets/AButton.h index aceeaf3ac0..3c090f5c03 100644 --- a/src/widgets/AButton.h +++ b/src/widgets/AButton.h @@ -34,14 +34,14 @@ class SAUCEDACITY_DLL_API AButton final : public wxWindow { wxWindowID id, const wxPoint & pos, const wxSize & size, - ImageRoll up, - ImageRoll over, - ImageRoll down, - ImageRoll overDown, - ImageRoll dis, + const ImageRoll& up, + const ImageRoll& over, + const ImageRoll& down, + const ImageRoll& overDown, + const ImageRoll& dis, bool toggle); - virtual ~ AButton(); + ~ AButton() override; // hide the inherited function that takes naked wxString: void SetToolTip(const TranslatableString &toolTip); @@ -49,28 +49,28 @@ class SAUCEDACITY_DLL_API AButton final : public wxWindow { // hide the inherited function that takes naked wxString: void SetLabel(const TranslatableString &label); - bool AcceptsFocus() const override { return s_AcceptsFocus; } - bool AcceptsFocusFromKeyboard() const override { return mEnabled; } + [[nodiscard]] bool AcceptsFocus() const override { return s_AcceptsFocus; } + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override { return mEnabled; } void SetFocusFromKbd() override; // Associate a set of four images (button up, highlight, button down, // disabled) with one nondefault state of the button void SetAlternateImages(unsigned idx, - ImageRoll up, - ImageRoll over, - ImageRoll down, - ImageRoll overDown, - ImageRoll dis); + const ImageRoll& up, + const ImageRoll& over, + const ImageRoll& down, + const ImageRoll& overDown, + const ImageRoll& dis); // Associate a set of four images (button up, highlight, button down, // disabled) with one nondefault state of the button void SetAlternateImages(unsigned idx, - wxImage up, - wxImage over, - wxImage down, - wxImage overDown, - wxImage dis); + const wxImage& up, + const wxImage& over, + const wxImage& down, + const wxImage& overDown, + const wxImage& dis); // Choose state of the button void SetAlternateIdx(unsigned idx); @@ -82,7 +82,7 @@ class SAUCEDACITY_DLL_API AButton final : public wxWindow { void SetFocusRect(wxRect & r); - bool IsEnabled() const { return mEnabled; } + [[nodiscard]] bool IsEnabled() const { return mEnabled; } void Disable(); void Enable(); void SetEnabled(bool state) { @@ -106,14 +106,14 @@ class SAUCEDACITY_DLL_API AButton final : public wxWindow { void OnSetFocus(wxFocusEvent & event); void OnKillFocus(wxFocusEvent & event); - bool WasShiftDown(); // returns true if shift was held down + [[nodiscard]] bool WasShiftDown() const; // returns true if shift was held down // the last time the button was clicked - bool WasControlDown(); // returns true if control was held down + [[nodiscard]] bool WasControlDown() const; // returns true if control was held down // the last time the button was clicked - bool IsDown(){ return mButtonIsDown;} + [[nodiscard]] bool IsDown() const{ return mButtonIsDown;} // Double click is detected, but not automatically cleared. - bool IsDoubleClicked() const { return mIsDoubleClicked; } + [[nodiscard]] bool IsDoubleClicked() const { return mIsDoubleClicked; } void ClearDoubleClicked() { mIsDoubleClicked = false; } void SetButtonToggles( bool toggler ){ mToggle = toggler;} @@ -133,7 +133,7 @@ class SAUCEDACITY_DLL_API AButton final : public wxWindow { AButtonDis }; - AButtonState GetState(); + [[nodiscard]] AButtonState GetState() const; void UseDisabledAsDownHiliteImage(bool flag); @@ -153,11 +153,11 @@ class SAUCEDACITY_DLL_API AButton final : public wxWindow { wxWindowID id, const wxPoint & pos, const wxSize & size, - ImageRoll up, - ImageRoll over, - ImageRoll down, - ImageRoll overDown, - ImageRoll dis, + const ImageRoll& up, + const ImageRoll& over, + const ImageRoll& down, + const ImageRoll& overDown, + const ImageRoll& dis, bool toggle); unsigned mAlternateIdx; diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index 08de5f4a3d..a4b024e7ed 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -154,9 +154,9 @@ class TipWindow final : public wxFrame { public: TipWindow(wxWindow *parent, const TranslatableStrings & labels); - virtual ~TipWindow() {} + ~TipWindow() override = default; - wxSize GetSize() const; + [[nodiscard]] wxSize GetSize() const; void SetPos(const wxPoint & pos); void SetLabel(const TranslatableString & label); @@ -191,7 +191,7 @@ TipWindow::TipWindow(wxWindow *parent, const TranslatableStrings & labels) mWidth = mHeight = 0; for ( const auto &label : labels ) { int width, height; - GetTextExtent(label.Translation(), &width, &height, NULL, NULL, &mFont); + GetTextExtent(label.Translation(), &width, &height, nullptr, nullptr, &mFont); mWidth = std::max( mWidth, width ); mHeight = std::max( mHeight, height ); } @@ -329,8 +329,7 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id, } SliderDialog::~SliderDialog() -{ -} += default; bool SliderDialog::TransferDataToWindow() { @@ -585,7 +584,7 @@ void LWSlider::Init(wxWindow * parent, mThumbBitmapHilited = nullptr; mScrollLine = 1.0f; mScrollPage = 5.0f; - mTipPanel = NULL; + mTipPanel = nullptr; AdjustSize(size); @@ -593,8 +592,7 @@ void LWSlider::Init(wxWindow * parent, } LWSlider::~LWSlider() -{ -} += default; wxWindowID LWSlider::GetId() { @@ -1080,7 +1078,7 @@ bool LWSlider::DoShowDialog(wxPoint pos) float value = mCurrentValue; bool changed = false; - SliderDialog dlg( NULL, + SliderDialog dlg( nullptr, wxID_ANY, mName, pos, diff --git a/src/widgets/ASlider.h b/src/widgets/ASlider.h index 4f1ca8dea3..a540729642 100644 --- a/src/widgets/ASlider.h +++ b/src/widgets/ASlider.h @@ -36,13 +36,13 @@ class TipWindow; #define VEL_SLIDER 5 // -50..50 -#define DB_MIN -36.0f +#define DB_MIN (-36.0f) #define DB_MAX 36.0f #define FRAC_MIN 0.0f #define FRAC_MAX 1.0f #define SPEED_MIN 0.01f #define SPEED_MAX 3.0f -#define VEL_MIN -50.0f +#define VEL_MIN (-50.0f) #define VEL_MAX 50.0f // Customizable slider only: If stepValue is STEP_CONTINUOUS, @@ -142,18 +142,18 @@ class SAUCEDACITY_DLL_API LWSlider bool ShowDialog(wxPoint pos); void SetEnabled(bool enabled); - bool GetEnabled() const; + [[nodiscard]] bool GetEnabled() const; - float GetMinValue() const; - float GetMaxValue() const; + [[nodiscard]] float GetMinValue() const; + [[nodiscard]] float GetMaxValue() const; void SetParent(wxWindow *parent) { mParent = parent; } void SendUpdate(float newValue); private: - TranslatableString GetTip(float value) const; - TranslatableStrings GetWidestTips() const; + [[nodiscard]] TranslatableString GetTip(float value) const; + [[nodiscard]] TranslatableStrings GetWidestTips() const; void FormatPopWin(); void SetPopWinPosition(); void CreatePopWin(); @@ -236,7 +236,7 @@ class SAUCEDACITY_DLL_API ASlider /* not final */ : public wxPanel public: struct Options { - Options() {} + Options() { }; int style{ FRAC_SLIDER }; wxOrientation orientation{ wxHORIZONTAL }; @@ -264,10 +264,10 @@ class SAUCEDACITY_DLL_API ASlider /* not final */ : public wxPanel const wxPoint & pos, const wxSize & size, const Options &options = Options{}); - virtual ~ASlider(); + ~ASlider() override; - bool AcceptsFocus() const override { return s_AcceptsFocus; } - bool AcceptsFocusFromKeyboard() const override { return true; } + [[nodiscard]] bool AcceptsFocus() const override { return s_AcceptsFocus; } + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override { return true; } void SetFocusFromKbd() override; @@ -300,7 +300,7 @@ class SAUCEDACITY_DLL_API ASlider /* not final */ : public wxPanel // Overrides of the wxWindow functions with the same semantics bool Enable(bool enable = true) override; - bool IsEnabled() const; + [[nodiscard]] bool IsEnabled() const; private: static bool s_AcceptsFocus; @@ -342,7 +342,7 @@ class SliderDialog final : public wxDialogWrapper float line, float page, LWSlider * pSlider=nullptr); - ~SliderDialog(); + ~SliderDialog() override; float Get(); diff --git a/src/widgets/AttachableScrollBar.cpp b/src/widgets/AttachableScrollBar.cpp index 7d555f5344..075c95eb19 100644 --- a/src/widgets/AttachableScrollBar.cpp +++ b/src/widgets/AttachableScrollBar.cpp @@ -46,12 +46,11 @@ AttachableScrollBar::AttachableScrollBar( long style) : wxScrollBar( parent, id, pos, size, style ) { - mpViewInfo = NULL; + mpViewInfo = nullptr; } -AttachableScrollBar::~AttachableScrollBar(void) -{ -} +AttachableScrollBar::~AttachableScrollBar() += default; // Essentially a float to int conversion. void AttachableScrollBar::SetScrollBarFromViewInfo() @@ -94,7 +93,7 @@ void AttachableScrollBar::SetViewInfo( ViewInfo * view ) void AttachableScrollBar::OnScroll(wxScrollEvent & event) { - if( mpViewInfo == NULL ) + if( mpViewInfo == nullptr ) { event.Skip(); return; diff --git a/src/widgets/AttachableScrollBar.h b/src/widgets/AttachableScrollBar.h index d101870765..4a41fc363e 100644 --- a/src/widgets/AttachableScrollBar.h +++ b/src/widgets/AttachableScrollBar.h @@ -32,7 +32,7 @@ class SAUCEDACITY_DLL_API AttachableScrollBar final : const wxSize& size = wxDefaultSize, long style = wxSB_HORIZONTAL); public: - ~AttachableScrollBar(void); + ~AttachableScrollBar() override; void OnScroll(wxScrollEvent & event); void SetViewInfo( ViewInfo * view ); diff --git a/src/widgets/AuStaticText.cpp b/src/widgets/AuStaticText.cpp index d7575f8a9d..5ccda46470 100644 --- a/src/widgets/AuStaticText.cpp +++ b/src/widgets/AuStaticText.cpp @@ -19,7 +19,7 @@ BEGIN_EVENT_TABLE(AuStaticText, wxWindow) EVT_ERASE_BACKGROUND(AuStaticText::OnErase) END_EVENT_TABLE() -AuStaticText::AuStaticText(wxWindow* parent, wxString textIn) : +AuStaticText::AuStaticText(wxWindow* parent, const wxString& textIn) : wxWindow(parent, wxID_ANY) { int textWidth, textHeight; @@ -29,7 +29,7 @@ AuStaticText::AuStaticText(wxWindow* parent, wxString textIn) : fontSize = 9; #endif wxFont font(fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - GetTextExtent(textIn, &textWidth, &textHeight, NULL, NULL, &font); + GetTextExtent(textIn, &textWidth, &textHeight, nullptr, nullptr, &font); SetFont( font ); SetMinSize( wxSize(textWidth, textHeight) ); diff --git a/src/widgets/AuStaticText.h b/src/widgets/AuStaticText.h index 333018f1e3..da72377ff8 100644 --- a/src/widgets/AuStaticText.h +++ b/src/widgets/AuStaticText.h @@ -19,10 +19,10 @@ class SAUCEDACITY_DLL_API AuStaticText : public wxWindow { public: - AuStaticText(wxWindow* parent, wxString text); + AuStaticText(wxWindow* parent, const wxString& text); void OnPaint(wxPaintEvent & evt); - bool AcceptsFocus() const override { return false; } + [[nodiscard]] bool AcceptsFocus() const override { return false; } void OnErase(wxEraseEvent& event) { diff --git a/src/widgets/AudacityMessageBox.h b/src/widgets/AudacityMessageBox.h index 0a0491548a..86566e80a7 100644 --- a/src/widgets/AudacityMessageBox.h +++ b/src/widgets/AudacityMessageBox.h @@ -22,7 +22,7 @@ extern SAUCEDACITY_DLL_API TranslatableString AudacityMessageBoxCaptionStr(); inline int AudacityMessageBox(const TranslatableString& message, const TranslatableString& caption = XO("Message"), long style = wxOK | wxCENTRE, - wxWindow *parent = NULL, + wxWindow *parent = nullptr, int x = wxDefaultCoord, int y = wxDefaultCoord) { return ::wxMessageBox(message.Translation(), caption.Translation(), diff --git a/src/widgets/BackedPanel.h b/src/widgets/BackedPanel.h index ef7e3d9490..bf60bfa61e 100644 --- a/src/widgets/BackedPanel.h +++ b/src/widgets/BackedPanel.h @@ -23,7 +23,7 @@ class SAUCEDACITY_DLL_API BackedPanel /* not final */ : public wxPanelWrapper { const wxSize & size, long style); - ~BackedPanel(); + ~BackedPanel() override; wxDC &GetBackingDC(); wxDC &GetBackingDCForRepaint(); diff --git a/src/widgets/ErrorDialog.h b/src/widgets/ErrorDialog.h index 5b3cb7ffb7..8a96390423 100644 --- a/src/widgets/ErrorDialog.h +++ b/src/widgets/ErrorDialog.h @@ -30,9 +30,9 @@ class ErrorDialog /* not final */ : public wxDialogWrapper const TranslatableString & message, const ManualPageID & helpPage, const std::wstring & log, - const bool Close = true, const bool modal = true); + bool Close = true, bool modal = true); - virtual ~ErrorDialog(){} + ~ErrorDialog() override{} private: ManualPageID dhelpPage; diff --git a/src/widgets/ExpandingToolBar.cpp b/src/widgets/ExpandingToolBar.cpp index a3b6890c0f..029599aaea 100644 --- a/src/widgets/ExpandingToolBar.cpp +++ b/src/widgets/ExpandingToolBar.cpp @@ -122,20 +122,20 @@ ExpandingToolBar::ExpandingToolBar(wxWindow* parent, mIsExpanded(false), mAutoExpand(true), mFirstTime(true), - mFrameParent(NULL), - mDialogParent(NULL), - mAreaParent(NULL), + mFrameParent(nullptr), + mDialogParent(nullptr), + mAreaParent(nullptr), mSavedArrangement{}, - mTopLevelParent(NULL) + mTopLevelParent(nullptr) { mMainPanel = safenew wxPanelWrapper(this, -1, wxDefaultPosition, wxSize(1, 1)); mExtraPanel = safenew wxPanelWrapper(this, -1, wxDefaultPosition, wxSize(1, 1)); - mGrabber = NULL; + mGrabber = nullptr; - ToolBarArea *toolBarParent = + auto *toolBarParent = dynamic_cast(GetParent()); if (toolBarParent) mGrabber = safenew ToolBarGrabber(this, -1, this); @@ -176,7 +176,7 @@ void ExpandingToolBar::OnSize(wxSizeEvent & WXUNUSED(event)) // for it during our first OnSize event. if (!mFrameParent) { - ToolBarFrame *toolBarParent = + auto *toolBarParent = dynamic_cast(GetParent()); if (toolBarParent) { // We were placed into a floating window @@ -186,7 +186,7 @@ void ExpandingToolBar::OnSize(wxSizeEvent & WXUNUSED(event)) } if (!mDialogParent) { - ToolBarDialog *toolBarParent = + auto *toolBarParent = dynamic_cast(GetParent()); if (toolBarParent) { // We were placed into a dialog @@ -196,7 +196,7 @@ void ExpandingToolBar::OnSize(wxSizeEvent & WXUNUSED(event)) } if (!mAreaParent) { - ToolBarArea *toolBarParent = + auto *toolBarParent = dynamic_cast(GetParent()); if (toolBarParent) { // We were placed into an area full of other toolbars @@ -293,7 +293,7 @@ class ExpandingToolBarEvtHandler final : public wxEvtHandler return mInheritedEvtHandler->ProcessEvent(evt); } - ~ExpandingToolBarEvtHandler() + ~ExpandingToolBarEvtHandler() override { mWindow->RemoveEventHandler(this); } @@ -626,7 +626,7 @@ void ExpandingToolBar::FinishMoving() // DELETE mTargetPanel; // I think this is not needed, but unreachable anyway -- PRL - mAreaParent->SetCapturedChild(NULL); + mAreaParent->SetCapturedChild(nullptr); mDragImage->Hide(); mDragImage->EndDrag(); @@ -746,7 +746,7 @@ ToolBarDialog::ToolBarDialog(wxWindow* parent, wxSYSTEM_MENU | #endif wxCAPTION|wxCLOSE_BOX), - mChild(NULL) + mChild(nullptr) { } @@ -798,7 +798,7 @@ ToolBarFrame::ToolBarFrame(wxWindow* parent, wxSYSTEM_MENU | #endif wxCAPTION|wxCLOSE_BOX), - mChild(NULL) + mChild(nullptr) { } @@ -848,7 +848,7 @@ ToolBarArea::ToolBarArea(wxWindow* parent, const wxSize& size): wxPanelWrapper(parent, id, pos, size), mInOnSize(false), - mCapturedChild(NULL) + mCapturedChild(nullptr) { } @@ -1236,15 +1236,15 @@ std::vector ToolBarArea::GetDropTargets() row = childRow; mDropTargetIndices.push_back(i); mDropTargetRows.push_back(row); - mDropTargets.push_back(wxRect(childRect.x, childRect.y, - 0, childRect.height)); + mDropTargets.emplace_back(childRect.x, childRect.y, + 0, childRect.height); } // Add a target after this child (always) mDropTargetIndices.push_back(i+1); mDropTargetRows.push_back(row); - mDropTargets.push_back(wxRect(childRect.x+childRect.width, childRect.y, - 0, childRect.height)); + mDropTargets.emplace_back(childRect.x+childRect.width, childRect.y, + 0, childRect.height); } return mDropTargets; diff --git a/src/widgets/ExpandingToolBar.h b/src/widgets/ExpandingToolBar.h index 74ed0ef499..25d7bb0712 100644 --- a/src/widgets/ExpandingToolBar.h +++ b/src/widgets/ExpandingToolBar.h @@ -51,18 +51,18 @@ class ExpandingToolBar final : public wxPanelWrapper const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - virtual ~ExpandingToolBar(); + ~ExpandingToolBar() override; wxPanel *GetMainPanel() { return mMainPanel; } wxPanel *GetExtraPanel() { return mExtraPanel; } void SetAutoExpand(bool enabled) { mAutoExpand = enabled; } - bool GetAutoExpand() { return mAutoExpand; } + bool GetAutoExpand() const { return mAutoExpand; } void Expand(); void Collapse(bool now = false); - bool IsExpanded() { return mIsExpanded; } + bool IsExpanded() const { return mIsExpanded; } void OnSize(wxSizeEvent &evt); void OnToggle(wxCommandEvent &evt); @@ -154,7 +154,7 @@ class ToolBarDialog final : public wxDialogWrapper const TranslatableString& name = {}, const wxPoint& pos = wxDefaultPosition); - ~ToolBarDialog(); + ~ToolBarDialog() override; void Fit() override; @@ -176,7 +176,7 @@ class ToolBarFrame final : public wxMiniFrame const wxString& name = {}, const wxPoint& pos = wxDefaultPosition); - ~ToolBarFrame(); + ~ToolBarFrame() override; void Fit() override; @@ -202,7 +202,7 @@ class ToolBarArea final : public wxPanelWrapper wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - ~ToolBarArea(); + ~ToolBarArea() override; bool Layout() override; void Fit() override; diff --git a/src/widgets/FileDialog/FileDialog.cpp b/src/widgets/FileDialog/FileDialog.cpp index 663b614dec..fce438bf7c 100644 --- a/src/widgets/FileDialog/FileDialog.cpp +++ b/src/widgets/FileDialog/FileDialog.cpp @@ -18,13 +18,13 @@ custom controls. FileDialogBase::FileDialogBase() { - m_creator = NULL; + m_creator = nullptr; m_userdata = 0; } bool FileDialogBase::HasUserPaneCreator() const { - return m_creator != NULL; + return m_creator != nullptr; } void FileDialogBase::SetUserPaneCreator(UserPaneCreatorFunction creator, wxUIntPtr userdata) diff --git a/src/widgets/FileDialog/FileDialog.h b/src/widgets/FileDialog/FileDialog.h index ffe3693e36..c832e7568b 100644 --- a/src/widgets/FileDialog/FileDialog.h +++ b/src/widgets/FileDialog/FileDialog.h @@ -23,13 +23,13 @@ class SAUCEDACITY_DLL_API FileDialogBase : public wxFileDialogBase { public: FileDialogBase(); - virtual ~FileDialogBase() {}; + ~FileDialogBase() override {}; // FileDialogBase typedef void (*UserPaneCreatorFunction)(wxWindow *parent, wxUIntPtr userdata); - virtual bool HasUserPaneCreator() const; + [[nodiscard]] virtual bool HasUserPaneCreator() const; virtual void SetUserPaneCreator(UserPaneCreatorFunction creator, wxUIntPtr userdata); virtual void SetFileExtension(const wxString& extension) {}; @@ -75,7 +75,7 @@ FileSelector(const wxString& message = wxFileSelectorPromptStr, const wxString& default_extension = wxEmptyString, const wxString& wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, - wxWindow *parent = NULL, + wxWindow *parent = nullptr, int x = wxDefaultCoord, int y = wxDefaultCoord); // An extended version of FileSelector @@ -83,10 +83,10 @@ wxString FileSelectorEx(const wxString& message = wxFileSelectorPromptStr, const wxString& default_path = wxEmptyString, const wxString& default_filename = wxEmptyString, - int *indexDefaultExtension = NULL, + int *indexDefaultExtension = nullptr, const wxString& wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, - wxWindow *parent = NULL, + wxWindow *parent = nullptr, int x = wxDefaultCoord, int y = wxDefaultCoord); #endif diff --git a/src/widgets/FileDialog/gtk/FileDialogPrivate.cpp b/src/widgets/FileDialog/gtk/FileDialogPrivate.cpp index fcf8f0160e..be13fe2e9c 100644 --- a/src/widgets/FileDialog/gtk/FileDialogPrivate.cpp +++ b/src/widgets/FileDialog/gtk/FileDialogPrivate.cpp @@ -38,7 +38,7 @@ class wxGtkString explicit wxGtkString(gchar *s) : m_str(s) { } ~wxGtkString() { g_free(m_str); } - const gchar *c_str() const { return m_str; } + [[nodiscard]] const gchar *c_str() const { return m_str; } operator gchar *() const { return m_str; } @@ -150,8 +150,8 @@ static void gtk_filedialog_update_preview_callback(GtkFileChooser *chooser, if ( !filename ) return; - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(filename, 128, 128, NULL); - gboolean have_preview = pixbuf != NULL; + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(filename, 128, 128, nullptr); + gboolean have_preview = pixbuf != nullptr; gtk_image_set_from_pixbuf(GTK_IMAGE(preview), pixbuf); if ( pixbuf ) @@ -177,7 +177,7 @@ static GtkWidget* find_widget(GtkWidget* parent, const gchar* name, int depth) { // printf("%*.*c%s\n", depth, depth, ' ', gtk_widget_get_name(parent)); - GtkWidget *widget = NULL; + GtkWidget *widget = nullptr; if (g_ascii_strncasecmp(gtk_widget_get_name(parent), name, strlen(name)) == 0) { return parent; @@ -285,7 +285,7 @@ bool FileDialog::Create(wxWindow *parent, const wxString& message, } GtkFileChooserAction gtk_action; - GtkWindow* gtk_parent = NULL; + GtkWindow* gtk_parent = nullptr; if (parent) gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); @@ -427,7 +427,7 @@ FileDialog::~FileDialog() // get chooser to drop its reference right now, allowing wxWindow dtor // to verify that ref count drops to zero gtk_file_chooser_set_extra_widget( - GTK_FILE_CHOOSER(m_widget), NULL); + GTK_FILE_CHOOSER(m_widget), nullptr); } } @@ -447,15 +447,15 @@ int FileDialog::ShowModal() WX_HOOK_MODAL_DIALOG(); // Create the root window - wxBoxSizer *verticalSizer = new wxBoxSizer(wxVERTICAL); - wxPanel *root = new wxPanel(this, wxID_ANY); + auto *verticalSizer = new wxBoxSizer(wxVERTICAL); + auto *root = new wxPanel(this, wxID_ANY); if (HasUserPaneCreator()) { - wxPanel *userpane = new wxPanel(root, wxID_ANY); + auto *userpane = new wxPanel(root, wxID_ANY); CreateUserPane(userpane); - wxBoxSizer *horizontalSizer = new wxBoxSizer(wxHORIZONTAL); + auto *horizontalSizer = new wxBoxSizer(wxHORIZONTAL); horizontalSizer->Add(userpane, 1, wxEXPAND, 0); verticalSizer->Add(horizontalSizer, 1, wxEXPAND|wxALL, 0); } diff --git a/src/widgets/FileDialog/gtk/FileDialogPrivate.h b/src/widgets/FileDialog/gtk/FileDialogPrivate.h index 08bd7abea3..f7964aa4dc 100644 --- a/src/widgets/FileDialog/gtk/FileDialogPrivate.h +++ b/src/widgets/FileDialog/gtk/FileDialogPrivate.h @@ -44,11 +44,11 @@ class WXDLLIMPEXP_CORE FileDialog: public FileDialogBase const wxString& name = wxFileDialogNameStr); virtual ~FileDialog(); - virtual wxString GetPath() const; + [[nodiscard]] virtual wxString GetPath() const; virtual void GetPaths(wxArrayString& paths) const; - virtual wxString GetFilename() const; + [[nodiscard]] virtual wxString GetFilename() const; virtual void GetFilenames(wxArrayString& files) const; - virtual int GetFilterIndex() const; + [[nodiscard]] virtual int GetFilterIndex() const; virtual void SetMessage(const wxString& message); virtual void SetPath(const wxString& path); @@ -59,7 +59,7 @@ class WXDLLIMPEXP_CORE FileDialog: public FileDialogBase virtual int ShowModal(); - virtual bool SupportsExtraControl() const { return true; } + [[nodiscard]] virtual bool SupportsExtraControl() const { return true; } virtual void SetFileExtension(const wxString& extension); diff --git a/src/widgets/FileHistory.cpp b/src/widgets/FileHistory.cpp index 84d535031f..2ee28a29f6 100644 --- a/src/widgets/FileHistory.cpp +++ b/src/widgets/FileHistory.cpp @@ -104,7 +104,7 @@ void FileHistory::UseMenu(wxMenu *menu) auto found = (iter != end); if (!found) - mMenus.push_back(menu); + mMenus.emplace_back(menu); else { wxASSERT(false); } @@ -154,7 +154,7 @@ void FileHistory::Save(wxConfigBase & config) void FileHistory::NotifyMenus() { Compress(); - for (auto pMenu : mMenus) + for (const auto& pMenu : mMenus) if (pMenu) NotifyMenu(pMenu); Save(*gPrefs); @@ -172,11 +172,11 @@ void FileHistory::NotifyMenu(wxMenu *menu) menu->Append(mIDBase + 1 + i,item); } - if (mHistory.size() > 0) { + if (!mHistory.empty()) { menu->AppendSeparator(); } menu->Append(mIDBase, _("&Clear")); - menu->Enable(mIDBase, mHistory.size() > 0); + menu->Enable(mIDBase, !mHistory.empty()); } void FileHistory::Compress() diff --git a/src/widgets/FileHistory.h b/src/widgets/FileHistory.h index 064174d5c1..244c901035 100644 --- a/src/widgets/FileHistory.h +++ b/src/widgets/FileHistory.h @@ -53,10 +53,10 @@ class SAUCEDACITY_DLL_API FileHistory // stl-style accessors using const_iterator = FilePaths::const_iterator; - const_iterator begin() const { return mHistory.begin(); } - const_iterator end() const { return mHistory.end(); } + [[nodiscard]] const_iterator begin() const { return mHistory.begin(); } + [[nodiscard]] const_iterator end() const { return mHistory.end(); } const FilePath &operator[] ( size_t ii ) const { return mHistory[ ii ]; } - bool empty() const { return mHistory.empty(); } + [[nodiscard]] bool empty() const { return mHistory.empty(); } private: void AddFileToHistory(const FilePath & file, bool update); diff --git a/src/widgets/Grabber.h b/src/widgets/Grabber.h index 102cf95d0a..12296003e4 100644 --- a/src/widgets/Grabber.h +++ b/src/widgets/Grabber.h @@ -60,7 +60,7 @@ class GrabberEvent final : public wxCommandEvent GrabberEvent(const GrabberEvent & event) = default; // Position of event (in screen coordinates) - const wxPoint & GetPosition() const + [[nodiscard]] const wxPoint & GetPosition() const { return mPos; } @@ -70,10 +70,10 @@ class GrabberEvent final : public wxCommandEvent mPos = pos; } - bool IsEscaping() const { return mEscaping; } + [[nodiscard]] bool IsEscaping() const { return mEscaping; } // Clone is required by wxwidgets; implemented via copy constructor - wxEvent *Clone() const override + [[nodiscard]] wxEvent *Clone() const override { return safenew GrabberEvent(*this); } @@ -104,7 +104,7 @@ class SAUCEDACITY_DLL_API Grabber final : public wxWindow public: Grabber(wxWindow *parent, wxWindowID id); - virtual ~Grabber(); + ~Grabber() override; // We don't need or want to accept focus since there's really // not a need to dock/float a toolbar from the keyboard. If this @@ -112,7 +112,7 @@ class SAUCEDACITY_DLL_API Grabber final : public wxWindow // handling. // Note that AcceptsFocusFromKeyboard() rather than AcceptsFocus() // is overridden so that ESC can cancel toolbar drag. - bool AcceptsFocusFromKeyboard() const override {return false;} + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override {return false;} void PushButton(bool state); void SetAsSpacer( bool bIsSpacer ); diff --git a/src/widgets/Grid.cpp b/src/widgets/Grid.cpp index 4d7b7c92a0..48f725ac9f 100644 --- a/src/widgets/Grid.cpp +++ b/src/widgets/Grid.cpp @@ -260,8 +260,8 @@ void NumericRenderer::Draw(wxGrid &grid, wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); wxGridTableBase *table = grid.GetTable(); - NumericEditor *ne = - static_cast(grid.GetCellEditor(row, col)); + auto *ne = + dynamic_cast(grid.GetCellEditor(row, col)); wxString tstr; if (ne) { @@ -318,8 +318,8 @@ wxSize NumericRenderer::GetBestSize(wxGrid &grid, int col) { wxGridTableBase *table = grid.GetTable(); - NumericEditor *ne = - static_cast(grid.GetCellEditor(row, col)); + auto *ne = + dynamic_cast(grid.GetCellEditor(row, col)); wxSize sz; if (ne) { @@ -565,7 +565,7 @@ void Grid::OnKeyDown(wxKeyEvent &event) { case 'C': // Copy { - wxTextDataObject *data = safenew wxTextDataObject(GetCellValue(crow, ccol)); + auto *data = safenew wxTextDataObject(GetCellValue(crow, ccol)); wxClipboard::Get()->SetData(data); return; } @@ -573,7 +573,7 @@ void Grid::OnKeyDown(wxKeyEvent &event) case 'X': // Cut { - wxTextDataObject *data = safenew wxTextDataObject(GetCellValue(crow, ccol)); + auto *data = safenew wxTextDataObject(GetCellValue(crow, ccol)); wxClipboard::Get()->SetData(data); SetCellValue(crow, ccol, "" ); return; diff --git a/src/widgets/Grid.h b/src/widgets/Grid.h index e82bbf1102..880ef98279 100644 --- a/src/widgets/Grid.h +++ b/src/widgets/Grid.h @@ -41,7 +41,7 @@ class SAUCEDACITY_DLL_API NumericEditor /* not final */ : public wxGridCellEdito NumericEditor (NumericConverter::Type type, const NumericFormatSymbol &format, double rate); - ~NumericEditor(); + ~NumericEditor() override; // Precondition: parent != NULL void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler) override; @@ -58,16 +58,16 @@ class SAUCEDACITY_DLL_API NumericEditor /* not final */ : public wxGridCellEdito void Reset() override; - NumericFormatSymbol GetFormat() const; - double GetRate() const; + [[nodiscard]] NumericFormatSymbol GetFormat() const; + [[nodiscard]] double GetRate() const; void SetFormat(const NumericFormatSymbol &format); void SetRate(double rate); - wxGridCellEditor *Clone() const override; - wxString GetValue() const override; + [[nodiscard]] wxGridCellEditor *Clone() const override; + [[nodiscard]] wxString GetValue() const override; - NumericTextCtrl *GetNumericTextControl() const - { return static_cast(m_control); } + [[nodiscard]] NumericTextCtrl *GetNumericTextControl() const + { return dynamic_cast(m_control); } private: @@ -103,7 +103,7 @@ class NumericRenderer final : public wxGridCellRenderer int row, int col) override; - wxGridCellRenderer *Clone() const override; + [[nodiscard]] wxGridCellRenderer *Clone() const override; private: NumericConverter::Type mType; @@ -122,11 +122,11 @@ class SAUCEDACITY_DLL_API ChoiceEditor final public: ChoiceEditor(size_t count = 0, - const wxString choices[] = NULL); + const wxString choices[] = nullptr); ChoiceEditor(const wxArrayString &choices); - ~ChoiceEditor(); + ~ChoiceEditor() override; void Create(wxWindow *parent, wxWindowID id, @@ -140,14 +140,14 @@ class SAUCEDACITY_DLL_API ChoiceEditor final void ApplyEdit(int row, int col, wxGrid *grid) override; void Reset() override; - wxGridCellEditor *Clone() const override; + [[nodiscard]] wxGridCellEditor *Clone() const override; void SetChoices(const wxArrayString &choices); - wxString GetValue() const override; + [[nodiscard]] wxString GetValue() const override; protected: - wxChoice *Choice() const { return (wxChoice *)m_control; } + [[nodiscard]] wxChoice *Choice() const { return (wxChoice *)m_control; } private: @@ -155,20 +155,19 @@ class SAUCEDACITY_DLL_API ChoiceEditor final class FocusHandler:wxEvtHandler { public: - void ConnectEvent(wxWindow *w) + static void ConnectEvent(wxWindow *w) { // Need to use a named function pointer, not a lambda, so that we // can unbind the same later w->GetEventHandler()->Bind(wxEVT_KILL_FOCUS, OnKillFocus); }; - void DisconnectEvent(wxWindow *w) + static void DisconnectEvent(wxWindow *w) { w->GetEventHandler()->Unbind(wxEVT_KILL_FOCUS, OnKillFocus); }; static void OnKillFocus(wxFocusEvent & WXUNUSED(event)) { - return; - }; + }; } mHandler; wxArrayString mChoices; @@ -193,7 +192,7 @@ class SAUCEDACITY_DLL_API Grid final : public wxGrid long style = wxWANTS_CHARS | wxBORDER, const wxString& name = wxPanelNameStr); - ~Grid(); + ~Grid() override; #if wxUSE_ACCESSIBILITY void ClearGrid(); diff --git a/src/widgets/HelpSystem.cpp b/src/widgets/HelpSystem.cpp index 184434a197..79171a6a51 100644 --- a/src/widgets/HelpSystem.cpp +++ b/src/widgets/HelpSystem.cpp @@ -73,7 +73,7 @@ class HtmlTextHelpDialog final : public BrowserDialog MakeModal( true ); #endif } - virtual ~HtmlTextHelpDialog() + ~HtmlTextHelpDialog() override { #if !wxCHECK_VERSION(3, 0, 0) MakeModal( false ); @@ -231,8 +231,6 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent, } html->SetRelatedStatusBar( 0 ); - - return; } // Shows help in browser, or possibly in own dialog. @@ -499,11 +497,11 @@ void BrowserDialog::OnKeyDown(wxKeyEvent & event) void BrowserDialog::UpdateButtons() { wxWindow * pWnd; - if( (pWnd = FindWindowById( wxID_BACKWARD, this )) != NULL ) + if( (pWnd = FindWindowById( wxID_BACKWARD, this )) != nullptr ) { pWnd->Enable(mpHtml->HistoryCanBack()); } - if( (pWnd = FindWindowById( wxID_FORWARD, this )) != NULL ) + if( (pWnd = FindWindowById( wxID_FORWARD, this )) != nullptr ) { pWnd->Enable(mpHtml->HistoryCanForward()); } diff --git a/src/widgets/HelpSystem.h b/src/widgets/HelpSystem.h index 0119d9b687..5fa330e15b 100644 --- a/src/widgets/HelpSystem.h +++ b/src/widgets/HelpSystem.h @@ -43,7 +43,7 @@ class SAUCEDACITY_DLL_API HelpSystem const TranslatableString &dlogTitle, const TranslatableString &shortMsg, const wxString &message, - const int xSize, const int ySize); + int xSize, int ySize); /// Displays a NEW window with wxHTML help. /// @param HtmlText Either the literal HTML code to go into the window, diff --git a/src/widgets/HtmlWindow.h b/src/widgets/HtmlWindow.h index a2f16f0741..68dd68a91f 100644 --- a/src/widgets/HtmlWindow.h +++ b/src/widgets/HtmlWindow.h @@ -41,7 +41,7 @@ class SAUCEDACITY_DLL_API HtmlWindow /* not final */ : public wxHtmlWindow const wxSize& size = wxDefaultSize, long style = wxHW_DEFAULT_STYLE, const wxString& name = wxT("htmlWindow")); - virtual ~HtmlWindow(); + ~HtmlWindow() override; }; #endif diff --git a/src/widgets/ImageRoll.cpp b/src/widgets/ImageRoll.cpp index 8e949d099e..3c9d928a11 100644 --- a/src/widgets/ImageRoll.cpp +++ b/src/widgets/ImageRoll.cpp @@ -107,7 +107,7 @@ ImageRoll &ImageRoll::operator =(const ImageRoll&) = default; ImageRoll::~ImageRoll() = default; // static -ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor) +ImageArray ImageRoll::SplitH(const wxImage &src, const wxColour& magicColor) { ImageArray result; @@ -122,7 +122,7 @@ ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor) int i, j, start; // Sanity check... - if (width<=0 || height<=0 || data==NULL) + if (width<=0 || height<=0 || data==nullptr) return result; prev = false; @@ -163,7 +163,7 @@ ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor) } // static -ImageArray ImageRoll::SplitV(const wxImage &src, wxColour magicColor) +ImageArray ImageRoll::SplitV(const wxImage &src, const wxColour& magicColor) { ImageArray result; int width = src.GetWidth(); @@ -177,7 +177,7 @@ ImageArray ImageRoll::SplitV(const wxImage &src, wxColour magicColor) int i, j, start; // Sanity check... - if (width<=0 || height<=0 || data==NULL) + if (width<=0 || height<=0 || data==nullptr) return result; prev = false; @@ -217,7 +217,7 @@ ImageArray ImageRoll::SplitV(const wxImage &src, wxColour magicColor) return result; } -void ImageRoll::Init(RollType type, const wxImage &src, wxColour magicColor) +void ImageRoll::Init(RollType type, const wxImage &src, const wxColour& magicColor) { ImageArray images; int i; @@ -235,11 +235,11 @@ void ImageRoll::Init(RollType type, const wxImage &src, wxColour magicColor) for(i = 0; i < (int)images.size(); i++) { if (images[i].Ok()) { - mPieces.push_back(wxBitmap(images[i])); + mPieces.emplace_back(images[i]); mMinSize.x += mPieces[i].GetWidth(); } else - mPieces.push_back(wxBitmap()); + mPieces.emplace_back(); } break; @@ -253,16 +253,16 @@ void ImageRoll::Init(RollType type, const wxImage &src, wxColour magicColor) for(i = 0; i < (int)images.size(); i++) { if (images[i].Ok()) { - mPieces.push_back(wxBitmap(images[i])); + mPieces.emplace_back(images[i]); mMinSize.y += mPieces[i].GetHeight(); } else - mPieces.push_back(wxBitmap()); + mPieces.emplace_back(); } break; case FixedImage: - mPieces.push_back(wxBitmap(src)); + mPieces.emplace_back(src); mMinSize.x = src.GetWidth(); mMinSize.y = src.GetHeight(); mMaxSize.x = src.GetWidth(); @@ -285,7 +285,7 @@ ImageRoll::ImageRoll() mType = Uninitialized; } -ImageRoll::ImageRoll(RollType type, const wxImage &src, wxColour magicColor) +ImageRoll::ImageRoll(RollType type, const wxImage &src, const wxColour& magicColor) { Init(type, src, magicColor); } diff --git a/src/widgets/ImageRoll.h b/src/widgets/ImageRoll.h index eb3a8836c2..a9d5431962 100644 --- a/src/widgets/ImageRoll.h +++ b/src/widgets/ImageRoll.h @@ -37,28 +37,28 @@ class SAUCEDACITY_DLL_API ImageRoll ImageRoll(); ImageRoll(const wxImage &src); - ImageRoll(RollType type, const wxImage &src, wxColour magicColor); + ImageRoll(RollType type, const wxImage &src, const wxColour& magicColor); ImageRoll(const ImageRoll&); ImageRoll &operator =(const ImageRoll&); ~ImageRoll(); - bool Ok() const; + [[nodiscard]] bool Ok() const; - wxSize GetMinSize() const { return mMinSize; } - wxSize GetMaxSize() const { return mMaxSize; } + [[nodiscard]] wxSize GetMinSize() const { return mMinSize; } + [[nodiscard]] wxSize GetMaxSize() const { return mMaxSize; } void Draw(wxDC &dc, wxRect rect); - static ImageArray SplitH(const wxImage &src, wxColour magicColor); - static ImageArray SplitV(const wxImage &src, wxColour magicColor); + static ImageArray SplitH(const wxImage &src, const wxColour& magicColor); + static ImageArray SplitV(const wxImage &src, const wxColour& magicColor); protected: - void DrawBitmap(wxDC &dc, wxBitmap &bitmap, + static void DrawBitmap(wxDC &dc, wxBitmap &bitmap, int x, int y, int /* wxRasterOperationMode */ logicalFunc); - void Init(RollType type, const wxImage &src, wxColour magicColor); + void Init(RollType type, const wxImage &src, const wxColour& magicColor); RollType mType; // wxBitmap copies cheaply with reference counting diff --git a/src/widgets/KeyView.cpp b/src/widgets/KeyView.cpp index 52635813a7..87801295f2 100644 --- a/src/widgets/KeyView.cpp +++ b/src/widgets/KeyView.cpp @@ -462,8 +462,7 @@ KeyView::SetView(ViewByType type) SelectNode(LineToIndex(0)); } - return; -} + } // // Sets the filter @@ -663,7 +662,7 @@ KeyView::RefreshBindings(const CommandIDs & names, int cnt = (int) names.size(); for (int i = 0; i < cnt; i++) { - auto name = names[i]; + const auto& name = names[i]; int x, y; // Remove any menu code from the category and prefix @@ -1307,8 +1306,7 @@ KeyView::OnDrawItem(wxDC & dc, const wxRect & rect, size_t line) const } } - return; -} + } // // Provide the height of the given line diff --git a/src/widgets/KeyView.h b/src/widgets/KeyView.h index a6008898f5..f121382977 100644 --- a/src/widgets/KeyView.h +++ b/src/widgets/KeyView.h @@ -77,8 +77,8 @@ class KeyView final : public wxVListBox wxWindowID id = wxID_ANY, const wxPoint & pos = wxDefaultPosition, const wxSize & size = wxDefaultSize); - virtual ~KeyView(); - wxString GetName() const override; // Gets the control name from the base class + ~KeyView() override; + [[nodiscard]] wxString GetName() const override; // Gets the control name from the base class void RefreshBindings(const CommandIDs & names, const TranslatableStrings & categories, @@ -87,18 +87,18 @@ class KeyView final : public wxVListBox const std::vector & keys, bool bSort); - int GetSelected() const; + [[nodiscard]] int GetSelected() const; - wxString GetLabel(int index) const; - wxString GetFullLabel(int index) const; + [[nodiscard]] wxString GetLabel(int index) const; + [[nodiscard]] wxString GetFullLabel(int index) const; - int GetIndexByName(const CommandID & name) const; - CommandID GetName(int index) const; - CommandID GetNameByKey(const NormalizedKeyString & key) const; + [[nodiscard]] int GetIndexByName(const CommandID & name) const; + [[nodiscard]] CommandID GetName(int index) const; + [[nodiscard]] CommandID GetNameByKey(const NormalizedKeyString & key) const; - int GetIndexByKey(const NormalizedKeyString & key) const; - NormalizedKeyString GetKey(int index) const; - bool CanSetKey(int index) const; + [[nodiscard]] int GetIndexByKey(const NormalizedKeyString & key) const; + [[nodiscard]] NormalizedKeyString GetKey(int index) const; + [[nodiscard]] bool CanSetKey(int index) const; bool SetKey(int index, const NormalizedKeyString & key); bool SetKeyByName(const CommandID & name, const NormalizedKeyString & key); @@ -116,12 +116,12 @@ class KeyView final : public wxVListBox void UpdateHScroll(); void RefreshLines(bool bSort = true); - int LineToIndex(int line) const; - int IndexToLine(int index) const; + [[nodiscard]] int LineToIndex(int line) const; + [[nodiscard]] int IndexToLine(int index) const; void OnDrawBackground(wxDC & dc, const wxRect & rect, size_t line) const override; void OnDrawItem(wxDC & dc, const wxRect & rect, size_t line) const override; - wxCoord OnMeasureItem(size_t line) const override; + [[nodiscard]] wxCoord OnMeasureItem(size_t line) const override; void OnSelected(wxCommandEvent & event); void OnSetFocus(wxFocusEvent & event); diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index 93ac8f1928..7d6bc8e52a 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -932,9 +932,9 @@ void MeterPanel::Reset(double sampleRate, bool resetClipping) { mT = 0; mRate = sampleRate; - for (int j = 0; j < kMaxMeterBars; j++) + for (auto & j : mBar) { - ResetBar(&mBar[j], resetClipping); + ResetBar(&j, resetClipping); } // wxTimers seem to be a little unreliable - sometimes they stop for @@ -1156,7 +1156,7 @@ float MeterPanel::GetMaxPeak() const return(maxPeak); } -wxFont MeterPanel::GetFont() const +wxFont MeterPanel::GetFont() { int fontSize = 10; #if defined __WXMSW__ @@ -1183,8 +1183,8 @@ void MeterPanel::ResetBar(MeterBar *b, bool resetClipping) bool MeterPanel::IsClipping() const { - for (int c = 0; c < kMaxMeterBars; c++) - if (mBar[c].isclipping) + for (const auto & c : mBar) + if (c.isclipping) return true; return false; } @@ -1893,7 +1893,7 @@ void MeterPanel::StopMonitoring(){ void MeterPanel::OnAudioIOStatus(wxCommandEvent &evt) { evt.Skip(); - SaucedacityProject *p = (SaucedacityProject *) evt.GetEventObject(); + auto *p = (SaucedacityProject *) evt.GetEventObject(); mActive = (evt.GetInt() != 0) && (p == mProject); diff --git a/src/widgets/Meter.h b/src/widgets/Meter.h index 046183db4e..1c2336724f 100644 --- a/src/widgets/Meter.h +++ b/src/widgets/Meter.h @@ -215,9 +215,9 @@ class SAUCEDACITY_DLL_API MeterPanel final void SetActiveStyle(Style style); void SetBarAndClip(int iBar, bool vert); void DrawMeterBar(wxDC &dc, MeterBar *meterBar); - void ResetBar(MeterBar *bar, bool resetClipping); + static void ResetBar(MeterBar *bar, bool resetClipping); void RepaintBarsNow(); - wxFont GetFont() const; + static wxFont GetFont() ; // // Pop-up menu diff --git a/src/widgets/MeterPanelBase.h b/src/widgets/MeterPanelBase.h index 5495e49f9e..b9b1370a55 100644 --- a/src/widgets/MeterPanelBase.h +++ b/src/widgets/MeterPanelBase.h @@ -24,14 +24,14 @@ class SAUCEDACITY_DLL_API MeterPanelBase /* not final */ virtual void Reset(double sampleRate, bool resetClipping) = 0; virtual void UpdateDisplay(unsigned numChannels, int numFrames, float *sampleData) = 0; - virtual bool IsMeterDisabled() const = 0; - virtual float GetMaxPeak() const = 0; + [[nodiscard]] virtual bool IsMeterDisabled() const = 0; + [[nodiscard]] virtual float GetMaxPeak() const = 0; - virtual bool IsClipping() const = 0; - virtual int GetDBRange() const = 0; + [[nodiscard]] virtual bool IsClipping() const = 0; + [[nodiscard]] virtual int GetDBRange() const = 0; - bool AcceptsFocus() const override { return s_AcceptsFocus; } - bool AcceptsFocusFromKeyboard() const override { return true; } + [[nodiscard]] bool AcceptsFocus() const override { return s_AcceptsFocus; } + [[nodiscard]] bool AcceptsFocusFromKeyboard() const override { return true; } private: static bool s_AcceptsFocus; diff --git a/src/widgets/MultiDialog.cpp b/src/widgets/MultiDialog.cpp index 048f1c9eef..41abc79a03 100644 --- a/src/widgets/MultiDialog.cpp +++ b/src/widgets/MultiDialog.cpp @@ -50,7 +50,7 @@ class MultiDialog final : public wxDialogWrapper const TranslatableStrings &buttons, const wxString &helpPage, const TranslatableString &boxMsg, bool log); - ~MultiDialog() {}; + ~MultiDialog() override {}; private: void OnOK( wxCommandEvent &event ); @@ -188,12 +188,12 @@ int ShowMultiDialog(const TranslatableString &message, // window is a STAY_ON_TOP. if (pParent) { if ((pParent->GetWindowStyle() & wxSTAY_ON_TOP) == wxSTAY_ON_TOP) - pParent = NULL; + pParent = nullptr; } MultiDialog dlog(pParent, message, title, buttons, helpPage, boxMsg, log); // If dialog does not have a parent, cannot be centred on it. - if (pParent != NULL) + if (pParent != nullptr) dlog.CentreOnParent(); else { dlog.CenterOnScreen(); diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp index ef723b2fc5..0ec8881b4b 100644 --- a/src/widgets/NumericTextCtrl.cpp +++ b/src/widgets/NumericTextCtrl.cpp @@ -365,7 +365,7 @@ namespace { * array of string pairs for name of the format and the format string * needed to create that format output. This is used for the pop-up * list of formats to choose from in the control. */ -static const BuiltinFormatString TimeConverterFormats_[] = { +const BuiltinFormatString TimeConverterFormats_[] = { { /* i18n-hint: Name of time display format that shows time in seconds */ { XO("seconds") }, @@ -573,7 +573,7 @@ static const BuiltinFormatString TimeConverterFormats_[] = { * array of string pairs for name of the format and the format string * needed to create that format output. This is used for the pop-up * list of formats to choose from in the control. */ -static const BuiltinFormatString FrequencyConverterFormats_[] = { +const BuiltinFormatString FrequencyConverterFormats_[] = { { /* i18n-hint: Name of display format that shows frequency in hertz */ { XO("Hz") }, @@ -605,7 +605,7 @@ static const BuiltinFormatString FrequencyConverterFormats_[] = { * array of string pairs for name of the format and the format string * needed to create that format output. This is used for the pop-up * list of formats to choose from in the control. */ -static const BuiltinFormatString BandwidthConverterFormats_[] = { +const BuiltinFormatString BandwidthConverterFormats_[] = { { /* i18n-hint: Name of display format that shows log of frequency * in octaves */ @@ -830,7 +830,7 @@ void NumericConverter::ParseFormatString( if (inFrac) { int base = fracMult * range; - mFields.push_back(NumericField(inFrac, base, range, zeropad)); + mFields.emplace_back(inFrac, base, range, zeropad); fracMult *= range; numFracFields++; } @@ -838,7 +838,7 @@ void NumericConverter::ParseFormatString( unsigned int j; for(j=0; j 0 && + if (!mFields.empty() && mValueString.Mid(mFields[0].pos, 1) == wxChar('-')) { mValue = mInvalidValue; return; @@ -1191,7 +1191,7 @@ int NumericConverter::GetFormatIndex() return ndx; } -int NumericConverter::GetNumBuiltins() +int NumericConverter::GetNumBuiltins() const { return mNBuiltins; } @@ -1259,10 +1259,10 @@ void NumericConverter::Adjust(int steps, int dir) while (steps != 0) { - for (size_t i = 0; i < mFields.size(); i++) + for (auto & mField : mFields) { - if ((mDigits[mFocusedDigit].pos >= mFields[i].pos) && - (mDigits[mFocusedDigit].pos < mFields[i].pos + mFields[i].digits)) + if ((mDigits[mFocusedDigit].pos >= mField.pos) && + (mDigits[mFocusedDigit].pos < mField.pos + mField.digits)) { //it's this field if (!mNtscDrop) { @@ -1280,14 +1280,14 @@ void NumericConverter::Adjust(int steps, int dir) mValue *= mScalingFactor; - double mult = pow(10., mFields[i].digits - (mDigits[mFocusedDigit].pos - mFields[i].pos) - 1); - if (mFields[i].frac) + double mult = pow(10., mField.digits - (mDigits[mFocusedDigit].pos - mField.pos) - 1); + if (mField.frac) { - mValue += ((mult / (double)mFields[i].base) * dir); + mValue += ((mult / (double)mField.base) * dir); } else { - mValue += ((mult * (double)mFields[i].base) * dir); + mValue += ((mult * (double)mField.base) * dir); } if (mNtscDrop) @@ -1498,7 +1498,7 @@ void NumericTextCtrl::EnableMenu(bool enable) else { wxToolTip *tt = GetToolTip(); if (tt && tt->GetTip() == tip) - SetToolTip(NULL); + SetToolTip(nullptr); } #endif mMenuEnabled = enable; @@ -1589,7 +1589,7 @@ wxSize NumericTextCtrl::ComputeSizing(bool update, wxCoord boxW, wxCoord boxH) // Remember metrics for each digit for (int j = 0, dcnt = mFields[i].digits; j < dcnt; ++j) { - mDigits.push_back(DigitInfo(i, j, pos, wxRect(x, mBorderTop, boxW, boxH))); + mDigits.emplace_back(i, j, pos, wxRect(x, mBorderTop, boxW, boxH)); x += boxW; pos++; } @@ -1609,12 +1609,12 @@ wxSize NumericTextCtrl::ComputeSizing(bool update, wxCoord boxW, wxCoord boxH) } else { // Determine the maximum x-position (length) of the remaining fields - for (int i = 0, fcnt = mFields.size(); i < fcnt; ++i) { + for (auto & mField : mFields) { // Get the size of the label - dc.GetTextExtent(mFields[i].label, &strW, &strH); + dc.GetTextExtent(mField.label, &strW, &strH); // Just bump to next field - x += (boxW * mFields[i].digits) + strW; + x += (boxW * mField.digits) + strW; } } @@ -1859,7 +1859,7 @@ void NumericTextCtrl::OnFocus(wxFocusEvent &event) void NumericTextCtrl::OnCaptureKey(wxCommandEvent &event) { - wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject(); + auto *kevent = (wxKeyEvent *)event.GetEventObject(); int keyCode = kevent->GetKeyCode(); // Convert numeric keypad entries. @@ -1887,8 +1887,6 @@ void NumericTextCtrl::OnCaptureKey(wxCommandEvent &event) } event.Skip(); - - return; } void NumericTextCtrl::OnKeyUp(wxKeyEvent &event) @@ -1911,7 +1909,7 @@ void NumericTextCtrl::OnKeyUp(wxKeyEvent &event) void NumericTextCtrl::OnKeyDown(wxKeyEvent &event) { - if (mDigits.size() == 0) + if (mDigits.empty()) { mFocusedDigit = 0; return; diff --git a/src/widgets/NumericTextCtrl.h b/src/widgets/NumericTextCtrl.h index 7b15c0b92f..6322b6de22 100644 --- a/src/widgets/NumericTextCtrl.h +++ b/src/widgets/NumericTextCtrl.h @@ -21,6 +21,7 @@ #include #include +#include #include #include // for wxUSE_* macros #include @@ -61,9 +62,9 @@ class SAUCEDACITY_DLL_API NumericConverter /* not final */ TranslatableString fraction; FormatStrings( - const TranslatableString &format = {}, - const TranslatableString &fraction = {}) - : formatStr{ format }, fraction{ fraction } + TranslatableString format = {}, + TranslatableString fraction = {}) + : formatStr{std::move( format )}, fraction{std::move( fraction )} {} friend bool operator == ( const FormatStrings &x, const FormatStrings &y ) @@ -124,7 +125,7 @@ class SAUCEDACITY_DLL_API NumericConverter /* not final */ int GetFormatIndex(); - int GetNumBuiltins(); + int GetNumBuiltins() const; NumericFormatSymbol GetBuiltinName(const int index); FormatStrings GetBuiltinFormat(const int index); FormatStrings GetBuiltinFormat(const NumericFormatSymbol & name); @@ -207,7 +208,7 @@ class SAUCEDACITY_DLL_API NumericTextCtrl final const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize); - virtual ~NumericTextCtrl(); + ~NumericTextCtrl() override; // Hide the inherited function that takes wxString void SetName( const TranslatableString &name ); @@ -227,8 +228,8 @@ class SAUCEDACITY_DLL_API NumericTextCtrl final void SetFieldFocus(int /* digit */); - wxSize GetDimensions() { return wxSize(mWidth + mButtonWidth, mHeight); } - wxSize GetDigitSize() { return wxSize(mDigitBoxW, mDigitBoxH); } + wxSize GetDimensions() const { return wxSize(mWidth + mButtonWidth, mHeight); } + wxSize GetDigitSize() const { return wxSize(mDigitBoxW, mDigitBoxH); } void SetDigitSize(int width, int height); void SetReadOnly(bool readOnly = true); void EnableMenu(bool enable = true); @@ -239,7 +240,7 @@ class SAUCEDACITY_DLL_API NumericTextCtrl final // this control returns to the program, so you can specify. void SetInvalidValue(double invalidValue); - int GetFocusedField() { return mLastField; } + int GetFocusedField() const { return mLastField; } int GetFocusedDigit() { return mFocusedDigit; } private: diff --git a/src/widgets/Overlay.h b/src/widgets/Overlay.h index 5d047d2485..4c4e0c5adf 100644 --- a/src/widgets/Overlay.h +++ b/src/widgets/Overlay.h @@ -100,7 +100,7 @@ class SAUCEDACITY_DLL_API Overlay ///\brief This number determines an ordering of overlays, so that those /// with higher numbers overpaint those with lower numbers that intersect - virtual unsigned SequenceNumber() const = 0; + [[nodiscard]] virtual unsigned SequenceNumber() const = 0; // nonvirtual wrapper std::pair GetRectangle(wxSize size); diff --git a/src/widgets/OverlayPanel.cpp b/src/widgets/OverlayPanel.cpp index 360b810e3f..58581ff345 100644 --- a/src/widgets/OverlayPanel.cpp +++ b/src/widgets/OverlayPanel.cpp @@ -60,7 +60,7 @@ void OverlayPanel::DrawOverlays(bool repaint_all, wxDC *pDC) // Find out the rectangles and outdatedness for each overlay wxSize size(GetBackingDC().GetSize()); - for (const auto pOverlay : mOverlays) + for (const auto& pOverlay : mOverlays) pairs.push_back( pOverlay.lock()->GetRectangle(size) ); // See what requires redrawing. If repainting, all. @@ -107,7 +107,7 @@ void OverlayPanel::DrawOverlays(bool repaint_all, wxDC *pDC) // Erase auto it2 = pairs.begin(); - for (auto pOverlay : mOverlays) { + for (const auto& pOverlay : mOverlays) { if (repaint_all || it2->second) pOverlay.lock()->Erase(dc, GetBackingDC()); ++it2; @@ -115,7 +115,7 @@ void OverlayPanel::DrawOverlays(bool repaint_all, wxDC *pDC) // Draw it2 = pairs.begin(); - for (auto pOverlay : mOverlays) { + for (const auto& pOverlay : mOverlays) { if (repaint_all || it2->second) { // Guarantee a clean state of the dc each pass: ADCChanger changer{ &dc }; diff --git a/src/widgets/Plot.cpp b/src/widgets/Plot.cpp index fda1e81425..c9b13ab18b 100644 --- a/src/widgets/Plot.cpp +++ b/src/widgets/Plot.cpp @@ -24,6 +24,8 @@ #include #include +#include + Plot::Plot(wxWindow *parent, wxWindowID winid, float x_min, float x_max, float y_min, float y_max, const TranslatableString& xlabel, const TranslatableString& ylabel, @@ -34,13 +36,13 @@ Plot::Plot(wxWindow *parent, wxWindowID winid, m_xmin(x_min), m_xmax(x_max), m_ymin(y_min), m_ymax(y_max), m_plots(count) { - m_xruler = std::unique_ptr(safenew Ruler); + m_xruler = std::make_unique(); m_xruler->SetOrientation(wxHORIZONTAL); m_xruler->SetFormat(static_cast(xformat)); m_xruler->SetUnits(xlabel); m_xruler->SetFlip(true); - m_yruler = std::unique_ptr(safenew Ruler); + m_yruler = std::make_unique(); m_yruler->SetOrientation(wxVERTICAL); m_yruler->SetFormat(static_cast(yformat)); m_yruler->SetUnits(ylabel); @@ -63,11 +65,11 @@ void Plot::OnPaint(wxPaintEvent & evt) m_xruler->SetBounds(0, 0, width, height); m_xruler->SetRange(m_xmin, m_xmax); - m_xruler->GetMaxSize(NULL, &h); + m_xruler->GetMaxSize(nullptr, &h); m_yruler->SetBounds(0, 0, width, height); m_yruler->SetRange(m_ymax, m_ymin); - m_yruler->GetMaxSize(&w, NULL); + m_yruler->GetMaxSize(&w, nullptr); m_xruler->SetBounds(w, height - h, width, height); m_yruler->SetBounds(0, 0, w, height - h); @@ -91,7 +93,7 @@ void Plot::OnPaint(wxPaintEvent & evt) for(const auto& plot : m_plots) { wxASSERT(plot.xdata.size() == plot.ydata.size()); - if(plot.xdata.size() == 0) + if(plot.xdata.empty()) continue; dc.SetPen(*plot.pen); @@ -118,12 +120,12 @@ void Plot::OnSize(wxSizeEvent & evt) Refresh(false); } -int Plot::XToScreen(float x, wxRect& rect) +int Plot::XToScreen(float x, wxRect& rect) const { return rect.x + lrint((x-m_xmin)*rect.width/(m_xmax-m_xmin)); } -int Plot::YToScreen(float y, wxRect& rect) +int Plot::YToScreen(float y, wxRect& rect) const { return rect.y + rect.height - lrint((y-m_ymin)*rect.height/(m_ymax-m_ymin)); } diff --git a/src/widgets/Plot.h b/src/widgets/Plot.h index 86253f9563..5283917f52 100644 --- a/src/widgets/Plot.h +++ b/src/widgets/Plot.h @@ -49,8 +49,8 @@ class Plot : public wxPanelWrapper std::vector m_plots; std::unique_ptr m_xruler, m_yruler; - int XToScreen(float x, wxRect& rect); - int YToScreen(float y, wxRect& rect); + int XToScreen(float x, wxRect& rect) const; + int YToScreen(float y, wxRect& rect) const; DECLARE_EVENT_TABLE() }; diff --git a/src/widgets/PopupMenuTable.cpp b/src/widgets/PopupMenuTable.cpp index 6f5610e604..d4ca1c9ce6 100644 --- a/src/widgets/PopupMenuTable.cpp +++ b/src/widgets/PopupMenuTable.cpp @@ -90,7 +90,7 @@ void PopupMenuBuilder::DoEndGroup( Registry::GroupItem &item, const Path &path ) void PopupMenuBuilder::DoVisit( Registry::SingleItem &item, const Path &path ) { - auto pEntry = static_cast( &item ); + auto pEntry = dynamic_cast( &item ); switch (pEntry->type) { case PopupMenuTable::Entry::Item: { @@ -192,7 +192,7 @@ void PopupMenu::DisconnectTable(PopupMenuTable *pTable) void DoVisit( Registry::SingleItem &item, const Path &path ) override { - auto pEntry = static_cast( &item ); + auto pEntry = dynamic_cast( &item ); mMenu.pParent->Unbind( wxEVT_COMMAND_MENU_SELECTED, pEntry->func, &pEntry->handler, pEntry->id ); pEntry->handler.DestroyMenu(); diff --git a/src/widgets/ProgressDialog.cpp b/src/widgets/ProgressDialog.cpp index f93ee26d95..bfda051066 100644 --- a/src/widgets/ProgressDialog.cpp +++ b/src/widgets/ProgressDialog.cpp @@ -1115,7 +1115,7 @@ void ProgressDialog::AddMessageAsColumn(wxBoxSizer * pSizer, { sText.Join( text, wxT("\n") ); }); // Create a statictext object and add to the sizer - wxStaticText* oText = safenew wxStaticText(this, + auto* oText = safenew wxStaticText(this, wxID_ANY, sText.Translation(), wxDefaultPosition, diff --git a/src/widgets/ProgressDialog.h b/src/widgets/ProgressDialog.h index c574571aa7..9e860cc460 100644 --- a/src/widgets/ProgressDialog.h +++ b/src/widgets/ProgressDialog.h @@ -74,7 +74,7 @@ class SAUCEDACITY_DLL_API ProgressDialog /* not final */ : public wxDialogWrappe const TranslatableString & sRemainingLabelText = {}); public: - virtual ~ProgressDialog(); + ~ProgressDialog() override; bool Create(const TranslatableString & title, const TranslatableString & message = {}, diff --git a/src/widgets/ReadOnlyText.h b/src/widgets/ReadOnlyText.h index 709da63b4a..0bf4e7f642 100644 --- a/src/widgets/ReadOnlyText.h +++ b/src/widgets/ReadOnlyText.h @@ -103,11 +103,11 @@ class ReadOnlyText final : public wxControl }); }; - ~ReadOnlyText() + ~ReadOnlyText() override { }; - wxSize DoGetBestClientSize() const override + [[nodiscard]] wxSize DoGetBestClientSize() const override { wxClientDC dc(wxConstCast(this, ReadOnlyText)); diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index 3a9cab2b4a..bd728d0a16 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -75,7 +75,7 @@ class SAUCEDACITY_DLL_API Ruler { // Specify the name of the units (like "dB") if you // want numbers like "1.6" formatted as "1.6 dB". void SetUnits(const TranslatableString &units); - void SetDbMirrorValue( const double d ); + void SetDbMirrorValue( double d ); // Logarithmic void SetLog(bool log); @@ -253,7 +253,7 @@ class SAUCEDACITY_DLL_API RulerPanel final : public wxPanelWrapper { Options &TicksAtExtremes( bool t ) { ticksAtExtremes = t; return *this; } - Options &TickColour( const wxColour c ) + Options &TickColour( const wxColour& c ) { tickColour = c; hasTickColour = true; return *this; } }; @@ -267,7 +267,7 @@ class SAUCEDACITY_DLL_API RulerPanel final : public wxPanelWrapper { const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - ~RulerPanel(); + ~RulerPanel() override; void DoSetSize(int x, int y, int width, int height, diff --git a/src/widgets/SliderTextCtrl.h b/src/widgets/SliderTextCtrl.h index b2c0d15da3..b6d01e3724 100644 --- a/src/widgets/SliderTextCtrl.h +++ b/src/widgets/SliderTextCtrl.h @@ -40,18 +40,18 @@ class SliderTextCtrl : public wxPanelWrapper double scale = 0, double offset = 0, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = HORIZONTAL, - double* varValue = NULL); + double* varValue = nullptr); void SetMinTextboxWidth(int width); - double GetValue() const; + [[nodiscard]] double GetValue() const; void SetValue(double value); private: void OnTextChange(wxCommandEvent& event); void OnSlider(wxCommandEvent& event); void OnKillFocus(wxFocusEvent& event); - wxString FormatValue() const; + [[nodiscard]] wxString FormatValue() const; enum { diff --git a/src/widgets/UnwritableLocationErrorDialog.h b/src/widgets/UnwritableLocationErrorDialog.h index cf20b8c632..94f4dd9a36 100644 --- a/src/widgets/UnwritableLocationErrorDialog.h +++ b/src/widgets/UnwritableLocationErrorDialog.h @@ -18,7 +18,7 @@ class UnwritableLocationErrorDialog final : public wxDialogWrapper { public: explicit UnwritableLocationErrorDialog(wxWindow* parent, const wxString& path); - virtual ~UnwritableLocationErrorDialog(); + ~UnwritableLocationErrorDialog() override; void OnOk(wxCommandEvent& event); void OnError(wxCommandEvent& event); diff --git a/src/widgets/numformatter.cpp b/src/widgets/numformatter.cpp index a7f4fd18bf..504ca818b3 100644 --- a/src/widgets/numformatter.cpp +++ b/src/widgets/numformatter.cpp @@ -34,7 +34,7 @@ #include -#include // for setlocale and LC_ALL +#include // for setlocale and LC_ALL #include #include #include diff --git a/src/widgets/valnum.cpp b/src/widgets/valnum.cpp index a3ca489c7e..b190b3e734 100644 --- a/src/widgets/valnum.cpp +++ b/src/widgets/valnum.cpp @@ -87,7 +87,7 @@ wxTextEntry *NumValidatorBase::GetTextEntry() const wxFAIL_MSG(wxT("Can only be used with wxTextCtrl or wxComboBox")); - return NULL; + return nullptr; } bool NumValidatorBase::Validate(wxWindow *parent) @@ -150,7 +150,7 @@ NumValidatorBase::GetCurrentValueAndInsertionPoint(wxString& val, } } -bool NumValidatorBase::IsMinusOk(const wxString& val, int pos) const +bool NumValidatorBase::IsMinusOk(const wxString& val, int pos) { // Minus is only ever accepted in the beginning of the string. if ( pos != 0 ) @@ -242,9 +242,9 @@ void NumValidatorBase::OnPaste(wxClipboardTextEvent& event) int pos; GetCurrentValueAndInsertionPoint(val, pos); - for (size_t i = 0, cnt = toPaste.length(); i < cnt; i++) + for (auto && i : toPaste) { - const wxChar ch = toPaste[i]; + const wxChar ch = i; // Check if this character is allowed in the current state. if ( IsCharOk(val, pos, ch) ) diff --git a/src/widgets/valnum.h b/src/widgets/valnum.h index a759c0f768..2935e595d1 100644 --- a/src/widgets/valnum.h +++ b/src/widgets/valnum.h @@ -71,7 +71,7 @@ class SAUCEDACITY_DLL_API NumValidatorBase /* not final */ : public wxValidator m_maxSet = other.m_maxSet; } - bool HasFlag(NumValidatorStyle style) const + [[nodiscard]] bool HasFlag(NumValidatorStyle style) const { return (m_style & style) != 0; } @@ -79,20 +79,20 @@ class SAUCEDACITY_DLL_API NumValidatorBase /* not final */ : public wxValidator // Get the text entry of the associated control. Normally shouldn't ever // return NULL (and will assert if it does return it) but the caller should // still test the return value for safety. - wxTextEntry *GetTextEntry() const; + [[nodiscard]] wxTextEntry *GetTextEntry() const; // Convert NumValidatorStyle::THOUSANDS_SEPARATOR and NumValidatorStyle::NO_TRAILING_ZEROES // bits of our style to the corresponding NumberFormatter::Style values. - int GetFormatFlags() const; + [[nodiscard]] int GetFormatFlags() const; // Return true if pressing a '-' key is acceptable for the current control // contents and insertion point. This is meant to be called from the // derived class IsCharOk() implementation. - bool IsMinusOk(const wxString& val, int pos) const; + [[nodiscard]] static bool IsMinusOk(const wxString& val, int pos) ; // Return the string which would result from inserting the given character // at the specified position. - wxString GetValueAfterInsertingChar(const wxString &valArg, int pos, wxChar ch) const + static wxString GetValueAfterInsertingChar(const wxString &valArg, int pos, wxChar ch) { wxString val(valArg); val.insert(pos, ch); @@ -109,11 +109,11 @@ class SAUCEDACITY_DLL_API NumValidatorBase /* not final */ : public wxValidator // // Notice that the base class checks for '-' itself so it's never passed to // this function. - virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const = 0; + [[nodiscard]] virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const = 0; // NormalizeString the contents of the string if it's a valid number, return // empty string otherwise. - virtual wxString NormalizeString(const wxString& s) const = 0; + [[nodiscard]] virtual wxString NormalizeString(const wxString& s) const = 0; // Do all checks to ensure this is a valid value. // Returns 'true' if the control has valid value. @@ -241,7 +241,7 @@ class NumValidator /* final */ : public B // Implement NumValidatorBase virtual method which is the same for // both integer and floating point numbers. - wxString NormalizeString(const wxString& s) const override + [[nodiscard]] wxString NormalizeString(const wxString& s) const override { LongestValueType value; return BaseValidator::FromString(s, &value) ? NormalizeValue(value) @@ -311,19 +311,19 @@ class SAUCEDACITY_DLL_API IntegerValidatorBase /* not final */ } // Provide methods for NumValidator use. - wxString ToString(LongestValueType value) const; + [[nodiscard]] wxString ToString(LongestValueType value) const; static bool FromString(const wxString& s, LongestValueType *value); void DoSetMin(LongestValueType min) { m_min = min; } void DoSetMax(LongestValueType max) { m_max = max; } - bool IsInRange(LongestValueType value) const + [[nodiscard]] bool IsInRange(LongestValueType value) const { return m_min <= value && value <= m_max; } // Implement NumValidatorBase pure virtual method. - bool IsCharOk(const wxString& val, int pos, wxChar ch) const override; + [[nodiscard]] bool IsCharOk(const wxString& val, int pos, wxChar ch) const override; bool DoValidateNumber(TranslatableString * errMsg) const override; private: @@ -361,7 +361,7 @@ class IntegerValidator final } // Clone is required by wxwidgets; implemented via copy constructor - wxObject *Clone() const override { return safenew IntegerValidator(*this); } + [[nodiscard]] wxObject *Clone() const override { return safenew IntegerValidator(*this); } private: DECLARE_NO_ASSIGN_CLASS(IntegerValidator) @@ -412,23 +412,23 @@ class SAUCEDACITY_DLL_API FloatingPointValidatorBase /* not final */ } // Provide methods for NumValidator use. - wxString ToString(LongestValueType value) const; + [[nodiscard]] wxString ToString(LongestValueType value) const; static bool FromString(const wxString& s, LongestValueType *value); void DoSetMin(LongestValueType min) { m_min = min; } void DoSetMax(LongestValueType max) { m_max = max; } - bool IsInRange(LongestValueType value) const + [[nodiscard]] bool IsInRange(LongestValueType value) const { return m_min <= value && value <= m_max; } // Implement NumValidatorBase pure virtual method. - bool IsCharOk(const wxString& val, int pos, wxChar ch) const override; + [[nodiscard]] bool IsCharOk(const wxString& val, int pos, wxChar ch) const override; bool DoValidateNumber(TranslatableString * errMsg) const override; //Checks that it doesn't have too many decimal digits. - bool ValidatePrecision(const wxString& s) const; + [[nodiscard]] bool ValidatePrecision(const wxString& s) const; private: // Maximum number of decimals digits after the decimal separator. @@ -474,7 +474,7 @@ class FloatingPointValidator final } // Clone is required by wxwidgets; implemented via copy constructor - wxObject *Clone() const override + [[nodiscard]] wxObject *Clone() const override { return safenew FloatingPointValidator(*this); } diff --git a/src/widgets/wxTextCtrlWrapper.h b/src/widgets/wxTextCtrlWrapper.h index 51e7106ea9..2c17453020 100644 --- a/src/widgets/wxTextCtrlWrapper.h +++ b/src/widgets/wxTextCtrlWrapper.h @@ -48,16 +48,16 @@ class wxTextCtrlWrapper final : public wxTextCtrl }); }; - ~wxTextCtrlWrapper() + ~wxTextCtrlWrapper() override { }; - virtual bool AcceptsFocusFromKeyboard() const override + bool AcceptsFocusFromKeyboard() const override { return true; } - bool IsReadOnly() + bool IsReadOnly() const { return mReadOnly; }