diff --git a/include/audacity/Types.h b/include/audacity/Types.h
index 3a814f6ab33674777c0e2b44d377d2ac9a73f719..04bf36a5e438a08e079e106f24e897877a9ec9eb 100644
--- a/include/audacity/Types.h
+++ b/include/audacity/Types.h
@@ -58,33 +58,6 @@
 //        until proper public headers are created for the stuff in here.
 // ----------------------------------------------------------------------------
 
-// ----------------------------------------------------------------------------
-// Supported sample formats
-// ----------------------------------------------------------------------------
-enum sampleFormat : unsigned
-{
-   //! The increasing sequence of these enum values must correspond to the increasing data type width
-   //! These values persist in saved project files, so must not be changed in later program versions
-   int16Sample = 0x00020001,
-   int24Sample = 0x00040001,
-   floatSample = 0x0004000F,
-
-   //! Two synonyms for previous values that might change if more values were added
-   narrowestSampleFormat = int16Sample,
-   widestSampleFormat = floatSample,
-};
-
-// ----------------------------------------------------------------------------
-// Provide the number of bytes a specific sample will take
-// ----------------------------------------------------------------------------
-#define SAMPLE_SIZE(SampleFormat) (SampleFormat >> 16)
-
-// ----------------------------------------------------------------------------
-// Generic pointer to sample data
-// ----------------------------------------------------------------------------
-typedef char *samplePtr;
-typedef const char *constSamplePtr;
-
 // ----------------------------------------------------------------------------
 // The type for plugin IDs
 // ----------------------------------------------------------------------------
diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt
index 891b4d805a60c38151e0d937f7d8c8ff1fa42e60..1b572a4db9fc95d2ad26742ed91950f14c5143a6 100644
--- a/libraries/CMakeLists.txt
+++ b/libraries/CMakeLists.txt
@@ -11,6 +11,7 @@ set( LIBRARIES
    lib-basic-ui
    lib-exceptions
    lib-preferences
+   lib-math
 )
 
 if ( ${_OPT}has_networking )
diff --git a/libraries/lib-math/CMakeLists.txt b/libraries/lib-math/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..2b87133ab5c59b28b649f2b8b3a545454715c513
--- /dev/null
+++ b/libraries/lib-math/CMakeLists.txt
@@ -0,0 +1,31 @@
+#[[
+A library of mathematical utilities and manipulation of samples
+]]#
+
+set( SOURCES
+   Dither.cpp
+   Dither.h
+   FFT.cpp
+   FFT.h
+   InterpolateAudio.cpp
+   InterpolateAudio.h
+   Matrix.cpp
+   Matrix.h
+   RealFFTf.cpp
+   RealFFTf.h
+   SampleCount.cpp
+   SampleCount.h
+   SampleFormat.cpp
+   SampleFormat.h
+   Spectrum.cpp
+   Spectrum.h
+   float_cast.h
+)
+set( LIBRARIES
+   lib-preferences-interface
+   PRIVATE
+   wxBase
+)
+audacity_library( lib-math "${SOURCES}" "${LIBRARIES}"
+   "" ""
+)
diff --git a/src/Dither.cpp b/libraries/lib-math/Dither.cpp
similarity index 100%
rename from src/Dither.cpp
rename to libraries/lib-math/Dither.cpp
diff --git a/src/Dither.h b/libraries/lib-math/Dither.h
similarity index 91%
rename from src/Dither.h
rename to libraries/lib-math/Dither.h
index e257243efd8f4a86bf4a720017f5bd399d9288e7..369273b7f7bfe9986cf7b8049859a3b3bb8a388b 100644
--- a/src/Dither.h
+++ b/libraries/lib-math/Dither.h
@@ -10,7 +10,7 @@
 #ifndef __AUDACITY_DITHER_H__
 #define __AUDACITY_DITHER_H__
 
-#include "audacity/Types.h" // for samplePtr
+#include "SampleFormat.h"
 
 template< typename Enum > class EnumSetting;
 
@@ -19,13 +19,14 @@ template< typename Enum > class EnumSetting;
 enum DitherType : unsigned {
    none = 0, rectangle = 1, triangle = 2, shaped = 3 };
 
-class Dither
+class MATH_API Dither
 {
 public:
     static DitherType FastDitherChoice();
     static DitherType BestDitherChoice();
 
-    static AUDACITY_DLL_API EnumSetting< DitherType > FastSetting, BestSetting;
+    static EnumSetting< DitherType > FastSetting;
+    static EnumSetting< DitherType > BestSetting;
 
     /// Default constructor
     Dither();
diff --git a/src/FFT.cpp b/libraries/lib-math/FFT.cpp
similarity index 99%
rename from src/FFT.cpp
rename to libraries/lib-math/FFT.cpp
index 158ba2f63683aea4bf49dc1f0e1074c0582495b1..3a946ac8835301e5bfef8254ee2bac64d9e45e2a 100644
--- a/src/FFT.cpp
+++ b/libraries/lib-math/FFT.cpp
@@ -39,7 +39,6 @@
     * 9: Gaussian(a=4.5)
 */
 
-
 #include "FFT.h"
 
 #include "Internat.h"
diff --git a/src/FFT.h b/libraries/lib-math/FFT.h
similarity index 95%
rename from src/FFT.h
rename to libraries/lib-math/FFT.h
index 20fe262b13923b4da0ef2abbdf484872f3423abe..9ac8f0e9c7bf7c7b87202b5713afdbb7a2bc7498 100644
--- a/src/FFT.h
+++ b/libraries/lib-math/FFT.h
@@ -63,6 +63,7 @@ class TranslatableString;
  * input array, and that NumSamples must be a power of two.
  */
 
+MATH_API
 void PowerSpectrum(size_t NumSamples, const float *In, float *Out);
 
 /*
@@ -72,7 +73,7 @@ void PowerSpectrum(size_t NumSamples, const float *In, float *Out);
  * NumSamples must be a power of two.
  */
 
-AUDACITY_DLL_API
+MATH_API
 void RealFFT(size_t NumSamples,
              const float *RealIn, float *RealOut, float *ImagOut);
 
@@ -81,7 +82,7 @@ void RealFFT(size_t NumSamples,
  * so the output is purely real.  NumSamples must be a power of
  * two.
  */
-AUDACITY_DLL_API
+MATH_API
 void InverseRealFFT(size_t NumSamples,
 		    const float *RealIn, const float *ImagIn, float *RealOut);
 
@@ -91,7 +92,7 @@ void InverseRealFFT(size_t NumSamples,
  * inverse transform as well.
  */
 
-AUDACITY_DLL_API
+MATH_API
 void FFT(size_t NumSamples,
          bool InverseTransform,
          const float *RealIn, const float *ImagIn, float *RealOut, float *ImagOut);
@@ -120,7 +121,7 @@ enum eWindowFunctions
    eWinFuncCount
 };
 
-AUDACITY_DLL_API
+MATH_API
 void WindowFunc(int whichFunction, size_t NumSamples, float *data);
 
 /*
@@ -129,7 +130,7 @@ void WindowFunc(int whichFunction, size_t NumSamples, float *data);
  * otherwise about (NumSamples - 1) / 2
  * All functions have 0 in data[0] except Rectangular, Hamming and Gaussians
  */
-AUDACITY_DLL_API
+MATH_API
 void NewWindowFunc(int whichFunction, size_t NumSamples, bool extraSample, float *data);
 
 /*
@@ -139,21 +140,21 @@ void NewWindowFunc(int whichFunction, size_t NumSamples, bool extraSample, float
  * otherwise about (NumSamples - 1) / 2
  * All functions have 0 in data[0] except Rectangular, Hamming and Gaussians
  */
-AUDACITY_DLL_API
+MATH_API
 void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSample, float *data);
 
 /*
  * Returns the name of the windowing function (for UI display)
  */
 
-AUDACITY_DLL_API const TranslatableString WindowFuncName(int whichFunction);
+MATH_API const TranslatableString WindowFuncName(int whichFunction);
 
 /*
  * Returns the number of windowing functions supported
  */
 
-AUDACITY_DLL_API int NumWindowFuncs();
+MATH_API int NumWindowFuncs();
 
-void DeinitFFT();
+MATH_API void DeinitFFT();
 
 #endif
diff --git a/src/InterpolateAudio.cpp b/libraries/lib-math/InterpolateAudio.cpp
similarity index 100%
rename from src/InterpolateAudio.cpp
rename to libraries/lib-math/InterpolateAudio.cpp
diff --git a/src/InterpolateAudio.h b/libraries/lib-math/InterpolateAudio.h
similarity index 95%
rename from src/InterpolateAudio.h
rename to libraries/lib-math/InterpolateAudio.h
index d19c8d58e6b3b4e642a006f1dba911d95ff0ce2e..4f036dc6fbdb797df80027b0f15ba813d2a00b94 100644
--- a/src/InterpolateAudio.h
+++ b/libraries/lib-math/InterpolateAudio.h
@@ -25,7 +25,6 @@
 #ifndef __AUDACITY_INTERPOLATE_AUDIO__
 #define __AUDACITY_INTERPOLATE_AUDIO__
 
-
 #include <cstddef>
 
 // See top of file for a description of the algorithm.  Interpolates
@@ -36,7 +35,7 @@
 // side (6x the number of bad samples on either side is great).  However,
 // it will work with less data, and with the bad samples on one end or
 // the other.
-void AUDACITY_DLL_API InterpolateAudio(float *buffer, size_t len,
+void MATH_API InterpolateAudio(float *buffer, size_t len,
                                        size_t firstBad, size_t numBad);
 
 #endif // __AUDACITY_INTERPOLATE_AUDIO__
diff --git a/src/Matrix.cpp b/libraries/lib-math/Matrix.cpp
similarity index 100%
rename from src/Matrix.cpp
rename to libraries/lib-math/Matrix.cpp
diff --git a/src/Matrix.h b/libraries/lib-math/Matrix.h
similarity index 100%
rename from src/Matrix.h
rename to libraries/lib-math/Matrix.h
diff --git a/src/RealFFTf.cpp b/libraries/lib-math/RealFFTf.cpp
similarity index 99%
rename from src/RealFFTf.cpp
rename to libraries/lib-math/RealFFTf.cpp
index ed443d1aede900727d0e8178275860797b9477be..f26c5df0ddc3923abfbb4ca0f5ae31c67bd95dfc 100644
--- a/src/RealFFTf.cpp
+++ b/libraries/lib-math/RealFFTf.cpp
@@ -36,11 +36,8 @@
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-
 #include "RealFFTf.h"
 
-
-
 #include <vector>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/src/RealFFTf.h b/libraries/lib-math/RealFFTf.h
similarity index 50%
rename from src/RealFFTf.h
rename to libraries/lib-math/RealFFTf.h
index 02a221aab68af70502e7e081bb57974cd7ff4311..a4fc294ad6a7691b537b4bc09736426f145049ff 100644
--- a/src/RealFFTf.h
+++ b/libraries/lib-math/RealFFTf.h
@@ -1,10 +1,6 @@
 #ifndef __realfftf_h
 #define __realfftf_h
 
-
-
-
-
 #include "MemoryX.h"
 
 using fft_type = float;
@@ -17,7 +13,7 @@ struct FFTParam {
 #endif
 };
 
-struct AUDACITY_DLL_API FFTDeleter{
+struct MATH_API FFTDeleter{
    void operator () (FFTParam *p) const;
 };
 
@@ -25,11 +21,11 @@ using HFFT = std::unique_ptr<
    FFTParam, FFTDeleter
 >;
 
-AUDACITY_DLL_API HFFT GetFFT(size_t);
-AUDACITY_DLL_API void RealFFTf(fft_type *, const FFTParam *);
-AUDACITY_DLL_API void InverseRealFFTf(fft_type *, const FFTParam *);
-AUDACITY_DLL_API void ReorderToTime(const FFTParam *hFFT, const fft_type *buffer, fft_type *TimeOut);
-AUDACITY_DLL_API void ReorderToFreq(const FFTParam *hFFT, const fft_type *buffer,
+MATH_API HFFT GetFFT(size_t);
+MATH_API void RealFFTf(fft_type *, const FFTParam *);
+MATH_API void InverseRealFFTf(fft_type *, const FFTParam *);
+MATH_API void ReorderToTime(const FFTParam *hFFT, const fft_type *buffer, fft_type *TimeOut);
+MATH_API void ReorderToFreq(const FFTParam *hFFT, const fft_type *buffer,
 		   fft_type *RealOut, fft_type *ImagOut);
 
 #endif
diff --git a/src/SampleCount.cpp b/libraries/lib-math/SampleCount.cpp
similarity index 100%
rename from src/SampleCount.cpp
rename to libraries/lib-math/SampleCount.cpp
diff --git a/src/SampleCount.h b/libraries/lib-math/SampleCount.h
similarity index 98%
rename from src/SampleCount.h
rename to libraries/lib-math/SampleCount.h
index 8b8cebfbfb5c466d71df296f3f52079b62b5681c..19be036250ffedff95231a3ed45fd34bf59a2116 100644
--- a/src/SampleCount.h
+++ b/libraries/lib-math/SampleCount.h
@@ -14,7 +14,7 @@
 
 //! Positions or offsets within audio files need a wide type
 /*! This type disallows implicit interconversions with narrower types */
-class AUDACITY_DLL_API sampleCount
+class MATH_API sampleCount
 {
 public:
    using type = long long;
@@ -128,7 +128,7 @@ inline sampleCount operator % (sampleCount a, sampleCount b)
 // hiding the casts
 // ----------------------------------------------------------------------------
 
-AUDACITY_DLL_API
+MATH_API
 size_t limitSampleBufferSize( size_t bufferSize, sampleCount limit );
 
 #endif
diff --git a/src/SampleFormat.cpp b/libraries/lib-math/SampleFormat.cpp
similarity index 99%
rename from src/SampleFormat.cpp
rename to libraries/lib-math/SampleFormat.cpp
index 1d4e7baee73dcc9e172b9ebf45bdc2ef231e4f56..25f38ba1d49d055a68d56f337e132f8dd505d58e 100644
--- a/src/SampleFormat.cpp
+++ b/libraries/lib-math/SampleFormat.cpp
@@ -35,6 +35,7 @@
 *//*******************************************************************/
 
 #include "SampleFormat.h"
+#include "Dither.h" // CYCLE
 
 #include <wx/intl.h>
 #include <math.h>
diff --git a/src/SampleFormat.h b/libraries/lib-math/SampleFormat.h
similarity index 73%
rename from src/SampleFormat.h
rename to libraries/lib-math/SampleFormat.h
index 90e88ed1f7f397b35a740780845ff20ec0a38470..d2ca09069bbbdbaae4dc6a162d38e348b163338b 100644
--- a/src/SampleFormat.h
+++ b/libraries/lib-math/SampleFormat.h
@@ -11,32 +11,43 @@
 #ifndef __AUDACITY_SAMPLE_FORMAT__
 #define __AUDACITY_SAMPLE_FORMAT__
 
-
-
 #include "MemoryX.h"
-#include <wx/defs.h>
-
-#include "audacity/Types.h"
-#include "Dither.h"
+#include <cstdlib>
 
 //
 // Definitions / Meta-Information
 //
 
+enum DitherType : unsigned;
 //! These global variables are assigned at application startup or after change of preferences.
-extern AUDACITY_DLL_API DitherType gLowQualityDither, gHighQualityDither;
+extern MATH_API DitherType gLowQualityDither, gHighQualityDither;
 
-#if 0
-// Moved to audacity/types.h
-typedef enum {
+// ----------------------------------------------------------------------------
+// Supported sample formats
+// ----------------------------------------------------------------------------
+enum sampleFormat : unsigned
+{
+   //! The increasing sequence of these enum values must correspond to the increasing data type width
+   //! These values persist in saved project files, so must not be changed in later program versions
    int16Sample = 0x00020001,
    int24Sample = 0x00040001,
-   floatSample = 0x0004000F
-} sampleFormat;
+   floatSample = 0x0004000F,
 
-/** \brief Return the size (in memory) of one sample (bytes) */
-#define SAMPLE_SIZE(SampleFormat) ( size_t{ (SampleFormat) >> 16 } )
-#endif
+   //! Two synonyms for previous values that might change if more values were added
+   narrowestSampleFormat = int16Sample,
+   widestSampleFormat = floatSample,
+};
+
+// ----------------------------------------------------------------------------
+// Provide the number of bytes a specific sample will take
+// ----------------------------------------------------------------------------
+#define SAMPLE_SIZE(SampleFormat) (SampleFormat >> 16)
+
+// ----------------------------------------------------------------------------
+// Generic pointer to sample data
+// ----------------------------------------------------------------------------
+using samplePtr = char *;
+using constSamplePtr = const char *;
 
 // Used to determine how to fill in empty areas of audio.
 typedef enum {
@@ -48,7 +59,8 @@ typedef enum {
 #define SAMPLE_SIZE_DISK(SampleFormat) (((SampleFormat) == int24Sample) ? \
    size_t{ 3 } : SAMPLE_SIZE(SampleFormat) )
 
-AUDACITY_DLL_API TranslatableString GetSampleFormatStr(sampleFormat format);
+class TranslatableString;
+MATH_API TranslatableString GetSampleFormatStr(sampleFormat format);
 
 //
 // Allocating/Freeing Samples
@@ -128,7 +140,7 @@ private:
 // Copying, Converting and Clearing Samples
 //
 
-AUDACITY_DLL_API
+MATH_API
 //! Copy samples from any format into the widest format, which is 32 bit float, with no dithering
 /*!
  @param src address of source samples
@@ -141,7 +153,7 @@ AUDACITY_DLL_API
 void SamplesToFloats(constSamplePtr src, sampleFormat srcFormat,
     float *dst, size_t len, size_t srcStride = 1, size_t dstStride = 1);
 
-AUDACITY_DLL_API
+MATH_API
 //! Copy samples from any format to any other format; apply dithering only if narrowing the format
 /*!
  @copydetails SamplesToFloats()
@@ -153,11 +165,11 @@ void CopySamples(constSamplePtr src, sampleFormat srcFormat,
    DitherType ditherType = gHighQualityDither, //!< default is loaded from a global variable
    unsigned int srcStride=1, unsigned int dstStride=1);
 
-AUDACITY_DLL_API
+MATH_API
 void      ClearSamples(samplePtr buffer, sampleFormat format,
                        size_t start, size_t len);
 
-AUDACITY_DLL_API
+MATH_API
 void      ReverseSamples(samplePtr buffer, sampleFormat format,
                          int start, int len);
 
@@ -166,7 +178,7 @@ void      ReverseSamples(samplePtr buffer, sampleFormat format,
 // are set in preferences.
 //
 
-AUDACITY_DLL_API
+MATH_API
 void      InitDitherers();
 
 // These are so commonly done for processing samples in floating point form in memory,
diff --git a/src/Spectrum.cpp b/libraries/lib-math/Spectrum.cpp
similarity index 100%
rename from src/Spectrum.cpp
rename to libraries/lib-math/Spectrum.cpp
diff --git a/src/Spectrum.h b/libraries/lib-math/Spectrum.h
similarity index 97%
rename from src/Spectrum.h
rename to libraries/lib-math/Spectrum.h
index aaaae6356a997a1c88748a048c2b8556f5317b62..3ff362bf6481c08d6a0159e20572592e12744094 100644
--- a/src/Spectrum.h
+++ b/libraries/lib-math/Spectrum.h
@@ -21,7 +21,7 @@
   calculates windowSize/2 frequency samples
 */
 
-AUDACITY_DLL_API
+MATH_API
 bool ComputeSpectrum(const float * data, size_t width, size_t windowSize,
                      double rate, float *out, bool autocorrelation,
                      int windowFunc = eWinFuncHann);
diff --git a/src/float_cast.h b/libraries/lib-math/float_cast.h
similarity index 99%
rename from src/float_cast.h
rename to libraries/lib-math/float_cast.h
index 6d3fc734a948bebab6109f81650fa53efd64c217..6886e3d93d2470bac6604d08c6d1cc2a1d6e06e2 100644
--- a/src/float_cast.h
+++ b/libraries/lib-math/float_cast.h
@@ -35,8 +35,6 @@
 **		long int lrint  (double x) ;
 */
 
-
-
 /*	The presence of the required functions are detected during the configure
 **	process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
 **	the config.h file.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f43d2dfb9fbaba839b7e3d9e609802c752be5ed4..133f6b9836de434316d82dd7dc299aaa38203c30 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -129,14 +129,10 @@ list( APPEND SOURCES
       DeviceManager.h
       Diags.cpp
       Diags.h
-      Dither.cpp
-      Dither.h
       Envelope.cpp
       Envelope.h
       EnvelopeEditor.cpp
       EnvelopeEditor.h
-      FFT.cpp
-      FFT.h
       FFmpeg.cpp
       FFmpeg.h
       FileException.cpp
@@ -157,8 +153,6 @@ list( APPEND SOURCES
       HitTestResult.h
       ImageManipulation.cpp
       ImageManipulation.h
-      InterpolateAudio.cpp
-      InterpolateAudio.h
       KeyboardCapture.cpp
       KeyboardCapture.h
       LabelDialog.cpp
@@ -175,8 +169,6 @@ list( APPEND SOURCES
       LyricsWindow.cpp
       LyricsWindow.h
       MacroMagic.h
-      Matrix.cpp
-      Matrix.h
       Menus.cpp
       Menus.h
       Mix.cpp
@@ -232,10 +224,6 @@ list( APPEND SOURCES
       ProjectWindow.h
       ProjectWindowBase.cpp
       ProjectWindowBase.h
-      RealFFTf.cpp
-      RealFFTf.h
-      RealFFTf48x.cpp
-      RealFFTf48x.h
       RefreshCode.h
       Registrar.h
       Registry.cpp
@@ -246,10 +234,6 @@ list( APPEND SOURCES
       RingBuffer.h
       SampleBlock.cpp
       SampleBlock.h
-      SampleCount.cpp
-      SampleCount.h
-      SampleFormat.cpp
-      SampleFormat.h
       Screenshot.cpp
       Screenshot.h
       SelectUtilities.cpp
@@ -272,8 +256,6 @@ list( APPEND SOURCES
       Snap.h
       SoundActivatedRecord.cpp
       SoundActivatedRecord.h
-      Spectrum.cpp
-      Spectrum.h
       SpectrumAnalyst.cpp
       SpectrumAnalyst.h
       SplashDialog.cpp
@@ -334,7 +316,6 @@ list( APPEND SOURCES
       WrappedType.h
       ZoomInfo.cpp
       ZoomInfo.h
-      float_cast.h
       wxFileNameWrapper.h
 
       # Commands
@@ -1354,8 +1335,8 @@ target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} )
 target_compile_options( ${TARGET} PRIVATE ${OPTIONS} )
 target_include_directories( ${TARGET} PRIVATE ${INCLUDES} )
 target_link_options( ${TARGET} PRIVATE ${LDFLAGS} )
-target_link_libraries( ${TARGET} ${LIBRARIES} )
 target_link_libraries( ${TARGET} PUBLIC ${AUDACITY_LIBRARIES} )
+target_link_libraries( ${TARGET} ${LIBRARIES} )
 
 if( CMAKE_VERSION VERSION_GREATER_EQUAL "3.16" AND NOT CCACHE_PROGRAM )
    if( ${_OPT}use_pch )
diff --git a/src/FFmpeg.h b/src/FFmpeg.h
index 1f2d1be17793c56a6ea29410362eef3f6dd78be1..53f55de343067a0775c50862daca35c0ef96e965 100644
--- a/src/FFmpeg.h
+++ b/src/FFmpeg.h
@@ -153,6 +153,7 @@ extern "C" {
 #include "Prefs.h"
 
 #include "Identifier.h"
+#include "SampleFormat.h"
 
 class wxDynamicLibrary;
 
diff --git a/src/FileFormats.h b/src/FileFormats.h
index 03619f180fbcda86b735eaa945ad50339f6bb2fd..14394b9aa44b61647ce740225159d4d359d0c9ad 100644
--- a/src/FileFormats.h
+++ b/src/FileFormats.h
@@ -13,8 +13,8 @@
 
 
 
-#include "audacity/Types.h"
 #include "Identifier.h"
+#include "SampleFormat.h"
 
 //#include <mutex>
 #include <memory>
diff --git a/src/Mix.h b/src/Mix.h
index 0cc58a115f3bfb16d9916663df0c8b7a3c45333c..5eae40b883d640a15c33f764d0e24eb12d27f53a 100644
--- a/src/Mix.h
+++ b/src/Mix.h
@@ -20,6 +20,7 @@
 #ifndef __AUDACITY_MIX__
 #define __AUDACITY_MIX__
 
+#include "audacity/Types.h"
 #include "SampleFormat.h"
 #include <vector>
 
diff --git a/src/RingBuffer.cpp b/src/RingBuffer.cpp
index a5d54dac6000eff2d1a8d966d8c5d024db92f865..b62e8bb58b63cabe2362e4b949806a94a33e0fc0 100644
--- a/src/RingBuffer.cpp
+++ b/src/RingBuffer.cpp
@@ -26,6 +26,7 @@
 
 
 #include "RingBuffer.h"
+#include "Dither.h"
 
 RingBuffer::RingBuffer(sampleFormat format, size_t size)
    : mFormat{ format }
diff --git a/src/SampleBlock.h b/src/SampleBlock.h
index dbe5b119baff7511085b5540c858d91d117340c9..8d80fa195954a0497ea65733fe3c575aec960f00 100644
--- a/src/SampleBlock.h
+++ b/src/SampleBlock.h
@@ -9,7 +9,7 @@ SampleBlock.h
 #ifndef __AUDACITY_SAMPLE_BLOCK__
 #define __AUDACITY_SAMPLE_BLOCK__
 
-#include "audacity/Types.h"
+#include "SampleFormat.h"
 
 #include <functional>
 #include <memory>
diff --git a/src/commands/Demo.h b/src/commands/Demo.h
index cb76b0c84e3d6ace4ecea593b8531844eb1ae012..61f2ca970f9829749311fc684cd8c081911ea1fe 100644
--- a/src/commands/Demo.h
+++ b/src/commands/Demo.h
@@ -12,7 +12,7 @@
 #define __AUDACITY_DEMO_COMMAND__
 
 #include "AudacityCommand.h"
-#include "../SampleFormat.h"
+#include "SampleFormat.h"
 
 class ShuttleGui;
 
diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp
index b9519b52526d86d6d7540be2441f47c45cb7e3f9..1e11a446301b7a55faba75dae5162dc02610d4a0 100644
--- a/src/effects/ChangePitch.cpp
+++ b/src/effects/ChangePitch.cpp
@@ -38,7 +38,7 @@ the pitch without changing the tempo.
 #include "../PitchName.h"
 #include "../Shuttle.h"
 #include "../ShuttleGui.h"
-#include "../Spectrum.h"
+#include "Spectrum.h"
 #include "../WaveTrack.h"
 #include "../widgets/valnum.h"
 #include "TimeWarper.h"
diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp
index b7d73fc68f2710699e6a58811975fa5829cc6db9..ae03ece993eaf33864e74258990a71925d5c119e 100644
--- a/src/effects/Compressor.cpp
+++ b/src/effects/Compressor.cpp
@@ -42,7 +42,7 @@
 #include "../Shuttle.h"
 #include "../ShuttleGui.h"
 #include "../Theme.h"
-#include "../float_cast.h"
+#include "float_cast.h"
 #include "../widgets/Ruler.h"
 
 #include "../WaveTrack.h"
diff --git a/src/effects/Effect.h b/src/effects/Effect.h
index 10777b6565e8d162aef73ad099e66d13c468deca..225c3e4b19ed226bdbf9e1c1133c6f9134d137b6 100644
--- a/src/effects/Effect.h
+++ b/src/effects/Effect.h
@@ -27,8 +27,9 @@ class wxWindow;
 
 #include "ConfigInterface.h"
 #include "EffectInterface.h"
+#include "PluginInterface.h"
 
-#include "../SampleCount.h"
+#include "SampleCount.h"
 #include "../SelectedRegion.h"
 
 #include "../Track.h"
diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp
index d453eceff376181cb2d0d33d361e542539ef1bed..c5861666f9320d784751c564dc75b69b7d17b064 100644
--- a/src/effects/Equalization.cpp
+++ b/src/effects/Equalization.cpp
@@ -94,7 +94,7 @@
 #include "../FileNames.h"
 #include "../Envelope.h"
 #include "../EnvelopeEditor.h"
-#include "../FFT.h"
+#include "FFT.h"
 #include "Prefs.h"
 #include "../Project.h"
 #include "../Theme.h"
@@ -106,7 +106,7 @@
 #include "../widgets/AudacityTextEntryDialog.h"
 #include "../xml/XMLFileReader.h"
 #include "../AllThemeResources.h"
-#include "../float_cast.h"
+#include "float_cast.h"
 
 #if wxUSE_ACCESSIBILITY
 #include "../widgets/WindowAccessible.h"
diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h
index b0a9084676dd4719f2a5febbbc0dd6cd7d88528d..67c5a38ca600ac9240549e0229ff32597c466533 100644
--- a/src/effects/Equalization.h
+++ b/src/effects/Equalization.h
@@ -18,7 +18,7 @@
 #include <wx/setup.h> // for wxUSE_* macros
 
 #include "Effect.h"
-#include "../RealFFTf.h"
+#include "RealFFTf.h"
 
 // Flags to specialise the UI
 const int kEqOptionGraphic =1;
diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp
index 8b05bee70289ac6ab158f35af32bb4ebc88ada9a..0cc6d12d6afdb60d84dff55b2814879944937573 100644
--- a/src/effects/NoiseReduction.cpp
+++ b/src/effects/NoiseReduction.cpp
@@ -46,7 +46,7 @@
 #include "../ShuttleGui.h"
 #include "../widgets/HelpSystem.h"
 #include "Prefs.h"
-#include "../RealFFTf.h"
+#include "RealFFTf.h"
 
 #include "../WaveTrack.h"
 #include "../widgets/AudacityMessageBox.h"
diff --git a/src/effects/Paulstretch.cpp b/src/effects/Paulstretch.cpp
index 7a275d1ba11b9edca6d3b130f396d8b17a7867a8..7c2823ea17a652cfcb8d017136d422cf6f3a214a 100644
--- a/src/effects/Paulstretch.cpp
+++ b/src/effects/Paulstretch.cpp
@@ -28,7 +28,7 @@
 
 #include "../Shuttle.h"
 #include "../ShuttleGui.h"
-#include "../FFT.h"
+#include "FFT.h"
 #include "../widgets/valnum.h"
 #include "../widgets/AudacityMessageBox.h"
 #include "Prefs.h"
diff --git a/src/effects/Repair.cpp b/src/effects/Repair.cpp
index 57fff709f0620efee6e016b1361ecb15fc99a024..18ad678b10ea0b07deb9df24e11fc0821e61de20 100644
--- a/src/effects/Repair.cpp
+++ b/src/effects/Repair.cpp
@@ -28,7 +28,7 @@ the audio, rather than actually finding the clicks.
 
 #include <wx/intl.h>
 
-#include "../InterpolateAudio.h"
+#include "InterpolateAudio.h"
 #include "../WaveTrack.h"
 #include "../widgets/AudacityMessageBox.h"
 
diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp
index e427def28a4d4d6bf1bcf8f5348810ec9114177e..3d2d59e68ef7bfd3d95254896cdc5c6724a1a2a9 100644
--- a/src/effects/VST/VSTEffect.cpp
+++ b/src/effects/VST/VSTEffect.cpp
@@ -27,7 +27,7 @@
 
 #include "VSTEffect.h"
 #include "../../ModuleManager.h"
-#include "../../SampleCount.h"
+#include "SampleCount.h"
 
 #include "../../widgets/ProgressDialog.h"
 
diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h
index f3ef7404ace3cfdbaaa8edf9fef6efda4c120a18..ef306cffc45fe929063bc139055d51ed3e7d861e 100644
--- a/src/effects/VST/VSTEffect.h
+++ b/src/effects/VST/VSTEffect.h
@@ -16,7 +16,7 @@
 #include "ModuleInterface.h"
 #include "PluginInterface.h"
 
-#include "../../SampleFormat.h"
+#include "SampleFormat.h"
 #include "../../xml/XMLTagHandler.h"
 
 class wxSizerItem;
diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp
index 5c1f30c51ce52ed247dc820754cf65473eeacb89..108c5ca45c846fb85963a165bdecd7991540b8d9 100644
--- a/src/effects/audiounits/AudioUnitEffect.cpp
+++ b/src/effects/audiounits/AudioUnitEffect.cpp
@@ -19,7 +19,7 @@
 #if USE_AUDIO_UNITS
 #include "AudioUnitEffect.h"
 #include "../../ModuleManager.h"
-#include "../../SampleCount.h"
+#include "SampleCount.h"
 
 #include <wx/defs.h>
 #include <wx/base64.h>
diff --git a/src/effects/ladspa/LadspaEffect.h b/src/effects/ladspa/LadspaEffect.h
index ebd001e7025b08cb1cba8e8bb48b3b0161b1e7b1..8c1970e8b0704643c1697bab04464e660f8c9f0f 100644
--- a/src/effects/ladspa/LadspaEffect.h
+++ b/src/effects/ladspa/LadspaEffect.h
@@ -23,7 +23,7 @@ class NumericTextCtrl;
 #include "PluginInterface.h"
 
 #include "ladspa.h"
-#include "../../SampleFormat.h"
+#include "SampleFormat.h"
 
 #define LADSPAEFFECTS_VERSION wxT("1.0.0.0")
 /* i18n-hint: abbreviates "Linux Audio Developer's Simple Plugin API"
diff --git a/src/effects/lv2/LV2Effect.h b/src/effects/lv2/LV2Effect.h
index be249f19137804ce45b94062f8de8612546e43b8..bb5b1d98218a3f9828d989037947ebb2abbc7355 100755
--- a/src/effects/lv2/LV2Effect.h
+++ b/src/effects/lv2/LV2Effect.h
@@ -38,7 +38,7 @@ class wxArrayString;
 #include <suil/suil.h>
 
 #include "../../ShuttleGui.h"
-#include "../../SampleFormat.h"
+#include "SampleFormat.h"
 
 #include "LoadLV2.h"
 #include "NativeWindow.h"
diff --git a/src/export/Export.h b/src/export/Export.h
index f972e3c027f396489bc77b146d815fbb53191b6c..7a88e931133aeb7fc82593dc065592a05fa79e28 100644
--- a/src/export/Export.h
+++ b/src/export/Export.h
@@ -15,7 +15,7 @@
 #include <vector>
 #include <wx/filename.h> // member variable
 #include "Identifier.h"
-#include "../SampleFormat.h"
+#include "SampleFormat.h"
 #include "../widgets/wxPanelWrapper.h" // to inherit
 #include "../FileNames.h" // for FileTypes
 
diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp
index 236a1c98e17748b1c79dd1c90db190eb8e1bfd26..096dfa2df0a56d2ea9a36380cd0827f37d7c6671 100644
--- a/src/export/ExportCL.cpp
+++ b/src/export/ExportCL.cpp
@@ -35,7 +35,7 @@
 #include "../ShuttleGui.h"
 #include "../Tags.h"
 #include "../Track.h"
-#include "../float_cast.h"
+#include "float_cast.h"
 #include "../widgets/FileHistory.h"
 #include "../widgets/AudacityMessageBox.h"
 #include "../widgets/ProgressDialog.h"
diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp
index 98efdf030a1c1996a735b16569058bd1ae1dfe08..a4f1f3cc9b705184e22dda111b61077942e2637d 100644
--- a/src/export/ExportFLAC.cpp
+++ b/src/export/ExportFLAC.cpp
@@ -29,7 +29,7 @@ and libvorbis examples, Monty <monty@xiph.org>
 
 #include "FLAC++/encoder.h"
 
-#include "../float_cast.h"
+#include "float_cast.h"
 #include "../ProjectSettings.h"
 #include "../Mix.h"
 #include "Prefs.h"
diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp
index 4c998e05487cbe1b4ef7cc3885f2998ceb43997c..46fb1db3f691df7b0191e45bb7f0ff85f26a5e64 100644
--- a/src/export/ExportMP3.cpp
+++ b/src/export/ExportMP3.cpp
@@ -80,7 +80,7 @@
 #include <wx/window.h>
 
 #include "../FileNames.h"
-#include "../float_cast.h"
+#include "float_cast.h"
 #include "../Mix.h"
 #include "Prefs.h"
 #include "../ProjectSettings.h"
diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp
index a7fffd27972523f00b60e78e5db884ba34eb4f94..f2edfe9bee5f981502bdcd1e1b7bbb3037153957 100644
--- a/src/export/ExportPCM.cpp
+++ b/src/export/ExportPCM.cpp
@@ -24,6 +24,7 @@
 
 #include "sndfile.h"
 
+#include "Dither.h"
 #include "../FileFormats.h"
 #include "../Mix.h"
 #include "Prefs.h"
diff --git a/src/import/ImportPlugin.h b/src/import/ImportPlugin.h
index 78c9fb54d02a4e88791956b8433186f56963022c..7a9d6f95899d96a66970913104ba1306018caba8 100644
--- a/src/import/ImportPlugin.h
+++ b/src/import/ImportPlugin.h
@@ -51,6 +51,7 @@ but little else.
 #include "audacity/Types.h"
 #include "Identifier.h"
 #include "Internat.h"
+#include "SampleFormat.h"
 #include "wxArrayStringEx.h"
 
 class AudacityProject;
diff --git a/src/import/SpecPowerMeter.cpp b/src/import/SpecPowerMeter.cpp
index a0b2a2c21cfdd2103e0c3fd2505a9e313cf859a8..45020d30ee12ac30ef938e06a1d8298fb0d063d7 100644
--- a/src/import/SpecPowerMeter.cpp
+++ b/src/import/SpecPowerMeter.cpp
@@ -22,7 +22,7 @@ measurements in subbands or in the entire signal band.
 #include <cstdlib>
 #include <wx/defs.h>
 
-#include "../FFT.h"
+#include "FFT.h"
 
 SpecPowerCalculation::SpecPowerCalculation(size_t sigLen)
   : mSigLen(sigLen)
diff --git a/src/import/SpecPowerMeter.h b/src/import/SpecPowerMeter.h
index 5fba4fe71a2643ad7e8b12e737a84ff4f695f85b..9df7dff49f2a52659787785b40be9d97a53e873a 100644
--- a/src/import/SpecPowerMeter.h
+++ b/src/import/SpecPowerMeter.h
@@ -12,7 +12,7 @@
 #define __AUDACITY_SPECPOWERMETER_H_
 
 #include <cstddef>
-#include "../SampleFormat.h"
+#include "SampleFormat.h"
 
 class SpecPowerCalculation
 {
diff --git a/src/prefs/QualityPrefs.cpp b/src/prefs/QualityPrefs.cpp
index 1357c66111a7b6cb9012931da732d408ba34092c..f16fc20cfbc34f0ecf21d309a0ab13d6d4b41c30 100644
--- a/src/prefs/QualityPrefs.cpp
+++ b/src/prefs/QualityPrefs.cpp
@@ -24,7 +24,7 @@
 #include <wx/textctrl.h>
 
 #include "../AudioIOBase.h"
-#include "../Dither.h"
+#include "Dither.h"
 #include "Prefs.h"
 #include "../Resample.h"
 #include "../ShuttleGui.h"
diff --git a/src/prefs/QualitySettings.h b/src/prefs/QualitySettings.h
index fb5431160b38c4655a3f484cb66f9cc8c9ae5f68..9bc0b430e6503a3c0a22e682c9a2cfe19899348b 100644
--- a/src/prefs/QualitySettings.h
+++ b/src/prefs/QualitySettings.h
@@ -13,6 +13,7 @@
 
 #include <audacity/Types.h>
 #include "Prefs.h" // for EnumSetting
+#include "SampleFormat.h"
 
 class IntSetting;
 
diff --git a/src/prefs/SpectrogramSettings.cpp b/src/prefs/SpectrogramSettings.cpp
index 66ecc675efba2cb57997c7f6e574d983a1021434..c71b0e3bf0ed6d67df081c83efe2c3749cd96e70 100644
--- a/src/prefs/SpectrogramSettings.cpp
+++ b/src/prefs/SpectrogramSettings.cpp
@@ -21,7 +21,7 @@ Paul Licameli
 
 #include <algorithm>
 
-#include "../FFT.h"
+#include "FFT.h"
 #include "Prefs.h"
 
 #include <cmath>
diff --git a/src/prefs/SpectrogramSettings.h b/src/prefs/SpectrogramSettings.h
index b1d7e749568dacf7faa6048bc5116e25838cfb36..fecab413e38fd65a71a82138519b861b8d959b1b 100644
--- a/src/prefs/SpectrogramSettings.h
+++ b/src/prefs/SpectrogramSettings.h
@@ -12,8 +12,8 @@ Paul Licameli
 #define __AUDACITY_SPECTROGRAM_SETTINGS__
 
 #include "Prefs.h"
-#include "../SampleFormat.h"
-#include "../RealFFTf.h"
+#include "SampleFormat.h"
+#include "RealFFTf.h"
 
 #undef SPECTRAL_SELECTION_GLOBAL_SWITCH
 
diff --git a/src/prefs/SpectrumPrefs.cpp b/src/prefs/SpectrumPrefs.cpp
index 1dd719079c8da908a862bd155cba464e4cf020bb..e9feefb9432b75ef12521ce60162709ff822e38b 100644
--- a/src/prefs/SpectrumPrefs.cpp
+++ b/src/prefs/SpectrumPrefs.cpp
@@ -23,7 +23,7 @@
 #include <wx/checkbox.h>
 #include <wx/textctrl.h>
 
-#include "../FFT.h"
+#include "FFT.h"
 #include "../Project.h"
 #include "../ShuttleGui.h"
 
diff --git a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h
index 004e0f272df37589eefd62c6eea4c2617064ced1..5899fca23da758c53d0addc1d73d2c22e38f9613 100644
--- a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h
+++ b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.h
@@ -12,7 +12,7 @@ Paul Licameli
 #define __AUDACITY_SAMPLE_HANDLE__
 
 #include "../../../../UIHandle.h"
-#include "../../../../SampleCount.h"
+#include "SampleCount.h"
 
 class wxMouseEvent;
 class wxMouseState;
diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.h b/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.h
index 144e1de23606f91c6b502909ecd7867b6eb24ae0..1c0554e18df6f5ccea3bd145a45cfaa9d64a86e9 100644
--- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.h
+++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.h
@@ -13,7 +13,7 @@ Paul Licameli split from class WaveTrack
 
 #include "../../../ui/CommonTrackView.h"
 #include "../../../../ClientData.h"
-#include "../../../../SampleCount.h"
+#include "SampleCount.h"
 namespace WaveTrackViewConstants{ enum Display : int; }
 struct WaveTrackSubViewType;
 
diff --git a/src/widgets/Meter.h b/src/widgets/Meter.h
index 2c22c30205364d3585b02fab44afd608fcef4c6b..e6060e92f079342f479ffb0212a673f18762902e 100644
--- a/src/widgets/Meter.h
+++ b/src/widgets/Meter.h
@@ -21,7 +21,7 @@
 #include <wx/defs.h>
 #include <wx/timer.h> // member variable
 
-#include "../SampleFormat.h"
+#include "SampleFormat.h"
 #include "Prefs.h"
 #include "MeterPanelBase.h" // to inherit
 #include "Ruler.h" // member variable
diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp
index edbe85d3b60c14512b2b999af69414912fae4a73..9a034078749783c9ec8a8fb455af2c6cae7d88f4 100644
--- a/src/widgets/NumericTextCtrl.cpp
+++ b/src/widgets/NumericTextCtrl.cpp
@@ -168,7 +168,7 @@ different formats.
 
 #include "NumericTextCtrl.h"
 
-#include "../SampleCount.h"
+#include "SampleCount.h"
 #include "../AllThemeResources.h"
 #include "../AColor.h"
 #include "../KeyboardCapture.h"
diff --git a/src/xml/XMLTagHandler.cpp b/src/xml/XMLTagHandler.cpp
index 8e32f1773750e694d08cf5276a503d2adaba60ff..1dd6fa0327767892cb98b052a4716d92c91a4d4c 100644
--- a/src/xml/XMLTagHandler.cpp
+++ b/src/xml/XMLTagHandler.cpp
@@ -35,6 +35,7 @@
 #include <wx/filename.h>
 
 #include "FileNames.h"
+#include "SampleFormat.h"
 
 // Length check.  Is in part about not supplying malicious strings to file functions.
 bool XMLValueChecker::IsGoodString(const wxString & str)