diff --git a/Makefile b/Makefile
index 6b7036f8c..05b848121 100644
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,6 @@ ALL_LIBS += $(MODULEDIR)/carla_engine_plugin.a
ALL_LIBS += $(MODULEDIR)/carla_plugin.a
ALL_LIBS += $(MODULEDIR)/jackbridge.a
ALL_LIBS += $(MODULEDIR)/native-plugins.a
-ALL_LIBS += $(MODULEDIR)/juce_audio_basics.a
ALL_LIBS += $(MODULEDIR)/juce_core.a
ALL_LIBS += $(MODULEDIR)/lilv.a
ALL_LIBS += $(MODULEDIR)/rtmempool.a
@@ -150,7 +149,6 @@ theme: libs
# Binaries (posix32)
LIBS_POSIX32 = $(MODULEDIR)/jackbridge.posix32.a
-LIBS_POSIX32 += $(MODULEDIR)/juce_audio_basics.posix32.a
LIBS_POSIX32 += $(MODULEDIR)/juce_core.posix32.a
LIBS_POSIX32 += $(MODULEDIR)/lilv.posix32.a
LIBS_POSIX32 += $(MODULEDIR)/rtmempool.posix32.a
@@ -163,7 +161,6 @@ posix32: $(LIBS_POSIX32)
# Binaries (posix64)
LIBS_POSIX64 = $(MODULEDIR)/jackbridge.posix64.a
-LIBS_POSIX64 += $(MODULEDIR)/juce_audio_basics.posix64.a
LIBS_POSIX64 += $(MODULEDIR)/juce_core.posix64.a
LIBS_POSIX64 += $(MODULEDIR)/lilv.posix64.a
LIBS_POSIX64 += $(MODULEDIR)/rtmempool.posix64.a
@@ -180,7 +177,6 @@ LIBS_WIN32 = $(MODULEDIR)/jackbridge.win32.a
else
LIBS_WIN32 = $(MODULEDIR)/jackbridge.win32e.a
endif
-LIBS_WIN32 += $(MODULEDIR)/juce_audio_basics.win32.a
LIBS_WIN32 += $(MODULEDIR)/juce_core.win32.a
LIBS_WIN32 += $(MODULEDIR)/lilv.win32.a
LIBS_WIN32 += $(MODULEDIR)/rtmempool.win32.a
@@ -197,7 +193,6 @@ LIBS_WIN64 = $(MODULEDIR)/jackbridge.win64.a
else
LIBS_WIN64 = $(MODULEDIR)/jackbridge.win64e.a
endif
-LIBS_WIN64 += $(MODULEDIR)/juce_audio_basics.win64.a
LIBS_WIN64 += $(MODULEDIR)/juce_core.win64.a
LIBS_WIN64 += $(MODULEDIR)/lilv.win64.a
LIBS_WIN64 += $(MODULEDIR)/rtmempool.win64.a
diff --git a/resources/48x48/juce.png b/resources/48x48/juce.png
deleted file mode 100644
index 365d3d542..000000000
Binary files a/resources/48x48/juce.png and /dev/null differ
diff --git a/resources/resources.qrc b/resources/resources.qrc
index 606b0f5a5..852862e75 100644
--- a/resources/resources.qrc
+++ b/resources/resources.qrc
@@ -39,7 +39,6 @@
48x48/canvas.png
48x48/jack.png
- 48x48/juce.png
48x48/folder.png
48x48/warning.png
48x48/wine.png
diff --git a/source/Makefile.mk b/source/Makefile.mk
index 1f2b8f968..370b8e0a0 100644
--- a/source/Makefile.mk
+++ b/source/Makefile.mk
@@ -401,7 +401,6 @@ ifeq ($(MACOS),true)
DGL_LIBS = -framework OpenGL -framework Cocoa
HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
JACKBRIDGE_LIBS = -ldl -lpthread
-JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
JUCE_CORE_LIBS = -framework AppKit
LILV_LIBS = -ldl -lm
RTAUDIO_FLAGS += -D__MACOSX_CORE__
diff --git a/source/backend/Makefile b/source/backend/Makefile
index f441d334e..806ca4c79 100644
--- a/source/backend/Makefile
+++ b/source/backend/Makefile
@@ -26,7 +26,6 @@ STANDALONE_LIBS = $(MODULEDIR)/carla_engine.a
STANDALONE_LIBS += $(MODULEDIR)/carla_plugin.a
STANDALONE_LIBS += $(MODULEDIR)/jackbridge.a
-STANDALONE_LIBS += $(MODULEDIR)/juce_audio_basics.a
STANDALONE_LIBS += $(MODULEDIR)/juce_core.a
STANDALONE_LIBS += $(MODULEDIR)/lilv.a
STANDALONE_LIBS += $(MODULEDIR)/native-plugins.a
@@ -43,14 +42,12 @@ endif
STANDALONE_LIBS += $(MODULEDIR)/rtaudio.a
STANDALONE_LIBS += $(MODULEDIR)/rtmidi.a
-UTILS_LIBS = $(MODULEDIR)/juce_audio_basics.a
UTILS_LIBS += $(MODULEDIR)/juce_core.a
UTILS_LIBS += $(MODULEDIR)/lilv.a
# ----------------------------------------------------------------------------------------------------------------------------
STANDALONE_LINK_FLAGS = $(JACKBRIDGE_LIBS)
-STANDALONE_LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS)
STANDALONE_LINK_FLAGS += $(JUCE_CORE_LIBS)
STANDALONE_LINK_FLAGS += $(LILV_LIBS)
STANDALONE_LINK_FLAGS += $(NATIVE_PLUGINS_LIBS)
@@ -79,7 +76,6 @@ ifeq ($(HAVE_X11),true)
STANDALONE_LINK_FLAGS += $(X11_LIBS)
endif
-UTILS_LINK_FLAGS = $(JUCE_AUDIO_BASICS_LIBS)
UTILS_LINK_FLAGS += $(JUCE_CORE_LIBS)
UTILS_LINK_FLAGS += $(LILV_LIBS)
diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp
index 0753e4e5d..61923279f 100644
--- a/source/backend/engine/CarlaEngineGraph.cpp
+++ b/source/backend/engine/CarlaEngineGraph.cpp
@@ -883,8 +883,6 @@ void RackGraph::processHelper(CarlaEngine::ProtectedData* const data, const floa
{
CARLA_SAFE_ASSERT_RETURN(audioBuffers.outBuf[1] != nullptr,);
- const int iframes(static_cast(frames));
-
const CarlaRecursiveMutexLocker _cml(audioBuffers.mutex);
if (inBuf != nullptr && inputs > 0)
@@ -910,7 +908,7 @@ void RackGraph::processHelper(CarlaEngine::ProtectedData* const data, const floa
}
if (noConnections)
- carla_zeroFloats(audioBuffers.inBuf[0], iframes);
+ carla_zeroFloats(audioBuffers.inBuf[0], frames);
noConnections = true;
diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp
index f83d9de8c..c78c7e70e 100644
--- a/source/backend/plugin/CarlaPluginBridge.cpp
+++ b/source/backend/plugin/CarlaPluginBridge.cpp
@@ -1035,9 +1035,9 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
for (uint32_t i=0; i < pData->cvOut.count; ++i)
- FloatVectorOperations::clear(cvOut[i], static_cast(frames));
+ carla_zeroFloats(cvOut[i], frames);
return;
}
@@ -1344,8 +1344,6 @@ public:
CARLA_SAFE_ASSERT_RETURN(cvOut != nullptr, false);
}
- const int iframes(static_cast(frames));
-
// --------------------------------------------------------------------------------------------------------
// Try lock, silence otherwise
@@ -1356,9 +1354,9 @@ public:
else if (! pData->singleMutex.tryLock())
{
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], iframes);
+ carla_zeroFloats(audioOut[i], frames);
for (uint32_t i=0; i < pData->cvOut.count; ++i)
- FloatVectorOperations::clear(cvOut[i], iframes);
+ carla_zeroFloats(cvOut[i], frames);
return false;
}
@@ -1366,7 +1364,7 @@ public:
// Reset audio buffers
for (uint32_t i=0; i < fInfo.aIns; ++i)
- FloatVectorOperations::copy(fShmAudioPool.data + (i * frames), audioIn[i], iframes);
+ carla_copyFloats(fShmAudioPool.data + (i * frames), audioIn[i], frames);
// --------------------------------------------------------------------------------------------------------
// TimeInfo
@@ -1410,7 +1408,7 @@ public:
}
for (uint32_t i=0; i < fInfo.aOuts; ++i)
- FloatVectorOperations::copy(audioOut[i], fShmAudioPool.data + ((i + fInfo.aIns) * frames), iframes);
+ carla_copyFloats(audioOut[i], fShmAudioPool.data + ((i + fInfo.aIns) * frames), frames);
#ifndef BUILD_BRIDGE
// --------------------------------------------------------------------------------------------------------
@@ -1453,7 +1451,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
- FloatVectorOperations::copy(oldBufLeft, audioOut[i], iframes);
+ carla_copyFloats(oldBufLeft, audioOut[i], frames);
}
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
@@ -1494,7 +1492,7 @@ public:
if (latframes <= frames)
{
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(pData->latency.buffers[i], audioIn[i]+(frames-latframes), static_cast(latframes));
+ carla_copyFloats(pData->latency.buffers[i], audioIn[i]+(frames-latframes), latframes);
}
else
{
diff --git a/source/backend/plugin/CarlaPluginDSSI.cpp b/source/backend/plugin/CarlaPluginDSSI.cpp
index bd08d3aeb..6e66f0097 100644
--- a/source/backend/plugin/CarlaPluginDSSI.cpp
+++ b/source/backend/plugin/CarlaPluginDSSI.cpp
@@ -777,7 +777,7 @@ public:
pData->param.createNew(params, true);
fParamBuffers = new float[params];
- FloatVectorOperations::clear(fParamBuffers, static_cast(params));
+ carla_zeroFloats(fParamBuffers, params);
}
const uint portNameSize(pData->engine->getMaxPortNameSize());
@@ -1294,7 +1294,7 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
return;
}
@@ -1764,8 +1764,6 @@ public:
return false;
}
- const int iframes(static_cast(frames));
-
// --------------------------------------------------------------------------------------------------------
// Set audio buffers
@@ -1775,11 +1773,11 @@ public:
if (! customMonoOut)
{
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(fAudioOutBuffers[i], iframes);
+ carla_zeroFloats(fAudioOutBuffers[i], frames);
}
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(fAudioInBuffers[i], audioIn[i]+timeOffset, iframes);
+ carla_copyFloats(fAudioInBuffers[i], audioIn[i]+timeOffset, frames);
// --------------------------------------------------------------------------------------------------------
// Run plugin
@@ -1794,7 +1792,7 @@ public:
// Mixdown for forced stereo
if (customMonoOut)
- FloatVectorOperations::clear(fAudioOutBuffers[instn], iframes);
+ carla_zeroFloats(fAudioOutBuffers[instn], frames);
// ----------------------------------------------------------------------------------------------------
// Run it
@@ -1816,15 +1814,15 @@ public:
// Mixdown for forced stereo
if (customMonoOut)
- FloatVectorOperations::multiply(fAudioOutBuffers[instn], 0.5f, iframes);
+ carla_multiply(fAudioOutBuffers[instn], 0.5f, frames);
else if (customStereoOut)
- FloatVectorOperations::copy(fExtraStereoBuffer[instn], fAudioOutBuffers[instn], iframes);
+ carla_copyFloats(fExtraStereoBuffer[instn], fAudioOutBuffers[instn], frames);
}
if (customStereoOut)
{
- FloatVectorOperations::copy(fAudioOutBuffers[0], fExtraStereoBuffer[0], iframes);
- FloatVectorOperations::copy(fAudioOutBuffers[1], fExtraStereoBuffer[1], iframes);
+ carla_copyFloats(fAudioOutBuffers[0], fExtraStereoBuffer[0], frames);
+ carla_copyFloats(fAudioOutBuffers[1], fExtraStereoBuffer[1], frames);
}
#ifndef BUILD_BRIDGE
@@ -1867,7 +1865,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
- FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], iframes);
+ carla_copyFloats(oldBufLeft, fAudioOutBuffers[i], frames);
}
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
@@ -1909,7 +1907,7 @@ public:
if (latframes <= frames)
{
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(pData->latency.buffers[i], audioIn[i]+(frames-latframes), static_cast(latframes));
+ carla_copyFloats(pData->latency.buffers[i], audioIn[i]+(frames-latframes), latframes);
}
else
{
@@ -1947,15 +1945,13 @@ public:
CARLA_ASSERT_INT(newBufferSize > 0, newBufferSize);
carla_debug("CarlaPluginDSSI::bufferSizeChanged(%i) - start", newBufferSize);
- const int iBufferSize(static_cast(newBufferSize));
-
for (uint32_t i=0; i < pData->audioIn.count; ++i)
{
if (fAudioInBuffers[i] != nullptr)
delete[] fAudioInBuffers[i];
fAudioInBuffers[i] = new float[newBufferSize];
- FloatVectorOperations::clear(fAudioInBuffers[i], iBufferSize);
+ carla_zeroFloats(fAudioInBuffers[i], newBufferSize);
}
for (uint32_t i=0; i < pData->audioOut.count; ++i)
@@ -1964,7 +1960,7 @@ public:
delete[] fAudioOutBuffers[i];
fAudioOutBuffers[i] = new float[newBufferSize];
- FloatVectorOperations::clear(fAudioOutBuffers[i], iBufferSize);
+ carla_zeroFloats(fAudioOutBuffers[i], newBufferSize);
}
if (fExtraStereoBuffer[0] != nullptr)
@@ -1983,8 +1979,8 @@ public:
{
fExtraStereoBuffer[0] = new float[newBufferSize];
fExtraStereoBuffer[1] = new float[newBufferSize];
- FloatVectorOperations::clear(fExtraStereoBuffer[0], iBufferSize);
- FloatVectorOperations::clear(fExtraStereoBuffer[1], iBufferSize);
+ carla_zeroFloats(fExtraStereoBuffer[0], newBufferSize);
+ carla_zeroFloats(fExtraStereoBuffer[1], newBufferSize);
}
reconnectAudioPorts();
diff --git a/source/backend/plugin/CarlaPluginFluidSynth.cpp b/source/backend/plugin/CarlaPluginFluidSynth.cpp
index 165a0cd35..2826c52b4 100644
--- a/source/backend/plugin/CarlaPluginFluidSynth.cpp
+++ b/source/backend/plugin/CarlaPluginFluidSynth.cpp
@@ -58,7 +58,7 @@ public:
{
carla_debug("CarlaPluginFluidSynth::CarlaPluginFluidSynth(%p, %i, %s)", engine, id, bool2str(use16Outs));
- FloatVectorOperations::clear(fParamBuffers, FluidSynthParametersMax);
+ carla_zeroFloats(fParamBuffers, FluidSynthParametersMax);
carla_fill(fCurMidiProgs, 0, MAX_MIDI_CHANNELS);
// create settings
@@ -1013,7 +1013,7 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
return;
}
@@ -1405,13 +1405,13 @@ public:
if (kUse16Outs)
{
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(fAudio16Buffers[i], static_cast(frames));
+ carla_zeroFloats(fAudio16Buffers[i], frames);
// FIXME use '32' or '16' instead of outs
- fluid_synth_process(fSynth, static_cast(frames), 0, nullptr, static_cast(pData->audioOut.count), fAudio16Buffers);
+ fluid_synth_process(fSynth, frames, 0, nullptr, static_cast(pData->audioOut.count), fAudio16Buffers);
}
else
- fluid_synth_write_float(fSynth, static_cast(frames), outBuffer[0] + timeOffset, 0, 1, outBuffer[1] + timeOffset, 0, 1);
+ fluid_synth_write_float(fSynth, frames, outBuffer[0] + timeOffset, 0, 1, outBuffer[1] + timeOffset, 0, 1);
#ifndef BUILD_BRIDGE
// --------------------------------------------------------------------------------------------------------
@@ -1430,7 +1430,7 @@ public:
if (doBalance)
{
if (i % 2 == 0)
- FloatVectorOperations::copy(oldBufLeft, outBuffer[i]+timeOffset, static_cast(frames));
+ carla_copyFloats(oldBufLeft, outBuffer[i]+timeOffset, frames);
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f;
diff --git a/source/backend/plugin/CarlaPluginInternal.cpp b/source/backend/plugin/CarlaPluginInternal.cpp
index 14af7148e..35f880beb 100644
--- a/source/backend/plugin/CarlaPluginInternal.cpp
+++ b/source/backend/plugin/CarlaPluginInternal.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Carla Plugin
* Copyright (C) 2011-2014 Filipe Coelho
*
@@ -461,18 +461,18 @@ void CarlaPlugin::ProtectedData::Latency::recreateBuffers(const uint32_t newChan
if (oldFrames > frames)
{
const uint32_t diff = oldFrames - frames;
- FloatVectorOperations::copy(buffers[i], oldBuffers[i] + diff, static_cast(frames));
+ carla_copyFloats(buffers[i], oldBuffers[i] + diff, frames);
}
else
{
const uint32_t diff = frames - oldFrames;
- FloatVectorOperations::clear(buffers[i], static_cast(diff));
- FloatVectorOperations::copy(buffers[i] + diff, oldBuffers[i], static_cast(oldFrames));
+ carla_zeroFloats(buffers[i], diff);
+ carla_copyFloats(buffers[i] + diff, oldBuffers[i], static_cast(oldFrames));
}
}
else
{
- FloatVectorOperations::clear(buffers[i], static_cast(frames));
+ carla_zeroFloats(buffers[i], frames);
}
}
}
diff --git a/source/backend/plugin/CarlaPluginInternal.hpp b/source/backend/plugin/CarlaPluginInternal.hpp
index 68998647a..8a9a14169 100644
--- a/source/backend/plugin/CarlaPluginInternal.hpp
+++ b/source/backend/plugin/CarlaPluginInternal.hpp
@@ -28,10 +28,6 @@
#include "CarlaString.hpp"
#include "RtLinkedList.hpp"
-#include "juce_audio_basics/juce_audio_basics.h"
-
-using juce::FloatVectorOperations;
-
CARLA_BACKEND_START_NAMESPACE
// -----------------------------------------------------------------------
diff --git a/source/backend/plugin/CarlaPluginJack.cpp b/source/backend/plugin/CarlaPluginJack.cpp
index 8a24ac407..d8affed08 100644
--- a/source/backend/plugin/CarlaPluginJack.cpp
+++ b/source/backend/plugin/CarlaPluginJack.cpp
@@ -611,7 +611,7 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
return;
}
@@ -888,8 +888,6 @@ public:
CARLA_SAFE_ASSERT_RETURN(audioOut != nullptr, false);
}
- const int iframes(static_cast(frames));
-
// --------------------------------------------------------------------------------------------------------
// Try lock, silence otherwise
@@ -900,7 +898,7 @@ public:
else if (! pData->singleMutex.tryLock())
{
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], iframes);
+ carla_zeroFloats(audioOut[i], frames);
return false;
}
@@ -908,7 +906,7 @@ public:
// Reset audio buffers
for (uint32_t i=0; i < fInfo.aIns; ++i)
- FloatVectorOperations::copy(fShmAudioPool.data + (i * frames), audioIn[i], iframes);
+ carla_copyFloats(fShmAudioPool.data + (i * frames), audioIn[i], frames);
// --------------------------------------------------------------------------------------------------------
// TimeInfo
@@ -958,7 +956,7 @@ public:
}
for (uint32_t i=0; i < fInfo.aOuts; ++i)
- FloatVectorOperations::copy(audioOut[i], fShmAudioPool.data + ((i + fInfo.aIns) * frames), iframes);
+ carla_copyFloats(audioOut[i], fShmAudioPool.data + ((i + fInfo.aIns) * frames), frames);
#ifndef BUILD_BRIDGE
// --------------------------------------------------------------------------------------------------------
@@ -995,7 +993,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
- FloatVectorOperations::copy(oldBufLeft, audioOut[i], iframes);
+ carla_copyFloats(oldBufLeft, audioOut[i], frames);
}
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
diff --git a/source/backend/plugin/CarlaPluginLADSPA.cpp b/source/backend/plugin/CarlaPluginLADSPA.cpp
index ec5e5f218..f4503d3c7 100644
--- a/source/backend/plugin/CarlaPluginLADSPA.cpp
+++ b/source/backend/plugin/CarlaPluginLADSPA.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Carla Plugin, LADSPA implementation
* Copyright (C) 2011-2017 Filipe Coelho
*
@@ -494,7 +494,7 @@ public:
pData->param.createNew(params, true);
fParamBuffers = new float[params];
- FloatVectorOperations::clear(fParamBuffers, static_cast(params));
+ carla_zeroFloats(fParamBuffers, params);
}
const uint portNameSize(pData->engine->getMaxPortNameSize());
@@ -902,7 +902,7 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
return;
}
@@ -1129,8 +1129,6 @@ public:
return false;
}
- const int iframes(static_cast(frames));
-
// --------------------------------------------------------------------------------------------------------
// Set audio buffers
@@ -1140,11 +1138,11 @@ public:
if (! customMonoOut)
{
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(fAudioOutBuffers[i], iframes);
+ carla_zeroFloats(fAudioOutBuffers[i], frames);
}
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(fAudioInBuffers[i], audioIn[i]+timeOffset, iframes);
+ carla_copyFloats(fAudioInBuffers[i], audioIn[i]+timeOffset, frames);
// --------------------------------------------------------------------------------------------------------
// Run plugin
@@ -1159,7 +1157,7 @@ public:
// Mixdown for forced stereo
if (customMonoOut)
- FloatVectorOperations::clear(fAudioOutBuffers[instn], iframes);
+ carla_zeroFloats(fAudioOutBuffers[instn], frames);
// ----------------------------------------------------------------------------------------------------
// Run it
@@ -1172,15 +1170,15 @@ public:
// Mixdown for forced stereo
if (customMonoOut)
- FloatVectorOperations::multiply(fAudioOutBuffers[instn], 0.5f, iframes);
+ carla_multiply(fAudioOutBuffers[instn], 0.5f, frames);
else if (customStereoOut)
- FloatVectorOperations::copy(fExtraStereoBuffer[instn], fAudioOutBuffers[instn], iframes);
+ carla_copyFloats(fExtraStereoBuffer[instn], fAudioOutBuffers[instn], frames);
}
if (customStereoOut)
{
- FloatVectorOperations::copy(fAudioOutBuffers[0], fExtraStereoBuffer[0], iframes);
- FloatVectorOperations::copy(fAudioOutBuffers[1], fExtraStereoBuffer[1], iframes);
+ carla_copyFloats(fAudioOutBuffers[0], fExtraStereoBuffer[0], frames);
+ carla_copyFloats(fAudioOutBuffers[1], fExtraStereoBuffer[1], frames);
}
#ifndef BUILD_BRIDGE
@@ -1223,7 +1221,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
- FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], iframes);
+ carla_copyFloats(oldBufLeft, fAudioOutBuffers[i], frames);
}
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
@@ -1265,7 +1263,7 @@ public:
if (latframes <= frames)
{
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(pData->latency.buffers[i], audioIn[i]+(frames-latframes), static_cast(latframes));
+ carla_copyFloats(pData->latency.buffers[i], audioIn[i]+(frames-latframes), static_cast(latframes));
}
else
{
@@ -1303,15 +1301,13 @@ public:
CARLA_ASSERT_INT(newBufferSize > 0, newBufferSize);
carla_debug("CarlaPluginLADSPA::bufferSizeChanged(%i) - start", newBufferSize);
- const int iBufferSize(static_cast(newBufferSize));
-
for (uint32_t i=0; i < pData->audioIn.count; ++i)
{
if (fAudioInBuffers[i] != nullptr)
delete[] fAudioInBuffers[i];
fAudioInBuffers[i] = new float[newBufferSize];
- FloatVectorOperations::clear(fAudioInBuffers[i], iBufferSize);
+ carla_zeroFloats(fAudioInBuffers[i], newBufferSize);
}
for (uint32_t i=0; i < pData->audioOut.count; ++i)
@@ -1320,7 +1316,7 @@ public:
delete[] fAudioOutBuffers[i];
fAudioOutBuffers[i] = new float[newBufferSize];
- FloatVectorOperations::clear(fAudioOutBuffers[i], iBufferSize);
+ carla_zeroFloats(fAudioOutBuffers[i], newBufferSize);
}
if (fExtraStereoBuffer[0] != nullptr)
@@ -1339,8 +1335,8 @@ public:
{
fExtraStereoBuffer[0] = new float[newBufferSize];
fExtraStereoBuffer[1] = new float[newBufferSize];
- FloatVectorOperations::clear(fExtraStereoBuffer[0], iBufferSize);
- FloatVectorOperations::clear(fExtraStereoBuffer[1], iBufferSize);
+ carla_zeroFloats(fExtraStereoBuffer[0], newBufferSize);
+ carla_zeroFloats(fExtraStereoBuffer[1], newBufferSize);
}
reconnectAudioPorts();
diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp
index 38cc1681b..dc6da0108 100644
--- a/source/backend/plugin/CarlaPluginLV2.cpp
+++ b/source/backend/plugin/CarlaPluginLV2.cpp
@@ -1736,7 +1736,7 @@ public:
{
pData->param.createNew(params, true);
fParamBuffers = new float[params];
- FloatVectorOperations::clear(fParamBuffers, static_cast(params));
+ carla_zeroFloats(fParamBuffers, params);
}
if (const uint32_t count = static_cast(evIns.count()))
@@ -2655,9 +2655,9 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
for (uint32_t i=0; i < pData->cvOut.count; ++i)
- FloatVectorOperations::clear(cvOut[i], static_cast(frames));
+ carla_zeroFloats(cvOut[i], frames);
return;
}
@@ -3574,25 +3574,23 @@ public:
return false;
}
- const int iframes(static_cast(frames));
-
// --------------------------------------------------------------------------------------------------------
// Set audio buffers
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(fAudioInBuffers[i], audioIn[i]+timeOffset, iframes);
+ carla_copyFloats(fAudioInBuffers[i], audioIn[i]+timeOffset, frames);
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(fAudioOutBuffers[i], iframes);
+ carla_zeroFloats(fAudioOutBuffers[i], frames);
// --------------------------------------------------------------------------------------------------------
// Set CV buffers
for (uint32_t i=0; i < pData->cvIn.count; ++i)
- FloatVectorOperations::copy(fCvInBuffers[i], cvIn[i]+timeOffset, iframes);
+ carla_copyFloats(fCvInBuffers[i], cvIn[i]+timeOffset, frames);
for (uint32_t i=0; i < pData->cvOut.count; ++i)
- FloatVectorOperations::clear(fCvOutBuffers[i], iframes);
+ carla_zeroFloats(fCvOutBuffers[i], frames);
// --------------------------------------------------------------------------------------------------------
// Run plugin
@@ -3662,7 +3660,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
- FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], iframes);
+ carla_copyFloats(oldBufLeft, fAudioOutBuffers[i], frames);
}
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
@@ -3703,7 +3701,7 @@ public:
if (latframes <= frames)
{
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(pData->latency.buffers[i], audioIn[i]+(frames-latframes), static_cast(latframes));
+ carla_copyFloats(pData->latency.buffers[i], audioIn[i]+(frames-latframes), latframes);
}
else
{
diff --git a/source/backend/plugin/CarlaPluginLinuxSampler.cpp b/source/backend/plugin/CarlaPluginLinuxSampler.cpp
index 9f2e16373..09a9e0f45 100644
--- a/source/backend/plugin/CarlaPluginLinuxSampler.cpp
+++ b/source/backend/plugin/CarlaPluginLinuxSampler.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Carla LinuxSampler Plugin
* Copyright (C) 2011-2014 Filipe Coelho
*
@@ -799,7 +799,7 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
fParamBuffers[LinuxSamplerDiskStreamCount] = 0.0f;
fParamBuffers[LinuxSamplerVoiceCount] = 0.0f;
@@ -1128,7 +1128,7 @@ public:
if (doBalance)
{
if (i % 2 == 0)
- FloatVectorOperations::copy(oldBufLeft, outBuffer[i], static_cast(frames));
+ carla_copyFloats(oldBufLeft, outBuffer[i], frames);
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f;
diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp
index 65cf70d1e..7159ed98e 100644
--- a/source/backend/plugin/CarlaPluginNative.cpp
+++ b/source/backend/plugin/CarlaPluginNative.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Carla Native Plugin
* Copyright (C) 2012-2014 Filipe Coelho
*
@@ -1327,9 +1327,9 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
for (uint32_t i=0; i < pData->cvOut.count; ++i)
- FloatVectorOperations::clear(cvOut[i], static_cast(frames));
+ carla_zeroFloats(cvOut[i], frames);
return;
}
@@ -1860,20 +1860,20 @@ public:
// Set audio buffers
for (uint32_t i=0; i < pData->audioIn.count; ++i)
- FloatVectorOperations::copy(fAudioInBuffers[i], audioIn[i]+timeOffset, static_cast(frames));
+ carla_copyFloats(fAudioInBuffers[i], audioIn[i]+timeOffset, frames);
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(fAudioOutBuffers[i], static_cast(frames));
+ carla_zeroFloats(fAudioOutBuffers[i], frames);
#if 0
// --------------------------------------------------------------------------------------------------------
// Set CV buffers
for (uint32_t i=0; i < pData->cvIn.count; ++i)
- FloatVectorOperations::copy(fCvInBuffers[i], cvIn[i]+timeOffset, static_cast(frames));
+ carla_copyFloats(fCvInBuffers[i], cvIn[i]+timeOffset, frames);
for (uint32_t i=0; i < pData->cvOut.count; ++i)
- FloatVectorOperations::clear(fCvOutBuffers[i], static_cast(frames));
+ carla_zeroFloats(fCvOutBuffers[i], frames);
#endif
// --------------------------------------------------------------------------------------------------------
@@ -1932,7 +1932,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
- FloatVectorOperations::copy(oldBufLeft, fAudioOutBuffers[i], static_cast(frames));
+ carla_copyFloats(oldBufLeft, fAudioOutBuffers[i], frames);
}
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp
index e9abcb545..05390b46d 100644
--- a/source/backend/plugin/CarlaPluginVST2.cpp
+++ b/source/backend/plugin/CarlaPluginVST2.cpp
@@ -993,7 +993,7 @@ public:
{
// disable any output sound
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(audioOut[i], static_cast(frames));
+ carla_zeroFloats(audioOut[i], frames);
return;
}
@@ -1489,7 +1489,7 @@ public:
else
{
for (uint32_t i=0; i < pData->audioOut.count; ++i)
- FloatVectorOperations::clear(vstOutBuffer[i], static_cast(frames));
+ carla_zeroFloats(vstOutBuffer[i], frames);
#if ! VST_FORCE_DEPRECATED
fEffect->process(fEffect, (pData->audioIn.count > 0) ? vstInBuffer : nullptr, (pData->audioOut.count > 0) ? vstOutBuffer : nullptr, static_cast(frames));
@@ -1532,7 +1532,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
- FloatVectorOperations::copy(oldBufLeft, outBuffer[i]+timeOffset, static_cast(frames));
+ carla_copyFloats(oldBufLeft, outBuffer[i]+timeOffset, frames);
}
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
diff --git a/source/bridges-plugin/Makefile b/source/bridges-plugin/Makefile
index e0904cb1b..4a5210d93 100644
--- a/source/bridges-plugin/Makefile
+++ b/source/bridges-plugin/Makefile
@@ -43,13 +43,6 @@ LIBS_win64 = $(MODULEDIR)/jackbridge.win64e.a
endif
LINK_FLAGS += $(JACKBRIDGE_LIBS)
-LIBS_native += $(MODULEDIR)/juce_audio_basics.a
-LIBS_posix32 += $(MODULEDIR)/juce_audio_basics.posix32.a
-LIBS_posix64 += $(MODULEDIR)/juce_audio_basics.posix64.a
-LIBS_win32 += $(MODULEDIR)/juce_audio_basics.win32.a
-LIBS_win64 += $(MODULEDIR)/juce_audio_basics.win64.a
-LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS)
-
LIBS_native += $(MODULEDIR)/juce_core.a
LIBS_posix32 += $(MODULEDIR)/juce_core.posix32.a
LIBS_posix64 += $(MODULEDIR)/juce_core.posix64.a
diff --git a/source/carla_backend.pro b/source/carla_backend.pro
index 58f5c5c17..8459a4bc3 100644
--- a/source/carla_backend.pro
+++ b/source/carla_backend.pro
@@ -76,15 +76,7 @@ INCLUDEPATH = \
LIBS = \
# Pre-Compiled modules
../build/modules/Debug/jackbridge.a \
- ../build/modules/Debug/juce_audio_basics.a \
- ../build/modules/Debug/juce_audio_devices.a \
- ../build/modules/Debug/juce_audio_formats.a \
- ../build/modules/Debug/juce_audio_processors.a \
../build/modules/Debug/juce_core.a \
- ../build/modules/Debug/juce_data_structures.a \
- ../build/modules/Debug/juce_events.a \
- ../build/modules/Debug/juce_graphics.a \
- ../build/modules/Debug/juce_gui_basics.a \
../build/modules/Debug/lilv.a \
../build/modules/Debug/native-plugins.a \
../build/modules/Debug/rtmempool.a
diff --git a/source/libjack/Makefile b/source/libjack/Makefile
index f6d691973..13da478cd 100644
--- a/source/libjack/Makefile
+++ b/source/libjack/Makefile
@@ -24,8 +24,6 @@ endif
BUILD_C_FLAGS += -I$(CWD) -I$(CWD)/includes
BUILD_CXX_FLAGS += -I$(CWD) -I$(CWD)/backend -I$(CWD)/includes -I$(CWD)/modules -I$(CWD)/utils
LINK_FLAGS += $(MODULEDIR)/juce_core.a
-LINK_FLAGS += $(MODULEDIR)/juce_audio_basics.a
-LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS)
LINK_FLAGS += $(JUCE_CORE_LIBS)
# ----------------------------------------------------------------------------------------------------------------------
diff --git a/source/libjack/libjack.cpp b/source/libjack/libjack.cpp
index ed1218d3c..1b29db0e5 100644
--- a/source/libjack/libjack.cpp
+++ b/source/libjack/libjack.cpp
@@ -20,7 +20,6 @@
#include "CarlaThread.hpp"
-using juce::FloatVectorOperations;
using juce::Thread;
using juce::Time;
@@ -367,7 +366,7 @@ bool CarlaJackAppClient::initSharedMemmory()
}
fAudioTmpBuf = new float[fServer.bufferSize];
- FloatVectorOperations::clear(fAudioTmpBuf, fServer.bufferSize);
+ carla_zeroFloats(fAudioTmpBuf, fServer.bufferSize);
// tell backend we're live
const CarlaMutexLocker _cml(fShmNonRtServerControl.mutex);
@@ -479,7 +478,7 @@ bool CarlaJackAppClient::handleRtData()
delete[] fAudioTmpBuf;
fAudioTmpBuf = new float[fServer.bufferSize];
- FloatVectorOperations::clear(fAudioTmpBuf, fServer.bufferSize);
+ carla_zeroFloats(fAudioTmpBuf, fServer.bufferSize);
}
}
break;
@@ -565,7 +564,7 @@ bool CarlaJackAppClient::handleRtData()
float* const fdataRealOuts = fShmAudioPool.data+(fServer.bufferSize*fServer.numAudioIns);
if (doBufferAddition && fServer.numAudioOuts > 0)
- FloatVectorOperations::clear(fdataRealOuts, fServer.bufferSize*fServer.numAudioOuts);
+ carla_zeroFloats(fdataRealOuts, fServer.bufferSize*fServer.numAudioOuts);
if (! fClients.isEmpty())
{
@@ -611,7 +610,7 @@ bool CarlaJackAppClient::handleRtData()
if (cmtl2.wasNotLocked() || jclient->processCb == nullptr || ! jclient->activated)
{
if (fServer.numAudioOuts > 0)
- FloatVectorOperations::clear(fdataRealOuts, fServer.bufferSize*fServer.numAudioOuts);
+ carla_zeroFloats(fdataRealOuts, fServer.bufferSize*fServer.numAudioOuts);
if (jclient->deactivated)
fShmRtClientControl.data->procFlags = 1;
@@ -680,7 +679,7 @@ bool CarlaJackAppClient::handleRtData()
if (i < fServer.numAudioOuts)
{
const std::size_t remainingBufferSize = fServer.bufferSize * (fServer.numAudioOuts - i);
- FloatVectorOperations::clear(fdataCopy, remainingBufferSize);
+ carla_zeroFloats(fdataCopy, remainingBufferSize);
fdataCopy += remainingBufferSize;
}
@@ -711,7 +710,7 @@ bool CarlaJackAppClient::handleRtData()
}
if (needsTmpBufClear)
- FloatVectorOperations::clear(fAudioTmpBuf, fServer.bufferSize);
+ carla_zeroFloats(fAudioTmpBuf, fServer.bufferSize);
jclient->processCb(fServer.bufferSize, jclient->processCbPtr);
@@ -720,21 +719,21 @@ bool CarlaJackAppClient::handleRtData()
if (++numClientOutputsProcessed == 1)
{
// first client, we can copy stuff over
- FloatVectorOperations::copy(fdataRealOuts, fdataCopyOuts,
- fServer.bufferSize*fServer.numAudioOuts);
+ carla_copyFloats(fdataRealOuts, fdataCopyOuts,
+ fServer.bufferSize*fServer.numAudioOuts);
}
else
{
// subsequent clients, add data (then divide by number of clients later on)
- FloatVectorOperations::add(fdataRealOuts, fdataCopyOuts,
- fServer.bufferSize*fServer.numAudioOuts);
+ carla_add(fdataRealOuts, fdataCopyOuts,
+ fServer.bufferSize*fServer.numAudioOuts);
if (doBufferAddition)
{
// for more than 1 client addition, we need to divide buffers now
- FloatVectorOperations::multiply(fdataRealOuts,
- 1.0f/static_cast(numClientOutputsProcessed),
- fServer.bufferSize*fServer.numAudioOuts);
+ carla_multiply(fdataRealOuts,
+ 1.0f/static_cast(numClientOutputsProcessed),
+ fServer.bufferSize*fServer.numAudioOuts);
}
}
@@ -742,9 +741,9 @@ bool CarlaJackAppClient::handleRtData()
{
for (uint8_t i=1; i 1 && ! doBufferAddition)
{
// more than 1 client active, need to divide buffers
- FloatVectorOperations::multiply(fdataRealOuts,
- 1.0f/static_cast(numClientOutputsProcessed),
- fServer.bufferSize*fServer.numAudioOuts);
+ carla_multiply(fdataRealOuts,
+ 1.0f/static_cast(numClientOutputsProcessed),
+ fServer.bufferSize*fServer.numAudioOuts);
}
}
// fClients.isEmpty()
else if (fServer.numAudioOuts > 0)
{
- FloatVectorOperations::clear(fdataRealOuts, fServer.bufferSize*fServer.numAudioOuts);
+ carla_zeroFloats(fdataRealOuts, fServer.bufferSize*fServer.numAudioOuts);
}
for (uint8_t i=0; i
diff --git a/source/modules/AppConfig.h b/source/modules/AppConfig.h
index 443c4ca09..95be33336 100644
--- a/source/modules/AppConfig.h
+++ b/source/modules/AppConfig.h
@@ -28,7 +28,6 @@
// --------------------------------------------------------------------------------------------------------------------
// always enabled
-#define JUCE_MODULE_AVAILABLE_juce_audio_basics 1
#define JUCE_MODULE_AVAILABLE_juce_core 1
// always disabled
@@ -39,6 +38,7 @@
#define JUCE_MODULE_AVAILABLE_juce_video 0
// also disabled
+#define JUCE_MODULE_AVAILABLE_juce_audio_basics 0
#define JUCE_MODULE_AVAILABLE_juce_audio_devices 0
#define JUCE_MODULE_AVAILABLE_juce_audio_formats 0
#define JUCE_MODULE_AVAILABLE_juce_audio_processors 0
@@ -63,160 +63,6 @@
# define JUCE_AUDIOPROCESSOR_NO_GUI 1
#endif
-// --------------------------------------------------------------------------------------------------------------------
-// juce_audio_basics
-
-// nothing here
-
-// --------------------------------------------------------------------------------------------------------------------
-// juce_audio_devices
-
-//=============================================================================
-/** Config: JUCE_ASIO
- Enables ASIO audio devices (MS Windows only).
- Turning this on means that you'll need to have the Steinberg ASIO SDK installed
- on your Windows build machine.
-
- See the comments in the ASIOAudioIODevice class's header file for more
- info about this.
-*/
-#ifdef APPCONFIG_OS_WIN
- #define JUCE_ASIO 1
-#else
- #define JUCE_ASIO 0
-#endif
-
-/** Config: JUCE_WASAPI
- Enables WASAPI audio devices (Windows Vista and above).
-*/
-#define JUCE_WASAPI 0
-
-/** Config: JUCE_DIRECTSOUND
- Enables DirectSound audio (MS Windows only).
-*/
-#ifdef APPCONFIG_OS_WIN
- #define JUCE_DIRECTSOUND 1
-#else
- #define JUCE_DIRECTSOUND 0
-#endif
-
-/** Config: JUCE_ALSA
- Enables ALSA audio devices (Linux only).
-*/
-#if 0 //APPCONFIG_OS_LINUX
- #define JUCE_ALSA 1
- #define JUCE_ALSA_MIDI_INPUT_NAME "Carla"
- #define JUCE_ALSA_MIDI_OUTPUT_NAME "Carla"
- #define JUCE_ALSA_MIDI_INPUT_PORT_NAME "Midi In"
- #define JUCE_ALSA_MIDI_OUTPUT_PORT_NAME "Midi Out"
-#else
- #define JUCE_ALSA 0
-#endif
-
-/** Config: JUCE_JACK
- Enables JACK audio devices (Linux only).
-*/
-#if 0 //APPCONFIG_OS_LINUX
- #define JUCE_JACK 1
- #define JUCE_JACK_CLIENT_NAME "Carla"
-#else
- #define JUCE_JACK 0
-#endif
-
-//=============================================================================
-/** Config: JUCE_USE_CDREADER
- Enables the AudioCDReader class (on supported platforms).
-*/
-#define JUCE_USE_CDREADER 0
-
-/** Config: JUCE_USE_CDBURNER
- Enables the AudioCDBurner class (on supported platforms).
-*/
-#define JUCE_USE_CDBURNER 0
-
-// --------------------------------------------------------------------------------------------------------------------
-// juce_audio_formats
-
-//=============================================================================
-/** Config: JUCE_USE_FLAC
- Enables the FLAC audio codec classes (available on all platforms).
- If your app doesn't need to read FLAC files, you might want to disable this to
- reduce the size of your codebase and build time.
-*/
-#define JUCE_USE_FLAC 1
-
-/** Config: JUCE_USE_OGGVORBIS
- Enables the Ogg-Vorbis audio codec classes (available on all platforms).
- If your app doesn't need to read Ogg-Vorbis files, you might want to disable this to
- reduce the size of your codebase and build time.
-*/
-#define JUCE_USE_OGGVORBIS 1
-
-/** Config: JUCE_USE_MP3AUDIOFORMAT
- Enables the software-based MP3AudioFormat class.
- IMPORTANT DISCLAIMER: By choosing to enable the JUCE_USE_MP3AUDIOFORMAT flag and to compile
- this MP3 code into your software, you do so AT YOUR OWN RISK! By doing so, you are agreeing
- that Raw Material Software is in no way responsible for any patent, copyright, or other
- legal issues that you may suffer as a result.
-
- The code in juce_MP3AudioFormat.cpp is NOT guaranteed to be free from infringements of 3rd-party
- intellectual property. If you wish to use it, please seek your own independent advice about the
- legality of doing so. If you are not willing to accept full responsibility for the consequences
- of using this code, then do not enable this setting.
-*/
-#define JUCE_USE_MP3AUDIOFORMAT 0
-
-/** Config: JUCE_USE_LAME_AUDIO_FORMAT
- Enables the LameEncoderAudioFormat class.
-*/
-#define JUCE_USE_LAME_AUDIO_FORMAT 1
-
-/** Config: JUCE_USE_WINDOWS_MEDIA_FORMAT
- Enables the Windows Media SDK codecs.
-*/
-#define JUCE_USE_WINDOWS_MEDIA_FORMAT 0
-
-// --------------------------------------------------------------------------------------------------------------------
-// juce_audio_processors
-
-//=============================================================================
-/** Config: JUCE_PLUGINHOST_VST
- Enables the VST audio plugin hosting classes. This requires the Steinberg VST SDK to be
- installed on your machine.
-
- @see VSTPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_AU
-*/
-#ifndef VESTIGE_HEADER
-# define JUCE_PLUGINHOST_VST 1
-#else
-# define JUCE_PLUGINHOST_VST 0
-#endif
-
-/** Config: JUCE_PLUGINHOST_VST3
- Enables the VST3 audio plugin hosting classes. This requires the Steinberg VST3 SDK to be
- installed on your machine.
-
- @see VSTPluginFormat, VST3PluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_VST, JUCE_PLUGINHOST_AU
-*/
-#if defined(APPCONFIG_OS_MAC) || defined(APPCONFIG_OS_WIN)
-# define JUCE_PLUGINHOST_VST3 1
-#else
-# define JUCE_PLUGINHOST_VST3 0
-#endif
-
-/** Config: JUCE_PLUGINHOST_AU
- Enables the AudioUnit plugin hosting classes. This is Mac-only, of course.
-
- @see AudioUnitPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_VST
-*/
-#ifdef APPCONFIG_OS_MAC
-# define JUCE_PLUGINHOST_AU 1
-#else
-# define JUCE_PLUGINHOST_AU 0
-#endif
-
-#define JUCE_PLUGINHOST_LADSPA 0
-
// --------------------------------------------------------------------------------------------------------------------
// juce_core
@@ -293,104 +139,6 @@
*/
#define JUCE_ALLOW_STATIC_NULL_VARIABLES 0
-// --------------------------------------------------------------------------------------------------------------------
-// juce_data_structures
-
-// nothing here
-
-// --------------------------------------------------------------------------------------------------------------------
-// juce_events
-
-// nothing here
-
-// --------------------------------------------------------------------------------------------------------------------
-// juce_graphics
-
-//=============================================================================
-/** Config: JUCE_USE_COREIMAGE_LOADER
-
- On OSX, enabling this flag means that the CoreImage codecs will be used to load
- PNG/JPEG/GIF files. It is enabled by default, but you may want to disable it if
- you'd rather use libpng, libjpeg, etc.
-*/
-#define JUCE_USE_COREIMAGE_LOADER 1
-
-/** Config: JUCE_USE_DIRECTWRITE
-
- Enabling this flag means that DirectWrite will be used when available for font
- management and layout.
-*/
-#define JUCE_USE_DIRECTWRITE 0
-
-#define JUCE_INCLUDE_PNGLIB_CODE 1
-
-#define JUCE_INCLUDE_JPEGLIB_CODE 1
-
-#ifdef APPCONFIG_OS_MAC
-# define USE_COREGRAPHICS_RENDERING 1
-#else
-# define USE_COREGRAPHICS_RENDERING 0
-#endif
-
-// --------------------------------------------------------------------------------------------------------------------
-// juce_gui_basics
-
-//=============================================================================
-/** Config: JUCE_ENABLE_REPAINT_DEBUGGING
- If this option is turned on, each area of the screen that gets repainted will
- flash in a random colour, so that you can see exactly which bits of your
- components are being drawn.
-*/
-#define JUCE_ENABLE_REPAINT_DEBUGGING 0
-
-/** JUCE_USE_XRANDR: Enables Xrandr multi-monitor support (Linux only).
- Unless you specifically want to disable this, it's best to leave this option turned on.
- Note that your users do not need to have Xrandr installed for your JUCE app to run, as
- the availability of Xrandr is queried during runtime.
-*/
-#define JUCE_USE_XRANDR 0
-
-/** JUCE_USE_XINERAMA: Enables Xinerama multi-monitor support (Linux only).
- Unless you specifically want to disable this, it's best to leave this option turned on.
- This will be used as a fallback if JUCE_USE_XRANDR not set or libxrandr cannot be found.
- Note that your users do not need to have Xrandr installed for your JUCE app to run, as
- the availability of Xinerama is queried during runtime.
-*/
-#define JUCE_USE_XINERAMA 0
-
-/** Config: JUCE_USE_XSHM
- Enables X shared memory for faster rendering on Linux. This is best left turned on
- unless you have a good reason to disable it.
-*/
-#define JUCE_USE_XSHM 1
-
-/** Config: JUCE_USE_XRENDER
- Enables XRender to allow semi-transparent windowing on Linux.
-*/
-#define JUCE_USE_XRENDER 0
-
-/** Config: JUCE_USE_XCURSOR
- Uses XCursor to allow ARGB cursor on Linux. This is best left turned on unless you have
- a good reason to disable it.
-*/
-#define JUCE_USE_XCURSOR 1
-
-// --------------------------------------------------------------------------------------------------------------------
-// juce_gui_extra
-
-//=============================================================================
-/** Config: JUCE_WEB_BROWSER
- This lets you disable the WebBrowserComponent class (Mac and Windows).
- If you're not using any embedded web-pages, turning this off may reduce your code size.
-*/
-#define JUCE_WEB_BROWSER 0
-
-/** Config: JUCE_ENABLE_LIVE_CONSTANT_EDITOR
- This lets you turn on the JUCE_ENABLE_LIVE_CONSTANT_EDITOR support. See the documentation
- for that macro for more details.
-*/
-#define JUCE_ENABLE_LIVE_CONSTANT_EDITOR 0
-
// --------------------------------------------------------------------------------------------------------------------
#endif // CARLA_JUCE_APPCONFIG_H_INCLUDED
diff --git a/source/modules/Makefile b/source/modules/Makefile
index eb951f2d6..509dc20a6 100644
--- a/source/modules/Makefile
+++ b/source/modules/Makefile
@@ -9,7 +9,6 @@
all:
clean:
- $(MAKE) clean -C juce_audio_basics
$(MAKE) clean -C juce_core
$(MAKE) clean -C lilv
$(MAKE) clean -C rtaudio
diff --git a/source/modules/juce_audio_basics/Makefile b/source/modules/juce_audio_basics/Makefile
deleted file mode 100644
index 471c5245e..000000000
--- a/source/modules/juce_audio_basics/Makefile
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/make -f
-# Makefile for juce_audio_basics #
-# ------------------------------ #
-# Created by falkTX
-#
-
-CWD=../..
-MODULENAME=juce_audio_basics
-include ../Makefile.mk
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
-BUILD_CXX_FLAGS += $(JUCE_AUDIO_BASICS_FLAGS) -I..
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
-ifeq ($(MACOS),true)
-OBJS = $(OBJDIR)/$(MODULENAME).mm.o
-OBJS_posix32 = $(OBJDIR)/$(MODULENAME).mm.posix32.o
-OBJS_posix64 = $(OBJDIR)/$(MODULENAME).mm.posix64.o
-else
-OBJS = $(OBJDIR)/$(MODULENAME).cpp.o
-OBJS_posix32 = $(OBJDIR)/$(MODULENAME).cpp.posix32.o
-OBJS_posix64 = $(OBJDIR)/$(MODULENAME).cpp.posix64.o
-endif
-OBJS_win32 = $(OBJDIR)/$(MODULENAME).cpp.win32.o
-OBJS_win64 = $(OBJDIR)/$(MODULENAME).cpp.win64.o
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
-all: $(MODULEDIR)/$(MODULENAME).a
-posix32: $(MODULEDIR)/$(MODULENAME).posix32.a
-posix64: $(MODULEDIR)/$(MODULENAME).posix64.a
-win32: $(MODULEDIR)/$(MODULENAME).win32.a
-win64: $(MODULEDIR)/$(MODULENAME).win64.a
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
-clean:
- rm -f $(OBJDIR)/*.o $(MODULEDIR)/$(MODULENAME)*.a
-
-debug:
- $(MAKE) DEBUG=true
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
-$(MODULEDIR)/$(MODULENAME).a: $(OBJS)
- -@mkdir -p $(MODULEDIR)
- @echo "Creating $(MODULENAME).a"
- @rm -f $@
- @$(AR) crs $@ $^
-
-$(MODULEDIR)/$(MODULENAME).posix32.a: $(OBJS_posix32)
- -@mkdir -p $(MODULEDIR)
- @echo "Creating $(MODULENAME).posix32.a"
- @rm -f $@
- @$(AR) crs $@ $^
-
-$(MODULEDIR)/$(MODULENAME).posix64.a: $(OBJS_posix64)
- -@mkdir -p $(MODULEDIR)
- @echo "Creating $(MODULENAME).posix64.a"
- @rm -f $@
- @$(AR) crs $@ $^
-
-$(MODULEDIR)/$(MODULENAME).win32.a: $(OBJS_win32)
- -@mkdir -p $(MODULEDIR)
- @echo "Creating $(MODULENAME).win32.a"
- @rm -f $@
- @$(AR) crs $@ $^
-
-$(MODULEDIR)/$(MODULENAME).win64.a: $(OBJS_win64)
- -@mkdir -p $(MODULEDIR)
- @echo "Creating $(MODULENAME).win64.a"
- @rm -f $@
- @$(AR) crs $@ $^
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
-$(OBJDIR)/$(MODULENAME).cpp.o: $(MODULENAME).cpp
- -@mkdir -p $(OBJDIR)
- @echo "Compiling $<"
- @$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
-
-$(OBJDIR)/$(MODULENAME).cpp.%32.o: $(MODULENAME).cpp
- -@mkdir -p $(OBJDIR)
- @echo "Compiling $< (32bit)"
- @$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@
-
-$(OBJDIR)/$(MODULENAME).cpp.%64.o: $(MODULENAME).cpp
- -@mkdir -p $(OBJDIR)
- @echo "Compiling $< (64bit)"
- @$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -c -o $@
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
-$(OBJDIR)/$(MODULENAME).mm.o: $(MODULENAME).cpp
- -@mkdir -p $(OBJDIR)
- @echo "Compiling $<"
- @$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@
-
-$(OBJDIR)/$(MODULENAME).mm.%32.o: $(MODULENAME).cpp
- -@mkdir -p $(OBJDIR)
- @echo "Compiling $< (32bit)"
- @$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -ObjC++ -c -o $@
-
-$(OBJDIR)/$(MODULENAME).mm.%64.o: $(MODULENAME).cpp
- -@mkdir -p $(OBJDIR)
- @echo "Compiling $< (64bit)"
- @$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -ObjC++ -c -o $@
-
-# ----------------------------------------------------------------------------------------------------------------------------
-
--include $(OBJS:%.o=%.d)
--include $(OBJS_posix32:%.o=%.d)
--include $(OBJS_posix64:%.o=%.d)
--include $(OBJS_win32:%.o=%.d)
--include $(OBJS_win64:%.o=%.d)
-
-# ----------------------------------------------------------------------------------------------------------------------------
diff --git a/source/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h b/source/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h
deleted file mode 100644
index 16e729db2..000000000
--- a/source/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- A subclass of AudioPlayHead can supply information about the position and
- status of a moving play head during audio playback.
-
- One of these can be supplied to an AudioProcessor object so that it can find
- out about the position of the audio that it is rendering.
-
- @see AudioProcessor::setPlayHead, AudioProcessor::getPlayHead
-*/
-class JUCE_API AudioPlayHead
-{
-protected:
- //==============================================================================
- AudioPlayHead() {}
-
-public:
- virtual ~AudioPlayHead() {}
-
- //==============================================================================
- /** Frame rate types. */
- enum FrameRateType
- {
- fps23976 = 0,
- fps24 = 1,
- fps25 = 2,
- fps2997 = 3,
- fps30 = 4,
- fps2997drop = 5,
- fps30drop = 6,
- fps60 = 7,
- fps60drop = 8,
- fpsUnknown = 99
- };
-
- //==============================================================================
- /** This structure is filled-in by the AudioPlayHead::getCurrentPosition() method.
- */
- struct JUCE_API CurrentPositionInfo
- {
- /** The tempo in BPM */
- double bpm;
-
- /** Time signature numerator, e.g. the 3 of a 3/4 time sig */
- int timeSigNumerator;
- /** Time signature denominator, e.g. the 4 of a 3/4 time sig */
- int timeSigDenominator;
-
- /** The current play position, in samples from the start of the timeline. */
- int64 timeInSamples;
- /** The current play position, in seconds from the start of the timeline. */
- double timeInSeconds;
-
- /** For timecode, the position of the start of the timeline, in seconds from 00:00:00:00. */
- double editOriginTime;
-
- /** The current play position, in pulses-per-quarter-note. */
- double ppqPosition;
-
- /** The position of the start of the last bar, in pulses-per-quarter-note.
-
- This is the time from the start of the timeline to the start of the current
- bar, in ppq units.
-
- Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If
- it's not available, the value will be 0.
- */
- double ppqPositionOfLastBarStart;
-
- /** The video frame rate, if applicable. */
- FrameRateType frameRate;
-
- /** True if the transport is currently playing. */
- bool isPlaying;
-
- /** True if the transport is currently recording.
-
- (When isRecording is true, then isPlaying will also be true).
- */
- bool isRecording;
-
- /** The current cycle start position in pulses-per-quarter-note.
- Note that not all hosts or plugin formats may provide this value.
- @see isLooping
- */
- double ppqLoopStart;
-
- /** The current cycle end position in pulses-per-quarter-note.
- Note that not all hosts or plugin formats may provide this value.
- @see isLooping
- */
- double ppqLoopEnd;
-
- /** True if the transport is currently looping. */
- bool isLooping;
-
- //==============================================================================
- bool operator== (const CurrentPositionInfo& other) const noexcept;
- bool operator!= (const CurrentPositionInfo& other) const noexcept;
-
- void resetToDefault();
- };
-
- //==============================================================================
- /** Fills-in the given structure with details about the transport's
- position at the start of the current processing block. If this method returns
- false then the current play head position is not available and the given
- structure will be undefined.
-
- You can ONLY call this from your processBlock() method! Calling it at other
- times will produce undefined behaviour, as the host may not have any context
- in which a time would make sense, and some hosts will almost certainly have
- multithreading issues if it's not called on the audio thread.
- */
- virtual bool getCurrentPosition (CurrentPositionInfo& result) = 0;
-
- /** Returns true if this object can control the transport. */
- virtual bool canControlTransport() { return false; }
-
- /** Starts or stops the audio. */
- virtual void transportPlay (bool shouldStartPlaying) { ignoreUnused (shouldStartPlaying); }
-
- /** Starts or stops recording the audio. */
- virtual void transportRecord (bool shouldStartRecording) { ignoreUnused (shouldStartRecording); }
-
- /** Rewinds the audio. */
- virtual void transportRewind() {}
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp b/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp
deleted file mode 100644
index bffc3f4bf..000000000
--- a/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-AudioChannelSet::AudioChannelSet (uint32 c) : channels (c) {}
-AudioChannelSet::AudioChannelSet (const Array& c)
-{
- for (auto channel : c)
- addChannel (channel);
-}
-
-bool AudioChannelSet::operator== (const AudioChannelSet& other) const noexcept { return channels == other.channels; }
-bool AudioChannelSet::operator!= (const AudioChannelSet& other) const noexcept { return channels != other.channels; }
-bool AudioChannelSet::operator< (const AudioChannelSet& other) const noexcept { return channels < other.channels; }
-
-String AudioChannelSet::getChannelTypeName (AudioChannelSet::ChannelType type)
-{
- if (type >= discreteChannel0)
- return "Discrete " + String (type - discreteChannel0 + 1);
-
- switch (type)
- {
- case left: return NEEDS_TRANS("Left");
- case right: return NEEDS_TRANS("Right");
- case centre: return NEEDS_TRANS("Centre");
- case LFE: return NEEDS_TRANS("LFE");
- case leftSurround: return NEEDS_TRANS("Left Surround");
- case rightSurround: return NEEDS_TRANS("Right Surround");
- case leftCentre: return NEEDS_TRANS("Left Centre");
- case rightCentre: return NEEDS_TRANS("Right Centre");
- case centreSurround: return NEEDS_TRANS("Centre Surround");
- case leftSurroundRear: return NEEDS_TRANS("Left Surround Rear");
- case rightSurroundRear: return NEEDS_TRANS("Right Surround Rear");
- case topMiddle: return NEEDS_TRANS("Top Middle");
- case topFrontLeft: return NEEDS_TRANS("Top Front Left");
- case topFrontCentre: return NEEDS_TRANS("Top Front Centre");
- case topFrontRight: return NEEDS_TRANS("Top Front Right");
- case topRearLeft: return NEEDS_TRANS("Top Rear Left");
- case topRearCentre: return NEEDS_TRANS("Top Rear Centre");
- case topRearRight: return NEEDS_TRANS("Top Rear Right");
- case wideLeft: return NEEDS_TRANS("Wide Left");
- case wideRight: return NEEDS_TRANS("Wide Right");
- case LFE2: return NEEDS_TRANS("LFE 2");
- case leftSurroundSide: return NEEDS_TRANS("Left Surround Side");
- case rightSurroundSide: return NEEDS_TRANS("Right Surround Side");
- case ambisonicW: return NEEDS_TRANS("Ambisonic W");
- case ambisonicX: return NEEDS_TRANS("Ambisonic X");
- case ambisonicY: return NEEDS_TRANS("Ambisonic Y");
- case ambisonicZ: return NEEDS_TRANS("Ambisonic Z");
- case topSideLeft: return NEEDS_TRANS("Top Side Left");
- case topSideRight: return NEEDS_TRANS("Top Side Right");
- default: break;
- }
-
- return "Unknown";
-}
-
-String AudioChannelSet::getAbbreviatedChannelTypeName (AudioChannelSet::ChannelType type)
-{
- if (type >= discreteChannel0)
- return String (type - discreteChannel0 + 1);
-
- switch (type)
- {
- case left: return "L";
- case right: return "R";
- case centre: return "C";
- case LFE: return "Lfe";
- case leftSurround: return "Ls";
- case rightSurround: return "Rs";
- case leftCentre: return "Lc";
- case rightCentre: return "Rc";
- case centreSurround: return "Cs";
- case leftSurroundRear: return "Lrs";
- case rightSurroundRear: return "Rrs";
- case topMiddle: return "Tm";
- case topFrontLeft: return "Tfl";
- case topFrontCentre: return "Tfc";
- case topFrontRight: return "Tfr";
- case topRearLeft: return "Trl";
- case topRearCentre: return "Trc";
- case topRearRight: return "Trr";
- case wideLeft: return "Wl";
- case wideRight: return "Wr";
- case LFE2: return "Lfe2";
- case leftSurroundSide: return "Lss";
- case rightSurroundSide: return "Rss";
- case ambisonicW: return "W";
- case ambisonicX: return "X";
- case ambisonicY: return "Y";
- case ambisonicZ: return "Z";
- case topSideLeft: return "Tsl";
- case topSideRight: return "Tsr";
- default: break;
- }
-
- return {};
-}
-
-AudioChannelSet::ChannelType AudioChannelSet::getChannelTypeFromAbbreviation (const String& abbr)
-{
- if (abbr.length() > 0 && (abbr[0] >= '0' && abbr[0] <= '9'))
- return static_cast (static_cast (discreteChannel0)
- + abbr.getIntValue() + 1);
-
- if (abbr == "L") return left;
- if (abbr == "R") return right;
- if (abbr == "C") return centre;
- if (abbr == "Lfe") return LFE;
- if (abbr == "Ls") return leftSurround;
- if (abbr == "Rs") return rightSurround;
- if (abbr == "Lc") return leftCentre;
- if (abbr == "Rc") return rightCentre;
- if (abbr == "Cs") return centreSurround;
- if (abbr == "Lrs") return leftSurroundRear;
- if (abbr == "Rrs") return rightSurroundRear;
- if (abbr == "Tm") return topMiddle;
- if (abbr == "Tfl") return topFrontLeft;
- if (abbr == "Tfc") return topFrontCentre;
- if (abbr == "Tfr") return topFrontRight;
- if (abbr == "Trl") return topRearLeft;
- if (abbr == "Trc") return topRearCentre;
- if (abbr == "Trr") return topRearRight;
- if (abbr == "Wl") return wideLeft;
- if (abbr == "Wr") return wideRight;
- if (abbr == "Lfe2") return LFE2;
- if (abbr == "Lss") return leftSurroundSide;
- if (abbr == "Rss") return rightSurroundSide;
- if (abbr == "W") return ambisonicW;
- if (abbr == "X") return ambisonicX;
- if (abbr == "Y") return ambisonicY;
- if (abbr == "Z") return ambisonicZ;
- if (abbr == "Tsl") return topSideLeft;
- if (abbr == "Tsr") return topSideRight;
-
- return unknown;
-}
-
-String AudioChannelSet::getSpeakerArrangementAsString() const
-{
- StringArray speakerTypes;
-
- for (auto& speaker : getChannelTypes())
- {
- auto name = getAbbreviatedChannelTypeName (speaker);
-
- if (name.isNotEmpty())
- speakerTypes.add (name);
- }
-
- return speakerTypes.joinIntoString (" ");
-}
-
-AudioChannelSet AudioChannelSet::fromAbbreviatedString (const String& str)
-{
- AudioChannelSet set;
-
- for (auto& abbr : StringArray::fromTokens (str, true))
- {
- auto type = getChannelTypeFromAbbreviation (abbr);
-
- if (type != unknown)
- set.addChannel (type);
- }
-
- return set;
-}
-
-String AudioChannelSet::getDescription() const
-{
- if (isDiscreteLayout()) return "Discrete #" + String (size());
- if (*this == disabled()) return "Disabled";
- if (*this == mono()) return "Mono";
- if (*this == stereo()) return "Stereo";
-
- if (*this == createLCR()) return "LCR";
- if (*this == createLRS()) return "LRS";
- if (*this == createLCRS()) return "LCRS";
-
- if (*this == create5point0()) return "5.0 Surround";
- if (*this == create5point1()) return "5.1 Surround";
- if (*this == create6point0()) return "6.0 Surround";
- if (*this == create6point1()) return "6.1 Surround";
- if (*this == create6point0Music()) return "6.0 (Music) Surround";
- if (*this == create6point1Music()) return "6.1 (Music) Surround";
- if (*this == create7point0()) return "7.0 Surround";
- if (*this == create7point1()) return "7.1 Surround";
- if (*this == create7point0SDDS()) return "7.0 Surround SDDS";
- if (*this == create7point1SDDS()) return "7.1 Surround SDDS";
- if (*this == create7point0point2()) return "7.0.2 Surround";
- if (*this == create7point1point2()) return "7.1.2 Surround";
-
- if (*this == quadraphonic()) return "Quadraphonic";
- if (*this == pentagonal()) return "Pentagonal";
- if (*this == hexagonal()) return "Hexagonal";
- if (*this == octagonal()) return "Octagonal";
- if (*this == ambisonic()) return "Ambisonic";
-
- return "Unknown";
-}
-
-bool AudioChannelSet::isDiscreteLayout() const noexcept
-{
- for (auto& speaker : getChannelTypes())
- if (speaker <= topSideRight)
- return false;
-
- return true;
-}
-
-int AudioChannelSet::size() const noexcept
-{
- return channels.countNumberOfSetBits();
-}
-
-AudioChannelSet::ChannelType AudioChannelSet::getTypeOfChannel (int index) const noexcept
-{
- int bit = channels.findNextSetBit(0);
-
- for (int i = 0; i < index && bit >= 0; ++i)
- bit = channels.findNextSetBit (bit + 1);
-
- return static_cast (bit);
-}
-
-int AudioChannelSet::getChannelIndexForType (AudioChannelSet::ChannelType type) const noexcept
-{
- int idx = 0;
-
- for (int bit = channels.findNextSetBit (0); bit >= 0; bit = channels.findNextSetBit (bit + 1))
- {
- if (static_cast (bit) == type)
- return idx;
-
- idx++;
- }
-
- return -1;
-}
-
-Array AudioChannelSet::getChannelTypes() const
-{
- Array result;
-
- for (int bit = channels.findNextSetBit(0); bit >= 0; bit = channels.findNextSetBit (bit + 1))
- result.add (static_cast (bit));
-
- return result;
-}
-
-void AudioChannelSet::addChannel (ChannelType newChannel)
-{
- const int bit = static_cast (newChannel);
- jassert (bit >= 0 && bit < 1024);
- channels.setBit (bit);
-}
-
-void AudioChannelSet::removeChannel (ChannelType newChannel)
-{
- const int bit = static_cast (newChannel);
- jassert (bit >= 0 && bit < 1024);
- channels.clearBit (bit);
-}
-
-AudioChannelSet AudioChannelSet::disabled() { return {}; }
-AudioChannelSet AudioChannelSet::mono() { return AudioChannelSet (1u << centre); }
-AudioChannelSet AudioChannelSet::stereo() { return AudioChannelSet ((1u << left) | (1u << right)); }
-AudioChannelSet AudioChannelSet::createLCR() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre)); }
-AudioChannelSet AudioChannelSet::createLRS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << surround)); }
-AudioChannelSet AudioChannelSet::createLCRS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << surround)); }
-AudioChannelSet AudioChannelSet::create5point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround)); }
-AudioChannelSet AudioChannelSet::create5point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround)); }
-AudioChannelSet AudioChannelSet::create6point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround)); }
-AudioChannelSet AudioChannelSet::create6point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround)); }
-AudioChannelSet AudioChannelSet::create6point0Music() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftSurroundSide) | (1u << rightSurroundSide)); }
-AudioChannelSet AudioChannelSet::create6point1Music() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftSurroundSide) | (1u << rightSurroundSide)); }
-AudioChannelSet AudioChannelSet::create7point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); }
-AudioChannelSet AudioChannelSet::create7point0SDDS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftCentre) | (1u << rightCentre)); }
-AudioChannelSet AudioChannelSet::create7point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); }
-AudioChannelSet AudioChannelSet::create7point1SDDS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftCentre) | (1u << rightCentre)); }
-AudioChannelSet AudioChannelSet::ambisonic() { return AudioChannelSet ((1u << ambisonicW) | (1u << ambisonicX) | (1u << ambisonicY) | (1u << ambisonicZ)); }
-AudioChannelSet AudioChannelSet::quadraphonic() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << leftSurround) | (1u << rightSurround)); }
-AudioChannelSet AudioChannelSet::pentagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); }
-AudioChannelSet AudioChannelSet::hexagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << centreSurround) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); }
-AudioChannelSet AudioChannelSet::octagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround) | (1u << wideLeft) | (1u << wideRight)); }
-AudioChannelSet AudioChannelSet::create7point0point2() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear) | (1u << topSideLeft) | (1u << topSideRight)); }
-AudioChannelSet AudioChannelSet::create7point1point2() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear) | (1u << topSideLeft) | (1u << topSideRight)); }
-
-
-AudioChannelSet AudioChannelSet::discreteChannels (int numChannels)
-{
- AudioChannelSet s;
- s.channels.setRange (discreteChannel0, numChannels, true);
- return s;
-}
-
-AudioChannelSet AudioChannelSet::canonicalChannelSet (int numChannels)
-{
- if (numChannels == 1) return AudioChannelSet::mono();
- if (numChannels == 2) return AudioChannelSet::stereo();
- if (numChannels == 3) return AudioChannelSet::createLCR();
- if (numChannels == 4) return AudioChannelSet::quadraphonic();
- if (numChannels == 5) return AudioChannelSet::create5point0();
- if (numChannels == 6) return AudioChannelSet::create5point1();
- if (numChannels == 7) return AudioChannelSet::create7point0();
- if (numChannels == 8) return AudioChannelSet::create7point1();
-
- return discreteChannels (numChannels);
-}
-
-AudioChannelSet AudioChannelSet::namedChannelSet (int numChannels)
-{
- if (numChannels == 1) return AudioChannelSet::mono();
- if (numChannels == 2) return AudioChannelSet::stereo();
- if (numChannels == 3) return AudioChannelSet::createLCR();
- if (numChannels == 4) return AudioChannelSet::quadraphonic();
- if (numChannels == 5) return AudioChannelSet::create5point0();
- if (numChannels == 6) return AudioChannelSet::create5point1();
- if (numChannels == 7) return AudioChannelSet::create7point0();
- if (numChannels == 8) return AudioChannelSet::create7point1();
-
- return {};
-}
-
-Array AudioChannelSet::channelSetsWithNumberOfChannels (int numChannels)
-{
- Array retval;
-
- if (numChannels != 0)
- {
- retval.add (AudioChannelSet::discreteChannels (numChannels));
-
- if (numChannels == 1)
- {
- retval.add (AudioChannelSet::mono());
- }
- else if (numChannels == 2)
- {
- retval.add (AudioChannelSet::stereo());
- }
- else if (numChannels == 3)
- {
- retval.add (AudioChannelSet::createLCR());
- retval.add (AudioChannelSet::createLRS());
- }
- else if (numChannels == 4)
- {
- retval.add (AudioChannelSet::quadraphonic());
- retval.add (AudioChannelSet::createLCRS());
- retval.add (AudioChannelSet::ambisonic());
- }
- else if (numChannels == 5)
- {
- retval.add (AudioChannelSet::create5point0());
- retval.add (AudioChannelSet::pentagonal());
- }
- else if (numChannels == 6)
- {
- retval.add (AudioChannelSet::create5point1());
- retval.add (AudioChannelSet::create6point0());
- retval.add (AudioChannelSet::create6point0Music());
- retval.add (AudioChannelSet::hexagonal());
- }
- else if (numChannels == 7)
- {
- retval.add (AudioChannelSet::create7point0());
- retval.add (AudioChannelSet::create7point0SDDS());
- retval.add (AudioChannelSet::create6point1());
- retval.add (AudioChannelSet::create6point1Music());
- }
- else if (numChannels == 8)
- {
- retval.add (AudioChannelSet::create7point1());
- retval.add (AudioChannelSet::create7point1SDDS());
- retval.add (AudioChannelSet::octagonal());
- }
- }
-
- return retval;
-}
-
-AudioChannelSet JUCE_CALLTYPE AudioChannelSet::channelSetWithChannels (const Array& channelArray)
-{
- AudioChannelSet set;
-
- for (auto ch : channelArray)
- {
- jassert (! set.channels[static_cast (ch)]);
-
- set.addChannel (ch);
- }
-
- return set;
-}
-
-//==============================================================================
-AudioChannelSet JUCE_CALLTYPE AudioChannelSet::fromWaveChannelMask (int32 dwChannelMask)
-{
- return AudioChannelSet (static_cast ((dwChannelMask & ((1 << 18) - 1)) << 1));
-}
-
-int32 AudioChannelSet::getWaveChannelMask() const noexcept
-{
- if (channels.getHighestBit() > topRearRight)
- return -1;
-
- return (channels.toInteger() >> 1);
-}
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h b/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h
deleted file mode 100644
index 431ae389d..000000000
--- a/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- Represents a set of audio channel types.
-
- For example, you might have a set of left + right channels, which is a stereo
- channel set. It is a collection of values from the AudioChannelSet::ChannelType
- enum, where each type may only occur once within the set.
-
- The documentation below lists which AudioChannelSet corresponds to which native
- layouts used by AAX, VST2/VST3 and CoreAudio/AU. The layout tags in CoreAudio
- are particularly confusing. For example, the layout which is labeled as "7.1 SDDS"
- in Logic Pro, corresponds to CoreAudio/AU's kAudioChannelLayoutTag_DTS_7_0 tag, whereas
- AAX's DTS 7.1 Layout corresponds to CoreAudio/AU's
- kAudioChannelLayoutTag_MPEG_7_1_A format, etc. Please do not use the CoreAudio tag
- as an indication to the actual layout of the speakers.
-
- @see Bus
-*/
-class JUCE_API AudioChannelSet
-{
-public:
- /** Creates an empty channel set.
- You can call addChannel to add channels to the set.
- */
- AudioChannelSet() noexcept {}
-
- /** Creates a zero-channel set which can be used to indicate that a
- bus is disabled. */
- static AudioChannelSet JUCE_CALLTYPE disabled();
-
- //==============================================================================
- /** Creates a one-channel mono set (centre).
-
- Is equivalent to: kMonoAAX (VST), AAX_eStemFormat_Mono (AAX), kAudioChannelLayoutTag_Mono (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE mono();
-
-
- /** Creates a set containing a stereo set (left, right).
-
- Is equivalent to: kStereo (VST), AAX_eStemFormat_Stereo (AAX), kAudioChannelLayoutTag_Stereo (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE stereo();
-
-
- //==============================================================================
- /** Creates a set containing an LCR set (left, right, centre).
-
- Is equivalent to: k30Cine (VST), AAX_eStemFormat_LCR (AAX), kAudioChannelLayoutTag_MPEG_3_0_A (CoreAudio)
-
- This format is referred to as "LRC" in Cubase.
- This format is referred to as "LCR" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE createLCR();
-
-
- /** Creates a set containing an LRS set (left, right, surround).
-
- Is equivalent to: k30Music (VST), n/a (AAX), kAudioChannelLayoutTag_ITU_2_1 (CoreAudio)
-
- This format is referred to as "LRS" in Cubase.
- */
- static AudioChannelSet JUCE_CALLTYPE createLRS();
-
-
- /** Creates a set containing an LCRS set (left, right, centre, surround).
-
- Is equivalent to: k40Cine (VST), AAX_eStemFormat_LCRS (AAX), kAudioChannelLayoutTag_MPEG_4_0_A (CoreAudio)
-
- This format is referred to as "LCRS (Pro Logic)" in Logic Pro.
- This format is referred to as "LRCS" in Cubase.
- This format is referred to as "LCRS" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE createLCRS();
-
-
- //==============================================================================
- /** Creates a set for a 5.0 surround setup (left, right, centre, leftSurround, rightSurround).
-
- Is equivalent to: k50 (VST), AAX_eStemFormat_5_0 (AAX), kAudioChannelLayoutTag_MPEG_5_0_A (CoreAudio)
-
- This format is referred to as "5.0" in Cubase.
- This format is referred to as "5.0" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create5point0();
-
-
- /** Creates a set for a 5.1 surround setup (left, right, centre, leftSurround, rightSurround, LFE).
-
- Is equivalent to: k51 (VST), AAX_eStemFormat_5_1 (AAX), kAudioChannelLayoutTag_MPEG_5_1_A (CoreAudio)
-
- This format is referred to as "5.1 (ITU 775)" in Logic Pro.
- This format is referred to as "5.1" in Cubase.
- This format is referred to as "5.1" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create5point1();
-
-
- /** Creates a set for a 6.0 Cine surround setup (left, right, centre, leftSurround, rightSurround, centreSurround).
-
- Is equivalent to: k60Cine (VST), AAX_eStemFormat_6_0 (AAX), kAudioChannelLayoutTag_AudioUnit_6_0 (CoreAudio)
-
- Logic Pro incorrectly uses this for the surround format labeled "6.1 (ES/EX)".
- This format is referred to as "6.0 Cine" in Cubase.
- This format is referred to as "6.0" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create6point0();
-
-
- /** Creates a set for a 6.1 Cine surround setup (left, right, centre, leftSurround, rightSurround, centreSurround, LFE).
-
- Is equivalent to: k61Cine (VST), AAX_eStemFormat_6_1 (AAX), kAudioChannelLayoutTag_MPEG_6_1_A (CoreAudio)
-
- This format is referred to as "6.1" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create6point1();
-
-
- /** Creates a set for a 6.0 Music surround setup (left, right, leftSurround, rightSurround, leftSurroundSide, rightSurroundSide).
-
- Is equivalent to: k60Music (VST), n/a (AAX), kAudioChannelLayoutTag_DTS_6_0_A (CoreAudio)
-
- This format is referred to as "6.0 Music" in Cubase.
- */
- static AudioChannelSet JUCE_CALLTYPE create6point0Music();
-
-
- /** Creates a set for a 6.0 Music surround setup (left, right, leftSurround, rightSurround, leftSurroundSide, rightSurroundSide, LFE).
-
- Is equivalent to: k61Music (VST), n/a (AAX), kAudioChannelLayoutTag_DTS_6_1_A (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE create6point1Music();
-
-
- /** Creates a set for a DTS 7.0 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear).
-
- Is equivalent to: k70Music (VST), AAX_eStemFormat_7_0_DTS (AAX), kAudioChannelLayoutTag_AudioUnit_7_0 (CoreAudio)
-
- This format is referred to as "7.0" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create7point0();
-
-
- /** Creates a set for a SDDS 7.0 surround setup (left, right, centre, leftSurround, rightSurround, leftCentre, rightCentre).
-
- Is equivalent to: k70Cine (VST), AAX_eStemFormat_7_0_SDDS (AAX), kAudioChannelLayoutTag_AudioUnit_7_0_Front (CoreAudio)
-
- This format is referred to as "7.0 SDDS" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create7point0SDDS();
-
-
- /** Creates a set for a DTS 7.1 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear, LFE).
-
- Is equivalent to: k71CineSideFill (VST), AAX_eStemFormat_7_1_DTS (AAX), kAudioChannelLayoutTag_MPEG_7_1_C/kAudioChannelLayoutTag_ITU_3_4_1 (CoreAudio)
-
- This format is referred to as "7.1 (3/4.1)" in Logic Pro.
- This format is referred to as "7.1" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create7point1();
-
-
- /** Creates a set for a 7.1 surround setup (left, right, centre, leftSurround, rightSurround, leftCentre, rightCentre, LFE).
-
- Is equivalent to: k71Cine (VST), AAX_eStemFormat_7_1_SDDS (AAX), kAudioChannelLayoutTag_MPEG_7_1_A (CoreAudio)
-
- This format is referred to as "7.1 (SDDS)" in Logic Pro.
- This format is referred to as "7.1 SDDS" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE create7point1SDDS();
-
- /** Creates a set for Dolby Atmos 7.0.2 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear, topSideLeft, topSideRight).
-
- Is equivalent to: n/a (VST), AAX_eStemFormat_7_0_2 (AAX), n/a (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE create7point0point2();
-
- /** Creates a set for Dolby Atmos 7.1.2 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear, LFE, topSideLeft, topSideRight).
-
- Is equivalent to: k71_2 (VST), AAX_eStemFormat_7_1_2 (AAX), n/a (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE create7point1point2();
-
-
- //==============================================================================
- /** Creates a set for ambisonic surround setups (ambisonicW, ambisonicX, ambisonicY, ambisonicZ).
-
- Is equivalent to: kBFormat (VST), n/a (AAX), kAudioChannelLayoutTag_Ambisonic_B_Format (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE ambisonic();
-
-
- /** Creates a set for quadraphonic surround setup (left, right, leftSurround, rightSurround)
-
- Is equivalent to: k40Music (VST), AAX_eStemFormat_Quad (AAX), kAudioChannelLayoutTag_Quadraphonic (CoreAudio)
-
- This format is referred to as "Quadraphonic" in Logic Pro.
- This format is referred to as "Quadro" in Cubase.
- This format is referred to as "Quad" in Pro Tools.
- */
- static AudioChannelSet JUCE_CALLTYPE quadraphonic();
-
-
- /** Creates a set for pentagonal surround setup (left, right, centre, leftSurroundRear, rightSurroundRear).
-
- Is equivalent to: n/a (VST), n/a (AAX), kAudioChannelLayoutTag_Pentagonal (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE pentagonal();
-
-
- /** Creates a set for hexagonal surround setup (left, right, leftSurroundRear, rightSurroundRear, centre, surroundCentre).
-
- Is equivalent to: n/a (VST), n/a (AAX), kAudioChannelLayoutTag_Hexagonal (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE hexagonal();
-
-
- /** Creates a set for octagonal surround setup (left, right, leftSurround, rightSurround, centre, centreSurround, wideLeft, wideRight).
-
- Is equivalent to: n/a (VST), n/a (AAX), kAudioChannelLayoutTag_Octagonal (CoreAudio)
- */
- static AudioChannelSet JUCE_CALLTYPE octagonal();
-
- //==============================================================================
- /** Creates a set of untyped discrete channels. */
- static AudioChannelSet JUCE_CALLTYPE discreteChannels (int numChannels);
-
- /** Create a canonical channel set for a given number of channels.
- For example, numChannels = 1 will return mono, numChannels = 2 will return stereo, etc. */
- static AudioChannelSet JUCE_CALLTYPE canonicalChannelSet (int numChannels);
-
- /** Create a channel set for a given number of channels which is non-discrete.
- If numChannels is larger than the number of channels of the surround format
- with the maximum amount of channels (currently 7.1 Surround), then this
- function returns an empty set.*/
- static AudioChannelSet JUCE_CALLTYPE namedChannelSet (int numChannels);
-
- /** Return an array of channel sets which have a given number of channels */
- static Array JUCE_CALLTYPE channelSetsWithNumberOfChannels (int numChannels);
-
- //==============================================================================
- /** Represents different audio channel types. */
- enum ChannelType
- {
- unknown = 0,
-
- left = 1, // L
- right = 2, // R
- centre = 3, // C (sometimes M for mono)
-
- LFE = 4,
- leftSurround = 5, // Ls
- rightSurround = 6, // Rs
- leftCentre = 7, // Lc (AAX/VST), Lc used as Lss in AU for most layouts
- rightCentre = 8, // Rc (AAX/VST), Rc used as Rss in AU for most layouts
- centreSurround = 9, // Cs/S
- surround = centreSurround, // Cs/S
- leftSurroundSide = 10, // Lss (AXX), Side Left "Sl" (VST), Left Centre "LC" (AU)
- rightSurroundSide = 11, // Rss (AXX), Side right "Sr" (VST), Right Centre "Rc" (AU)
- topMiddle = 12,
- topFrontLeft = 13,
- topFrontCentre = 14,
- topFrontRight = 15,
- topRearLeft = 16,
- topRearCentre = 17,
- topRearRight = 18,
- LFE2 = 19,
- leftSurroundRear = 20, // Lsr (AAX), Lcs (VST), Rls (AU)
- rightSurroundRear = 21, // Rsr (AAX), Rcs (VST), Rrs (AU)
- wideLeft = 22,
- wideRight = 23,
-
-
- ambisonicW = 24,
- ambisonicX = 25,
- ambisonicY = 26,
- ambisonicZ = 27,
-
- // Used by Dolby Atmos 7.0.2 and 7.1.2
- topSideLeft = 28, // Lts (AAX), Tsl (VST)
- topSideRight = 29, // Rts (AAX), Tsr (VST)
-
-
- discreteChannel0 = 64 /**< Non-typed individual channels are indexed upwards from this value. */
- };
-
- /** Returns the name of a given channel type. For example, this method may return "Surround Left". */
- static String JUCE_CALLTYPE getChannelTypeName (ChannelType);
-
- /** Returns the abbreviated name of a channel type. For example, this method may return "Ls". */
- static String JUCE_CALLTYPE getAbbreviatedChannelTypeName (ChannelType);
-
- /** Returns the channel type from an abbreviated name. */
- static ChannelType JUCE_CALLTYPE getChannelTypeFromAbbreviation (const String& abbreviation);
-
- //==============================================================================
- enum
- {
- maxChannelsOfNamedLayout = 10
- };
-
- /** Adds a channel to the set. */
- void addChannel (ChannelType newChannelType);
-
- /** Removes a channel from the set. */
- void removeChannel (ChannelType newChannelType);
-
- /** Returns the number of channels in the set. */
- int size() const noexcept;
-
- /** Returns true if there are no channels in the set. */
- bool isDisabled() const noexcept { return size() == 0; }
-
- /** Returns an array of all the types in this channel set. */
- Array getChannelTypes() const;
-
- /** Returns the type of one of the channels in the set, by index. */
- ChannelType getTypeOfChannel (int channelIndex) const noexcept;
-
- /** Returns the index for a particular channel-type.
- Will return -1 if the this set does not contain a channel of this type. */
- int getChannelIndexForType (ChannelType type) const noexcept;
-
- /** Returns a string containing a whitespace-separated list of speaker types
- corresponding to each channel. For example in a 5.1 arrangement,
- the string may be "L R C Lfe Ls Rs". If the speaker arrangement is unknown,
- the returned string will be empty.*/
- String getSpeakerArrangementAsString() const;
-
- /** Returns an AudioChannelSet from a string returned by getSpeakerArrangementAsString
-
- @see getSpeakerArrangementAsString */
- static AudioChannelSet fromAbbreviatedString (const String& set);
-
- /** Returns the description of the current layout. For example, this method may return
- "Quadraphonic". Note that the returned string may not be unique. */
- String getDescription() const;
-
- /** Returns if this is a channel layout made-up of discrete channels. */
- bool isDiscreteLayout() const noexcept;
-
- /** Intersect two channel layouts. */
- void intersect (const AudioChannelSet& other) { channels &= other.channels; }
-
- /** Creates a channel set for a list of channel types. This function will assert
- if you supply a duplicate channel.
-
- Note that this method ignores the order in which the channels are given, i.e.
- two arrays with the same elements but in a different order will still result
- in the same channel set.
- */
- static AudioChannelSet JUCE_CALLTYPE channelSetWithChannels (const Array&);
-
- //==============================================================================
- // Conversion between wave and juce channel layout identifiers
-
- /** Create an AudioChannelSet from a WAVEFORMATEXTENSIBLE channelMask (typically used
- in .wav files). */
- static AudioChannelSet JUCE_CALLTYPE fromWaveChannelMask (int32 dwChannelMask);
-
- /** Returns a WAVEFORMATEXTENSIBLE channelMask representation (typically used in .wav
- files) of the receiver.
-
- Returns -1 if the receiver cannot be represented in a WAVEFORMATEXTENSIBLE channelMask
- representation.
- */
- int32 getWaveChannelMask() const noexcept;
-
- //==============================================================================
- bool operator== (const AudioChannelSet&) const noexcept;
- bool operator!= (const AudioChannelSet&) const noexcept;
- bool operator< (const AudioChannelSet&) const noexcept;
-
-private:
- //==============================================================================
- BigInteger channels;
-
- //==============================================================================
- explicit AudioChannelSet (uint32);
- explicit AudioChannelSet (const Array&);
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp
deleted file mode 100644
index 3f31379dd..000000000
--- a/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- const double maxVal = (double) 0x7fff;
- char* intData = static_cast (dest);
-
- if (dest != (void*) source || destBytesPerSample <= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- *(uint16*) intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- intData += destBytesPerSample;
- }
- }
- else
- {
- intData += destBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= destBytesPerSample;
- *(uint16*) intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- }
- }
-}
-
-void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- const double maxVal = (double) 0x7fff;
- char* intData = static_cast (dest);
-
- if (dest != (void*) source || destBytesPerSample <= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- *(uint16*) intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- intData += destBytesPerSample;
- }
- }
- else
- {
- intData += destBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= destBytesPerSample;
- *(uint16*) intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- }
- }
-}
-
-void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- const double maxVal = (double) 0x7fffff;
- char* intData = static_cast (dest);
-
- if (dest != (void*) source || destBytesPerSample <= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- ByteOrder::littleEndian24BitToChars (roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData);
- intData += destBytesPerSample;
- }
- }
- else
- {
- intData += destBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= destBytesPerSample;
- ByteOrder::littleEndian24BitToChars (roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData);
- }
- }
-}
-
-void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- const double maxVal = (double) 0x7fffff;
- char* intData = static_cast (dest);
-
- if (dest != (void*) source || destBytesPerSample <= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- ByteOrder::bigEndian24BitToChars (roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData);
- intData += destBytesPerSample;
- }
- }
- else
- {
- intData += destBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= destBytesPerSample;
- ByteOrder::bigEndian24BitToChars (roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData);
- }
- }
-}
-
-void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- const double maxVal = (double) 0x7fffffff;
- char* intData = static_cast (dest);
-
- if (dest != (void*) source || destBytesPerSample <= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- *(uint32*)intData = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- intData += destBytesPerSample;
- }
- }
- else
- {
- intData += destBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= destBytesPerSample;
- *(uint32*)intData = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- }
- }
-}
-
-void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- const double maxVal = (double) 0x7fffffff;
- char* intData = static_cast (dest);
-
- if (dest != (void*) source || destBytesPerSample <= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- *(uint32*)intData = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- intData += destBytesPerSample;
- }
- }
- else
- {
- intData += destBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= destBytesPerSample;
- *(uint32*)intData = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])));
- }
- }
-}
-
-void AudioDataConverters::convertFloatToFloat32LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data!
-
- char* d = static_cast (dest);
-
- for (int i = 0; i < numSamples; ++i)
- {
- *(float*) d = source[i];
-
- #if JUCE_BIG_ENDIAN
- *(uint32*) d = ByteOrder::swap (*(uint32*) d);
- #endif
-
- d += destBytesPerSample;
- }
-}
-
-void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
-{
- jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data!
-
- char* d = static_cast (dest);
-
- for (int i = 0; i < numSamples; ++i)
- {
- *(float*) d = source[i];
-
- #if JUCE_LITTLE_ENDIAN
- *(uint32*) d = ByteOrder::swap (*(uint32*) d);
- #endif
-
- d += destBytesPerSample;
- }
-}
-
-//==============================================================================
-void AudioDataConverters::convertInt16LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const float scale = 1.0f / 0x7fff;
- const char* intData = static_cast (source);
-
- if (source != (void*) dest || srcBytesPerSample >= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = scale * (short) ByteOrder::swapIfBigEndian (*(uint16*)intData);
- intData += srcBytesPerSample;
- }
- }
- else
- {
- intData += srcBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= srcBytesPerSample;
- dest[i] = scale * (short) ByteOrder::swapIfBigEndian (*(uint16*)intData);
- }
- }
-}
-
-void AudioDataConverters::convertInt16BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const float scale = 1.0f / 0x7fff;
- const char* intData = static_cast (source);
-
- if (source != (void*) dest || srcBytesPerSample >= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = scale * (short) ByteOrder::swapIfLittleEndian (*(uint16*)intData);
- intData += srcBytesPerSample;
- }
- }
- else
- {
- intData += srcBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= srcBytesPerSample;
- dest[i] = scale * (short) ByteOrder::swapIfLittleEndian (*(uint16*)intData);
- }
- }
-}
-
-void AudioDataConverters::convertInt24LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const float scale = 1.0f / 0x7fffff;
- const char* intData = static_cast (source);
-
- if (source != (void*) dest || srcBytesPerSample >= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = scale * (short) ByteOrder::littleEndian24Bit (intData);
- intData += srcBytesPerSample;
- }
- }
- else
- {
- intData += srcBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= srcBytesPerSample;
- dest[i] = scale * (short) ByteOrder::littleEndian24Bit (intData);
- }
- }
-}
-
-void AudioDataConverters::convertInt24BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const float scale = 1.0f / 0x7fffff;
- const char* intData = static_cast (source);
-
- if (source != (void*) dest || srcBytesPerSample >= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = scale * (short) ByteOrder::bigEndian24Bit (intData);
- intData += srcBytesPerSample;
- }
- }
- else
- {
- intData += srcBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= srcBytesPerSample;
- dest[i] = scale * (short) ByteOrder::bigEndian24Bit (intData);
- }
- }
-}
-
-void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const auto scale = 1.0f / (float) 0x7fffffff;
- const char* intData = static_cast (source);
-
- if (source != (void*) dest || srcBytesPerSample >= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = scale * (int) ByteOrder::swapIfBigEndian (*(uint32*) intData);
- intData += srcBytesPerSample;
- }
- }
- else
- {
- intData += srcBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= srcBytesPerSample;
- dest[i] = scale * (int) ByteOrder::swapIfBigEndian (*(uint32*) intData);
- }
- }
-}
-
-void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const auto scale = 1.0f / (float) 0x7fffffff;
- const char* intData = static_cast (source);
-
- if (source != (void*) dest || srcBytesPerSample >= 4)
- {
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = scale * (int) ByteOrder::swapIfLittleEndian (*(uint32*) intData);
- intData += srcBytesPerSample;
- }
- }
- else
- {
- intData += srcBytesPerSample * numSamples;
-
- for (int i = numSamples; --i >= 0;)
- {
- intData -= srcBytesPerSample;
- dest[i] = scale * (int) ByteOrder::swapIfLittleEndian (*(uint32*) intData);
- }
- }
-}
-
-void AudioDataConverters::convertFloat32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const char* s = static_cast (source);
-
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = *(float*)s;
-
- #if JUCE_BIG_ENDIAN
- uint32* const d = (uint32*) (dest + i);
- *d = ByteOrder::swap (*d);
- #endif
-
- s += srcBytesPerSample;
- }
-}
-
-void AudioDataConverters::convertFloat32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
-{
- const char* s = static_cast (source);
-
- for (int i = 0; i < numSamples; ++i)
- {
- dest[i] = *(float*)s;
-
- #if JUCE_LITTLE_ENDIAN
- uint32* const d = (uint32*) (dest + i);
- *d = ByteOrder::swap (*d);
- #endif
-
- s += srcBytesPerSample;
- }
-}
-
-
-//==============================================================================
-void AudioDataConverters::convertFloatToFormat (const DataFormat destFormat,
- const float* const source,
- void* const dest,
- const int numSamples)
-{
- switch (destFormat)
- {
- case int16LE: convertFloatToInt16LE (source, dest, numSamples); break;
- case int16BE: convertFloatToInt16BE (source, dest, numSamples); break;
- case int24LE: convertFloatToInt24LE (source, dest, numSamples); break;
- case int24BE: convertFloatToInt24BE (source, dest, numSamples); break;
- case int32LE: convertFloatToInt32LE (source, dest, numSamples); break;
- case int32BE: convertFloatToInt32BE (source, dest, numSamples); break;
- case float32LE: convertFloatToFloat32LE (source, dest, numSamples); break;
- case float32BE: convertFloatToFloat32BE (source, dest, numSamples); break;
- default: jassertfalse; break;
- }
-}
-
-void AudioDataConverters::convertFormatToFloat (const DataFormat sourceFormat,
- const void* const source,
- float* const dest,
- const int numSamples)
-{
- switch (sourceFormat)
- {
- case int16LE: convertInt16LEToFloat (source, dest, numSamples); break;
- case int16BE: convertInt16BEToFloat (source, dest, numSamples); break;
- case int24LE: convertInt24LEToFloat (source, dest, numSamples); break;
- case int24BE: convertInt24BEToFloat (source, dest, numSamples); break;
- case int32LE: convertInt32LEToFloat (source, dest, numSamples); break;
- case int32BE: convertInt32BEToFloat (source, dest, numSamples); break;
- case float32LE: convertFloat32LEToFloat (source, dest, numSamples); break;
- case float32BE: convertFloat32BEToFloat (source, dest, numSamples); break;
- default: jassertfalse; break;
- }
-}
-
-//==============================================================================
-void AudioDataConverters::interleaveSamples (const float** const source,
- float* const dest,
- const int numSamples,
- const int numChannels)
-{
- for (int chan = 0; chan < numChannels; ++chan)
- {
- int i = chan;
- const float* src = source [chan];
-
- for (int j = 0; j < numSamples; ++j)
- {
- dest [i] = src [j];
- i += numChannels;
- }
- }
-}
-
-void AudioDataConverters::deinterleaveSamples (const float* const source,
- float** const dest,
- const int numSamples,
- const int numChannels)
-{
- for (int chan = 0; chan < numChannels; ++chan)
- {
- int i = chan;
- float* dst = dest [chan];
-
- for (int j = 0; j < numSamples; ++j)
- {
- dst [j] = source [i];
- i += numChannels;
- }
- }
-}
-
-
-//==============================================================================
-#if JUCE_UNIT_TESTS
-
-class AudioConversionTests : public UnitTest
-{
-public:
- AudioConversionTests() : UnitTest ("Audio data conversion", "Audio") {}
-
- template
- struct Test5
- {
- static void test (UnitTest& unitTest, Random& r)
- {
- test (unitTest, false, r);
- test (unitTest, true, r);
- }
-
- static void test (UnitTest& unitTest, bool inPlace, Random& r)
- {
- const int numSamples = 2048;
- int32 original [numSamples], converted [numSamples], reversed [numSamples];
-
- {
- AudioData::Pointer d (original);
- bool clippingFailed = false;
-
- for (int i = 0; i < numSamples / 2; ++i)
- {
- d.setAsFloat (r.nextFloat() * 2.2f - 1.1f);
-
- if (! d.isFloatingPoint())
- clippingFailed = d.getAsFloat() > 1.0f || d.getAsFloat() < -1.0f || clippingFailed;
-
- ++d;
- d.setAsInt32 (r.nextInt());
- ++d;
- }
-
- unitTest.expect (! clippingFailed);
- }
-
- // convert data from the source to dest format..
- ScopedPointer conv (new AudioData::ConverterInstance ,
- AudioData::Pointer >());
- conv->convertSamples (inPlace ? reversed : converted, original, numSamples);
-
- // ..and back again..
- conv = new AudioData::ConverterInstance ,
- AudioData::Pointer >();
- if (! inPlace)
- zeromem (reversed, sizeof (reversed));
-
- conv->convertSamples (reversed, inPlace ? reversed : converted, numSamples);
-
- {
- int biggestDiff = 0;
- AudioData::Pointer d1 (original);
- AudioData::Pointer d2 (reversed);
-
- const int errorMargin = 2 * AudioData::Pointer::get32BitResolution()
- + AudioData::Pointer::get32BitResolution();
-
- for (int i = 0; i < numSamples; ++i)
- {
- biggestDiff = jmax (biggestDiff, std::abs (d1.getAsInt32() - d2.getAsInt32()));
- ++d1;
- ++d2;
- }
-
- unitTest.expect (biggestDiff <= errorMargin);
- }
- }
- };
-
- template
- struct Test3
- {
- static void test (UnitTest& unitTest, Random& r)
- {
- Test5 ::test (unitTest, r);
- Test5 ::test (unitTest, r);
- }
- };
-
- template
- struct Test2
- {
- static void test (UnitTest& unitTest, Random& r)
- {
- Test3 ::test (unitTest, r);
- Test3 ::test (unitTest, r);
- Test3 ::test (unitTest, r);
- Test3 ::test (unitTest, r);
- Test3 ::test (unitTest, r);
- Test3 ::test (unitTest, r);
- }
- };
-
- template
- struct Test1
- {
- static void test (UnitTest& unitTest, Random& r)
- {
- Test2 ::test (unitTest, r);
- Test2 ::test (unitTest, r);
- }
- };
-
- void runTest() override
- {
- Random r = getRandom();
- beginTest ("Round-trip conversion: Int8");
- Test1 ::test (*this, r);
- beginTest ("Round-trip conversion: Int16");
- Test1 ::test (*this, r);
- beginTest ("Round-trip conversion: Int24");
- Test1 ::test (*this, r);
- beginTest ("Round-trip conversion: Int32");
- Test1 ::test (*this, r);
- beginTest ("Round-trip conversion: Float32");
- Test1 ::test (*this, r);
- }
-};
-
-static AudioConversionTests audioConversionUnitTests;
-
-#endif
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h b/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h
deleted file mode 100644
index 6af682200..000000000
--- a/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h
+++ /dev/null
@@ -1,712 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- This class a container which holds all the classes pertaining to the AudioData::Pointer
- audio sample format class.
-
- @see AudioData::Pointer.
-*/
-class JUCE_API AudioData
-{
-public:
- //==============================================================================
- // These types can be used as the SampleFormat template parameter for the AudioData::Pointer class.
-
- class Int8; /**< Used as a template parameter for AudioData::Pointer. Indicates an 8-bit integer packed data format. */
- class UInt8; /**< Used as a template parameter for AudioData::Pointer. Indicates an 8-bit unsigned integer packed data format. */
- class Int16; /**< Used as a template parameter for AudioData::Pointer. Indicates an 16-bit integer packed data format. */
- class Int24; /**< Used as a template parameter for AudioData::Pointer. Indicates an 24-bit integer packed data format. */
- class Int32; /**< Used as a template parameter for AudioData::Pointer. Indicates an 32-bit integer packed data format. */
- class Float32; /**< Used as a template parameter for AudioData::Pointer. Indicates an 32-bit float data format. */
-
- //==============================================================================
- // These types can be used as the Endianness template parameter for the AudioData::Pointer class.
-
- class BigEndian; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples are stored in big-endian order. */
- class LittleEndian; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples are stored in little-endian order. */
- class NativeEndian; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples are stored in the CPU's native endianness. */
-
- //==============================================================================
- // These types can be used as the InterleavingType template parameter for the AudioData::Pointer class.
-
- class NonInterleaved; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples are stored contiguously. */
- class Interleaved; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples are interleaved with a number of other channels. */
-
- //==============================================================================
- // These types can be used as the Constness template parameter for the AudioData::Pointer class.
-
- class NonConst; /**< Used as a template parameter for AudioData::Pointer. Indicates that the pointer can be used for non-const data. */
- class Const; /**< Used as a template parameter for AudioData::Pointer. Indicates that the samples can only be used for const data.. */
-
- #ifndef DOXYGEN
- //==============================================================================
- class BigEndian
- {
- public:
- template static inline float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatBE(); }
- template static inline void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatBE (newValue); }
- template static inline int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32BE(); }
- template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32BE (newValue); }
- template static inline void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromBE (source); }
- enum { isBigEndian = 1 };
- };
-
- class LittleEndian
- {
- public:
- template static inline float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatLE(); }
- template static inline void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatLE (newValue); }
- template static inline int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32LE(); }
- template static inline void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32LE (newValue); }
- template static inline void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromLE (source); }
- enum { isBigEndian = 0 };
- };
-
- #if JUCE_BIG_ENDIAN
- class NativeEndian : public BigEndian {};
- #else
- class NativeEndian : public LittleEndian {};
- #endif
-
- //==============================================================================
- class Int8
- {
- public:
- inline Int8 (void* d) noexcept : data (static_cast (d)) {}
-
- inline void advance() noexcept { ++data; }
- inline void skip (int numSamples) noexcept { data += numSamples; }
- inline float getAsFloatLE() const noexcept { return (float) (*data * (1.0 / (1.0 + maxValue))); }
- inline float getAsFloatBE() const noexcept { return getAsFloatLE(); }
- inline void setAsFloatLE (float newValue) noexcept { *data = (int8) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))); }
- inline void setAsFloatBE (float newValue) noexcept { setAsFloatLE (newValue); }
- inline int32 getAsInt32LE() const noexcept { return (int) (*((uint8*) data) << 24); }
- inline int32 getAsInt32BE() const noexcept { return getAsInt32LE(); }
- inline void setAsInt32LE (int newValue) noexcept { *data = (int8) (newValue >> 24); }
- inline void setAsInt32BE (int newValue) noexcept { setAsInt32LE (newValue); }
- inline void clear() noexcept { *data = 0; }
- inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
- template inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
- template inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
- inline void copyFromSameType (Int8& source) noexcept { *data = *source.data; }
-
- int8* data;
- enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 };
- };
-
- class UInt8
- {
- public:
- inline UInt8 (void* d) noexcept : data (static_cast (d)) {}
-
- inline void advance() noexcept { ++data; }
- inline void skip (int numSamples) noexcept { data += numSamples; }
- inline float getAsFloatLE() const noexcept { return (float) ((*data - 128) * (1.0 / (1.0 + maxValue))); }
- inline float getAsFloatBE() const noexcept { return getAsFloatLE(); }
- inline void setAsFloatLE (float newValue) noexcept { *data = (uint8) jlimit (0, 255, 128 + roundToInt (newValue * (1.0 + maxValue))); }
- inline void setAsFloatBE (float newValue) noexcept { setAsFloatLE (newValue); }
- inline int32 getAsInt32LE() const noexcept { return (int) (((uint8) (*data - 128)) << 24); }
- inline int32 getAsInt32BE() const noexcept { return getAsInt32LE(); }
- inline void setAsInt32LE (int newValue) noexcept { *data = (uint8) (128 + (newValue >> 24)); }
- inline void setAsInt32BE (int newValue) noexcept { setAsInt32LE (newValue); }
- inline void clear() noexcept { *data = 128; }
- inline void clearMultiple (int num) noexcept { memset (data, 128, (size_t) num) ;}
- template inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
- template inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
- inline void copyFromSameType (UInt8& source) noexcept { *data = *source.data; }
-
- uint8* data;
- enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 };
- };
-
- class Int16
- {
- public:
- inline Int16 (void* d) noexcept : data (static_cast (d)) {}
-
- inline void advance() noexcept { ++data; }
- inline void skip (int numSamples) noexcept { data += numSamples; }
- inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfBigEndian (*data)); }
- inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int16) ByteOrder::swapIfLittleEndian (*data)); }
- inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint16) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); }
- inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint16) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); }
- inline int32 getAsInt32LE() const noexcept { return (int32) (ByteOrder::swapIfBigEndian ((uint16) *data) << 16); }
- inline int32 getAsInt32BE() const noexcept { return (int32) (ByteOrder::swapIfLittleEndian ((uint16) *data) << 16); }
- inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint16) (newValue >> 16)); }
- inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint16) (newValue >> 16)); }
- inline void clear() noexcept { *data = 0; }
- inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
- template inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
- template inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
- inline void copyFromSameType (Int16& source) noexcept { *data = *source.data; }
-
- uint16* data;
- enum { bytesPerSample = 2, maxValue = 0x7fff, resolution = (1 << 16), isFloat = 0 };
- };
-
- class Int24
- {
- public:
- inline Int24 (void* d) noexcept : data (static_cast (d)) {}
-
- inline void advance() noexcept { data += 3; }
- inline void skip (int numSamples) noexcept { data += 3 * numSamples; }
- inline float getAsFloatLE() const noexcept { return (float) (ByteOrder::littleEndian24Bit (data) * (1.0 / (1.0 + maxValue))); }
- inline float getAsFloatBE() const noexcept { return (float) (ByteOrder::bigEndian24Bit (data) * (1.0 / (1.0 + maxValue))); }
- inline void setAsFloatLE (float newValue) noexcept { ByteOrder::littleEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); }
- inline void setAsFloatBE (float newValue) noexcept { ByteOrder::bigEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); }
- inline int32 getAsInt32LE() const noexcept { return (int32) (((unsigned int) ByteOrder::littleEndian24Bit (data)) << 8); }
- inline int32 getAsInt32BE() const noexcept { return (int32) (((unsigned int) ByteOrder::bigEndian24Bit (data)) << 8); }
- inline void setAsInt32LE (int32 newValue) noexcept { ByteOrder::littleEndian24BitToChars (newValue >> 8, data); }
- inline void setAsInt32BE (int32 newValue) noexcept { ByteOrder::bigEndian24BitToChars (newValue >> 8, data); }
- inline void clear() noexcept { data[0] = 0; data[1] = 0; data[2] = 0; }
- inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
- template inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
- template inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
- inline void copyFromSameType (Int24& source) noexcept { data[0] = source.data[0]; data[1] = source.data[1]; data[2] = source.data[2]; }
-
- char* data;
- enum { bytesPerSample = 3, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 };
- };
-
- class Int32
- {
- public:
- inline Int32 (void* d) noexcept : data (static_cast (d)) {}
-
- inline void advance() noexcept { ++data; }
- inline void skip (int numSamples) noexcept { data += numSamples; }
- inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); }
- inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); }
- inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) (int32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
- inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) (int32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
- inline int32 getAsInt32LE() const noexcept { return (int32) ByteOrder::swapIfBigEndian (*data); }
- inline int32 getAsInt32BE() const noexcept { return (int32) ByteOrder::swapIfLittleEndian (*data); }
- inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); }
- inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); }
- inline void clear() noexcept { *data = 0; }
- inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
- template inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
- template inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
- inline void copyFromSameType (Int32& source) noexcept { *data = *source.data; }
-
- uint32* data;
- enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 };
- };
-
- /** A 32-bit integer type, of which only the bottom 24 bits are used. */
- class Int24in32 : public Int32
- {
- public:
- inline Int24in32 (void* d) noexcept : Int32 (d) {}
-
- inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); }
- inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); }
- inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
- inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) (maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
- inline int32 getAsInt32LE() const noexcept { return (int32) ByteOrder::swapIfBigEndian (*data) << 8; }
- inline int32 getAsInt32BE() const noexcept { return (int32) ByteOrder::swapIfLittleEndian (*data) << 8; }
- inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) newValue >> 8); }
- inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue >> 8); }
- template inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
- template inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
- inline void copyFromSameType (Int24in32& source) noexcept { *data = *source.data; }
-
- enum { bytesPerSample = 4, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 };
- };
-
- class Float32
- {
- public:
- inline Float32 (void* d) noexcept : data (static_cast (d)) {}
-
- inline void advance() noexcept { ++data; }
- inline void skip (int numSamples) noexcept { data += numSamples; }
- #if JUCE_BIG_ENDIAN
- inline float getAsFloatBE() const noexcept { return *data; }
- inline void setAsFloatBE (float newValue) noexcept { *data = newValue; }
- inline float getAsFloatLE() const noexcept { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; }
- inline void setAsFloatLE (float newValue) noexcept { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); }
- #else
- inline float getAsFloatLE() const noexcept { return *data; }
- inline void setAsFloatLE (float newValue) noexcept { *data = newValue; }
- inline float getAsFloatBE() const noexcept { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; }
- inline void setAsFloatBE (float newValue) noexcept { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); }
- #endif
- inline int32 getAsInt32LE() const noexcept { return (int32) roundToInt (jlimit (-1.0, 1.0, (double) getAsFloatLE()) * (double) maxValue); }
- inline int32 getAsInt32BE() const noexcept { return (int32) roundToInt (jlimit (-1.0, 1.0, (double) getAsFloatBE()) * (double) maxValue); }
- inline void setAsInt32LE (int32 newValue) noexcept { setAsFloatLE ((float) (newValue * (1.0 / (1.0 + maxValue)))); }
- inline void setAsInt32BE (int32 newValue) noexcept { setAsFloatBE ((float) (newValue * (1.0 / (1.0 + maxValue)))); }
- inline void clear() noexcept { *data = 0; }
- inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
- template inline void copyFromLE (SourceType& source) noexcept { setAsFloatLE (source.getAsFloat()); }
- template inline void copyFromBE (SourceType& source) noexcept { setAsFloatBE (source.getAsFloat()); }
- inline void copyFromSameType (Float32& source) noexcept { *data = *source.data; }
-
- float* data;
- enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = (1 << 8), isFloat = 1 };
- };
-
- //==============================================================================
- class NonInterleaved
- {
- public:
- inline NonInterleaved() noexcept {}
- inline NonInterleaved (const NonInterleaved&) noexcept {}
- inline NonInterleaved (const int) noexcept {}
- inline void copyFrom (const NonInterleaved&) noexcept {}
- template inline void advanceData (SampleFormatType& s) noexcept { s.advance(); }
- template inline void advanceDataBy (SampleFormatType& s, int numSamples) noexcept { s.skip (numSamples); }
- template inline void clear (SampleFormatType& s, int numSamples) noexcept { s.clearMultiple (numSamples); }
- template inline static int getNumBytesBetweenSamples (const SampleFormatType&) noexcept { return SampleFormatType::bytesPerSample; }
-
- enum { isInterleavedType = 0, numInterleavedChannels = 1 };
- };
-
- class Interleaved
- {
- public:
- inline Interleaved() noexcept : numInterleavedChannels (1) {}
- inline Interleaved (const Interleaved& other) noexcept : numInterleavedChannels (other.numInterleavedChannels) {}
- inline Interleaved (const int numInterleavedChans) noexcept : numInterleavedChannels (numInterleavedChans) {}
- inline void copyFrom (const Interleaved& other) noexcept { numInterleavedChannels = other.numInterleavedChannels; }
- template inline void advanceData (SampleFormatType& s) noexcept { s.skip (numInterleavedChannels); }
- template inline void advanceDataBy (SampleFormatType& s, int numSamples) noexcept { s.skip (numInterleavedChannels * numSamples); }
- template inline void clear (SampleFormatType& s, int numSamples) noexcept { while (--numSamples >= 0) { s.clear(); s.skip (numInterleavedChannels); } }
- template inline int getNumBytesBetweenSamples (const SampleFormatType&) const noexcept { return numInterleavedChannels * SampleFormatType::bytesPerSample; }
- int numInterleavedChannels;
- enum { isInterleavedType = 1 };
- };
-
- //==============================================================================
- class NonConst
- {
- public:
- typedef void VoidType;
- static inline void* toVoidPtr (VoidType* v) noexcept { return v; }
- enum { isConst = 0 };
- };
-
- class Const
- {
- public:
- typedef const void VoidType;
- static inline void* toVoidPtr (VoidType* v) noexcept { return const_cast (v); }
- enum { isConst = 1 };
- };
- #endif
-
- //==============================================================================
- /**
- A pointer to a block of audio data with a particular encoding.
-
- This object can be used to read and write from blocks of encoded audio samples. To create one, you specify
- the audio format as a series of template parameters, e.g.
- @code
- // this creates a pointer for reading from a const array of 16-bit little-endian packed samples.
- AudioData::Pointer pointer (someRawAudioData);
-
- // These methods read the sample that is being pointed to
- float firstSampleAsFloat = pointer.getAsFloat();
- int32 firstSampleAsInt = pointer.getAsInt32();
- ++pointer; // moves the pointer to the next sample.
- pointer += 3; // skips the next 3 samples.
- @endcode
-
- The convertSamples() method lets you copy a range of samples from one format to another, automatically
- converting its format.
-
- @see AudioData::Converter
- */
- template
- class Pointer : private InterleavingType // (inherited for EBCO)
- {
- public:
- //==============================================================================
- /** Creates a non-interleaved pointer from some raw data in the appropriate format.
- This constructor is only used if you've specified the AudioData::NonInterleaved option -
- for interleaved formats, use the constructor that also takes a number of channels.
- */
- Pointer (typename Constness::VoidType* sourceData) noexcept
- : data (Constness::toVoidPtr (sourceData))
- {
- // If you're using interleaved data, call the other constructor! If you're using non-interleaved data,
- // you should pass NonInterleaved as the template parameter for the interleaving type!
- static_assert (InterleavingType::isInterleavedType == 0, "Incorrect constructor for interleaved data");
- }
-
- /** Creates a pointer from some raw data in the appropriate format with the specified number of interleaved channels.
- For non-interleaved data, use the other constructor.
- */
- Pointer (typename Constness::VoidType* sourceData, int numInterleaved) noexcept
- : InterleavingType (numInterleaved), data (Constness::toVoidPtr (sourceData))
- {
- }
-
- /** Creates a copy of another pointer. */
- Pointer (const Pointer& other) noexcept
- : InterleavingType (other), data (other.data)
- {
- }
-
- Pointer& operator= (const Pointer& other) noexcept
- {
- InterleavingType::operator= (other);
- data = other.data;
- return *this;
- }
-
- //==============================================================================
- /** Returns the value of the first sample as a floating point value.
- The value will be in the range -1.0 to 1.0 for integer formats. For floating point
- formats, the value could be outside that range, although -1 to 1 is the standard range.
- */
- inline float getAsFloat() const noexcept { return Endianness::getAsFloat (data); }
-
- /** Sets the value of the first sample as a floating point value.
-
- (This method can only be used if the AudioData::NonConst option was used).
- The value should be in the range -1.0 to 1.0 - for integer formats, values outside that
- range will be clipped. For floating point formats, any value passed in here will be
- written directly, although -1 to 1 is the standard range.
- */
- inline void setAsFloat (float newValue) noexcept
- {
- // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
- static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
- Endianness::setAsFloat (data, newValue);
- }
-
- /** Returns the value of the first sample as a 32-bit integer.
- The value returned will be in the range 0x80000000 to 0x7fffffff, and shorter values will be
- shifted to fill this range (e.g. if you're reading from 24-bit data, the values will be shifted up
- by 8 bits when returned here). If the source data is floating point, values beyond -1.0 to 1.0 will
- be clipped so that -1.0 maps onto -0x7fffffff and 1.0 maps to 0x7fffffff.
- */
- inline int32 getAsInt32() const noexcept { return Endianness::getAsInt32 (data); }
-
- /** Sets the value of the first sample as a 32-bit integer.
- This will be mapped to the range of the format that is being written - see getAsInt32().
- */
- inline void setAsInt32 (int32 newValue) noexcept
- {
- // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
- static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
- Endianness::setAsInt32 (data, newValue);
- }
-
- /** Moves the pointer along to the next sample. */
- inline Pointer& operator++() noexcept { advance(); return *this; }
-
- /** Moves the pointer back to the previous sample. */
- inline Pointer& operator--() noexcept { this->advanceDataBy (data, -1); return *this; }
-
- /** Adds a number of samples to the pointer's position. */
- Pointer& operator+= (int samplesToJump) noexcept { this->advanceDataBy (data, samplesToJump); return *this; }
-
- /** Writes a stream of samples into this pointer from another pointer.
- This will copy the specified number of samples, converting between formats appropriately.
- */
- void convertSamples (Pointer source, int numSamples) const noexcept
- {
- // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
- static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
-
- for (Pointer dest (*this); --numSamples >= 0;)
- {
- dest.data.copyFromSameType (source.data);
- dest.advance();
- source.advance();
- }
- }
-
- /** Writes a stream of samples into this pointer from another pointer.
- This will copy the specified number of samples, converting between formats appropriately.
- */
- template
- void convertSamples (OtherPointerType source, int numSamples) const noexcept
- {
- // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
- static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
-
- Pointer dest (*this);
-
- if (source.getRawData() != getRawData() || source.getNumBytesBetweenSamples() >= getNumBytesBetweenSamples())
- {
- while (--numSamples >= 0)
- {
- Endianness::copyFrom (dest.data, source);
- dest.advance();
- ++source;
- }
- }
- else // copy backwards if we're increasing the sample width..
- {
- dest += numSamples;
- source += numSamples;
-
- while (--numSamples >= 0)
- Endianness::copyFrom ((--dest).data, --source);
- }
- }
-
- /** Sets a number of samples to zero. */
- void clearSamples (int numSamples) const noexcept
- {
- Pointer dest (*this);
- dest.clear (dest.data, numSamples);
- }
-
- /** Scans a block of data, returning the lowest and highest levels as floats */
- Range findMinAndMax (size_t numSamples) const noexcept
- {
- if (numSamples == 0)
- return Range();
-
- Pointer dest (*this);
-
- if (isFloatingPoint())
- {
- float mn = dest.getAsFloat();
- dest.advance();
- float mx = mn;
-
- while (--numSamples > 0)
- {
- const float v = dest.getAsFloat();
- dest.advance();
-
- if (mx < v) mx = v;
- if (v < mn) mn = v;
- }
-
- return Range (mn, mx);
- }
-
- int32 mn = dest.getAsInt32();
- dest.advance();
- int32 mx = mn;
-
- while (--numSamples > 0)
- {
- const int v = dest.getAsInt32();
- dest.advance();
-
- if (mx < v) mx = v;
- if (v < mn) mn = v;
- }
-
- return Range (mn * (float) (1.0 / (1.0 + Int32::maxValue)),
- mx * (float) (1.0 / (1.0 + Int32::maxValue)));
- }
-
- /** Scans a block of data, returning the lowest and highest levels as floats */
- void findMinAndMax (size_t numSamples, float& minValue, float& maxValue) const noexcept
- {
- Range r (findMinAndMax (numSamples));
- minValue = r.getStart();
- maxValue = r.getEnd();
- }
-
- /** Returns true if the pointer is using a floating-point format. */
- static bool isFloatingPoint() noexcept { return (bool) SampleFormat::isFloat; }
-
- /** Returns true if the format is big-endian. */
- static bool isBigEndian() noexcept { return (bool) Endianness::isBigEndian; }
-
- /** Returns the number of bytes in each sample (ignoring the number of interleaved channels). */
- static int getBytesPerSample() noexcept { return (int) SampleFormat::bytesPerSample; }
-
- /** Returns the number of interleaved channels in the format. */
- int getNumInterleavedChannels() const noexcept { return (int) this->numInterleavedChannels; }
-
- /** Returns the number of bytes between the start address of each sample. */
- int getNumBytesBetweenSamples() const noexcept { return InterleavingType::getNumBytesBetweenSamples (data); }
-
- /** Returns the accuracy of this format when represented as a 32-bit integer.
- This is the smallest number above 0 that can be represented in the sample format, converted to
- a 32-bit range. E,g. if the format is 8-bit, its resolution is 0x01000000; if the format is 24-bit,
- its resolution is 0x100.
- */
- static int get32BitResolution() noexcept { return (int) SampleFormat::resolution; }
-
- /** Returns a pointer to the underlying data. */
- const void* getRawData() const noexcept { return data.data; }
-
- private:
- //==============================================================================
- SampleFormat data;
-
- inline void advance() noexcept { this->advanceData (data); }
-
- Pointer operator++ (int); // private to force you to use the more efficient pre-increment!
- Pointer operator-- (int);
- };
-
- //==============================================================================
- /** A base class for objects that are used to convert between two different sample formats.
-
- The AudioData::ConverterInstance implements this base class and can be templated, so
- you can create an instance that converts between two particular formats, and then
- store this in the abstract base class.
-
- @see AudioData::ConverterInstance
- */
- class Converter
- {
- public:
- virtual ~Converter() {}
-
- /** Converts a sequence of samples from the converter's source format into the dest format. */
- virtual void convertSamples (void* destSamples, const void* sourceSamples, int numSamples) const = 0;
-
- /** Converts a sequence of samples from the converter's source format into the dest format.
- This method takes sub-channel indexes, which can be used with interleaved formats in order to choose a
- particular sub-channel of the data to be used.
- */
- virtual void convertSamples (void* destSamples, int destSubChannel,
- const void* sourceSamples, int sourceSubChannel, int numSamples) const = 0;
- };
-
- //==============================================================================
- /**
- A class that converts between two templated AudioData::Pointer types, and which
- implements the AudioData::Converter interface.
-
- This can be used as a concrete instance of the AudioData::Converter abstract class.
-
- @see AudioData::Converter
- */
- template
- class ConverterInstance : public Converter
- {
- public:
- ConverterInstance (int numSourceChannels = 1, int numDestChannels = 1)
- : sourceChannels (numSourceChannels), destChannels (numDestChannels)
- {}
-
- void convertSamples (void* dest, const void* source, int numSamples) const override
- {
- SourceSampleType s (source, sourceChannels);
- DestSampleType d (dest, destChannels);
- d.convertSamples (s, numSamples);
- }
-
- void convertSamples (void* dest, int destSubChannel,
- const void* source, int sourceSubChannel, int numSamples) const override
- {
- jassert (destSubChannel < destChannels && sourceSubChannel < sourceChannels);
-
- SourceSampleType s (addBytesToPointer (source, sourceSubChannel * SourceSampleType::getBytesPerSample()), sourceChannels);
- DestSampleType d (addBytesToPointer (dest, destSubChannel * DestSampleType::getBytesPerSample()), destChannels);
- d.convertSamples (s, numSamples);
- }
-
- private:
- JUCE_DECLARE_NON_COPYABLE (ConverterInstance)
-
- const int sourceChannels, destChannels;
- };
-};
-
-
-
-//==============================================================================
-/**
- A set of routines to convert buffers of 32-bit floating point data to and from
- various integer formats.
-
- Note that these functions are deprecated - the AudioData class provides a much more
- flexible set of conversion classes now.
-*/
-class JUCE_API AudioDataConverters
-{
-public:
- //==============================================================================
- static void convertFloatToInt16LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 2);
- static void convertFloatToInt16BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 2);
-
- static void convertFloatToInt24LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 3);
- static void convertFloatToInt24BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 3);
-
- static void convertFloatToInt32LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
- static void convertFloatToInt32BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
-
- static void convertFloatToFloat32LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
- static void convertFloatToFloat32BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
-
- //==============================================================================
- static void convertInt16LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 2);
- static void convertInt16BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 2);
-
- static void convertInt24LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 3);
- static void convertInt24BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 3);
-
- static void convertInt32LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
- static void convertInt32BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
-
- static void convertFloat32LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
- static void convertFloat32BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
-
- //==============================================================================
- enum DataFormat
- {
- int16LE,
- int16BE,
- int24LE,
- int24BE,
- int32LE,
- int32BE,
- float32LE,
- float32BE,
- };
-
- static void convertFloatToFormat (DataFormat destFormat,
- const float* source, void* dest, int numSamples);
-
- static void convertFormatToFloat (DataFormat sourceFormat,
- const void* source, float* dest, int numSamples);
-
- //==============================================================================
- static void interleaveSamples (const float** source, float* dest,
- int numSamples, int numChannels);
-
- static void deinterleaveSamples (const float* source, float** dest,
- int numSamples, int numChannels);
-
-private:
- AudioDataConverters();
- JUCE_DECLARE_NON_COPYABLE (AudioDataConverters)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h
deleted file mode 100644
index ac9addd56..000000000
--- a/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h
+++ /dev/null
@@ -1,1126 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- A multi-channel buffer of floating point audio samples.
-
- @see AudioSampleBuffer
-*/
-template
-class AudioBuffer
-{
-public:
- //==============================================================================
- /** Creates an empty buffer with 0 channels and 0 length. */
- AudioBuffer() noexcept
- : numChannels (0), size (0), allocatedBytes (0),
- channels (static_cast (preallocatedChannelSpace)),
- isClear (false)
- {
- }
-
- //==============================================================================
- /** Creates a buffer with a specified number of channels and samples.
-
- The contents of the buffer will initially be undefined, so use clear() to
- set all the samples to zero.
-
- The buffer will allocate its memory internally, and this will be released
- when the buffer is deleted. If the memory can't be allocated, this will
- throw a std::bad_alloc exception.
- */
- AudioBuffer (int numChannelsToAllocate,
- int numSamplesToAllocate)
- : numChannels (numChannelsToAllocate),
- size (numSamplesToAllocate)
- {
- jassert (size >= 0 && numChannels >= 0);
- allocateData();
- }
-
- /** Creates a buffer using a pre-allocated block of memory.
-
- Note that if the buffer is resized or its number of channels is changed, it
- will re-allocate memory internally and copy the existing data to this new area,
- so it will then stop directly addressing this memory.
-
- @param dataToReferTo a pre-allocated array containing pointers to the data
- for each channel that should be used by this buffer. The
- buffer will only refer to this memory, it won't try to delete
- it when the buffer is deleted or resized.
- @param numChannelsToUse the number of channels to use - this must correspond to the
- number of elements in the array passed in
- @param numSamples the number of samples to use - this must correspond to the
- size of the arrays passed in
- */
- AudioBuffer (Type* const* dataToReferTo,
- int numChannelsToUse,
- int numSamples)
- : numChannels (numChannelsToUse),
- size (numSamples),
- allocatedBytes (0)
- {
- jassert (dataToReferTo != nullptr);
- jassert (numChannelsToUse >= 0 && numSamples >= 0);
- allocateChannels (dataToReferTo, 0);
- }
-
- /** Creates a buffer using a pre-allocated block of memory.
-
- Note that if the buffer is resized or its number of channels is changed, it
- will re-allocate memory internally and copy the existing data to this new area,
- so it will then stop directly addressing this memory.
-
- @param dataToReferTo a pre-allocated array containing pointers to the data
- for each channel that should be used by this buffer. The
- buffer will only refer to this memory, it won't try to delete
- it when the buffer is deleted or resized.
- @param numChannelsToUse the number of channels to use - this must correspond to the
- number of elements in the array passed in
- @param startSample the offset within the arrays at which the data begins
- @param numSamples the number of samples to use - this must correspond to the
- size of the arrays passed in
- */
- AudioBuffer (Type* const* dataToReferTo,
- int numChannelsToUse,
- int startSample,
- int numSamples)
- : numChannels (numChannelsToUse),
- size (numSamples),
- allocatedBytes (0),
- isClear (false)
- {
- jassert (dataToReferTo != nullptr);
- jassert (numChannelsToUse >= 0 && startSample >= 0 && numSamples >= 0);
- allocateChannels (dataToReferTo, startSample);
- }
-
- /** Copies another buffer.
-
- This buffer will make its own copy of the other's data, unless the buffer was created
- using an external data buffer, in which case boths buffers will just point to the same
- shared block of data.
- */
- AudioBuffer (const AudioBuffer& other)
- : numChannels (other.numChannels),
- size (other.size),
- allocatedBytes (other.allocatedBytes)
- {
- if (allocatedBytes == 0)
- {
- allocateChannels (other.channels, 0);
- }
- else
- {
- allocateData();
-
- if (other.isClear)
- {
- clear();
- }
- else
- {
- for (int i = 0; i < numChannels; ++i)
- FloatVectorOperations::copy (channels[i], other.channels[i], size);
- }
- }
- }
-
- /** Copies another buffer onto this one.
- This buffer's size will be changed to that of the other buffer.
- */
- AudioBuffer& operator= (const AudioBuffer& other)
- {
- if (this != &other)
- {
- setSize (other.getNumChannels(), other.getNumSamples(), false, false, false);
-
- if (other.isClear)
- {
- clear();
- }
- else
- {
- isClear = false;
-
- for (int i = 0; i < numChannels; ++i)
- FloatVectorOperations::copy (channels[i], other.channels[i], size);
- }
- }
-
- return *this;
- }
-
- /** Destructor.
- This will free any memory allocated by the buffer.
- */
- ~AudioBuffer() noexcept {}
-
- /** Move constructor */
- AudioBuffer (AudioBuffer&& other) noexcept
- : numChannels (other.numChannels),
- size (other.size),
- allocatedBytes (other.allocatedBytes),
- allocatedData (static_cast&&> (other.allocatedData)),
- isClear (other.isClear)
- {
- if (numChannels < (int) numElementsInArray (preallocatedChannelSpace))
- {
- channels = preallocatedChannelSpace;
- memcpy (preallocatedChannelSpace, other.channels, sizeof (preallocatedChannelSpace));
- }
- else
- {
- channels = other.channels;
- }
-
- other.numChannels = 0;
- other.size = 0;
- other.allocatedBytes = 0;
- }
-
- /** Move assignment */
- AudioBuffer& operator= (AudioBuffer&& other) noexcept
- {
- numChannels = other.numChannels;
- size = other.size;
- allocatedBytes = other.allocatedBytes;
- allocatedData = static_cast&&> (other.allocatedData);
- isClear = other.isClear;
-
- if (numChannels < (int) numElementsInArray (preallocatedChannelSpace))
- {
- channels = preallocatedChannelSpace;
- memcpy (preallocatedChannelSpace, other.channels, sizeof (preallocatedChannelSpace));
- }
- else
- {
- channels = other.channels;
- }
-
- other.numChannels = 0;
- other.size = 0;
- other.allocatedBytes = 0;
- return *this;
- }
-
- //==============================================================================
- /** Returns the number of channels of audio data that this buffer contains.
- @see getNumSamples, getReadPointer, getWritePointer
- */
- int getNumChannels() const noexcept { return numChannels; }
-
- /** Returns the number of samples allocated in each of the buffer's channels.
- @see getNumChannels, getReadPointer, getWritePointer
- */
- int getNumSamples() const noexcept { return size; }
-
- /** Returns a pointer to an array of read-only samples in one of the buffer's channels.
- For speed, this doesn't check whether the channel number is out of range,
- so be careful when using it!
- If you need to write to the data, do NOT call this method and const_cast the
- result! Instead, you must call getWritePointer so that the buffer knows you're
- planning on modifying the data.
- */
- const Type* getReadPointer (int channelNumber) const noexcept
- {
- jassert (isPositiveAndBelow (channelNumber, numChannels));
- return channels[channelNumber];
- }
-
- /** Returns a pointer to an array of read-only samples in one of the buffer's channels.
- For speed, this doesn't check whether the channel number or index are out of range,
- so be careful when using it!
- If you need to write to the data, do NOT call this method and const_cast the
- result! Instead, you must call getWritePointer so that the buffer knows you're
- planning on modifying the data.
- */
- const Type* getReadPointer (int channelNumber, int sampleIndex) const noexcept
- {
- jassert (isPositiveAndBelow (channelNumber, numChannels));
- jassert (isPositiveAndBelow (sampleIndex, size));
- return channels[channelNumber] + sampleIndex;
- }
-
- /** Returns a writeable pointer to one of the buffer's channels.
- For speed, this doesn't check whether the channel number is out of range,
- so be careful when using it!
- Note that if you're not planning on writing to the data, you should always
- use getReadPointer instead.
- */
- Type* getWritePointer (int channelNumber) noexcept
- {
- jassert (isPositiveAndBelow (channelNumber, numChannels));
- isClear = false;
- return channels[channelNumber];
- }
-
- /** Returns a writeable pointer to one of the buffer's channels.
- For speed, this doesn't check whether the channel number or index are out of range,
- so be careful when using it!
- Note that if you're not planning on writing to the data, you should
- use getReadPointer instead.
- */
- Type* getWritePointer (int channelNumber, int sampleIndex) noexcept
- {
- jassert (isPositiveAndBelow (channelNumber, numChannels));
- jassert (isPositiveAndBelow (sampleIndex, size));
- isClear = false;
- return channels[channelNumber] + sampleIndex;
- }
-
- /** Returns an array of pointers to the channels in the buffer.
-
- Don't modify any of the pointers that are returned, and bear in mind that
- these will become invalid if the buffer is resized.
- */
- const Type** getArrayOfReadPointers() const noexcept { return const_cast (channels); }
-
- /** Returns an array of pointers to the channels in the buffer.
-
- Don't modify any of the pointers that are returned, and bear in mind that
- these will become invalid if the buffer is resized.
- */
- Type** getArrayOfWritePointers() noexcept { isClear = false; return channels; }
-
- //==============================================================================
- /** Changes the buffer's size or number of channels.
-
- This can expand or contract the buffer's length, and add or remove channels.
-
- If keepExistingContent is true, it will try to preserve as much of the
- old data as it can in the new buffer.
-
- If clearExtraSpace is true, then any extra channels or space that is
- allocated will be also be cleared. If false, then this space is left
- uninitialised.
-
- If avoidReallocating is true, then changing the buffer's size won't reduce the
- amount of memory that is currently allocated (but it will still increase it if
- the new size is bigger than the amount it currently has). If this is false, then
- a new allocation will be done so that the buffer uses takes up the minimum amount
- of memory that it needs.
-
- If the required memory can't be allocated, this will throw a std::bad_alloc exception.
- */
- void setSize (int newNumChannels,
- int newNumSamples,
- bool keepExistingContent = false,
- bool clearExtraSpace = false,
- bool avoidReallocating = false)
- {
- jassert (newNumChannels >= 0);
- jassert (newNumSamples >= 0);
-
- if (newNumSamples != size || newNumChannels != numChannels)
- {
- const auto allocatedSamplesPerChannel = ((size_t) newNumSamples + 3) & ~3u;
- const auto channelListSize = ((sizeof (Type*) * (size_t) (newNumChannels + 1)) + 15) & ~15u;
- const auto newTotalBytes = ((size_t) newNumChannels * (size_t) allocatedSamplesPerChannel * sizeof (Type))
- + channelListSize + 32;
-
- if (keepExistingContent)
- {
- HeapBlock newData;
- newData.allocate (newTotalBytes, clearExtraSpace || isClear);
-
- auto numSamplesToCopy = (size_t) jmin (newNumSamples, size);
-
- auto newChannels = reinterpret_cast (newData.get());
- auto newChan = reinterpret_cast (newData + channelListSize);
-
- for (int j = 0; j < newNumChannels; ++j)
- {
- newChannels[j] = newChan;
- newChan += allocatedSamplesPerChannel;
- }
-
- if (! isClear)
- {
- auto numChansToCopy = jmin (numChannels, newNumChannels);
-
- for (int i = 0; i < numChansToCopy; ++i)
- FloatVectorOperations::copy (newChannels[i], channels[i], (int) numSamplesToCopy);
- }
-
- allocatedData.swapWith (newData);
- allocatedBytes = newTotalBytes;
- channels = newChannels;
- }
- else
- {
- if (avoidReallocating && allocatedBytes >= newTotalBytes)
- {
- if (clearExtraSpace || isClear)
- allocatedData.clear (newTotalBytes);
- }
- else
- {
- allocatedBytes = newTotalBytes;
- allocatedData.allocate (newTotalBytes, clearExtraSpace || isClear);
- channels = reinterpret_cast (allocatedData.get());
- }
-
- auto* chan = reinterpret_cast (allocatedData + channelListSize);
-
- for (int i = 0; i < newNumChannels; ++i)
- {
- channels[i] = chan;
- chan += allocatedSamplesPerChannel;
- }
- }
-
- channels[newNumChannels] = 0;
- size = newNumSamples;
- numChannels = newNumChannels;
- }
- }
-
- /** Makes this buffer point to a pre-allocated set of channel data arrays.
-
- There's also a constructor that lets you specify arrays like this, but this
- lets you change the channels dynamically.
-
- Note that if the buffer is resized or its number of channels is changed, it
- will re-allocate memory internally and copy the existing data to this new area,
- so it will then stop directly addressing this memory.
-
- @param dataToReferTo a pre-allocated array containing pointers to the data
- for each channel that should be used by this buffer. The
- buffer will only refer to this memory, it won't try to delete
- it when the buffer is deleted or resized.
- @param newNumChannels the number of channels to use - this must correspond to the
- number of elements in the array passed in
- @param newStartSample the offset within the arrays at which the data begins
- @param newNumSamples the number of samples to use - this must correspond to the
- size of the arrays passed in
- */
- void setDataToReferTo (Type** dataToReferTo,
- int newNumChannels,
- int newStartSample,
- int newNumSamples)
- {
- jassert (dataToReferTo != nullptr);
- jassert (newNumChannels >= 0 && newNumSamples >= 0);
-
- if (allocatedBytes != 0)
- {
- allocatedBytes = 0;
- allocatedData.free();
- }
-
- numChannels = newNumChannels;
- size = newNumSamples;
-
- allocateChannels (dataToReferTo, newStartSample);
- jassert (! isClear);
- }
-
- /** Makes this buffer point to a pre-allocated set of channel data arrays.
-
- There's also a constructor that lets you specify arrays like this, but this
- lets you change the channels dynamically.
-
- Note that if the buffer is resized or its number of channels is changed, it
- will re-allocate memory internally and copy the existing data to this new area,
- so it will then stop directly addressing this memory.
-
- @param dataToReferTo a pre-allocated array containing pointers to the data
- for each channel that should be used by this buffer. The
- buffer will only refer to this memory, it won't try to delete
- it when the buffer is deleted or resized.
- @param newNumChannels the number of channels to use - this must correspond to the
- number of elements in the array passed in
- @param newNumSamples the number of samples to use - this must correspond to the
- size of the arrays passed in
- */
- void setDataToReferTo (Type** dataToReferTo,
- int newNumChannels,
- int newNumSamples)
- {
- setDataToReferTo (dataToReferTo, newNumChannels, 0, newNumSamples);
- }
-
- /** Resizes this buffer to match the given one, and copies all of its content across.
- The source buffer can contain a different floating point type, so this can be used to
- convert between 32 and 64 bit float buffer types.
- */
- template
- void makeCopyOf (const AudioBuffer& other, bool avoidReallocating = false)
- {
- setSize (other.getNumChannels(), other.getNumSamples(), false, false, avoidReallocating);
-
- if (other.hasBeenCleared())
- {
- clear();
- }
- else
- {
- isClear = false;
-
- for (int chan = 0; chan < numChannels; ++chan)
- {
- auto* dest = channels[chan];
- auto* src = other.getReadPointer (chan);
-
- for (int i = 0; i < size; ++i)
- dest[i] = static_cast (src[i]);
- }
- }
- }
-
- //==============================================================================
- /** Clears all the samples in all channels. */
- void clear() noexcept
- {
- if (! isClear)
- {
- for (int i = 0; i < numChannels; ++i)
- FloatVectorOperations::clear (channels[i], size);
-
- isClear = true;
- }
- }
-
- /** Clears a specified region of all the channels.
-
- For speed, this doesn't check whether the channel and sample number
- are in-range, so be careful!
- */
- void clear (int startSample, int numSamples) noexcept
- {
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- if (! isClear)
- {
- if (startSample == 0 && numSamples == size)
- isClear = true;
-
- for (int i = 0; i < numChannels; ++i)
- FloatVectorOperations::clear (channels[i] + startSample, numSamples);
- }
- }
-
- /** Clears a specified region of just one channel.
-
- For speed, this doesn't check whether the channel and sample number
- are in-range, so be careful!
- */
- void clear (int channel, int startSample, int numSamples) noexcept
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- if (! isClear)
- FloatVectorOperations::clear (channels[channel] + startSample, numSamples);
- }
-
- /** Returns true if the buffer has been entirely cleared.
- Note that this does not actually measure the contents of the buffer - it simply
- returns a flag that is set when the buffer is cleared, and which is reset whenever
- functions like getWritePointer() are invoked. That means the method does not take
- any time, but it may return false negatives when in fact the buffer is still empty.
- */
- bool hasBeenCleared() const noexcept { return isClear; }
-
- //==============================================================================
- /** Returns a sample from the buffer.
- The channel and index are not checked - they are expected to be in-range. If not,
- an assertion will be thrown, but in a release build, you're into 'undefined behaviour'
- territory.
- */
- Type getSample (int channel, int sampleIndex) const noexcept
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (isPositiveAndBelow (sampleIndex, size));
- return *(channels[channel] + sampleIndex);
- }
-
- /** Sets a sample in the buffer.
- The channel and index are not checked - they are expected to be in-range. If not,
- an assertion will be thrown, but in a release build, you're into 'undefined behaviour'
- territory.
- */
- void setSample (int destChannel, int destSample, Type newValue) noexcept
- {
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (isPositiveAndBelow (destSample, size));
- *(channels[destChannel] + destSample) = newValue;
- isClear = false;
- }
-
- /** Adds a value to a sample in the buffer.
- The channel and index are not checked - they are expected to be in-range. If not,
- an assertion will be thrown, but in a release build, you're into 'undefined behaviour'
- territory.
- */
- void addSample (int destChannel, int destSample, Type valueToAdd) noexcept
- {
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (isPositiveAndBelow (destSample, size));
- *(channels[destChannel] + destSample) += valueToAdd;
- isClear = false;
- }
-
- /** Applies a gain multiple to a region of one channel.
-
- For speed, this doesn't check whether the channel and sample number
- are in-range, so be careful!
- */
- void applyGain (int channel, int startSample, int numSamples, Type gain) noexcept
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- if (gain != (Type) 1 && ! isClear)
- {
- auto* d = channels[channel] + startSample;
-
- if (gain == 0)
- FloatVectorOperations::clear (d, numSamples);
- else
- FloatVectorOperations::multiply (d, gain, numSamples);
- }
- }
-
- /** Applies a gain multiple to a region of all the channels.
-
- For speed, this doesn't check whether the sample numbers
- are in-range, so be careful!
- */
- void applyGain (int startSample, int numSamples, Type gain) noexcept
- {
- for (int i = 0; i < numChannels; ++i)
- applyGain (i, startSample, numSamples, gain);
- }
-
- /** Applies a gain multiple to all the audio data. */
- void applyGain (Type gain) noexcept
- {
- applyGain (0, size, gain);
- }
-
- /** Applies a range of gains to a region of a channel.
-
- The gain that is applied to each sample will vary from
- startGain on the first sample to endGain on the last Sample,
- so it can be used to do basic fades.
-
- For speed, this doesn't check whether the sample numbers
- are in-range, so be careful!
- */
- void applyGainRamp (int channel, int startSample, int numSamples,
- Type startGain, Type endGain) noexcept
- {
- if (! isClear)
- {
- if (startGain == endGain)
- {
- applyGain (channel, startSample, numSamples, startGain);
- }
- else
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- const auto increment = (endGain - startGain) / (float) numSamples;
- auto* d = channels[channel] + startSample;
-
- while (--numSamples >= 0)
- {
- *d++ *= startGain;
- startGain += increment;
- }
- }
- }
- }
-
- /** Applies a range of gains to a region of all channels.
-
- The gain that is applied to each sample will vary from
- startGain on the first sample to endGain on the last Sample,
- so it can be used to do basic fades.
-
- For speed, this doesn't check whether the sample numbers
- are in-range, so be careful!
- */
- void applyGainRamp (int startSample, int numSamples,
- Type startGain, Type endGain) noexcept
- {
- for (int i = 0; i < numChannels; ++i)
- applyGainRamp (i, startSample, numSamples, startGain, endGain);
- }
-
- /** Adds samples from another buffer to this one.
-
- @param destChannel the channel within this buffer to add the samples to
- @param destStartSample the start sample within this buffer's channel
- @param source the source buffer to add from
- @param sourceChannel the channel within the source buffer to read from
- @param sourceStartSample the offset within the source buffer's channel to start reading samples from
- @param numSamples the number of samples to process
- @param gainToApplyToSource an optional gain to apply to the source samples before they are
- added to this buffer's samples
-
- @see copyFrom
- */
- void addFrom (int destChannel,
- int destStartSample,
- const AudioBuffer& source,
- int sourceChannel,
- int sourceStartSample,
- int numSamples,
- Type gainToApplyToSource = (Type) 1) noexcept
- {
- jassert (&source != this || sourceChannel != destChannel);
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
- jassert (isPositiveAndBelow (sourceChannel, source.numChannels));
- jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size);
-
- if (gainToApplyToSource != 0 && numSamples > 0 && ! source.isClear)
- {
- auto* d = channels[destChannel] + destStartSample;
- auto* s = source.channels[sourceChannel] + sourceStartSample;
-
- if (isClear)
- {
- isClear = false;
-
- if (gainToApplyToSource != (Type) 1)
- FloatVectorOperations::copyWithMultiply (d, s, gainToApplyToSource, numSamples);
- else
- FloatVectorOperations::copy (d, s, numSamples);
- }
- else
- {
- if (gainToApplyToSource != (Type) 1)
- FloatVectorOperations::addWithMultiply (d, s, gainToApplyToSource, numSamples);
- else
- FloatVectorOperations::add (d, s, numSamples);
- }
- }
- }
-
-
- /** Adds samples from an array of floats to one of the channels.
-
- @param destChannel the channel within this buffer to add the samples to
- @param destStartSample the start sample within this buffer's channel
- @param source the source data to use
- @param numSamples the number of samples to process
- @param gainToApplyToSource an optional gain to apply to the source samples before they are
- added to this buffer's samples
-
- @see copyFrom
- */
- void addFrom (int destChannel,
- int destStartSample,
- const Type* source,
- int numSamples,
- Type gainToApplyToSource = (Type) 1) noexcept
- {
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
- jassert (source != nullptr);
-
- if (gainToApplyToSource != 0 && numSamples > 0)
- {
- auto* d = channels[destChannel] + destStartSample;
-
- if (isClear)
- {
- isClear = false;
-
- if (gainToApplyToSource != (Type) 1)
- FloatVectorOperations::copyWithMultiply (d, source, gainToApplyToSource, numSamples);
- else
- FloatVectorOperations::copy (d, source, numSamples);
- }
- else
- {
- if (gainToApplyToSource != (Type) 1)
- FloatVectorOperations::addWithMultiply (d, source, gainToApplyToSource, numSamples);
- else
- FloatVectorOperations::add (d, source, numSamples);
- }
- }
- }
-
-
- /** Adds samples from an array of floats, applying a gain ramp to them.
-
- @param destChannel the channel within this buffer to add the samples to
- @param destStartSample the start sample within this buffer's channel
- @param source the source data to use
- @param numSamples the number of samples to process
- @param startGain the gain to apply to the first sample (this is multiplied with
- the source samples before they are added to this buffer)
- @param endGain the gain to apply to the final sample. The gain is linearly
- interpolated between the first and last samples.
- */
- void addFromWithRamp (int destChannel,
- int destStartSample,
- const Type* source,
- int numSamples,
- Type startGain,
- Type endGain) noexcept
- {
- if (startGain == endGain)
- {
- addFrom (destChannel, destStartSample, source, numSamples, startGain);
- }
- else
- {
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
- jassert (source != nullptr);
-
- if (numSamples > 0)
- {
- isClear = false;
- const auto increment = (endGain - startGain) / numSamples;
- auto* d = channels[destChannel] + destStartSample;
-
- while (--numSamples >= 0)
- {
- *d++ += startGain * *source++;
- startGain += increment;
- }
- }
- }
- }
-
- /** Copies samples from another buffer to this one.
-
- @param destChannel the channel within this buffer to copy the samples to
- @param destStartSample the start sample within this buffer's channel
- @param source the source buffer to read from
- @param sourceChannel the channel within the source buffer to read from
- @param sourceStartSample the offset within the source buffer's channel to start reading samples from
- @param numSamples the number of samples to process
-
- @see addFrom
- */
- void copyFrom (int destChannel,
- int destStartSample,
- const AudioBuffer& source,
- int sourceChannel,
- int sourceStartSample,
- int numSamples) noexcept
- {
- jassert (&source != this || sourceChannel != destChannel);
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
- jassert (isPositiveAndBelow (sourceChannel, source.numChannels));
- jassert (sourceStartSample >= 0 && numSamples >= 0 && sourceStartSample + numSamples <= source.size);
-
- if (numSamples > 0)
- {
- if (source.isClear)
- {
- if (! isClear)
- FloatVectorOperations::clear (channels[destChannel] + destStartSample, numSamples);
- }
- else
- {
- isClear = false;
- FloatVectorOperations::copy (channels[destChannel] + destStartSample,
- source.channels[sourceChannel] + sourceStartSample,
- numSamples);
- }
- }
- }
-
- /** Copies samples from an array of floats into one of the channels.
-
- @param destChannel the channel within this buffer to copy the samples to
- @param destStartSample the start sample within this buffer's channel
- @param source the source buffer to read from
- @param numSamples the number of samples to process
-
- @see addFrom
- */
- void copyFrom (int destChannel,
- int destStartSample,
- const Type* source,
- int numSamples) noexcept
- {
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
- jassert (source != nullptr);
-
- if (numSamples > 0)
- {
- isClear = false;
- FloatVectorOperations::copy (channels[destChannel] + destStartSample, source, numSamples);
- }
- }
-
- /** Copies samples from an array of floats into one of the channels, applying a gain to it.
-
- @param destChannel the channel within this buffer to copy the samples to
- @param destStartSample the start sample within this buffer's channel
- @param source the source buffer to read from
- @param numSamples the number of samples to process
- @param gain the gain to apply
-
- @see addFrom
- */
- void copyFrom (int destChannel,
- int destStartSample,
- const Type* source,
- int numSamples,
- Type gain) noexcept
- {
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
- jassert (source != nullptr);
-
- if (numSamples > 0)
- {
- auto* d = channels[destChannel] + destStartSample;
-
- if (gain != (Type) 1)
- {
- if (gain == 0)
- {
- if (! isClear)
- FloatVectorOperations::clear (d, numSamples);
- }
- else
- {
- isClear = false;
- FloatVectorOperations::copyWithMultiply (d, source, gain, numSamples);
- }
- }
- else
- {
- isClear = false;
- FloatVectorOperations::copy (d, source, numSamples);
- }
- }
- }
-
- /** Copies samples from an array of floats into one of the channels, applying a gain ramp.
-
- @param destChannel the channel within this buffer to copy the samples to
- @param destStartSample the start sample within this buffer's channel
- @param source the source buffer to read from
- @param numSamples the number of samples to process
- @param startGain the gain to apply to the first sample (this is multiplied with
- the source samples before they are copied to this buffer)
- @param endGain the gain to apply to the final sample. The gain is linearly
- interpolated between the first and last samples.
-
- @see addFrom
- */
- void copyFromWithRamp (int destChannel,
- int destStartSample,
- const Type* source,
- int numSamples,
- Type startGain,
- Type endGain) noexcept
- {
- if (startGain == endGain)
- {
- copyFrom (destChannel, destStartSample, source, numSamples, startGain);
- }
- else
- {
- jassert (isPositiveAndBelow (destChannel, numChannels));
- jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
- jassert (source != nullptr);
-
- if (numSamples > 0)
- {
- isClear = false;
- const auto increment = (endGain - startGain) / numSamples;
- auto* d = channels[destChannel] + destStartSample;
-
- while (--numSamples >= 0)
- {
- *d++ = startGain * *source++;
- startGain += increment;
- }
- }
- }
- }
-
- /** Returns a Range indicating the lowest and highest sample values in a given section.
-
- @param channel the channel to read from
- @param startSample the start sample within the channel
- @param numSamples the number of samples to check
- */
- Range findMinMax (int channel, int startSample, int numSamples) const noexcept
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- if (isClear)
- return {};
-
- return FloatVectorOperations::findMinAndMax (channels[channel] + startSample, numSamples);
- }
-
- /** Finds the highest absolute sample value within a region of a channel. */
- Type getMagnitude (int channel, int startSample, int numSamples) const noexcept
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- if (isClear)
- return {};
-
- auto r = findMinMax (channel, startSample, numSamples);
-
- return jmax (r.getStart(), -r.getStart(), r.getEnd(), -r.getEnd());
- }
-
- /** Finds the highest absolute sample value within a region on all channels. */
- Type getMagnitude (int startSample, int numSamples) const noexcept
- {
- Type mag = 0;
-
- if (! isClear)
- for (int i = 0; i < numChannels; ++i)
- mag = jmax (mag, getMagnitude (i, startSample, numSamples));
-
- return mag;
- }
-
- /** Returns the root mean squared level for a region of a channel. */
- Type getRMSLevel (int channel, int startSample, int numSamples) const noexcept
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- if (numSamples <= 0 || channel < 0 || channel >= numChannels || isClear)
- return {};
-
- auto* data = channels[channel] + startSample;
- double sum = 0.0;
-
- for (int i = 0; i < numSamples; ++i)
- {
- const Type sample = data[i];
- sum += sample * sample;
- }
-
- return (Type) std::sqrt (sum / numSamples);
- }
-
- /** Reverses a part of a channel. */
- void reverse (int channel, int startSample, int numSamples) const noexcept
- {
- jassert (isPositiveAndBelow (channel, numChannels));
- jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
-
- if (! isClear)
- std::reverse (channels[channel] + startSample,
- channels[channel] + startSample + numSamples);
- }
-
- /** Reverses a part of the buffer. */
- void reverse (int startSample, int numSamples) const noexcept
- {
- for (int i = 0; i < numChannels; ++i)
- reverse (i, startSample, numSamples);
- }
-
-
-private:
- //==============================================================================
- int numChannels, size;
- size_t allocatedBytes;
- Type** channels;
- HeapBlock allocatedData;
- Type* preallocatedChannelSpace[32];
- bool isClear;
-
- void allocateData()
- {
- jassert (size >= 0);
- auto channelListSize = sizeof (Type*) * (size_t) (numChannels + 1);
- allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32;
- allocatedData.malloc (allocatedBytes);
- channels = reinterpret_cast (allocatedData.get());
- auto* chan = (Type*) (allocatedData + channelListSize);
-
- for (int i = 0; i < numChannels; ++i)
- {
- channels[i] = chan;
- chan += size;
- }
-
- channels[numChannels] = nullptr;
- isClear = false;
- }
-
- void allocateChannels (Type* const* dataToReferTo, int offset)
- {
- jassert (offset >= 0);
-
- // (try to avoid doing a malloc here, as that'll blow up things like Pro-Tools)
- if (numChannels < (int) numElementsInArray (preallocatedChannelSpace))
- {
- channels = static_cast (preallocatedChannelSpace);
- }
- else
- {
- allocatedData.malloc ((size_t) numChannels + 1, sizeof (Type*));
- channels = reinterpret_cast (allocatedData.get());
- }
-
- for (int i = 0; i < numChannels; ++i)
- {
- // you have to pass in the same number of valid pointers as numChannels
- jassert (dataToReferTo[i] != nullptr);
-
- channels[i] = dataToReferTo[i] + offset;
- }
-
- channels[numChannels] = nullptr;
- isClear = false;
- }
-
- JUCE_LEAK_DETECTOR (AudioBuffer)
-};
-
-//==============================================================================
-/**
- A multi-channel buffer of 32-bit floating point audio samples.
-
- This typedef is here for backwards compatibility with the older AudioSampleBuffer
- class, which was fixed for 32-bit data, but is otherwise the same as the new
- templated AudioBuffer class.
-
- @see AudioBuffer
-*/
-typedef AudioBuffer AudioSampleBuffer;
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp
deleted file mode 100644
index 5523a4a2f..000000000
--- a/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp
+++ /dev/null
@@ -1,1207 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-namespace FloatVectorHelpers
-{
- #define JUCE_INCREMENT_SRC_DEST dest += (16 / sizeof (*dest)); src += (16 / sizeof (*dest));
- #define JUCE_INCREMENT_SRC1_SRC2_DEST dest += (16 / sizeof (*dest)); src1 += (16 / sizeof (*dest)); src2 += (16 / sizeof (*dest));
- #define JUCE_INCREMENT_DEST dest += (16 / sizeof (*dest));
-
- #if JUCE_USE_SSE_INTRINSICS
- inline static bool isAligned (const void* p) noexcept
- {
- return (((pointer_sized_int) p) & 15) == 0;
- }
-
- struct BasicOps32
- {
- typedef float Type;
- typedef __m128 ParallelType;
- typedef __m128 IntegerType;
- enum { numParallel = 4 };
-
- // Integer and parallel types are the same for SSE. On neon they have different types
- static forcedinline IntegerType toint (ParallelType v) noexcept { return v; }
- static forcedinline ParallelType toflt (IntegerType v) noexcept { return v; }
-
- static forcedinline ParallelType load1 (Type v) noexcept { return _mm_load1_ps (&v); }
- static forcedinline ParallelType loadA (const Type* v) noexcept { return _mm_load_ps (v); }
- static forcedinline ParallelType loadU (const Type* v) noexcept { return _mm_loadu_ps (v); }
- static forcedinline void storeA (Type* dest, ParallelType a) noexcept { _mm_store_ps (dest, a); }
- static forcedinline void storeU (Type* dest, ParallelType a) noexcept { _mm_storeu_ps (dest, a); }
-
- static forcedinline ParallelType add (ParallelType a, ParallelType b) noexcept { return _mm_add_ps (a, b); }
- static forcedinline ParallelType sub (ParallelType a, ParallelType b) noexcept { return _mm_sub_ps (a, b); }
- static forcedinline ParallelType mul (ParallelType a, ParallelType b) noexcept { return _mm_mul_ps (a, b); }
- static forcedinline ParallelType max (ParallelType a, ParallelType b) noexcept { return _mm_max_ps (a, b); }
- static forcedinline ParallelType min (ParallelType a, ParallelType b) noexcept { return _mm_min_ps (a, b); }
-
- static forcedinline ParallelType bit_and (ParallelType a, ParallelType b) noexcept { return _mm_and_ps (a, b); }
- static forcedinline ParallelType bit_not (ParallelType a, ParallelType b) noexcept { return _mm_andnot_ps (a, b); }
- static forcedinline ParallelType bit_or (ParallelType a, ParallelType b) noexcept { return _mm_or_ps (a, b); }
- static forcedinline ParallelType bit_xor (ParallelType a, ParallelType b) noexcept { return _mm_xor_ps (a, b); }
-
- static forcedinline Type max (ParallelType a) noexcept { Type v[numParallel]; storeU (v, a); return jmax (v[0], v[1], v[2], v[3]); }
- static forcedinline Type min (ParallelType a) noexcept { Type v[numParallel]; storeU (v, a); return jmin (v[0], v[1], v[2], v[3]); }
- };
-
- struct BasicOps64
- {
- typedef double Type;
- typedef __m128d ParallelType;
- typedef __m128d IntegerType;
- enum { numParallel = 2 };
-
- // Integer and parallel types are the same for SSE. On neon they have different types
- static forcedinline IntegerType toint (ParallelType v) noexcept { return v; }
- static forcedinline ParallelType toflt (IntegerType v) noexcept { return v; }
-
- static forcedinline ParallelType load1 (Type v) noexcept { return _mm_load1_pd (&v); }
- static forcedinline ParallelType loadA (const Type* v) noexcept { return _mm_load_pd (v); }
- static forcedinline ParallelType loadU (const Type* v) noexcept { return _mm_loadu_pd (v); }
- static forcedinline void storeA (Type* dest, ParallelType a) noexcept { _mm_store_pd (dest, a); }
- static forcedinline void storeU (Type* dest, ParallelType a) noexcept { _mm_storeu_pd (dest, a); }
-
- static forcedinline ParallelType add (ParallelType a, ParallelType b) noexcept { return _mm_add_pd (a, b); }
- static forcedinline ParallelType sub (ParallelType a, ParallelType b) noexcept { return _mm_sub_pd (a, b); }
- static forcedinline ParallelType mul (ParallelType a, ParallelType b) noexcept { return _mm_mul_pd (a, b); }
- static forcedinline ParallelType max (ParallelType a, ParallelType b) noexcept { return _mm_max_pd (a, b); }
- static forcedinline ParallelType min (ParallelType a, ParallelType b) noexcept { return _mm_min_pd (a, b); }
-
- static forcedinline ParallelType bit_and (ParallelType a, ParallelType b) noexcept { return _mm_and_pd (a, b); }
- static forcedinline ParallelType bit_not (ParallelType a, ParallelType b) noexcept { return _mm_andnot_pd (a, b); }
- static forcedinline ParallelType bit_or (ParallelType a, ParallelType b) noexcept { return _mm_or_pd (a, b); }
- static forcedinline ParallelType bit_xor (ParallelType a, ParallelType b) noexcept { return _mm_xor_pd (a, b); }
-
- static forcedinline Type max (ParallelType a) noexcept { Type v[numParallel]; storeU (v, a); return jmax (v[0], v[1]); }
- static forcedinline Type min (ParallelType a) noexcept { Type v[numParallel]; storeU (v, a); return jmin (v[0], v[1]); }
- };
-
-
-
- #define JUCE_BEGIN_VEC_OP \
- typedef FloatVectorHelpers::ModeType::Mode Mode; \
- { \
- const int numLongOps = num / Mode::numParallel;
-
- #define JUCE_FINISH_VEC_OP(normalOp) \
- num &= (Mode::numParallel - 1); \
- if (num == 0) return; \
- } \
- for (int i = 0; i < num; ++i) normalOp;
-
- #define JUCE_PERFORM_VEC_OP_DEST(normalOp, vecOp, locals, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- if (FloatVectorHelpers::isAligned (dest)) JUCE_VEC_LOOP (vecOp, dummy, Mode::loadA, Mode::storeA, locals, JUCE_INCREMENT_DEST) \
- else JUCE_VEC_LOOP (vecOp, dummy, Mode::loadU, Mode::storeU, locals, JUCE_INCREMENT_DEST) \
- JUCE_FINISH_VEC_OP (normalOp)
-
- #define JUCE_PERFORM_VEC_OP_SRC_DEST(normalOp, vecOp, locals, increment, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- if (FloatVectorHelpers::isAligned (dest)) \
- { \
- if (FloatVectorHelpers::isAligned (src)) JUCE_VEC_LOOP (vecOp, Mode::loadA, Mode::loadA, Mode::storeA, locals, increment) \
- else JUCE_VEC_LOOP (vecOp, Mode::loadU, Mode::loadA, Mode::storeA, locals, increment) \
- }\
- else \
- { \
- if (FloatVectorHelpers::isAligned (src)) JUCE_VEC_LOOP (vecOp, Mode::loadA, Mode::loadU, Mode::storeU, locals, increment) \
- else JUCE_VEC_LOOP (vecOp, Mode::loadU, Mode::loadU, Mode::storeU, locals, increment) \
- } \
- JUCE_FINISH_VEC_OP (normalOp)
-
- #define JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST(normalOp, vecOp, locals, increment, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- if (FloatVectorHelpers::isAligned (dest)) \
- { \
- if (FloatVectorHelpers::isAligned (src1)) \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadA, Mode::loadA, Mode::storeA, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadA, Mode::loadU, Mode::storeA, locals, increment) \
- } \
- else \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadU, Mode::loadA, Mode::storeA, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadU, Mode::loadU, Mode::storeA, locals, increment) \
- } \
- } \
- else \
- { \
- if (FloatVectorHelpers::isAligned (src1)) \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadA, Mode::loadA, Mode::storeU, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadA, Mode::loadU, Mode::storeU, locals, increment) \
- } \
- else \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadU, Mode::loadA, Mode::storeU, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadU, Mode::loadU, Mode::storeU, locals, increment) \
- } \
- } \
- JUCE_FINISH_VEC_OP (normalOp)
-
- #define JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST_DEST(normalOp, vecOp, locals, increment, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- if (FloatVectorHelpers::isAligned (dest)) \
- { \
- if (FloatVectorHelpers::isAligned (src1)) \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadA, Mode::loadA, Mode::loadA, Mode::storeA, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadA, Mode::loadU, Mode::loadA, Mode::storeA, locals, increment) \
- } \
- else \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadU, Mode::loadA, Mode::loadA, Mode::storeA, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadU, Mode::loadU, Mode::loadA, Mode::storeA, locals, increment) \
- } \
- } \
- else \
- { \
- if (FloatVectorHelpers::isAligned (src1)) \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadA, Mode::loadA, Mode::loadU, Mode::storeU, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadA, Mode::loadU, Mode::loadU, Mode::storeU, locals, increment) \
- } \
- else \
- { \
- if (FloatVectorHelpers::isAligned (src2)) JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadU, Mode::loadA, Mode::loadU, Mode::storeU, locals, increment) \
- else JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadU, Mode::loadU, Mode::loadU, Mode::storeU, locals, increment) \
- } \
- } \
- JUCE_FINISH_VEC_OP (normalOp)
-
-
- //==============================================================================
- #elif JUCE_USE_ARM_NEON
-
- struct BasicOps32
- {
- typedef float Type;
- typedef float32x4_t ParallelType;
- typedef uint32x4_t IntegerType;
- union signMaskUnion { ParallelType f; IntegerType i; };
- enum { numParallel = 4 };
-
- static forcedinline IntegerType toint (ParallelType v) noexcept { signMaskUnion u; u.f = v; return u.i; }
- static forcedinline ParallelType toflt (IntegerType v) noexcept { signMaskUnion u; u.i = v; return u.f; }
-
- static forcedinline ParallelType load1 (Type v) noexcept { return vld1q_dup_f32 (&v); }
- static forcedinline ParallelType loadA (const Type* v) noexcept { return vld1q_f32 (v); }
- static forcedinline ParallelType loadU (const Type* v) noexcept { return vld1q_f32 (v); }
- static forcedinline void storeA (Type* dest, ParallelType a) noexcept { vst1q_f32 (dest, a); }
- static forcedinline void storeU (Type* dest, ParallelType a) noexcept { vst1q_f32 (dest, a); }
-
- static forcedinline ParallelType add (ParallelType a, ParallelType b) noexcept { return vaddq_f32 (a, b); }
- static forcedinline ParallelType sub (ParallelType a, ParallelType b) noexcept { return vsubq_f32 (a, b); }
- static forcedinline ParallelType mul (ParallelType a, ParallelType b) noexcept { return vmulq_f32 (a, b); }
- static forcedinline ParallelType max (ParallelType a, ParallelType b) noexcept { return vmaxq_f32 (a, b); }
- static forcedinline ParallelType min (ParallelType a, ParallelType b) noexcept { return vminq_f32 (a, b); }
-
- static forcedinline ParallelType bit_and (ParallelType a, ParallelType b) noexcept { return toflt (vandq_u32 (toint (a), toint (b))); }
- static forcedinline ParallelType bit_not (ParallelType a, ParallelType b) noexcept { return toflt (vbicq_u32 (toint (a), toint (b))); }
- static forcedinline ParallelType bit_or (ParallelType a, ParallelType b) noexcept { return toflt (vorrq_u32 (toint (a), toint (b))); }
- static forcedinline ParallelType bit_xor (ParallelType a, ParallelType b) noexcept { return toflt (veorq_u32 (toint (a), toint (b))); }
-
- static forcedinline Type max (ParallelType a) noexcept { Type v[numParallel]; storeU (v, a); return jmax (v[0], v[1], v[2], v[3]); }
- static forcedinline Type min (ParallelType a) noexcept { Type v[numParallel]; storeU (v, a); return jmin (v[0], v[1], v[2], v[3]); }
- };
-
- struct BasicOps64
- {
- typedef double Type;
- typedef double ParallelType;
- typedef uint64 IntegerType;
- union signMaskUnion { ParallelType f; IntegerType i; };
- enum { numParallel = 1 };
-
- static forcedinline IntegerType toint (ParallelType v) noexcept { signMaskUnion u; u.f = v; return u.i; }
- static forcedinline ParallelType toflt (IntegerType v) noexcept { signMaskUnion u; u.i = v; return u.f; }
-
- static forcedinline ParallelType load1 (Type v) noexcept { return v; }
- static forcedinline ParallelType loadA (const Type* v) noexcept { return *v; }
- static forcedinline ParallelType loadU (const Type* v) noexcept { return *v; }
- static forcedinline void storeA (Type* dest, ParallelType a) noexcept { *dest = a; }
- static forcedinline void storeU (Type* dest, ParallelType a) noexcept { *dest = a; }
-
- static forcedinline ParallelType add (ParallelType a, ParallelType b) noexcept { return a + b; }
- static forcedinline ParallelType sub (ParallelType a, ParallelType b) noexcept { return a - b; }
- static forcedinline ParallelType mul (ParallelType a, ParallelType b) noexcept { return a * b; }
- static forcedinline ParallelType max (ParallelType a, ParallelType b) noexcept { return jmax (a, b); }
- static forcedinline ParallelType min (ParallelType a, ParallelType b) noexcept { return jmin (a, b); }
-
- static forcedinline ParallelType bit_and (ParallelType a, ParallelType b) noexcept { return toflt (toint (a) & toint (b)); }
- static forcedinline ParallelType bit_not (ParallelType a, ParallelType b) noexcept { return toflt ((~toint (a)) & toint (b)); }
- static forcedinline ParallelType bit_or (ParallelType a, ParallelType b) noexcept { return toflt (toint (a) | toint (b)); }
- static forcedinline ParallelType bit_xor (ParallelType a, ParallelType b) noexcept { return toflt (toint (a) ^ toint (b)); }
-
- static forcedinline Type max (ParallelType a) noexcept { return a; }
- static forcedinline Type min (ParallelType a) noexcept { return a; }
- };
-
- #define JUCE_BEGIN_VEC_OP \
- typedef FloatVectorHelpers::ModeType::Mode Mode; \
- if (Mode::numParallel > 1) \
- { \
- const int numLongOps = num / Mode::numParallel;
-
- #define JUCE_FINISH_VEC_OP(normalOp) \
- num &= (Mode::numParallel - 1); \
- if (num == 0) return; \
- } \
- for (int i = 0; i < num; ++i) normalOp;
-
- #define JUCE_PERFORM_VEC_OP_DEST(normalOp, vecOp, locals, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- JUCE_VEC_LOOP (vecOp, dummy, Mode::loadU, Mode::storeU, locals, JUCE_INCREMENT_DEST) \
- JUCE_FINISH_VEC_OP (normalOp)
-
- #define JUCE_PERFORM_VEC_OP_SRC_DEST(normalOp, vecOp, locals, increment, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- JUCE_VEC_LOOP (vecOp, Mode::loadU, Mode::loadU, Mode::storeU, locals, increment) \
- JUCE_FINISH_VEC_OP (normalOp)
-
- #define JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST(normalOp, vecOp, locals, increment, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- JUCE_VEC_LOOP_TWO_SOURCES (vecOp, Mode::loadU, Mode::loadU, Mode::storeU, locals, increment) \
- JUCE_FINISH_VEC_OP (normalOp)
-
- #define JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST_DEST(normalOp, vecOp, locals, increment, setupOp) \
- JUCE_BEGIN_VEC_OP \
- setupOp \
- JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD (vecOp, Mode::loadU, Mode::loadU, Mode::loadU, Mode::storeU, locals, increment) \
- JUCE_FINISH_VEC_OP (normalOp)
-
-
- //==============================================================================
- #else
- #define JUCE_PERFORM_VEC_OP_DEST(normalOp, vecOp, locals, setupOp) \
- for (int i = 0; i < num; ++i) normalOp;
-
- #define JUCE_PERFORM_VEC_OP_SRC_DEST(normalOp, vecOp, locals, increment, setupOp) \
- for (int i = 0; i < num; ++i) normalOp;
-
- #define JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST(normalOp, vecOp, locals, increment, setupOp) \
- for (int i = 0; i < num; ++i) normalOp;
-
- #define JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST_DEST(normalOp, vecOp, locals, increment, setupOp) \
- for (int i = 0; i < num; ++i) normalOp;
-
- #endif
-
- //==============================================================================
- #define JUCE_VEC_LOOP(vecOp, srcLoad, dstLoad, dstStore, locals, increment) \
- for (int i = 0; i < numLongOps; ++i) \
- { \
- locals (srcLoad, dstLoad); \
- dstStore (dest, vecOp); \
- increment; \
- }
-
- #define JUCE_VEC_LOOP_TWO_SOURCES(vecOp, src1Load, src2Load, dstStore, locals, increment) \
- for (int i = 0; i < numLongOps; ++i) \
- { \
- locals (src1Load, src2Load); \
- dstStore (dest, vecOp); \
- increment; \
- }
-
- #define JUCE_VEC_LOOP_TWO_SOURCES_WITH_DEST_LOAD(vecOp, src1Load, src2Load, dstLoad, dstStore, locals, increment) \
- for (int i = 0; i < numLongOps; ++i) \
- { \
- locals (src1Load, src2Load, dstLoad); \
- dstStore (dest, vecOp); \
- increment; \
- }
-
- #define JUCE_LOAD_NONE(srcLoad, dstLoad)
- #define JUCE_LOAD_DEST(srcLoad, dstLoad) const Mode::ParallelType d = dstLoad (dest);
- #define JUCE_LOAD_SRC(srcLoad, dstLoad) const Mode::ParallelType s = srcLoad (src);
- #define JUCE_LOAD_SRC1_SRC2(src1Load, src2Load) const Mode::ParallelType s1 = src1Load (src1), s2 = src2Load (src2);
- #define JUCE_LOAD_SRC1_SRC2_DEST(src1Load, src2Load, dstLoad) const Mode::ParallelType d = dstLoad (dest), s1 = src1Load (src1), s2 = src2Load (src2);
- #define JUCE_LOAD_SRC_DEST(srcLoad, dstLoad) const Mode::ParallelType d = dstLoad (dest), s = srcLoad (src);
-
- union signMask32 { float f; uint32 i; };
- union signMask64 { double d; uint64 i; };
-
- #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON
- template struct ModeType { typedef BasicOps32 Mode; };
- template<> struct ModeType<8> { typedef BasicOps64 Mode; };
-
- template
- struct MinMax
- {
- typedef typename Mode::Type Type;
- typedef typename Mode::ParallelType ParallelType;
-
- static Type findMinOrMax (const Type* src, int num, const bool isMinimum) noexcept
- {
- int numLongOps = num / Mode::numParallel;
-
- if (numLongOps > 1)
- {
- ParallelType val;
-
- #if ! JUCE_USE_ARM_NEON
- if (isAligned (src))
- {
- val = Mode::loadA (src);
-
- if (isMinimum)
- {
- while (--numLongOps > 0)
- {
- src += Mode::numParallel;
- val = Mode::min (val, Mode::loadA (src));
- }
- }
- else
- {
- while (--numLongOps > 0)
- {
- src += Mode::numParallel;
- val = Mode::max (val, Mode::loadA (src));
- }
- }
- }
- else
- #endif
- {
- val = Mode::loadU (src);
-
- if (isMinimum)
- {
- while (--numLongOps > 0)
- {
- src += Mode::numParallel;
- val = Mode::min (val, Mode::loadU (src));
- }
- }
- else
- {
- while (--numLongOps > 0)
- {
- src += Mode::numParallel;
- val = Mode::max (val, Mode::loadU (src));
- }
- }
- }
-
- Type result = isMinimum ? Mode::min (val)
- : Mode::max (val);
-
- num &= (Mode::numParallel - 1);
- src += Mode::numParallel;
-
- for (int i = 0; i < num; ++i)
- result = isMinimum ? jmin (result, src[i])
- : jmax (result, src[i]);
-
- return result;
- }
-
- return isMinimum ? juce::findMinimum (src, num)
- : juce::findMaximum (src, num);
- }
-
- static Range findMinAndMax (const Type* src, int num) noexcept
- {
- int numLongOps = num / Mode::numParallel;
-
- if (numLongOps > 1)
- {
- ParallelType mn, mx;
-
- #if ! JUCE_USE_ARM_NEON
- if (isAligned (src))
- {
- mn = Mode::loadA (src);
- mx = mn;
-
- while (--numLongOps > 0)
- {
- src += Mode::numParallel;
- const ParallelType v = Mode::loadA (src);
- mn = Mode::min (mn, v);
- mx = Mode::max (mx, v);
- }
- }
- else
- #endif
- {
- mn = Mode::loadU (src);
- mx = mn;
-
- while (--numLongOps > 0)
- {
- src += Mode::numParallel;
- const ParallelType v = Mode::loadU (src);
- mn = Mode::min (mn, v);
- mx = Mode::max (mx, v);
- }
- }
-
- Range result (Mode::min (mn),
- Mode::max (mx));
-
- num &= (Mode::numParallel - 1);
- src += Mode::numParallel;
-
- for (int i = 0; i < num; ++i)
- result = result.getUnionWith (src[i]);
-
- return result;
- }
-
- return Range::findMinAndMax (src, num);
- }
- };
- #endif
-}
-
-//==============================================================================
-namespace
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- // This casts away constness to account for slightly different vDSP function signatures
- // in OSX 10.8 SDK and below. Can be safely removed once those SDKs are obsolete.
- template
- ValueType* osx108sdkCompatibilityCast (const ValueType* arg) noexcept { return const_cast (arg); }
- #endif
-}
-
-//==============================================================================
-void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vclr (dest, 1, (size_t) num);
- #else
- zeromem (dest, (size_t) num * sizeof (float));
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::clear (double* dest, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vclrD (dest, 1, (size_t) num);
- #else
- zeromem (dest, (size_t) num * sizeof (double));
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vfill (&valueToFill, dest, 1, (size_t) num);
- #else
- JUCE_PERFORM_VEC_OP_DEST (dest[i] = valueToFill, val, JUCE_LOAD_NONE,
- const Mode::ParallelType val = Mode::load1 (valueToFill);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::fill (double* dest, double valueToFill, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vfillD (&valueToFill, dest, 1, (size_t) num);
- #else
- JUCE_PERFORM_VEC_OP_DEST (dest[i] = valueToFill, val, JUCE_LOAD_NONE,
- const Mode::ParallelType val = Mode::load1 (valueToFill);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::copy (float* dest, const float* src, int num) noexcept
-{
- memcpy (dest, src, (size_t) num * sizeof (float));
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::copy (double* dest, const double* src, int num) noexcept
-{
- memcpy (dest, src, (size_t) num * sizeof (double));
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::copyWithMultiply (float* dest, const float* src, float multiplier, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsmul (src, 1, &multiplier, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier, Mode::mul (mult, s),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::copyWithMultiply (double* dest, const double* src, double multiplier, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsmulD (src, 1, &multiplier, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier, Mode::mul (mult, s),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (float* dest, float amount, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsadd (dest, 1, &amount, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_DEST (dest[i] += amount, Mode::add (d, amountToAdd), JUCE_LOAD_DEST,
- const Mode::ParallelType amountToAdd = Mode::load1 (amount);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (double* dest, double amount, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_DEST (dest[i] += amount, Mode::add (d, amountToAdd), JUCE_LOAD_DEST,
- const Mode::ParallelType amountToAdd = Mode::load1 (amount);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (float* dest, const float* src, float amount, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsadd (osx108sdkCompatibilityCast (src), 1, &amount, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] + amount, Mode::add (am, s),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType am = Mode::load1 (amount);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (double* dest, const double* src, double amount, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsaddD (osx108sdkCompatibilityCast (src), 1, &amount, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] + amount, Mode::add (am, s),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType am = Mode::load1 (amount);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (float* dest, const float* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vadd (src, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] += src[i], Mode::add (d, s), JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (double* dest, const double* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vaddD (src, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] += src[i], Mode::add (d, s), JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (float* dest, const float* src1, const float* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vadd (src1, 1, src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = src1[i] + src2[i], Mode::add (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::add (double* dest, const double* src1, const double* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vaddD (src1, 1, src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = src1[i] + src2[i], Mode::add (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtract (float* dest, const float* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsub (src, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] -= src[i], Mode::sub (d, s), JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtract (double* dest, const double* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsubD (src, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] -= src[i], Mode::sub (d, s), JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtract (float* dest, const float* src1, const float* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsub (src2, 1, src1, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = src1[i] - src2[i], Mode::sub (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtract (double* dest, const double* src1, const double* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsubD (src2, 1, src1, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = src1[i] - src2[i], Mode::sub (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::addWithMultiply (float* dest, const float* src, float multiplier, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsma (src, 1, &multiplier, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] += src[i] * multiplier, Mode::add (d, Mode::mul (mult, s)),
- JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::addWithMultiply (double* dest, const double* src, double multiplier, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsmaD (src, 1, &multiplier, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] += src[i] * multiplier, Mode::add (d, Mode::mul (mult, s)),
- JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::addWithMultiply (float* dest, const float* src1, const float* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vma ((float*) src1, 1, (float*) src2, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST_DEST (dest[i] += src1[i] * src2[i], Mode::add (d, Mode::mul (s1, s2)),
- JUCE_LOAD_SRC1_SRC2_DEST,
- JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::addWithMultiply (double* dest, const double* src1, const double* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmaD ((double*) src1, 1, (double*) src2, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST_DEST (dest[i] += src1[i] * src2[i], Mode::add (d, Mode::mul (s1, s2)),
- JUCE_LOAD_SRC1_SRC2_DEST,
- JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtractWithMultiply (float* dest, const float* src, float multiplier, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] -= src[i] * multiplier, Mode::sub (d, Mode::mul (mult, s)),
- JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtractWithMultiply (double* dest, const double* src, double multiplier, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] -= src[i] * multiplier, Mode::sub (d, Mode::mul (mult, s)),
- JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtractWithMultiply (float* dest, const float* src1, const float* src2, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST_DEST (dest[i] -= src1[i] * src2[i], Mode::sub (d, Mode::mul (s1, s2)),
- JUCE_LOAD_SRC1_SRC2_DEST,
- JUCE_INCREMENT_SRC1_SRC2_DEST, )
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::subtractWithMultiply (double* dest, const double* src1, const double* src2, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST_DEST (dest[i] -= src1[i] * src2[i], Mode::sub (d, Mode::mul (s1, s2)),
- JUCE_LOAD_SRC1_SRC2_DEST,
- JUCE_INCREMENT_SRC1_SRC2_DEST, )
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (float* dest, const float* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmul (src, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] *= src[i], Mode::mul (d, s), JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (double* dest, const double* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmulD (src, 1, dest, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] *= src[i], Mode::mul (d, s), JUCE_LOAD_SRC_DEST, JUCE_INCREMENT_SRC_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (float* dest, const float* src1, const float* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmul (src1, 1, src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = src1[i] * src2[i], Mode::mul (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (double* dest, const double* src1, const double* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmulD (src1, 1, src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = src1[i] * src2[i], Mode::mul (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (float* dest, float multiplier, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsmul (dest, 1, &multiplier, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_DEST (dest[i] *= multiplier, Mode::mul (d, mult), JUCE_LOAD_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (double* dest, double multiplier, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vsmulD (dest, 1, &multiplier, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_DEST (dest[i] *= multiplier, Mode::mul (d, mult), JUCE_LOAD_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (float* dest, const float* src, float multiplier, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier, Mode::mul (mult, s),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::multiply (double* dest, const double* src, double multiplier, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier, Mode::mul (mult, s),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
-}
-
-void FloatVectorOperations::negate (float* dest, const float* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vneg ((float*) src, 1, dest, 1, (vDSP_Length) num);
- #else
- copyWithMultiply (dest, src, -1.0f, num);
- #endif
-}
-
-void FloatVectorOperations::negate (double* dest, const double* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vnegD ((double*) src, 1, dest, 1, (vDSP_Length) num);
- #else
- copyWithMultiply (dest, src, -1.0f, num);
- #endif
-}
-
-void FloatVectorOperations::abs (float* dest, const float* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vabs ((float*) src, 1, dest, 1, (vDSP_Length) num);
- #else
- FloatVectorHelpers::signMask32 signMask;
- signMask.i = 0x7fffffffUL;
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = fabsf (src[i]), Mode::bit_and (s, mask),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mask = Mode::load1 (signMask.f);)
-
- ignoreUnused (signMask);
- #endif
-}
-
-void FloatVectorOperations::abs (double* dest, const double* src, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vabsD ((double*) src, 1, dest, 1, (vDSP_Length) num);
- #else
- FloatVectorHelpers::signMask64 signMask;
- signMask.i = 0x7fffffffffffffffULL;
-
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = fabs (src[i]), Mode::bit_and (s, mask),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mask = Mode::load1 (signMask.d);)
-
- ignoreUnused (signMask);
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::convertFixedToFloat (float* dest, const int* src, float multiplier, int num) noexcept
-{
- #if JUCE_USE_ARM_NEON
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier,
- vmulq_n_f32 (vcvtq_f32_s32 (vld1q_s32 (src)), multiplier),
- JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST, )
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = (float) src[i] * multiplier,
- Mode::mul (mult, _mm_cvtepi32_ps (_mm_loadu_si128 ((const __m128i*) src))),
- JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType mult = Mode::load1 (multiplier);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::min (float* dest, const float* src, float comp, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = jmin (src[i], comp), Mode::min (s, cmp),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType cmp = Mode::load1 (comp);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::min (double* dest, const double* src, double comp, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = jmin (src[i], comp), Mode::min (s, cmp),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType cmp = Mode::load1 (comp);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::min (float* dest, const float* src1, const float* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmin ((float*) src1, 1, (float*) src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = jmin (src1[i], src2[i]), Mode::min (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::min (double* dest, const double* src1, const double* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vminD ((double*) src1, 1, (double*) src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = jmin (src1[i], src2[i]), Mode::min (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::max (float* dest, const float* src, float comp, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = jmax (src[i], comp), Mode::max (s, cmp),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType cmp = Mode::load1 (comp);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::max (double* dest, const double* src, double comp, int num) noexcept
-{
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = jmax (src[i], comp), Mode::max (s, cmp),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType cmp = Mode::load1 (comp);)
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::max (float* dest, const float* src1, const float* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmax ((float*) src1, 1, (float*) src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = jmax (src1[i], src2[i]), Mode::max (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::max (double* dest, const double* src1, const double* src2, int num) noexcept
-{
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vmaxD ((double*) src1, 1, (double*) src2, 1, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST (dest[i] = jmax (src1[i], src2[i]), Mode::max (s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::clip (float* dest, const float* src, float low, float high, int num) noexcept
-{
- jassert(high >= low);
-
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vclip ((float*) src, 1, &low, &high, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = jmax (jmin (src[i], high), low), Mode::max (Mode::min (s, hi), lo),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType lo = Mode::load1 (low); const Mode::ParallelType hi = Mode::load1 (high);)
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::clip (double* dest, const double* src, double low, double high, int num) noexcept
-{
- jassert(high >= low);
-
- #if JUCE_USE_VDSP_FRAMEWORK
- vDSP_vclipD ((double*) src, 1, &low, &high, dest, 1, (vDSP_Length) num);
- #else
- JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = jmax (jmin (src[i], high), low), Mode::max (Mode::min (s, hi), lo),
- JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,
- const Mode::ParallelType lo = Mode::load1 (low); const Mode::ParallelType hi = Mode::load1 (high);)
- #endif
-}
-
-Range JUCE_CALLTYPE FloatVectorOperations::findMinAndMax (const float* src, int num) noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON
- return FloatVectorHelpers::MinMax::findMinAndMax (src, num);
- #else
- return Range::findMinAndMax (src, num);
- #endif
-}
-
-Range JUCE_CALLTYPE FloatVectorOperations::findMinAndMax (const double* src, int num) noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON
- return FloatVectorHelpers::MinMax::findMinAndMax (src, num);
- #else
- return Range::findMinAndMax (src, num);
- #endif
-}
-
-float JUCE_CALLTYPE FloatVectorOperations::findMinimum (const float* src, int num) noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON
- return FloatVectorHelpers::MinMax::findMinOrMax (src, num, true);
- #else
- return juce::findMinimum (src, num);
- #endif
-}
-
-double JUCE_CALLTYPE FloatVectorOperations::findMinimum (const double* src, int num) noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON
- return FloatVectorHelpers::MinMax::findMinOrMax (src, num, true);
- #else
- return juce::findMinimum (src, num);
- #endif
-}
-
-float JUCE_CALLTYPE FloatVectorOperations::findMaximum (const float* src, int num) noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON
- return FloatVectorHelpers::MinMax::findMinOrMax (src, num, false);
- #else
- return juce::findMaximum (src, num);
- #endif
-}
-
-double JUCE_CALLTYPE FloatVectorOperations::findMaximum (const double* src, int num) noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON
- return FloatVectorHelpers::MinMax::findMinOrMax (src, num, false);
- #else
- return juce::findMaximum (src, num);
- #endif
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::enableFlushToZeroMode (bool shouldEnable) noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS
- _MM_SET_FLUSH_ZERO_MODE (shouldEnable ? _MM_FLUSH_ZERO_ON : _MM_FLUSH_ZERO_OFF);
- #endif
- ignoreUnused (shouldEnable);
-}
-
-void JUCE_CALLTYPE FloatVectorOperations::disableDenormalisedNumberSupport() noexcept
-{
- #if JUCE_USE_SSE_INTRINSICS
- const unsigned int mxcsr = _mm_getcsr();
- _mm_setcsr (mxcsr | 0x8040); // add the DAZ and FZ bits
- #endif
-}
-
-//==============================================================================
-//==============================================================================
-#if JUCE_UNIT_TESTS
-
-class FloatVectorOperationsTests : public UnitTest
-{
-public:
- FloatVectorOperationsTests() : UnitTest ("FloatVectorOperations", "Audio") {}
-
- template
- struct TestRunner
- {
- static void runTest (UnitTest& u, Random random)
- {
- const int range = random.nextBool() ? 500 : 10;
- const int num = random.nextInt (range) + 1;
-
- HeapBlock buffer1 ((size_t) num + 16), buffer2 ((size_t) num + 16);
- HeapBlock buffer3 ((size_t) num + 16);
-
- #if JUCE_ARM
- ValueType* const data1 = buffer1;
- ValueType* const data2 = buffer2;
- int* const int1 = buffer3;
- #else
- // These tests deliberately operate on misaligned memory and will be flagged up by
- // checks for undefined behavior!
- ValueType* const data1 = addBytesToPointer (buffer1.get(), random.nextInt (16));
- ValueType* const data2 = addBytesToPointer (buffer2.get(), random.nextInt (16));
- int* const int1 = addBytesToPointer (buffer3.get(), random.nextInt (16));
- #endif
-
- fillRandomly (random, data1, num);
- fillRandomly (random, data2, num);
-
- Range minMax1 (FloatVectorOperations::findMinAndMax (data1, num));
- Range minMax2 (Range::findMinAndMax (data1, num));
- u.expect (minMax1 == minMax2);
-
- u.expect (valuesMatch (FloatVectorOperations::findMinimum (data1, num), juce::findMinimum (data1, num)));
- u.expect (valuesMatch (FloatVectorOperations::findMaximum (data1, num), juce::findMaximum (data1, num)));
-
- u.expect (valuesMatch (FloatVectorOperations::findMinimum (data2, num), juce::findMinimum (data2, num)));
- u.expect (valuesMatch (FloatVectorOperations::findMaximum (data2, num), juce::findMaximum (data2, num)));
-
- FloatVectorOperations::clear (data1, num);
- u.expect (areAllValuesEqual (data1, num, 0));
-
- FloatVectorOperations::fill (data1, (ValueType) 2, num);
- u.expect (areAllValuesEqual (data1, num, (ValueType) 2));
-
- FloatVectorOperations::add (data1, (ValueType) 2, num);
- u.expect (areAllValuesEqual (data1, num, (ValueType) 4));
-
- FloatVectorOperations::copy (data2, data1, num);
- u.expect (areAllValuesEqual (data2, num, (ValueType) 4));
-
- FloatVectorOperations::add (data2, data1, num);
- u.expect (areAllValuesEqual (data2, num, (ValueType) 8));
-
- FloatVectorOperations::copyWithMultiply (data2, data1, (ValueType) 4, num);
- u.expect (areAllValuesEqual (data2, num, (ValueType) 16));
-
- FloatVectorOperations::addWithMultiply (data2, data1, (ValueType) 4, num);
- u.expect (areAllValuesEqual (data2, num, (ValueType) 32));
-
- FloatVectorOperations::multiply (data1, (ValueType) 2, num);
- u.expect (areAllValuesEqual (data1, num, (ValueType) 8));
-
- FloatVectorOperations::multiply (data1, data2, num);
- u.expect (areAllValuesEqual (data1, num, (ValueType) 256));
-
- FloatVectorOperations::negate (data2, data1, num);
- u.expect (areAllValuesEqual (data2, num, (ValueType) -256));
-
- FloatVectorOperations::subtract (data1, data2, num);
- u.expect (areAllValuesEqual (data1, num, (ValueType) 512));
-
- FloatVectorOperations::abs (data1, data2, num);
- u.expect (areAllValuesEqual (data1, num, (ValueType) 256));
-
- FloatVectorOperations::abs (data2, data1, num);
- u.expect (areAllValuesEqual (data2, num, (ValueType) 256));
-
- fillRandomly (random, int1, num);
- doConversionTest (u, data1, data2, int1, num);
-
- FloatVectorOperations::fill (data1, (ValueType) 2, num);
- FloatVectorOperations::fill (data2, (ValueType) 3, num);
- FloatVectorOperations::addWithMultiply (data1, data1, data2, num);
- u.expect (areAllValuesEqual (data1, num, (ValueType) 8));
- }
-
- static void doConversionTest (UnitTest& u, float* data1, float* data2, int* const int1, int num)
- {
- FloatVectorOperations::convertFixedToFloat (data1, int1, 2.0f, num);
- convertFixed (data2, int1, 2.0f, num);
- u.expect (buffersMatch (data1, data2, num));
- }
-
- static void doConversionTest (UnitTest&, double*, double*, int*, int) {}
-
- static void fillRandomly (Random& random, ValueType* d, int num)
- {
- while (--num >= 0)
- *d++ = (ValueType) (random.nextDouble() * 1000.0);
- }
-
- static void fillRandomly (Random& random, int* d, int num)
- {
- while (--num >= 0)
- *d++ = random.nextInt();
- }
-
- static void convertFixed (float* d, const int* s, ValueType multiplier, int num)
- {
- while (--num >= 0)
- *d++ = (float) *s++ * multiplier;
- }
-
- static bool areAllValuesEqual (const ValueType* d, int num, ValueType target)
- {
- while (--num >= 0)
- if (*d++ != target)
- return false;
-
- return true;
- }
-
- static bool buffersMatch (const ValueType* d1, const ValueType* d2, int num)
- {
- while (--num >= 0)
- if (! valuesMatch (*d1++, *d2++))
- return false;
-
- return true;
- }
-
- static bool valuesMatch (ValueType v1, ValueType v2)
- {
- return std::abs (v1 - v2) < std::numeric_limits::epsilon();
- }
- };
-
- void runTest() override
- {
- beginTest ("FloatVectorOperations");
-
- for (int i = 1000; --i >= 0;)
- {
- TestRunner::runTest (*this, getRandom());
- TestRunner::runTest (*this, getRandom());
- }
- }
-};
-
-static FloatVectorOperationsTests vectorOpTests;
-
-#endif
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h
deleted file mode 100644
index c44bbd800..000000000
--- a/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-#if JUCE_INTEL
- #define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8f || n > 1.0e-8f)) n = 0;
-#else
- #define JUCE_SNAP_TO_ZERO(n) ignoreUnused (n)
-#endif
-
-//==============================================================================
-/**
- A collection of simple vector operations on arrays of floats, accelerated with
- SIMD instructions where possible.
-*/
-class JUCE_API FloatVectorOperations
-{
-public:
- //==============================================================================
- /** Clears a vector of floats. */
- static void JUCE_CALLTYPE clear (float* dest, int numValues) noexcept;
-
- /** Clears a vector of doubles. */
- static void JUCE_CALLTYPE clear (double* dest, int numValues) noexcept;
-
- /** Copies a repeated value into a vector of floats. */
- static void JUCE_CALLTYPE fill (float* dest, float valueToFill, int numValues) noexcept;
-
- /** Copies a repeated value into a vector of doubles. */
- static void JUCE_CALLTYPE fill (double* dest, double valueToFill, int numValues) noexcept;
-
- /** Copies a vector of floats. */
- static void JUCE_CALLTYPE copy (float* dest, const float* src, int numValues) noexcept;
-
- /** Copies a vector of doubles. */
- static void JUCE_CALLTYPE copy (double* dest, const double* src, int numValues) noexcept;
-
- /** Copies a vector of floats, multiplying each value by a given multiplier */
- static void JUCE_CALLTYPE copyWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
-
- /** Copies a vector of doubles, multiplying each value by a given multiplier */
- static void JUCE_CALLTYPE copyWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
-
- /** Adds a fixed value to the destination values. */
- static void JUCE_CALLTYPE add (float* dest, float amountToAdd, int numValues) noexcept;
-
- /** Adds a fixed value to the destination values. */
- static void JUCE_CALLTYPE add (double* dest, double amountToAdd, int numValues) noexcept;
-
- /** Adds a fixed value to each source value and stores it in the destination array. */
- static void JUCE_CALLTYPE add (float* dest, const float* src, float amount, int numValues) noexcept;
-
- /** Adds a fixed value to each source value and stores it in the destination array. */
- static void JUCE_CALLTYPE add (double* dest, const double* src, double amount, int numValues) noexcept;
-
- /** Adds the source values to the destination values. */
- static void JUCE_CALLTYPE add (float* dest, const float* src, int numValues) noexcept;
-
- /** Adds the source values to the destination values. */
- static void JUCE_CALLTYPE add (double* dest, const double* src, int numValues) noexcept;
-
- /** Adds each source1 value to the corresponding source2 value and stores the result in the destination array. */
- static void JUCE_CALLTYPE add (float* dest, const float* src1, const float* src2, int num) noexcept;
-
- /** Adds each source1 value to the corresponding source2 value and stores the result in the destination array. */
- static void JUCE_CALLTYPE add (double* dest, const double* src1, const double* src2, int num) noexcept;
-
- /** Subtracts the source values from the destination values. */
- static void JUCE_CALLTYPE subtract (float* dest, const float* src, int numValues) noexcept;
-
- /** Subtracts the source values from the destination values. */
- static void JUCE_CALLTYPE subtract (double* dest, const double* src, int numValues) noexcept;
-
- /** Subtracts each source2 value from the corresponding source1 value and stores the result in the destination array. */
- static void JUCE_CALLTYPE subtract (float* dest, const float* src1, const float* src2, int num) noexcept;
-
- /** Subtracts each source2 value from the corresponding source1 value and stores the result in the destination array. */
- static void JUCE_CALLTYPE subtract (double* dest, const double* src1, const double* src2, int num) noexcept;
-
- /** Multiplies each source value by the given multiplier, then adds it to the destination value. */
- static void JUCE_CALLTYPE addWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
-
- /** Multiplies each source value by the given multiplier, then adds it to the destination value. */
- static void JUCE_CALLTYPE addWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
-
- /** Multiplies each source1 value by the corresponding source2 value, then adds it to the destination value. */
- static void JUCE_CALLTYPE addWithMultiply (float* dest, const float* src1, const float* src2, int num) noexcept;
-
- /** Multiplies each source1 value by the corresponding source2 value, then adds it to the destination value. */
- static void JUCE_CALLTYPE addWithMultiply (double* dest, const double* src1, const double* src2, int num) noexcept;
-
- /** Multiplies each source value by the given multiplier, then subtracts it to the destination value. */
- static void JUCE_CALLTYPE subtractWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
-
- /** Multiplies each source value by the given multiplier, then subtracts it to the destination value. */
- static void JUCE_CALLTYPE subtractWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
-
- /** Multiplies each source1 value by the corresponding source2 value, then subtracts it to the destination value. */
- static void JUCE_CALLTYPE subtractWithMultiply (float* dest, const float* src1, const float* src2, int num) noexcept;
-
- /** Multiplies each source1 value by the corresponding source2 value, then subtracts it to the destination value. */
- static void JUCE_CALLTYPE subtractWithMultiply (double* dest, const double* src1, const double* src2, int num) noexcept;
-
- /** Multiplies the destination values by the source values. */
- static void JUCE_CALLTYPE multiply (float* dest, const float* src, int numValues) noexcept;
-
- /** Multiplies the destination values by the source values. */
- static void JUCE_CALLTYPE multiply (double* dest, const double* src, int numValues) noexcept;
-
- /** Multiplies each source1 value by the correspinding source2 value, then stores it in the destination array. */
- static void JUCE_CALLTYPE multiply (float* dest, const float* src1, const float* src2, int numValues) noexcept;
-
- /** Multiplies each source1 value by the correspinding source2 value, then stores it in the destination array. */
- static void JUCE_CALLTYPE multiply (double* dest, const double* src1, const double* src2, int numValues) noexcept;
-
- /** Multiplies each of the destination values by a fixed multiplier. */
- static void JUCE_CALLTYPE multiply (float* dest, float multiplier, int numValues) noexcept;
-
- /** Multiplies each of the destination values by a fixed multiplier. */
- static void JUCE_CALLTYPE multiply (double* dest, double multiplier, int numValues) noexcept;
-
- /** Multiplies each of the source values by a fixed multiplier and stores the result in the destination array. */
- static void JUCE_CALLTYPE multiply (float* dest, const float* src, float multiplier, int num) noexcept;
-
- /** Multiplies each of the source values by a fixed multiplier and stores the result in the destination array. */
- static void JUCE_CALLTYPE multiply (double* dest, const double* src, double multiplier, int num) noexcept;
-
- /** Copies a source vector to a destination, negating each value. */
- static void JUCE_CALLTYPE negate (float* dest, const float* src, int numValues) noexcept;
-
- /** Copies a source vector to a destination, negating each value. */
- static void JUCE_CALLTYPE negate (double* dest, const double* src, int numValues) noexcept;
-
- /** Copies a source vector to a destination, taking the absolute of each value. */
- static void JUCE_CALLTYPE abs (float* dest, const float* src, int numValues) noexcept;
-
- /** Copies a source vector to a destination, taking the absolute of each value. */
- static void JUCE_CALLTYPE abs (double* dest, const double* src, int numValues) noexcept;
-
- /** Converts a stream of integers to floats, multiplying each one by the given multiplier. */
- static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, int numValues) noexcept;
-
- /** Each element of dest will be the minimum of the corresponding element of the source array and the given comp value. */
- static void JUCE_CALLTYPE min (float* dest, const float* src, float comp, int num) noexcept;
-
- /** Each element of dest will be the minimum of the corresponding element of the source array and the given comp value. */
- static void JUCE_CALLTYPE min (double* dest, const double* src, double comp, int num) noexcept;
-
- /** Each element of dest will be the minimum of the corresponding source1 and source2 values. */
- static void JUCE_CALLTYPE min (float* dest, const float* src1, const float* src2, int num) noexcept;
-
- /** Each element of dest will be the minimum of the corresponding source1 and source2 values. */
- static void JUCE_CALLTYPE min (double* dest, const double* src1, const double* src2, int num) noexcept;
-
- /** Each element of dest will be the maximum of the corresponding element of the source array and the given comp value. */
- static void JUCE_CALLTYPE max (float* dest, const float* src, float comp, int num) noexcept;
-
- /** Each element of dest will be the maximum of the corresponding element of the source array and the given comp value. */
- static void JUCE_CALLTYPE max (double* dest, const double* src, double comp, int num) noexcept;
-
- /** Each element of dest will be the maximum of the corresponding source1 and source2 values. */
- static void JUCE_CALLTYPE max (float* dest, const float* src1, const float* src2, int num) noexcept;
-
- /** Each element of dest will be the maximum of the corresponding source1 and source2 values. */
- static void JUCE_CALLTYPE max (double* dest, const double* src1, const double* src2, int num) noexcept;
-
- /** Each element of dest is calculated by hard clipping the corresponding src element so that it is in the range specified by the arguments low and high. */
- static void JUCE_CALLTYPE clip (float* dest, const float* src, float low, float high, int num) noexcept;
-
- /** Each element of dest is calculated by hard clipping the corresponding src element so that it is in the range specified by the arguments low and high. */
- static void JUCE_CALLTYPE clip (double* dest, const double* src, double low, double high, int num) noexcept;
-
- /** Finds the miniumum and maximum values in the given array. */
- static Range JUCE_CALLTYPE findMinAndMax (const float* src, int numValues) noexcept;
-
- /** Finds the miniumum and maximum values in the given array. */
- static Range JUCE_CALLTYPE findMinAndMax (const double* src, int numValues) noexcept;
-
- /** Finds the miniumum value in the given array. */
- static float JUCE_CALLTYPE findMinimum (const float* src, int numValues) noexcept;
-
- /** Finds the miniumum value in the given array. */
- static double JUCE_CALLTYPE findMinimum (const double* src, int numValues) noexcept;
-
- /** Finds the maximum value in the given array. */
- static float JUCE_CALLTYPE findMaximum (const float* src, int numValues) noexcept;
-
- /** Finds the maximum value in the given array. */
- static double JUCE_CALLTYPE findMaximum (const double* src, int numValues) noexcept;
-
- /** On Intel CPUs, this method enables or disables the SSE flush-to-zero mode.
- Effectively, this is a wrapper around a call to _MM_SET_FLUSH_ZERO_MODE
- */
- static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
-
- /** On Intel CPUs, this method enables the SSE flush-to-zero and denormalised-are-zero modes.
- This effectively sets the DAZ and FZ bits of the MXCSR register. It's a convenient thing to
- call before audio processing code where you really want to avoid denormalisation performance hits.
- */
- static void JUCE_CALLTYPE disableDenormalisedNumberSupport() noexcept;
-};
-
-//==============================================================================
-/**
- Helper class providing an RAII-based mechanism for temporarily disabling
- denormals on your CPU.
-*/
-class ScopedNoDenormals
-{
-public:
- inline ScopedNoDenormals() noexcept
- {
- #if JUCE_USE_SSE_INTRINSICS
- mxcsr = _mm_getcsr();
- _mm_setcsr (mxcsr | 0x8040); // add the DAZ and FZ bits
- #endif
- }
-
-
- inline ~ScopedNoDenormals() noexcept
- {
- #if JUCE_USE_SSE_INTRINSICS
- _mm_setcsr (mxcsr);
- #endif
- }
-
-private:
- #if JUCE_USE_SSE_INTRINSICS
- unsigned int mxcsr;
- #endif
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp b/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp
deleted file mode 100644
index f38b66f95..000000000
--- a/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-struct CatmullRomAlgorithm
-{
- static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept
- {
- auto y0 = inputs[3];
- auto y1 = inputs[2];
- auto y2 = inputs[1];
- auto y3 = inputs[0];
-
- auto halfY0 = 0.5f * y0;
- auto halfY3 = 0.5f * y3;
-
- return y1 + offset * ((0.5f * y2 - halfY0)
- + (offset * (((y0 + 2.0f * y2) - (halfY3 + 2.5f * y1))
- + (offset * ((halfY3 + 1.5f * y1) - (halfY0 + 1.5f * y2))))));
- }
-};
-
-CatmullRomInterpolator::CatmullRomInterpolator() noexcept { reset(); }
-CatmullRomInterpolator::~CatmullRomInterpolator() noexcept {}
-
-void CatmullRomInterpolator::reset() noexcept
-{
- subSamplePos = 1.0;
-
- for (auto& s : lastInputSamples)
- s = 0;
-}
-
-int CatmullRomInterpolator::process (double actualRatio, const float* in, float* out, int numOut) noexcept
-{
- return interpolate (lastInputSamples, subSamplePos, actualRatio, in, out, numOut);
-}
-
-int CatmullRomInterpolator::processAdding (double actualRatio, const float* in, float* out, int numOut, float gain) noexcept
-{
- return interpolateAdding (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain);
-}
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h b/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h
deleted file mode 100644
index 3876ae612..000000000
--- a/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-/**
- Interpolator for resampling a stream of floats using Catmull-Rom interpolation.
-
- Note that the resampler is stateful, so when there's a break in the continuity
- of the input stream you're feeding it, you should call reset() before feeding
- it any new data. And like with any other stateful filter, if you're resampling
- multiple channels, make sure each one uses its own CatmullRomInterpolator
- object.
-
- @see LagrangeInterpolator
-*/
-class JUCE_API CatmullRomInterpolator
-{
-public:
- CatmullRomInterpolator() noexcept;
- ~CatmullRomInterpolator() noexcept;
-
- /** Resets the state of the interpolator.
- Call this when there's a break in the continuity of the input data stream.
- */
- void reset() noexcept;
-
- /** Resamples a stream of samples.
-
- @param speedRatio the number of input samples to use for each output sample
- @param inputSamples the source data to read from. This must contain at
- least (speedRatio * numOutputSamplesToProduce) samples.
- @param outputSamples the buffer to write the results into
- @param numOutputSamplesToProduce the number of output samples that should be created
-
- @returns the actual number of input samples that were used
- */
- int process (double speedRatio,
- const float* inputSamples,
- float* outputSamples,
- int numOutputSamplesToProduce) noexcept;
-
- /** Resamples a stream of samples, adding the results to the output data
- with a gain.
-
- @param speedRatio the number of input samples to use for each output sample
- @param inputSamples the source data to read from. This must contain at
- least (speedRatio * numOutputSamplesToProduce) samples.
- @param outputSamples the buffer to write the results to - the result values will be added
- to any pre-existing data in this buffer after being multiplied by
- the gain factor
- @param numOutputSamplesToProduce the number of output samples that should be created
- @param gain a gain factor to multiply the resulting samples by before
- adding them to the destination buffer
-
- @returns the actual number of input samples that were used
- */
- int processAdding (double speedRatio,
- const float* inputSamples,
- float* outputSamples,
- int numOutputSamplesToProduce,
- float gain) noexcept;
-
-private:
- float lastInputSamples[5];
- double subSamplePos;
-
- JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CatmullRomInterpolator)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_Decibels.h b/source/modules/juce_audio_basics/effects/juce_Decibels.h
deleted file mode 100644
index 4fc2d2fdb..000000000
--- a/source/modules/juce_audio_basics/effects/juce_Decibels.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- This class contains some helpful static methods for dealing with decibel values.
-*/
-class Decibels
-{
-public:
- //==============================================================================
- /** Converts a dBFS value to its equivalent gain level.
-
- A gain of 1.0 = 0 dB, and lower gains map onto negative decibel values. Any
- decibel value lower than minusInfinityDb will return a gain of 0.
- */
- template
- static Type decibelsToGain (const Type decibels,
- const Type minusInfinityDb = (Type) defaultMinusInfinitydB)
- {
- return decibels > minusInfinityDb ? std::pow ((Type) 10.0, decibels * (Type) 0.05)
- : Type();
- }
-
- /** Converts a gain level into a dBFS value.
-
- A gain of 1.0 = 0 dB, and lower gains map onto negative decibel values.
- If the gain is 0 (or negative), then the method will return the value
- provided as minusInfinityDb.
- */
- template
- static Type gainToDecibels (const Type gain,
- const Type minusInfinityDb = (Type) defaultMinusInfinitydB)
- {
- return gain > Type() ? jmax (minusInfinityDb, (Type) std::log10 (gain) * (Type) 20.0)
- : minusInfinityDb;
- }
-
- //==============================================================================
- /** Converts a decibel reading to a string, with the 'dB' suffix.
- If the decibel value is lower than minusInfinityDb, the return value will
- be "-INF dB".
- */
- template
- static String toString (const Type decibels,
- const int decimalPlaces = 2,
- const Type minusInfinityDb = (Type) defaultMinusInfinitydB)
- {
- String s;
-
- if (decibels <= minusInfinityDb)
- {
- s = "-INF dB";
- }
- else
- {
- if (decibels >= Type())
- s << '+';
-
- s << String (decibels, decimalPlaces) << " dB";
- }
-
- return s;
- }
-
-
-private:
- //==============================================================================
- enum
- {
- defaultMinusInfinitydB = -100
- };
-
- Decibels(); // This class can't be instantiated, it's just a holder for static methods..
- JUCE_DECLARE_NON_COPYABLE (Decibels)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp b/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp
deleted file mode 100644
index 01338c8d9..000000000
--- a/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-IIRCoefficients::IIRCoefficients() noexcept
-{
- zeromem (coefficients, sizeof (coefficients));
-}
-
-IIRCoefficients::~IIRCoefficients() noexcept {}
-
-IIRCoefficients::IIRCoefficients (const IIRCoefficients& other) noexcept
-{
- memcpy (coefficients, other.coefficients, sizeof (coefficients));
-}
-
-IIRCoefficients& IIRCoefficients::operator= (const IIRCoefficients& other) noexcept
-{
- memcpy (coefficients, other.coefficients, sizeof (coefficients));
- return *this;
-}
-
-IIRCoefficients::IIRCoefficients (double c1, double c2, double c3,
- double c4, double c5, double c6) noexcept
-{
- const double a = 1.0 / c4;
-
- coefficients[0] = (float) (c1 * a);
- coefficients[1] = (float) (c2 * a);
- coefficients[2] = (float) (c3 * a);
- coefficients[3] = (float) (c5 * a);
- coefficients[4] = (float) (c6 * a);
-}
-
-IIRCoefficients IIRCoefficients::makeLowPass (const double sampleRate,
- const double frequency) noexcept
-{
- return makeLowPass (sampleRate, frequency, 1.0 / std::sqrt (2.0));
-}
-
-IIRCoefficients IIRCoefficients::makeLowPass (const double sampleRate,
- const double frequency,
- const double Q) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double n = 1.0 / std::tan (double_Pi * frequency / sampleRate);
- const double nSquared = n * n;
- const double c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
-
- return IIRCoefficients (c1,
- c1 * 2.0,
- c1,
- 1.0,
- c1 * 2.0 * (1.0 - nSquared),
- c1 * (1.0 - 1.0 / Q * n + nSquared));
-}
-
-IIRCoefficients IIRCoefficients::makeHighPass (const double sampleRate,
- const double frequency) noexcept
-{
- return makeHighPass (sampleRate, frequency, 1.0 / std::sqrt(2.0));
-}
-
-IIRCoefficients IIRCoefficients::makeHighPass (const double sampleRate,
- const double frequency,
- const double Q) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double n = std::tan (double_Pi * frequency / sampleRate);
- const double nSquared = n * n;
- const double c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
-
- return IIRCoefficients (c1,
- c1 * -2.0,
- c1,
- 1.0,
- c1 * 2.0 * (nSquared - 1.0),
- c1 * (1.0 - 1.0 / Q * n + nSquared));
-}
-
-IIRCoefficients IIRCoefficients::makeBandPass (const double sampleRate,
- const double frequency) noexcept
-{
- return makeBandPass (sampleRate, frequency, 1.0 / std::sqrt (2.0));
-}
-
-IIRCoefficients IIRCoefficients::makeBandPass (const double sampleRate,
- const double frequency,
- const double Q) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double n = 1.0 / std::tan (double_Pi * frequency / sampleRate);
- const double nSquared = n * n;
- const double c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
-
- return IIRCoefficients (c1 * n / Q,
- 0.0,
- -c1 * n / Q,
- 1.0,
- c1 * 2.0 * (1.0 - nSquared),
- c1 * (1.0 - 1.0 / Q * n + nSquared));
-}
-
-IIRCoefficients IIRCoefficients::makeNotchFilter (const double sampleRate,
- const double frequency) noexcept
-{
- return makeNotchFilter (sampleRate, frequency, 1.0 / std::sqrt (2.0));
-}
-
-IIRCoefficients IIRCoefficients::makeNotchFilter (const double sampleRate,
- const double frequency,
- const double Q) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double n = 1.0 / std::tan (double_Pi * frequency / sampleRate);
- const double nSquared = n * n;
- const double c1 = 1.0 / (1.0 + n / Q + nSquared);
-
- return IIRCoefficients (c1 * (1.0 + nSquared),
- 2.0 * c1 * (1.0 - nSquared),
- c1 * (1.0 + nSquared),
- 1.0,
- c1 * 2.0 * (1.0 - nSquared),
- c1 * (1.0 - n / Q + nSquared));
-}
-
-IIRCoefficients IIRCoefficients::makeAllPass (const double sampleRate,
- const double frequency) noexcept
-{
- return makeAllPass (sampleRate, frequency, 1.0 / std::sqrt (2.0));
-}
-
-IIRCoefficients IIRCoefficients::makeAllPass (const double sampleRate,
- const double frequency,
- const double Q) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double n = 1.0 / std::tan (double_Pi * frequency / sampleRate);
- const double nSquared = n * n;
- const double c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
-
- return IIRCoefficients (c1 * (1.0 - n / Q + nSquared),
- c1 * 2.0 * (1.0 - nSquared),
- 1.0,
- 1.0,
- c1 * 2.0 * (1.0 - nSquared),
- c1 * (1.0 - n / Q + nSquared));
-}
-
-IIRCoefficients IIRCoefficients::makeLowShelf (const double sampleRate,
- const double cutOffFrequency,
- const double Q,
- const float gainFactor) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (cutOffFrequency > 0.0 && cutOffFrequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double A = jmax (0.0f, std::sqrt (gainFactor));
- const double aminus1 = A - 1.0;
- const double aplus1 = A + 1.0;
- const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate;
- const double coso = std::cos (omega);
- const double beta = std::sin (omega) * std::sqrt (A) / Q;
- const double aminus1TimesCoso = aminus1 * coso;
-
- return IIRCoefficients (A * (aplus1 - aminus1TimesCoso + beta),
- A * 2.0 * (aminus1 - aplus1 * coso),
- A * (aplus1 - aminus1TimesCoso - beta),
- aplus1 + aminus1TimesCoso + beta,
- -2.0 * (aminus1 + aplus1 * coso),
- aplus1 + aminus1TimesCoso - beta);
-}
-
-IIRCoefficients IIRCoefficients::makeHighShelf (const double sampleRate,
- const double cutOffFrequency,
- const double Q,
- const float gainFactor) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (cutOffFrequency > 0.0 && cutOffFrequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double A = jmax (0.0f, std::sqrt (gainFactor));
- const double aminus1 = A - 1.0;
- const double aplus1 = A + 1.0;
- const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate;
- const double coso = std::cos (omega);
- const double beta = std::sin (omega) * std::sqrt (A) / Q;
- const double aminus1TimesCoso = aminus1 * coso;
-
- return IIRCoefficients (A * (aplus1 + aminus1TimesCoso + beta),
- A * -2.0 * (aminus1 + aplus1 * coso),
- A * (aplus1 + aminus1TimesCoso - beta),
- aplus1 - aminus1TimesCoso + beta,
- 2.0 * (aminus1 - aplus1 * coso),
- aplus1 - aminus1TimesCoso - beta);
-}
-
-IIRCoefficients IIRCoefficients::makePeakFilter (const double sampleRate,
- const double frequency,
- const double Q,
- const float gainFactor) noexcept
-{
- jassert (sampleRate > 0.0);
- jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
- jassert (Q > 0.0);
-
- const double A = jmax (0.0f, std::sqrt (gainFactor));
- const double omega = (double_Pi * 2.0 * jmax (frequency, 2.0)) / sampleRate;
- const double alpha = 0.5 * std::sin (omega) / Q;
- const double c2 = -2.0 * std::cos (omega);
- const double alphaTimesA = alpha * A;
- const double alphaOverA = alpha / A;
-
- return IIRCoefficients (1.0 + alphaTimesA,
- c2,
- 1.0 - alphaTimesA,
- 1.0 + alphaOverA,
- c2,
- 1.0 - alphaOverA);
-}
-
-//==============================================================================
-IIRFilter::IIRFilter() noexcept
- : v1 (0.0), v2 (0.0), active (false)
-{
-}
-
-IIRFilter::IIRFilter (const IIRFilter& other) noexcept
- : v1 (0.0), v2 (0.0), active (other.active)
-{
- const SpinLock::ScopedLockType sl (other.processLock);
- coefficients = other.coefficients;
-}
-
-IIRFilter::~IIRFilter() noexcept
-{
-}
-
-//==============================================================================
-void IIRFilter::makeInactive() noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
- active = false;
-}
-
-void IIRFilter::setCoefficients (const IIRCoefficients& newCoefficients) noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
-
- coefficients = newCoefficients;
- active = true;
-}
-
-//==============================================================================
-void IIRFilter::reset() noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
- v1 = v2 = 0.0;
-}
-
-float IIRFilter::processSingleSampleRaw (const float in) noexcept
-{
- float out = coefficients.coefficients[0] * in + v1;
-
- JUCE_SNAP_TO_ZERO (out);
-
- v1 = coefficients.coefficients[1] * in - coefficients.coefficients[3] * out + v2;
- v2 = coefficients.coefficients[2] * in - coefficients.coefficients[4] * out;
-
- return out;
-}
-
-void IIRFilter::processSamples (float* const samples, const int numSamples) noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
-
- if (active)
- {
- const float c0 = coefficients.coefficients[0];
- const float c1 = coefficients.coefficients[1];
- const float c2 = coefficients.coefficients[2];
- const float c3 = coefficients.coefficients[3];
- const float c4 = coefficients.coefficients[4];
- float lv1 = v1, lv2 = v2;
-
- for (int i = 0; i < numSamples; ++i)
- {
- const float in = samples[i];
- const float out = c0 * in + lv1;
- samples[i] = out;
-
- lv1 = c1 * in - c3 * out + lv2;
- lv2 = c2 * in - c4 * out;
- }
-
- JUCE_SNAP_TO_ZERO (lv1); v1 = lv1;
- JUCE_SNAP_TO_ZERO (lv2); v2 = lv2;
- }
-}
-
-#undef JUCE_SNAP_TO_ZERO
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_IIRFilter.h b/source/modules/juce_audio_basics/effects/juce_IIRFilter.h
deleted file mode 100644
index 9db85b582..000000000
--- a/source/modules/juce_audio_basics/effects/juce_IIRFilter.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-class IIRFilter;
-
-//==============================================================================
-/**
- A set of coefficients for use in an IIRFilter object.
-
- @see IIRFilter
-*/
-class JUCE_API IIRCoefficients
-{
-public:
- //==============================================================================
- /** Creates a null set of coefficients (which will produce silence). */
- IIRCoefficients() noexcept;
-
- /** Directly constructs an object from the raw coefficients.
- Most people will want to use the static methods instead of this, but
- the constructor is public to allow tinkerers to create their own custom
- filters!
- */
- IIRCoefficients (double c1, double c2, double c3,
- double c4, double c5, double c6) noexcept;
-
- /** Creates a copy of another filter. */
- IIRCoefficients (const IIRCoefficients&) noexcept;
- /** Creates a copy of another filter. */
- IIRCoefficients& operator= (const IIRCoefficients&) noexcept;
- /** Destructor. */
- ~IIRCoefficients() noexcept;
-
- //==============================================================================
- /** Returns the coefficients for a low-pass filter. */
- static IIRCoefficients makeLowPass (double sampleRate,
- double frequency) noexcept;
-
- /** Returns the coefficients for a low-pass filter with variable Q. */
- static IIRCoefficients makeLowPass (double sampleRate,
- double frequency,
- double Q) noexcept;
-
- //==============================================================================
- /** Returns the coefficients for a high-pass filter. */
- static IIRCoefficients makeHighPass (double sampleRate,
- double frequency) noexcept;
-
- /** Returns the coefficients for a high-pass filter with variable Q. */
- static IIRCoefficients makeHighPass (double sampleRate,
- double frequency,
- double Q) noexcept;
-
- //==============================================================================
- /** Returns the coefficients for a band-pass filter. */
- static IIRCoefficients makeBandPass (double sampleRate, double frequency) noexcept;
-
- /** Returns the coefficients for a band-pass filter with variable Q. */
- static IIRCoefficients makeBandPass (double sampleRate,
- double frequency,
- double Q) noexcept;
-
- //==============================================================================
- /** Returns the coefficients for a notch filter. */
- static IIRCoefficients makeNotchFilter (double sampleRate, double frequency) noexcept;
-
- /** Returns the coefficients for a notch filter with variable Q. */
- static IIRCoefficients makeNotchFilter (double sampleRate,
- double frequency,
- double Q) noexcept;
-
- //==============================================================================
- /** Returns the coefficients for an all-pass filter. */
- static IIRCoefficients makeAllPass (double sampleRate, double frequency) noexcept;
-
- /** Returns the coefficients for an all-pass filter with variable Q. */
- static IIRCoefficients makeAllPass (double sampleRate,
- double frequency,
- double Q) noexcept;
-
- //==============================================================================
- /** Returns the coefficients for a low-pass shelf filter with variable Q and gain.
-
- The gain is a scale factor that the low frequencies are multiplied by, so values
- greater than 1.0 will boost the low frequencies, values less than 1.0 will
- attenuate them.
- */
- static IIRCoefficients makeLowShelf (double sampleRate,
- double cutOffFrequency,
- double Q,
- float gainFactor) noexcept;
-
- /** Returns the coefficients for a high-pass shelf filter with variable Q and gain.
-
- The gain is a scale factor that the high frequencies are multiplied by, so values
- greater than 1.0 will boost the high frequencies, values less than 1.0 will
- attenuate them.
- */
- static IIRCoefficients makeHighShelf (double sampleRate,
- double cutOffFrequency,
- double Q,
- float gainFactor) noexcept;
-
- /** Returns the coefficients for a peak filter centred around a
- given frequency, with a variable Q and gain.
-
- The gain is a scale factor that the centre frequencies are multiplied by, so
- values greater than 1.0 will boost the centre frequencies, values less than
- 1.0 will attenuate them.
- */
- static IIRCoefficients makePeakFilter (double sampleRate,
- double centreFrequency,
- double Q,
- float gainFactor) noexcept;
-
- //==============================================================================
- /** The raw coefficients.
- You should leave these numbers alone unless you really know what you're doing.
- */
- float coefficients[5];
-};
-
-//==============================================================================
-/**
- An IIR filter that can perform low, high, or band-pass filtering on an
- audio signal.
-
- @see IIRCoefficient, IIRFilterAudioSource
-*/
-class JUCE_API IIRFilter
-{
-public:
- //==============================================================================
- /** Creates a filter.
-
- Initially the filter is inactive, so will have no effect on samples that
- you process with it. Use the setCoefficients() method to turn it into the
- type of filter needed.
- */
- IIRFilter() noexcept;
-
- /** Creates a copy of another filter. */
- IIRFilter (const IIRFilter&) noexcept;
-
- /** Destructor. */
- ~IIRFilter() noexcept;
-
- //==============================================================================
- /** Clears the filter so that any incoming data passes through unchanged. */
- void makeInactive() noexcept;
-
- /** Applies a set of coefficients to this filter. */
- void setCoefficients (const IIRCoefficients& newCoefficients) noexcept;
-
- /** Returns the coefficients that this filter is using. */
- IIRCoefficients getCoefficients() const noexcept { return coefficients; }
-
- //==============================================================================
- /** Resets the filter's processing pipeline, ready to start a new stream of data.
-
- Note that this clears the processing state, but the type of filter and
- its coefficients aren't changed. To put a filter into an inactive state, use
- the makeInactive() method.
- */
- void reset() noexcept;
-
- /** Performs the filter operation on the given set of samples. */
- void processSamples (float* samples, int numSamples) noexcept;
-
- /** Processes a single sample, without any locking or checking.
-
- Use this if you need fast processing of a single value, but be aware that
- this isn't thread-safe in the way that processSamples() is.
- */
- float processSingleSampleRaw (float sample) noexcept;
-
-protected:
- //==============================================================================
- SpinLock processLock;
- IIRCoefficients coefficients;
- float v1, v2;
- bool active;
-
- IIRFilter& operator= (const IIRFilter&);
- JUCE_LEAK_DETECTOR (IIRFilter)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp b/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp
deleted file mode 100644
index f8d5ee3bc..000000000
--- a/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2013 - Raw Material Software Ltd.
-
- Permission is granted to use this software under the terms of either:
- a) the GPL v2 (or any later version)
- b) the Affero GPL v3
-
- Details of these licenses can be found at: www.gnu.org/licenses
-
- JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- ------------------------------------------------------------------------------
-
- To release a closed-source product which uses JUCE, commercial licenses are
- available: visit www.juce.com for more information.
-
- ==============================================================================
-*/
-
-#if JUCE_INTEL
- #define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8 || n > 1.0e-8)) n = 0;
-#else
- #define JUCE_SNAP_TO_ZERO(n)
-#endif
-
-namespace juce
-{
-
-//==============================================================================
-IIRFilterOld::IIRFilterOld()
- : active (false), v1 (0), v2 (0)
-{
- zeromem (coefficients, sizeof (coefficients));
-}
-
-IIRFilterOld::IIRFilterOld (const IIRFilterOld& other)
- : active (other.active), v1 (0), v2 (0)
-{
- const SpinLock::ScopedLockType sl (other.processLock);
- memcpy (coefficients, other.coefficients, sizeof (coefficients));
-}
-
-IIRFilterOld::~IIRFilterOld()
-{
-}
-
-//==============================================================================
-void IIRFilterOld::reset() noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
- v1 = v2 = 0;
-}
-
-float IIRFilterOld::processSingleSampleRaw (const float in) noexcept
-{
- float out = coefficients[0] * in + v1;
-
- JUCE_SNAP_TO_ZERO (out);
-
- v1 = coefficients[1] * in - coefficients[3] * out + v2;
- v2 = coefficients[2] * in - coefficients[4] * out;
-
- return out;
-}
-
-void IIRFilterOld::processSamples (float* const samples,
- const int numSamples) noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
-
- if (active)
- {
- const float c0 = coefficients[0];
- const float c1 = coefficients[1];
- const float c2 = coefficients[2];
- const float c3 = coefficients[3];
- const float c4 = coefficients[4];
- float lv1 = v1, lv2 = v2;
-
- for (int i = 0; i < numSamples; ++i)
- {
- const float in = samples[i];
- const float out = c0 * in + lv1;
- samples[i] = out;
-
- lv1 = c1 * in - c3 * out + lv2;
- lv2 = c2 * in - c4 * out;
- }
-
- JUCE_SNAP_TO_ZERO (lv1); v1 = lv1;
- JUCE_SNAP_TO_ZERO (lv2); v2 = lv2;
- }
-}
-
-//==============================================================================
-void IIRFilterOld::makeLowPass (const double sampleRate,
- const double frequency) noexcept
-{
- jassert (sampleRate > 0);
-
- const double n = 1.0 / tan (double_Pi * frequency / sampleRate);
- const double nSquared = n * n;
- const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared);
-
- setCoefficients (c1,
- c1 * 2.0f,
- c1,
- 1.0,
- c1 * 2.0 * (1.0 - nSquared),
- c1 * (1.0 - std::sqrt (2.0) * n + nSquared));
-}
-
-void IIRFilterOld::makeHighPass (const double sampleRate,
- const double frequency) noexcept
-{
- const double n = tan (double_Pi * frequency / sampleRate);
- const double nSquared = n * n;
- const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared);
-
- setCoefficients (c1,
- c1 * -2.0f,
- c1,
- 1.0,
- c1 * 2.0 * (nSquared - 1.0),
- c1 * (1.0 - std::sqrt (2.0) * n + nSquared));
-}
-
-void IIRFilterOld::makeLowShelf (const double sampleRate,
- const double cutOffFrequency,
- const double Q,
- const float gainFactor) noexcept
-{
- jassert (sampleRate > 0);
- jassert (Q > 0);
-
- const double A = jmax (0.0f, gainFactor);
- const double aminus1 = A - 1.0;
- const double aplus1 = A + 1.0;
- const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate;
- const double coso = std::cos (omega);
- const double beta = std::sin (omega) * std::sqrt (A) / Q;
- const double aminus1TimesCoso = aminus1 * coso;
-
- setCoefficients (A * (aplus1 - aminus1TimesCoso + beta),
- A * 2.0 * (aminus1 - aplus1 * coso),
- A * (aplus1 - aminus1TimesCoso - beta),
- aplus1 + aminus1TimesCoso + beta,
- -2.0 * (aminus1 + aplus1 * coso),
- aplus1 + aminus1TimesCoso - beta);
-}
-
-void IIRFilterOld::makeHighShelf (const double sampleRate,
- const double cutOffFrequency,
- const double Q,
- const float gainFactor) noexcept
-{
- jassert (sampleRate > 0);
- jassert (Q > 0);
-
- const double A = jmax (0.0f, gainFactor);
- const double aminus1 = A - 1.0;
- const double aplus1 = A + 1.0;
- const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate;
- const double coso = std::cos (omega);
- const double beta = std::sin (omega) * std::sqrt (A) / Q;
- const double aminus1TimesCoso = aminus1 * coso;
-
- setCoefficients (A * (aplus1 + aminus1TimesCoso + beta),
- A * -2.0 * (aminus1 + aplus1 * coso),
- A * (aplus1 + aminus1TimesCoso - beta),
- aplus1 - aminus1TimesCoso + beta,
- 2.0 * (aminus1 - aplus1 * coso),
- aplus1 - aminus1TimesCoso - beta);
-}
-
-void IIRFilterOld::makeBandPass (const double sampleRate,
- const double centreFrequency,
- const double Q,
- const float gainFactor) noexcept
-{
- jassert (sampleRate > 0);
- jassert (Q > 0);
-
- const double A = jmax (0.0f, gainFactor);
- const double omega = (double_Pi * 2.0 * jmax (centreFrequency, 2.0)) / sampleRate;
- const double alpha = 0.5 * std::sin (omega) / Q;
- const double c2 = -2.0 * std::cos (omega);
- const double alphaTimesA = alpha * A;
- const double alphaOverA = alpha / A;
-
- setCoefficients (1.0 + alphaTimesA,
- c2,
- 1.0 - alphaTimesA,
- 1.0 + alphaOverA,
- c2,
- 1.0 - alphaOverA);
-}
-
-void IIRFilterOld::makeInactive() noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
- active = false;
-}
-
-//==============================================================================
-void IIRFilterOld::copyCoefficientsFrom (const IIRFilterOld& other) noexcept
-{
- const SpinLock::ScopedLockType sl (processLock);
-
- memcpy (coefficients, other.coefficients, sizeof (coefficients));
- active = other.active;
-}
-
-//==============================================================================
-void IIRFilterOld::setCoefficients (double c1, double c2, double c3,
- double c4, double c5, double c6) noexcept
-{
- const double a = 1.0 / c4;
-
- c1 *= a;
- c2 *= a;
- c3 *= a;
- c5 *= a;
- c6 *= a;
-
- const SpinLock::ScopedLockType sl (processLock);
-
- coefficients[0] = (float) c1;
- coefficients[1] = (float) c2;
- coefficients[2] = (float) c3;
- coefficients[3] = (float) c5;
- coefficients[4] = (float) c6;
-
- active = true;
-}
-
-#undef JUCE_SNAP_TO_ZERO
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.h b/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.h
deleted file mode 100644
index c6332171f..000000000
--- a/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2013 - Raw Material Software Ltd.
-
- Permission is granted to use this software under the terms of either:
- a) the GPL v2 (or any later version)
- b) the Affero GPL v3
-
- Details of these licenses can be found at: www.gnu.org/licenses
-
- JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- ------------------------------------------------------------------------------
-
- To release a closed-source product which uses JUCE, commercial licenses are
- available: visit www.juce.com for more information.
-
- ==============================================================================
-*/
-
-#ifndef __JUCE_IIRFILTER_OLD_JUCEHEADER__
-#define __JUCE_IIRFILTER_OLD_JUCEHEADER__
-
-
-namespace juce
-{
-
-//==============================================================================
-/**
- An IIR filter that can perform low, high, or band-pass filtering on an
- audio signal.
-
- @see IIRFilterAudioSource
-*/
-class JUCE_API IIRFilterOld
-{
-public:
- //==============================================================================
- /** Creates a filter.
-
- Initially the filter is inactive, so will have no effect on samples that
- you process with it. Use the appropriate method to turn it into the type
- of filter needed.
- */
- IIRFilterOld();
-
- /** Creates a copy of another filter. */
- IIRFilterOld (const IIRFilterOld& other);
-
- /** Destructor. */
- ~IIRFilterOld();
-
- //==============================================================================
- /** Resets the filter's processing pipeline, ready to start a new stream of data.
-
- Note that this clears the processing state, but the type of filter and
- its coefficients aren't changed. To put a filter into an inactive state, use
- the makeInactive() method.
- */
- void reset() noexcept;
-
- /** Performs the filter operation on the given set of samples.
- */
- void processSamples (float* samples,
- int numSamples) noexcept;
-
- /** Processes a single sample, without any locking or checking.
-
- Use this if you need fast processing of a single value, but be aware that
- this isn't thread-safe in the way that processSamples() is.
- */
- float processSingleSampleRaw (float sample) noexcept;
-
- //==============================================================================
- /** Sets the filter up to act as a low-pass filter.
- */
- void makeLowPass (double sampleRate,
- double frequency) noexcept;
-
- /** Sets the filter up to act as a high-pass filter.
- */
- void makeHighPass (double sampleRate,
- double frequency) noexcept;
-
- //==============================================================================
- /** Sets the filter up to act as a low-pass shelf filter with variable Q and gain.
-
- The gain is a scale factor that the low frequencies are multiplied by, so values
- greater than 1.0 will boost the low frequencies, values less than 1.0 will
- attenuate them.
- */
- void makeLowShelf (double sampleRate,
- double cutOffFrequency,
- double Q,
- float gainFactor) noexcept;
-
- /** Sets the filter up to act as a high-pass shelf filter with variable Q and gain.
-
- The gain is a scale factor that the high frequencies are multiplied by, so values
- greater than 1.0 will boost the high frequencies, values less than 1.0 will
- attenuate them.
- */
- void makeHighShelf (double sampleRate,
- double cutOffFrequency,
- double Q,
- float gainFactor) noexcept;
-
- /** Sets the filter up to act as a band pass filter centred around a
- frequency, with a variable Q and gain.
-
- The gain is a scale factor that the centre frequencies are multiplied by, so
- values greater than 1.0 will boost the centre frequencies, values less than
- 1.0 will attenuate them.
- */
- void makeBandPass (double sampleRate,
- double centreFrequency,
- double Q,
- float gainFactor) noexcept;
-
- /** Clears the filter's coefficients so that it becomes inactive.
- */
- void makeInactive() noexcept;
-
- //==============================================================================
- /** Makes this filter duplicate the set-up of another one.
- */
- void copyCoefficientsFrom (const IIRFilterOld& other) noexcept;
-
-
-protected:
- //==============================================================================
- SpinLock processLock;
-
- void setCoefficients (double c1, double c2, double c3,
- double c4, double c5, double c6) noexcept;
-
- bool active;
- float coefficients[5];
- float v1, v2;
-
- // (use the copyCoefficientsFrom() method instead of this operator)
- IIRFilterOld& operator= (const IIRFilterOld&);
- JUCE_LEAK_DETECTOR (IIRFilterOld)
-};
-
-
-} // namespace juce
-
-#endif // __JUCE_IIRFILTER_OLD_JUCEHEADER__
diff --git a/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp b/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp
deleted file mode 100644
index 9488ef9b0..000000000
--- a/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-namespace
-{
- static forcedinline void pushInterpolationSample (float* lastInputSamples, const float newValue) noexcept
- {
- lastInputSamples[4] = lastInputSamples[3];
- lastInputSamples[3] = lastInputSamples[2];
- lastInputSamples[2] = lastInputSamples[1];
- lastInputSamples[1] = lastInputSamples[0];
- lastInputSamples[0] = newValue;
- }
-
- static forcedinline void pushInterpolationSamples (float* lastInputSamples, const float* input, int numOut) noexcept
- {
- if (numOut >= 5)
- {
- for (int i = 0; i < 5; ++i)
- lastInputSamples[i] = input[--numOut];
- }
- else
- {
- for (int i = 0; i < numOut; ++i)
- pushInterpolationSample (lastInputSamples, input[i]);
- }
- }
-
- template
- static int interpolate (float* lastInputSamples, double& subSamplePos, double actualRatio,
- const float* in, float* out, int numOut) noexcept
- {
- auto pos = subSamplePos;
-
- if (actualRatio == 1.0 && pos == 1.0)
- {
- memcpy (out, in, (size_t) numOut * sizeof (float));
- pushInterpolationSamples (lastInputSamples, in, numOut);
- return numOut;
- }
-
- int numUsed = 0;
-
- while (numOut > 0)
- {
- while (pos >= 1.0)
- {
- pushInterpolationSample (lastInputSamples, in[numUsed++]);
- pos -= 1.0;
- }
-
- *out++ = InterpolatorType::valueAtOffset (lastInputSamples, (float) pos);
- pos += actualRatio;
- --numOut;
- }
-
- subSamplePos = pos;
- return numUsed;
- }
-
- template
- static int interpolateAdding (float* lastInputSamples, double& subSamplePos, double actualRatio,
- const float* in, float* out, int numOut, const float gain) noexcept
- {
- auto pos = subSamplePos;
-
- if (actualRatio == 1.0 && pos == 1.0)
- {
- FloatVectorOperations::addWithMultiply (out, in, gain, numOut);
- pushInterpolationSamples (lastInputSamples, in, numOut);
- return numOut;
- }
-
- int numUsed = 0;
-
- while (numOut > 0)
- {
- while (pos >= 1.0)
- {
- pushInterpolationSample (lastInputSamples, in[numUsed++]);
- pos -= 1.0;
- }
-
- *out++ += gain * InterpolatorType::valueAtOffset (lastInputSamples, (float) pos);
- pos += actualRatio;
- --numOut;
- }
-
- subSamplePos = pos;
- return numUsed;
- }
-}
-
-//==============================================================================
-template
-struct LagrangeResampleHelper
-{
- static forcedinline void calc (float& a, float b) noexcept { a *= b * (1.0f / k); }
-};
-
-template<>
-struct LagrangeResampleHelper<0>
-{
- static forcedinline void calc (float&, float) noexcept {}
-};
-
-struct LagrangeAlgorithm
-{
- static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept
- {
- return calcCoefficient<0> (inputs[4], offset)
- + calcCoefficient<1> (inputs[3], offset)
- + calcCoefficient<2> (inputs[2], offset)
- + calcCoefficient<3> (inputs[1], offset)
- + calcCoefficient<4> (inputs[0], offset);
- }
-
- template
- static forcedinline float calcCoefficient (float input, const float offset) noexcept
- {
- LagrangeResampleHelper<0 - k>::calc (input, -2.0f - offset);
- LagrangeResampleHelper<1 - k>::calc (input, -1.0f - offset);
- LagrangeResampleHelper<2 - k>::calc (input, 0.0f - offset);
- LagrangeResampleHelper<3 - k>::calc (input, 1.0f - offset);
- LagrangeResampleHelper<4 - k>::calc (input, 2.0f - offset);
- return input;
- }
-};
-
-LagrangeInterpolator::LagrangeInterpolator() noexcept { reset(); }
-LagrangeInterpolator::~LagrangeInterpolator() noexcept {}
-
-void LagrangeInterpolator::reset() noexcept
-{
- subSamplePos = 1.0;
-
- for (auto& s : lastInputSamples)
- s = 0;
-}
-
-int LagrangeInterpolator::process (double actualRatio, const float* in, float* out, int numOut) noexcept
-{
- return interpolate (lastInputSamples, subSamplePos, actualRatio, in, out, numOut);
-}
-
-int LagrangeInterpolator::processAdding (double actualRatio, const float* in, float* out, int numOut, float gain) noexcept
-{
- return interpolateAdding (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain);
-}
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h b/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h
deleted file mode 100644
index d52757451..000000000
--- a/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-/**
- Interpolator for resampling a stream of floats using 4-point lagrange interpolation.
-
- Note that the resampler is stateful, so when there's a break in the continuity
- of the input stream you're feeding it, you should call reset() before feeding
- it any new data. And like with any other stateful filter, if you're resampling
- multiple channels, make sure each one uses its own LagrangeInterpolator
- object.
-
- @see CatmullRomInterpolator
-*/
-class JUCE_API LagrangeInterpolator
-{
-public:
- LagrangeInterpolator() noexcept;
- ~LagrangeInterpolator() noexcept;
-
- /** Resets the state of the interpolator.
- Call this when there's a break in the continuity of the input data stream.
- */
- void reset() noexcept;
-
- /** Resamples a stream of samples.
-
- @param speedRatio the number of input samples to use for each output sample
- @param inputSamples the source data to read from. This must contain at
- least (speedRatio * numOutputSamplesToProduce) samples.
- @param outputSamples the buffer to write the results into
- @param numOutputSamplesToProduce the number of output samples that should be created
-
- @returns the actual number of input samples that were used
- */
- int process (double speedRatio,
- const float* inputSamples,
- float* outputSamples,
- int numOutputSamplesToProduce) noexcept;
-
- /** Resamples a stream of samples, adding the results to the output data
- with a gain.
-
- @param speedRatio the number of input samples to use for each output sample
- @param inputSamples the source data to read from. This must contain at
- least (speedRatio * numOutputSamplesToProduce) samples.
- @param outputSamples the buffer to write the results to - the result values will be added
- to any pre-existing data in this buffer after being multiplied by
- the gain factor
- @param numOutputSamplesToProduce the number of output samples that should be created
- @param gain a gain factor to multiply the resulting samples by before
- adding them to the destination buffer
-
- @returns the actual number of input samples that were used
- */
- int processAdding (double speedRatio,
- const float* inputSamples,
- float* outputSamples,
- int numOutputSamplesToProduce,
- float gain) noexcept;
-
-private:
- float lastInputSamples[5];
- double subSamplePos;
-
- JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LagrangeInterpolator)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h b/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h
deleted file mode 100644
index 3dc342c41..000000000
--- a/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- Utility class for linearly smoothed values like volume etc. that should
- not change abruptly but as a linear ramp, to avoid audio glitches.
-*/
-
-//==============================================================================
-template
-class LinearSmoothedValue
-{
-public:
- /** Constructor. */
- LinearSmoothedValue() noexcept
- {
- }
-
- /** Constructor. */
- LinearSmoothedValue (FloatType initialValue) noexcept
- : currentValue (initialValue), target (initialValue)
- {
- }
-
- //==============================================================================
- /** Reset to a new sample rate and ramp length.
- @param sampleRate The sampling rate
- @param rampLengthInSeconds The duration of the ramp in seconds
- */
- void reset (double sampleRate, double rampLengthInSeconds) noexcept
- {
- jassert (sampleRate > 0 && rampLengthInSeconds >= 0);
- stepsToTarget = (int) std::floor (rampLengthInSeconds * sampleRate);
- currentValue = target;
- countdown = 0;
- }
-
- //==============================================================================
- /** Set a new target value.
- @param newValue New target value
- */
- void setValue (FloatType newValue) noexcept
- {
- if (target != newValue)
- {
- target = newValue;
- countdown = stepsToTarget;
-
- if (countdown <= 0)
- currentValue = target;
- else
- step = (target - currentValue) / (FloatType) countdown;
- }
- }
-
- //==============================================================================
- /** Compute the next value.
- @returns Smoothed value
- */
- FloatType getNextValue() noexcept
- {
- if (countdown <= 0)
- return target;
-
- --countdown;
- currentValue += step;
- return currentValue;
- }
-
- /** Returns true if the current value is currently being interpolated. */
- bool isSmoothing() const noexcept
- {
- return countdown > 0;
- }
-
- /** Returns the target value towards which the smoothed value is currently moving. */
- FloatType getTargetValue() const noexcept
- {
- return target;
- }
-
- //==============================================================================
- /** Applies a linear smoothed gain to a stream of samples
- S[i] *= gain
- @param samples Pointer to a raw array of samples
- @param numSamples Length of array of samples
- */
- void applyGain (FloatType* samples, int numSamples) noexcept
- {
- jassert(numSamples >= 0);
-
- if (isSmoothing())
- {
- for (int i = 0; i < numSamples; i++)
- samples[i] *= getNextValue();
- }
- else
- {
- FloatVectorOperations::multiply (samples, target, numSamples);
- }
- }
-
- //==============================================================================
- /** Computes output as linear smoothed gain applied to a stream of samples.
- Sout[i] = Sin[i] * gain
- @param samplesOut A pointer to a raw array of output samples
- @param samplesIn A pointer to a raw array of input samples
- @param numSamples The length of the array of samples
- */
- void applyGain (FloatType* samplesOut, const FloatType* samplesIn, int numSamples) noexcept
- {
- jassert (numSamples >= 0);
-
- if (isSmoothing())
- {
- for (int i = 0; i < numSamples; i++)
- samplesOut[i] = samplesIn[i] * getNextValue();
- }
- else
- {
- FloatVectorOperations::multiply (samplesOut, samplesIn, target, numSamples);
- }
- }
-
- //==============================================================================
- /** Applies a linear smoothed gain to a buffer */
- void applyGain (AudioBuffer& buffer, int numSamples) noexcept
- {
- jassert (numSamples >= 0);
-
- if (isSmoothing())
- {
- if (buffer.getNumChannels() == 1)
- {
- FloatType* samples = buffer.getWritePointer(0);
-
- for (int i = 0; i < numSamples; i++)
- samples[i] *= getNextValue();
- }
- else
- {
- for (int i = 0; i < numSamples; i++)
- {
- const FloatType gain = getNextValue();
-
- for (int channel = 0; channel < buffer.getNumChannels(); channel++)
- buffer.setSample (channel, i, buffer.getSample (channel, i) * gain);
- }
- }
- }
- else
- {
- buffer.applyGain (0, numSamples, target);
- }
- }
-
-private:
- //==============================================================================
- FloatType currentValue = 0, target = 0, step = 0;
- int countdown = 0, stepsToTarget = 0;
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/effects/juce_Reverb.h b/source/modules/juce_audio_basics/effects/juce_Reverb.h
deleted file mode 100644
index 02b95b3c3..000000000
--- a/source/modules/juce_audio_basics/effects/juce_Reverb.h
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- Performs a simple reverb effect on a stream of audio data.
-
- This is a simple stereo reverb, based on the technique and tunings used in FreeVerb.
- Use setSampleRate() to prepare it, and then call processStereo() or processMono() to
- apply the reverb to your audio data.
-
- @see ReverbAudioSource
-*/
-class Reverb
-{
-public:
- //==============================================================================
- Reverb()
- {
- setParameters (Parameters());
- setSampleRate (44100.0);
- }
-
- //==============================================================================
- /** Holds the parameters being used by a Reverb object. */
- struct Parameters
- {
- Parameters() noexcept
- : roomSize (0.5f),
- damping (0.5f),
- wetLevel (0.33f),
- dryLevel (0.4f),
- width (1.0f),
- freezeMode (0)
- {}
-
- float roomSize; /**< Room size, 0 to 1.0, where 1.0 is big, 0 is small. */
- float damping; /**< Damping, 0 to 1.0, where 0 is not damped, 1.0 is fully damped. */
- float wetLevel; /**< Wet level, 0 to 1.0 */
- float dryLevel; /**< Dry level, 0 to 1.0 */
- float width; /**< Reverb width, 0 to 1.0, where 1.0 is very wide. */
- float freezeMode; /**< Freeze mode - values < 0.5 are "normal" mode, values > 0.5
- put the reverb into a continuous feedback loop. */
- };
-
- //==============================================================================
- /** Returns the reverb's current parameters. */
- const Parameters& getParameters() const noexcept { return parameters; }
-
- /** Applies a new set of parameters to the reverb.
- Note that this doesn't attempt to lock the reverb, so if you call this in parallel with
- the process method, you may get artifacts.
- */
- void setParameters (const Parameters& newParams)
- {
- const float wetScaleFactor = 3.0f;
- const float dryScaleFactor = 2.0f;
-
- const float wet = newParams.wetLevel * wetScaleFactor;
- dryGain.setValue (newParams.dryLevel * dryScaleFactor);
- wetGain1.setValue (0.5f * wet * (1.0f + newParams.width));
- wetGain2.setValue (0.5f * wet * (1.0f - newParams.width));
-
- gain = isFrozen (newParams.freezeMode) ? 0.0f : 0.015f;
- parameters = newParams;
- updateDamping();
- }
-
- //==============================================================================
- /** Sets the sample rate that will be used for the reverb.
- You must call this before the process methods, in order to tell it the correct sample rate.
- */
- void setSampleRate (const double sampleRate)
- {
- jassert (sampleRate > 0);
-
- static const short combTunings[] = { 1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617 }; // (at 44100Hz)
- static const short allPassTunings[] = { 556, 441, 341, 225 };
- const int stereoSpread = 23;
- const int intSampleRate = (int) sampleRate;
-
- for (int i = 0; i < numCombs; ++i)
- {
- comb[0][i].setSize ((intSampleRate * combTunings[i]) / 44100);
- comb[1][i].setSize ((intSampleRate * (combTunings[i] + stereoSpread)) / 44100);
- }
-
- for (int i = 0; i < numAllPasses; ++i)
- {
- allPass[0][i].setSize ((intSampleRate * allPassTunings[i]) / 44100);
- allPass[1][i].setSize ((intSampleRate * (allPassTunings[i] + stereoSpread)) / 44100);
- }
-
- const double smoothTime = 0.01;
- damping .reset (sampleRate, smoothTime);
- feedback.reset (sampleRate, smoothTime);
- dryGain .reset (sampleRate, smoothTime);
- wetGain1.reset (sampleRate, smoothTime);
- wetGain2.reset (sampleRate, smoothTime);
- }
-
- /** Clears the reverb's buffers. */
- void reset()
- {
- for (int j = 0; j < numChannels; ++j)
- {
- for (int i = 0; i < numCombs; ++i)
- comb[j][i].clear();
-
- for (int i = 0; i < numAllPasses; ++i)
- allPass[j][i].clear();
- }
- }
-
- //==============================================================================
- /** Applies the reverb to two stereo channels of audio data. */
- void processStereo (float* const left, float* const right, const int numSamples) noexcept
- {
- jassert (left != nullptr && right != nullptr);
-
- for (int i = 0; i < numSamples; ++i)
- {
- const float input = (left[i] + right[i]) * gain;
- float outL = 0, outR = 0;
-
- const float damp = damping.getNextValue();
- const float feedbck = feedback.getNextValue();
-
- for (int j = 0; j < numCombs; ++j) // accumulate the comb filters in parallel
- {
- outL += comb[0][j].process (input, damp, feedbck);
- outR += comb[1][j].process (input, damp, feedbck);
- }
-
- for (int j = 0; j < numAllPasses; ++j) // run the allpass filters in series
- {
- outL = allPass[0][j].process (outL);
- outR = allPass[1][j].process (outR);
- }
-
- const float dry = dryGain.getNextValue();
- const float wet1 = wetGain1.getNextValue();
- const float wet2 = wetGain2.getNextValue();
-
- left[i] = outL * wet1 + outR * wet2 + left[i] * dry;
- right[i] = outR * wet1 + outL * wet2 + right[i] * dry;
- }
- }
-
- /** Applies the reverb to a single mono channel of audio data. */
- void processMono (float* const samples, const int numSamples) noexcept
- {
- jassert (samples != nullptr);
-
- for (int i = 0; i < numSamples; ++i)
- {
- const float input = samples[i] * gain;
- float output = 0;
-
- const float damp = damping.getNextValue();
- const float feedbck = feedback.getNextValue();
-
- for (int j = 0; j < numCombs; ++j) // accumulate the comb filters in parallel
- output += comb[0][j].process (input, damp, feedbck);
-
- for (int j = 0; j < numAllPasses; ++j) // run the allpass filters in series
- output = allPass[0][j].process (output);
-
- const float dry = dryGain.getNextValue();
- const float wet1 = wetGain1.getNextValue();
-
- samples[i] = output * wet1 + samples[i] * dry;
- }
- }
-
-private:
- //==============================================================================
- static bool isFrozen (const float freezeMode) noexcept { return freezeMode >= 0.5f; }
-
- void updateDamping() noexcept
- {
- const float roomScaleFactor = 0.28f;
- const float roomOffset = 0.7f;
- const float dampScaleFactor = 0.4f;
-
- if (isFrozen (parameters.freezeMode))
- setDamping (0.0f, 1.0f);
- else
- setDamping (parameters.damping * dampScaleFactor,
- parameters.roomSize * roomScaleFactor + roomOffset);
- }
-
- void setDamping (const float dampingToUse, const float roomSizeToUse) noexcept
- {
- damping.setValue (dampingToUse);
- feedback.setValue (roomSizeToUse);
- }
-
- //==============================================================================
- class CombFilter
- {
- public:
- CombFilter() noexcept : bufferSize (0), bufferIndex (0), last (0) {}
-
- void setSize (const int size)
- {
- if (size != bufferSize)
- {
- bufferIndex = 0;
- buffer.malloc ((size_t) size);
- bufferSize = size;
- }
-
- clear();
- }
-
- void clear() noexcept
- {
- last = 0;
- buffer.clear ((size_t) bufferSize);
- }
-
- float process (const float input, const float damp, const float feedbackLevel) noexcept
- {
- const float output = buffer[bufferIndex];
- last = (output * (1.0f - damp)) + (last * damp);
- JUCE_UNDENORMALISE (last);
-
- float temp = input + (last * feedbackLevel);
- JUCE_UNDENORMALISE (temp);
- buffer[bufferIndex] = temp;
- bufferIndex = (bufferIndex + 1) % bufferSize;
- return output;
- }
-
- private:
- HeapBlock buffer;
- int bufferSize, bufferIndex;
- float last;
-
- JUCE_DECLARE_NON_COPYABLE (CombFilter)
- };
-
- //==============================================================================
- class AllPassFilter
- {
- public:
- AllPassFilter() noexcept : bufferSize (0), bufferIndex (0) {}
-
- void setSize (const int size)
- {
- if (size != bufferSize)
- {
- bufferIndex = 0;
- buffer.malloc ((size_t) size);
- bufferSize = size;
- }
-
- clear();
- }
-
- void clear() noexcept
- {
- buffer.clear ((size_t) bufferSize);
- }
-
- float process (const float input) noexcept
- {
- const float bufferedValue = buffer [bufferIndex];
- float temp = input + (bufferedValue * 0.5f);
- JUCE_UNDENORMALISE (temp);
- buffer [bufferIndex] = temp;
- bufferIndex = (bufferIndex + 1) % bufferSize;
- return bufferedValue - input;
- }
-
- private:
- HeapBlock buffer;
- int bufferSize, bufferIndex;
-
- JUCE_DECLARE_NON_COPYABLE (AllPassFilter)
- };
-
- //==============================================================================
- enum { numCombs = 8, numAllPasses = 4, numChannels = 2 };
-
- Parameters parameters;
- float gain;
-
- CombFilter comb [numChannels][numCombs];
- AllPassFilter allPass [numChannels][numAllPasses];
-
- LinearSmoothedValue damping, feedback, dryGain, wetGain1, wetGain2;
-
- JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Reverb)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/juce_audio_basics.cpp b/source/modules/juce_audio_basics/juce_audio_basics.cpp
deleted file mode 100644
index 9ee676fb3..000000000
--- a/source/modules/juce_audio_basics/juce_audio_basics.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-#ifdef JUCE_AUDIO_BASICS_H_INCLUDED
- /* When you add this cpp file to your project, you mustn't include it in a file where you've
- already included any other headers - just put it inside a file on its own, possibly with your config
- flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
- header files that the compiler may be using.
- */
- #error "Incorrect use of JUCE cpp file"
-#endif
-
-#include "juce_audio_basics.h"
-
-#if JUCE_MINGW
- #define JUCE_USE_SSE_INTRINSICS 0
-#endif
-
-#if JUCE_MINGW && ! defined (alloca)
- #define alloca __builtin_alloca
-#endif
-
-#ifndef JUCE_USE_SSE_INTRINSICS
- #define JUCE_USE_SSE_INTRINSICS 1
-#endif
-
-#if ! JUCE_INTEL
- #undef JUCE_USE_SSE_INTRINSICS
-#endif
-
-#if JUCE_USE_SSE_INTRINSICS
- #include
-#endif
-
-#ifndef JUCE_USE_VDSP_FRAMEWORK
- #define JUCE_USE_VDSP_FRAMEWORK 1
-#endif
-
-#if (JUCE_MAC || JUCE_IOS) && JUCE_USE_VDSP_FRAMEWORK
- #include
-#else
- #undef JUCE_USE_VDSP_FRAMEWORK
-#endif
-
-#if __ARM_NEON__ && ! (JUCE_USE_VDSP_FRAMEWORK || defined (JUCE_USE_ARM_NEON))
- #define JUCE_USE_ARM_NEON 1
-#endif
-
-#if TARGET_IPHONE_SIMULATOR
- #ifdef JUCE_USE_ARM_NEON
- #undef JUCE_USE_ARM_NEON
- #endif
- #define JUCE_USE_ARM_NEON 0
-#endif
-
-#if JUCE_USE_ARM_NEON
- #include
-#endif
-
-#include "buffers/juce_AudioDataConverters.cpp"
-#include "buffers/juce_FloatVectorOperations.cpp"
-#include "buffers/juce_AudioChannelSet.cpp"
-#include "effects/juce_IIRFilter.cpp"
-#include "effects/juce_IIRFilterOld.cpp"
-#include "effects/juce_LagrangeInterpolator.cpp"
-#include "effects/juce_CatmullRomInterpolator.cpp"
-#include "midi/juce_MidiBuffer.cpp"
-#include "midi/juce_MidiFile.cpp"
-#include "midi/juce_MidiKeyboardState.cpp"
-#include "midi/juce_MidiMessage.cpp"
-#include "midi/juce_MidiMessageSequence.cpp"
-#include "midi/juce_MidiRPN.cpp"
-#include "mpe/juce_MPEValue.cpp"
-#include "mpe/juce_MPENote.cpp"
-#include "mpe/juce_MPEZone.cpp"
-#include "mpe/juce_MPEZoneLayout.cpp"
-#include "mpe/juce_MPEInstrument.cpp"
-#include "mpe/juce_MPEMessages.cpp"
-#include "mpe/juce_MPESynthesiserBase.cpp"
-#include "mpe/juce_MPESynthesiserVoice.cpp"
-#include "mpe/juce_MPESynthesiser.cpp"
-#include "sources/juce_BufferingAudioSource.cpp"
-#include "sources/juce_ChannelRemappingAudioSource.cpp"
-#include "sources/juce_IIRFilterAudioSource.cpp"
-#include "sources/juce_MemoryAudioSource.cpp"
-#include "sources/juce_MixerAudioSource.cpp"
-#include "sources/juce_ResamplingAudioSource.cpp"
-#include "sources/juce_ReverbAudioSource.cpp"
-#include "sources/juce_ToneGeneratorAudioSource.cpp"
-#include "synthesisers/juce_Synthesiser.cpp"
diff --git a/source/modules/juce_audio_basics/juce_audio_basics.h b/source/modules/juce_audio_basics/juce_audio_basics.h
deleted file mode 100644
index bcce98b41..000000000
--- a/source/modules/juce_audio_basics/juce_audio_basics.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-/*******************************************************************************
- The block below describes the properties of this module, and is read by
- the Projucer to automatically generate project code that uses it.
- For details about the syntax and how to create or use a module, see the
- JUCE Module Format.txt file.
-
-
- BEGIN_JUCE_MODULE_DECLARATION
-
- ID: juce_audio_basics
- vendor: juce
- version: 5.1.2
- name: JUCE audio and MIDI data classes
- description: Classes for audio buffer manipulation, midi message handling, synthesis, etc.
- website: http://www.juce.com/juce
- license: ISC
-
- dependencies: juce_core
- OSXFrameworks: Accelerate
- iOSFrameworks: Accelerate
-
- END_JUCE_MODULE_DECLARATION
-
-*******************************************************************************/
-
-
-#pragma once
-#define JUCE_AUDIO_BASICS_H_INCLUDED
-
-#include
-
-//==============================================================================
-#undef Complex // apparently some C libraries actually define these symbols (!)
-#undef Factor
-
-#include "buffers/juce_AudioDataConverters.h"
-#include "buffers/juce_FloatVectorOperations.h"
-#include "buffers/juce_AudioSampleBuffer.h"
-#include "buffers/juce_AudioChannelSet.h"
-#include "effects/juce_Decibels.h"
-#include "effects/juce_IIRFilter.h"
-#include "effects/juce_IIRFilterOld.h"
-#include "effects/juce_LagrangeInterpolator.h"
-#include "effects/juce_CatmullRomInterpolator.h"
-#include "effects/juce_LinearSmoothedValue.h"
-#include "effects/juce_Reverb.h"
-#include "midi/juce_MidiMessage.h"
-#include "midi/juce_MidiBuffer.h"
-#include "midi/juce_MidiMessageSequence.h"
-#include "midi/juce_MidiFile.h"
-#include "midi/juce_MidiKeyboardState.h"
-#include "midi/juce_MidiRPN.h"
-#include "mpe/juce_MPEValue.h"
-#include "mpe/juce_MPENote.h"
-#include "mpe/juce_MPEZone.h"
-#include "mpe/juce_MPEZoneLayout.h"
-#include "mpe/juce_MPEInstrument.h"
-#include "mpe/juce_MPEMessages.h"
-#include "mpe/juce_MPESynthesiserBase.h"
-#include "mpe/juce_MPESynthesiserVoice.h"
-#include "mpe/juce_MPESynthesiser.h"
-#include "sources/juce_AudioSource.h"
-#include "sources/juce_PositionableAudioSource.h"
-#include "sources/juce_BufferingAudioSource.h"
-#include "sources/juce_ChannelRemappingAudioSource.h"
-#include "sources/juce_IIRFilterAudioSource.h"
-#include "sources/juce_MemoryAudioSource.h"
-#include "sources/juce_MixerAudioSource.h"
-#include "sources/juce_ResamplingAudioSource.h"
-#include "sources/juce_ReverbAudioSource.h"
-#include "sources/juce_ToneGeneratorAudioSource.h"
-#include "synthesisers/juce_Synthesiser.h"
-#include "audio_play_head/juce_AudioPlayHead.h"
diff --git a/source/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp b/source/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp
deleted file mode 100644
index 94d19898f..000000000
--- a/source/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-namespace MidiBufferHelpers
-{
- inline int getEventTime (const void* const d) noexcept
- {
- return readUnaligned (d);
- }
-
- inline uint16 getEventDataSize (const void* const d) noexcept
- {
- return readUnaligned (static_cast (d) + sizeof (int32));
- }
-
- inline uint16 getEventTotalSize (const void* const d) noexcept
- {
- return (uint16) (getEventDataSize (d) + sizeof (int32) + sizeof (uint16));
- }
-
- static int findActualEventLength (const uint8* const data, const int maxBytes) noexcept
- {
- unsigned int byte = (unsigned int) *data;
- int size = 0;
-
- if (byte == 0xf0 || byte == 0xf7)
- {
- const uint8* d = data + 1;
-
- while (d < data + maxBytes)
- if (*d++ == 0xf7)
- break;
-
- size = (int) (d - data);
- }
- else if (byte == 0xff)
- {
- int n;
- const int bytesLeft = MidiMessage::readVariableLengthVal (data + 1, n);
- size = jmin (maxBytes, n + 2 + bytesLeft);
- }
- else if (byte >= 0x80)
- {
- size = jmin (maxBytes, MidiMessage::getMessageLengthFromFirstByte ((uint8) byte));
- }
-
- return size;
- }
-
- static uint8* findEventAfter (uint8* d, uint8* endData, const int samplePosition) noexcept
- {
- while (d < endData && getEventTime (d) <= samplePosition)
- d += getEventTotalSize (d);
-
- return d;
- }
-}
-
-//==============================================================================
-MidiBuffer::MidiBuffer() noexcept {}
-MidiBuffer::~MidiBuffer() {}
-
-MidiBuffer::MidiBuffer (const MidiBuffer& other) noexcept : data (other.data) {}
-
-MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) noexcept
-{
- data = other.data;
- return *this;
-}
-
-MidiBuffer::MidiBuffer (const MidiMessage& message) noexcept
-{
- addEvent (message, 0);
-}
-
-void MidiBuffer::swapWith (MidiBuffer& other) noexcept { data.swapWith (other.data); }
-void MidiBuffer::clear() noexcept { data.clearQuick(); }
-void MidiBuffer::ensureSize (size_t minimumNumBytes) { data.ensureStorageAllocated ((int) minimumNumBytes); }
-bool MidiBuffer::isEmpty() const noexcept { return data.size() == 0; }
-
-void MidiBuffer::clear (const int startSample, const int numSamples)
-{
- uint8* const start = MidiBufferHelpers::findEventAfter (data.begin(), data.end(), startSample - 1);
- uint8* const end = MidiBufferHelpers::findEventAfter (start, data.end(), startSample + numSamples - 1);
-
- data.removeRange ((int) (start - data.begin()), (int) (end - data.begin()));
-}
-
-void MidiBuffer::addEvent (const MidiMessage& m, const int sampleNumber)
-{
- addEvent (m.getRawData(), m.getRawDataSize(), sampleNumber);
-}
-
-void MidiBuffer::addEvent (const void* const newData, const int maxBytes, const int sampleNumber)
-{
- const int numBytes = MidiBufferHelpers::findActualEventLength (static_cast (newData), maxBytes);
-
- if (numBytes > 0)
- {
- const size_t newItemSize = (size_t) numBytes + sizeof (int32) + sizeof (uint16);
- const int offset = (int) (MidiBufferHelpers::findEventAfter (data.begin(), data.end(), sampleNumber) - data.begin());
-
- data.insertMultiple (offset, 0, (int) newItemSize);
-
- uint8* const d = data.begin() + offset;
- writeUnaligned (d, sampleNumber);
- writeUnaligned (d + 4, static_cast (numBytes));
- memcpy (d + 6, newData, (size_t) numBytes);
- }
-}
-
-void MidiBuffer::addEvents (const MidiBuffer& otherBuffer,
- const int startSample,
- const int numSamples,
- const int sampleDeltaToAdd)
-{
- Iterator i (otherBuffer);
- i.setNextSamplePosition (startSample);
-
- const uint8* eventData;
- int eventSize, position;
-
- while (i.getNextEvent (eventData, eventSize, position)
- && (position < startSample + numSamples || numSamples < 0))
- {
- addEvent (eventData, eventSize, position + sampleDeltaToAdd);
- }
-}
-
-int MidiBuffer::getNumEvents() const noexcept
-{
- int n = 0;
- const uint8* const end = data.end();
-
- for (const uint8* d = data.begin(); d < end; ++n)
- d += MidiBufferHelpers::getEventTotalSize (d);
-
- return n;
-}
-
-int MidiBuffer::getFirstEventTime() const noexcept
-{
- return data.size() > 0 ? MidiBufferHelpers::getEventTime (data.begin()) : 0;
-}
-
-int MidiBuffer::getLastEventTime() const noexcept
-{
- if (data.size() == 0)
- return 0;
-
- const uint8* const endData = data.end();
-
- for (const uint8* d = data.begin();;)
- {
- const uint8* const nextOne = d + MidiBufferHelpers::getEventTotalSize (d);
-
- if (nextOne >= endData)
- return MidiBufferHelpers::getEventTime (d);
-
- d = nextOne;
- }
-}
-
-//==============================================================================
-MidiBuffer::Iterator::Iterator (const MidiBuffer& b) noexcept
- : buffer (b), data (b.data.begin())
-{
-}
-
-MidiBuffer::Iterator::~Iterator() noexcept
-{
-}
-
-void MidiBuffer::Iterator::setNextSamplePosition (const int samplePosition) noexcept
-{
- data = buffer.data.begin();
- const uint8* const dataEnd = buffer.data.end();
-
- while (data < dataEnd && MidiBufferHelpers::getEventTime (data) < samplePosition)
- data += MidiBufferHelpers::getEventTotalSize (data);
-}
-
-bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, int& numBytes, int& samplePosition) noexcept
-{
- if (data >= buffer.data.end())
- return false;
-
- samplePosition = MidiBufferHelpers::getEventTime (data);
- const int itemSize = MidiBufferHelpers::getEventDataSize (data);
- numBytes = itemSize;
- midiData = data + sizeof (int32) + sizeof (uint16);
- data += sizeof (int32) + sizeof (uint16) + (size_t) itemSize;
-
- return true;
-}
-
-bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, int& samplePosition) noexcept
-{
- if (data >= buffer.data.end())
- return false;
-
- samplePosition = MidiBufferHelpers::getEventTime (data);
- const int itemSize = MidiBufferHelpers::getEventDataSize (data);
- result = MidiMessage (data + sizeof (int32) + sizeof (uint16), itemSize, samplePosition);
- data += sizeof (int32) + sizeof (uint16) + (size_t) itemSize;
-
- return true;
-}
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/source/modules/juce_audio_basics/midi/juce_MidiBuffer.h
deleted file mode 100644
index e856bfbd2..000000000
--- a/source/modules/juce_audio_basics/midi/juce_MidiBuffer.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- Holds a sequence of time-stamped midi events.
-
- Analogous to the AudioSampleBuffer, this holds a set of midi events with
- integer time-stamps. The buffer is kept sorted in order of the time-stamps.
-
- If you're working with a sequence of midi events that may need to be manipulated
- or read/written to a midi file, then MidiMessageSequence is probably a more
- appropriate container. MidiBuffer is designed for lower-level streams of raw
- midi data.
-
- @see MidiMessage
-*/
-class JUCE_API MidiBuffer
-{
-public:
- //==============================================================================
- /** Creates an empty MidiBuffer. */
- MidiBuffer() noexcept;
-
- /** Creates a MidiBuffer containing a single midi message. */
- explicit MidiBuffer (const MidiMessage& message) noexcept;
-
- /** Creates a copy of another MidiBuffer. */
- MidiBuffer (const MidiBuffer&) noexcept;
-
- /** Makes a copy of another MidiBuffer. */
- MidiBuffer& operator= (const MidiBuffer&) noexcept;
-
- /** Destructor */
- ~MidiBuffer();
-
- //==============================================================================
- /** Removes all events from the buffer. */
- void clear() noexcept;
-
- /** Removes all events between two times from the buffer.
-
- All events for which (start <= event position < start + numSamples) will
- be removed.
- */
- void clear (int start, int numSamples);
-
- /** Returns true if the buffer is empty.
- To actually retrieve the events, use a MidiBuffer::Iterator object
- */
- bool isEmpty() const noexcept;
-
- /** Counts the number of events in the buffer.
-
- This is actually quite a slow operation, as it has to iterate through all
- the events, so you might prefer to call isEmpty() if that's all you need
- to know.
- */
- int getNumEvents() const noexcept;
-
- /** Adds an event to the buffer.
-
- The sample number will be used to determine the position of the event in
- the buffer, which is always kept sorted. The MidiMessage's timestamp is
- ignored.
-
- If an event is added whose sample position is the same as one or more events
- already in the buffer, the new event will be placed after the existing ones.
-
- To retrieve events, use a MidiBuffer::Iterator object
- */
- void addEvent (const MidiMessage& midiMessage, int sampleNumber);
-
- /** Adds an event to the buffer from raw midi data.
-
- The sample number will be used to determine the position of the event in
- the buffer, which is always kept sorted.
-
- If an event is added whose sample position is the same as one or more events
- already in the buffer, the new event will be placed after the existing ones.
-
- The event data will be inspected to calculate the number of bytes in length that
- the midi event really takes up, so maxBytesOfMidiData may be longer than the data
- that actually gets stored. E.g. if you pass in a note-on and a length of 4 bytes,
- it'll actually only store 3 bytes. If the midi data is invalid, it might not
- add an event at all.
-
- To retrieve events, use a MidiBuffer::Iterator object
- */
- void addEvent (const void* rawMidiData,
- int maxBytesOfMidiData,
- int sampleNumber);
-
- /** Adds some events from another buffer to this one.
-
- @param otherBuffer the buffer containing the events you want to add
- @param startSample the lowest sample number in the source buffer for which
- events should be added. Any source events whose timestamp is
- less than this will be ignored
- @param numSamples the valid range of samples from the source buffer for which
- events should be added - i.e. events in the source buffer whose
- timestamp is greater than or equal to (startSample + numSamples)
- will be ignored. If this value is less than 0, all events after
- startSample will be taken.
- @param sampleDeltaToAdd a value which will be added to the source timestamps of the events
- that are added to this buffer
- */
- void addEvents (const MidiBuffer& otherBuffer,
- int startSample,
- int numSamples,
- int sampleDeltaToAdd);
-
- /** Returns the sample number of the first event in the buffer.
- If the buffer's empty, this will just return 0.
- */
- int getFirstEventTime() const noexcept;
-
- /** Returns the sample number of the last event in the buffer.
- If the buffer's empty, this will just return 0.
- */
- int getLastEventTime() const noexcept;
-
- //==============================================================================
- /** Exchanges the contents of this buffer with another one.
-
- This is a quick operation, because no memory allocating or copying is done, it
- just swaps the internal state of the two buffers.
- */
- void swapWith (MidiBuffer&) noexcept;
-
- /** Preallocates some memory for the buffer to use.
- This helps to avoid needing to reallocate space when the buffer has messages
- added to it.
- */
- void ensureSize (size_t minimumNumBytes);
-
- //==============================================================================
- /**
- Used to iterate through the events in a MidiBuffer.
-
- Note that altering the buffer while an iterator is using it will produce
- undefined behaviour.
-
- @see MidiBuffer
- */
- class JUCE_API Iterator
- {
- public:
- //==============================================================================
- /** Creates an Iterator for this MidiBuffer. */
- Iterator (const MidiBuffer&) noexcept;
-
- /** Creates a copy of an iterator. */
- Iterator (const Iterator&) noexcept = default;
-
- /** Destructor. */
- ~Iterator() noexcept;
-
- //==============================================================================
- /** Repositions the iterator so that the next event retrieved will be the first
- one whose sample position is at greater than or equal to the given position.
- */
- void setNextSamplePosition (int samplePosition) noexcept;
-
- /** Retrieves a copy of the next event from the buffer.
-
- @param result on return, this will be the message. The MidiMessage's timestamp
- is set to the same value as samplePosition.
- @param samplePosition on return, this will be the position of the event, as a
- sample index in the buffer
- @returns true if an event was found, or false if the iterator has reached
- the end of the buffer
- */
- bool getNextEvent (MidiMessage& result,
- int& samplePosition) noexcept;
-
- /** Retrieves the next event from the buffer.
-
- @param midiData on return, this pointer will be set to a block of data containing
- the midi message. Note that to make it fast, this is a pointer
- directly into the MidiBuffer's internal data, so is only valid
- temporarily until the MidiBuffer is altered.
- @param numBytesOfMidiData on return, this is the number of bytes of data used by the
- midi message
- @param samplePosition on return, this will be the position of the event, as a
- sample index in the buffer
- @returns true if an event was found, or false if the iterator has reached
- the end of the buffer
- */
- bool getNextEvent (const uint8* &midiData,
- int& numBytesOfMidiData,
- int& samplePosition) noexcept;
-
- private:
- //==============================================================================
- const MidiBuffer& buffer;
- const uint8* data;
- };
-
- /** The raw data holding this buffer.
- Obviously access to this data is provided at your own risk. Its internal format could
- change in future, so don't write code that relies on it!
- */
- Array data;
-
-private:
- JUCE_LEAK_DETECTOR (MidiBuffer)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp b/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp
deleted file mode 100644
index 6a67a0890..000000000
--- a/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-namespace MidiFileHelpers
-{
- static void writeVariableLengthInt (OutputStream& out, unsigned int v)
- {
- unsigned int buffer = v & 0x7f;
-
- while ((v >>= 7) != 0)
- {
- buffer <<= 8;
- buffer |= ((v & 0x7f) | 0x80);
- }
-
- for (;;)
- {
- out.writeByte ((char) buffer);
-
- if (buffer & 0x80)
- buffer >>= 8;
- else
- break;
- }
- }
-
- static bool parseMidiHeader (const uint8* &data, short& timeFormat, short& fileType, short& numberOfTracks) noexcept
- {
- unsigned int ch = ByteOrder::bigEndianInt (data);
- data += 4;
-
- if (ch != ByteOrder::bigEndianInt ("MThd"))
- {
- bool ok = false;
-
- if (ch == ByteOrder::bigEndianInt ("RIFF"))
- {
- for (int i = 0; i < 8; ++i)
- {
- ch = ByteOrder::bigEndianInt (data);
- data += 4;
-
- if (ch == ByteOrder::bigEndianInt ("MThd"))
- {
- ok = true;
- break;
- }
- }
- }
-
- if (! ok)
- return false;
- }
-
- unsigned int bytesRemaining = ByteOrder::bigEndianInt (data);
- data += 4;
- fileType = (short) ByteOrder::bigEndianShort (data);
- data += 2;
- numberOfTracks = (short) ByteOrder::bigEndianShort (data);
- data += 2;
- timeFormat = (short) ByteOrder::bigEndianShort (data);
- data += 2;
- bytesRemaining -= 6;
- data += bytesRemaining;
-
- return true;
- }
-
- static double convertTicksToSeconds (const double time,
- const MidiMessageSequence& tempoEvents,
- const int timeFormat)
- {
- if (timeFormat < 0)
- return time / (-(timeFormat >> 8) * (timeFormat & 0xff));
-
- double lastTime = 0.0, correctedTime = 0.0;
- const double tickLen = 1.0 / (timeFormat & 0x7fff);
- double secsPerTick = 0.5 * tickLen;
- const int numEvents = tempoEvents.getNumEvents();
-
- for (int i = 0; i < numEvents; ++i)
- {
- const MidiMessage& m = tempoEvents.getEventPointer(i)->message;
- const double eventTime = m.getTimeStamp();
-
- if (eventTime >= time)
- break;
-
- correctedTime += (eventTime - lastTime) * secsPerTick;
- lastTime = eventTime;
-
- if (m.isTempoMetaEvent())
- secsPerTick = tickLen * m.getTempoSecondsPerQuarterNote();
-
- while (i + 1 < numEvents)
- {
- const MidiMessage& m2 = tempoEvents.getEventPointer(i + 1)->message;
-
- if (m2.getTimeStamp() != eventTime)
- break;
-
- if (m2.isTempoMetaEvent())
- secsPerTick = tickLen * m2.getTempoSecondsPerQuarterNote();
-
- ++i;
- }
- }
-
- return correctedTime + (time - lastTime) * secsPerTick;
- }
-
- // a comparator that puts all the note-offs before note-ons that have the same time
- struct Sorter
- {
- static int compareElements (const MidiMessageSequence::MidiEventHolder* const first,
- const MidiMessageSequence::MidiEventHolder* const second) noexcept
- {
- const double diff = (first->message.getTimeStamp() - second->message.getTimeStamp());
-
- if (diff > 0) return 1;
- if (diff < 0) return -1;
- if (first->message.isNoteOff() && second->message.isNoteOn()) return -1;
- if (first->message.isNoteOn() && second->message.isNoteOff()) return 1;
-
- return 0;
- }
- };
-
- template
- static void findAllMatchingEvents (const OwnedArray& tracks,
- MidiMessageSequence& results,
- MethodType method)
- {
- for (int i = 0; i < tracks.size(); ++i)
- {
- const MidiMessageSequence& track = *tracks.getUnchecked(i);
- const int numEvents = track.getNumEvents();
-
- for (int j = 0; j < numEvents; ++j)
- {
- const MidiMessage& m = track.getEventPointer(j)->message;
-
- if ((m.*method)())
- results.addEvent (m);
- }
- }
- }
-}
-
-//==============================================================================
-MidiFile::MidiFile()
- : timeFormat ((short) (unsigned short) 0xe728)
-{
-}
-
-MidiFile::~MidiFile()
-{
-}
-
-MidiFile::MidiFile (const MidiFile& other)
- : timeFormat (other.timeFormat)
-{
- tracks.addCopiesOf (other.tracks);
-}
-
-MidiFile& MidiFile::operator= (const MidiFile& other)
-{
- timeFormat = other.timeFormat;
- tracks.clear();
- tracks.addCopiesOf (other.tracks);
-
- return *this;
-}
-
-void MidiFile::clear()
-{
- tracks.clear();
-}
-
-//==============================================================================
-int MidiFile::getNumTracks() const noexcept
-{
- return tracks.size();
-}
-
-const MidiMessageSequence* MidiFile::getTrack (const int index) const noexcept
-{
- return tracks [index];
-}
-
-void MidiFile::addTrack (const MidiMessageSequence& trackSequence)
-{
- tracks.add (new MidiMessageSequence (trackSequence));
-}
-
-//==============================================================================
-short MidiFile::getTimeFormat() const noexcept
-{
- return timeFormat;
-}
-
-void MidiFile::setTicksPerQuarterNote (const int ticks) noexcept
-{
- timeFormat = (short) ticks;
-}
-
-void MidiFile::setSmpteTimeFormat (const int framesPerSecond,
- const int subframeResolution) noexcept
-{
- timeFormat = (short) (((-framesPerSecond) << 8) | subframeResolution);
-}
-
-//==============================================================================
-void MidiFile::findAllTempoEvents (MidiMessageSequence& results) const
-{
- MidiFileHelpers::findAllMatchingEvents (tracks, results, &MidiMessage::isTempoMetaEvent);
-}
-
-void MidiFile::findAllTimeSigEvents (MidiMessageSequence& results) const
-{
- MidiFileHelpers::findAllMatchingEvents (tracks, results, &MidiMessage::isTimeSignatureMetaEvent);
-}
-
-void MidiFile::findAllKeySigEvents (MidiMessageSequence& results) const
-{
- MidiFileHelpers::findAllMatchingEvents (tracks, results, &MidiMessage::isKeySignatureMetaEvent);
-}
-
-double MidiFile::getLastTimestamp() const
-{
- double t = 0.0;
-
- for (int i = tracks.size(); --i >= 0;)
- t = jmax (t, tracks.getUnchecked(i)->getEndTime());
-
- return t;
-}
-
-//==============================================================================
-bool MidiFile::readFrom (InputStream& sourceStream)
-{
- clear();
- MemoryBlock data;
-
- const int maxSensibleMidiFileSize = 200 * 1024 * 1024;
-
- // (put a sanity-check on the file size, as midi files are generally small)
- if (sourceStream.readIntoMemoryBlock (data, maxSensibleMidiFileSize))
- {
- size_t size = data.getSize();
- const uint8* d = static_cast (data.getData());
- short fileType, expectedTracks;
-
- if (size > 16 && MidiFileHelpers::parseMidiHeader (d, timeFormat, fileType, expectedTracks))
- {
- size -= (size_t) (d - static_cast (data.getData()));
-
- int track = 0;
-
- while (size > 0 && track < expectedTracks)
- {
- const int chunkType = (int) ByteOrder::bigEndianInt (d);
- d += 4;
- const int chunkSize = (int) ByteOrder::bigEndianInt (d);
- d += 4;
-
- if (chunkSize <= 0)
- break;
-
- if (chunkType == (int) ByteOrder::bigEndianInt ("MTrk"))
- readNextTrack (d, chunkSize);
-
- size -= (size_t) chunkSize + 8;
- d += chunkSize;
- ++track;
- }
-
- return true;
- }
- }
-
- return false;
-}
-
-void MidiFile::readNextTrack (const uint8* data, int size)
-{
- double time = 0;
- uint8 lastStatusByte = 0;
-
- MidiMessageSequence result;
-
- while (size > 0)
- {
- int bytesUsed;
- const int delay = MidiMessage::readVariableLengthVal (data, bytesUsed);
- data += bytesUsed;
- size -= bytesUsed;
- time += delay;
-
- int messSize = 0;
- const MidiMessage mm (data, size, messSize, lastStatusByte, time);
-
- if (messSize <= 0)
- break;
-
- size -= messSize;
- data += messSize;
-
- result.addEvent (mm);
-
- const uint8 firstByte = *(mm.getRawData());
- if ((firstByte & 0xf0) != 0xf0)
- lastStatusByte = firstByte;
- }
-
- // use a sort that puts all the note-offs before note-ons that have the same time
- MidiFileHelpers::Sorter sorter;
- result.list.sort (sorter, true);
-
- addTrack (result);
- tracks.getLast()->updateMatchedPairs();
-}
-
-//==============================================================================
-void MidiFile::convertTimestampTicksToSeconds()
-{
- MidiMessageSequence tempoEvents;
- findAllTempoEvents (tempoEvents);
- findAllTimeSigEvents (tempoEvents);
-
- if (timeFormat != 0)
- {
- for (int i = 0; i < tracks.size(); ++i)
- {
- const MidiMessageSequence& ms = *tracks.getUnchecked(i);
-
- for (int j = ms.getNumEvents(); --j >= 0;)
- {
- MidiMessage& m = ms.getEventPointer(j)->message;
- m.setTimeStamp (MidiFileHelpers::convertTicksToSeconds (m.getTimeStamp(), tempoEvents, timeFormat));
- }
- }
- }
-}
-
-//==============================================================================
-bool MidiFile::writeTo (OutputStream& out, int midiFileType)
-{
- jassert (midiFileType >= 0 && midiFileType <= 2);
-
- if (! out.writeIntBigEndian ((int) ByteOrder::bigEndianInt ("MThd"))) return false;
- if (! out.writeIntBigEndian (6)) return false;
- if (! out.writeShortBigEndian ((short) midiFileType)) return false;
- if (! out.writeShortBigEndian ((short) tracks.size())) return false;
- if (! out.writeShortBigEndian (timeFormat)) return false;
-
- for (int i = 0; i < tracks.size(); ++i)
- if (! writeTrack (out, i))
- return false;
-
- out.flush();
- return true;
-}
-
-bool MidiFile::writeTrack (OutputStream& mainOut, const int trackNum)
-{
- MemoryOutputStream out;
- const MidiMessageSequence& ms = *tracks.getUnchecked (trackNum);
-
- int lastTick = 0;
- uint8 lastStatusByte = 0;
- bool endOfTrackEventWritten = false;
-
- for (int i = 0; i < ms.getNumEvents(); ++i)
- {
- const MidiMessage& mm = ms.getEventPointer(i)->message;
-
- if (mm.isEndOfTrackMetaEvent())
- endOfTrackEventWritten = true;
-
- const int tick = roundToInt (mm.getTimeStamp());
- const int delta = jmax (0, tick - lastTick);
- MidiFileHelpers::writeVariableLengthInt (out, (uint32) delta);
- lastTick = tick;
-
- const uint8* data = mm.getRawData();
- int dataSize = mm.getRawDataSize();
-
- const uint8 statusByte = data[0];
-
- if (statusByte == lastStatusByte
- && (statusByte & 0xf0) != 0xf0
- && dataSize > 1
- && i > 0)
- {
- ++data;
- --dataSize;
- }
- else if (statusByte == 0xf0) // Write sysex message with length bytes.
- {
- out.writeByte ((char) statusByte);
-
- ++data;
- --dataSize;
-
- MidiFileHelpers::writeVariableLengthInt (out, (uint32) dataSize);
- }
-
- out.write (data, (size_t) dataSize);
- lastStatusByte = statusByte;
- }
-
- if (! endOfTrackEventWritten)
- {
- out.writeByte (0); // (tick delta)
- const MidiMessage m (MidiMessage::endOfTrack());
- out.write (m.getRawData(), (size_t) m.getRawDataSize());
- }
-
- if (! mainOut.writeIntBigEndian ((int) ByteOrder::bigEndianInt ("MTrk"))) return false;
- if (! mainOut.writeIntBigEndian ((int) out.getDataSize())) return false;
-
- mainOut << out;
-
- return true;
-}
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/midi/juce_MidiFile.h b/source/modules/juce_audio_basics/midi/juce_MidiFile.h
deleted file mode 100644
index b06589d29..000000000
--- a/source/modules/juce_audio_basics/midi/juce_MidiFile.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-//==============================================================================
-/**
- Reads/writes standard midi format files.
-
- To read a midi file, create a MidiFile object and call its readFrom() method. You
- can then get the individual midi tracks from it using the getTrack() method.
-
- To write a file, create a MidiFile object, add some MidiMessageSequence objects
- to it using the addTrack() method, and then call its writeTo() method to stream
- it out.
-
- @see MidiMessageSequence
-*/
-class JUCE_API MidiFile
-{
-public:
- //==============================================================================
- /** Creates an empty MidiFile object.
- */
- MidiFile();
-
- /** Destructor. */
- ~MidiFile();
-
- /** Creates a copy of another MidiFile. */
- MidiFile (const MidiFile& other);
-
- /** Copies from another MidiFile object */
- MidiFile& operator= (const MidiFile& other);
-
- //==============================================================================
- /** Returns the number of tracks in the file.
- @see getTrack, addTrack
- */
- int getNumTracks() const noexcept;
-
- /** Returns a pointer to one of the tracks in the file.
- @returns a pointer to the track, or nullptr if the index is out-of-range
- @see getNumTracks, addTrack
- */
- const MidiMessageSequence* getTrack (int index) const noexcept;
-
- /** Adds a midi track to the file.
- This will make its own internal copy of the sequence that is passed-in.
- @see getNumTracks, getTrack
- */
- void addTrack (const MidiMessageSequence& trackSequence);
-
- /** Removes all midi tracks from the file.
- @see getNumTracks
- */
- void clear();
-
- /** Returns the raw time format code that will be written to a stream.
-
- After reading a midi file, this method will return the time-format that
- was read from the file's header. It can be changed using the setTicksPerQuarterNote()
- or setSmpteTimeFormat() methods.
-
- If the value returned is positive, it indicates the number of midi ticks
- per quarter-note - see setTicksPerQuarterNote().
-
- It it's negative, the upper byte indicates the frames-per-second (but negative), and
- the lower byte is the number of ticks per frame - see setSmpteTimeFormat().
- */
- short getTimeFormat() const noexcept;
-
- /** Sets the time format to use when this file is written to a stream.
-
- If this is called, the file will be written as bars/beats using the
- specified resolution, rather than SMPTE absolute times, as would be
- used if setSmpteTimeFormat() had been called instead.
-
- @param ticksPerQuarterNote e.g. 96, 960
- @see setSmpteTimeFormat
- */
- void setTicksPerQuarterNote (int ticksPerQuarterNote) noexcept;
-
- /** Sets the time format to use when this file is written to a stream.
-
- If this is called, the file will be written using absolute times, rather
- than bars/beats as would be the case if setTicksPerBeat() had been called
- instead.
-
- @param framesPerSecond must be 24, 25, 29 or 30
- @param subframeResolution the sub-second resolution, e.g. 4 (midi time code),
- 8, 10, 80 (SMPTE bit resolution), or 100. For millisecond
- timing, setSmpteTimeFormat (25, 40)
- @see setTicksPerBeat
- */
- void setSmpteTimeFormat (int framesPerSecond,
- int subframeResolution) noexcept;
-
- //==============================================================================
- /** Makes a list of all the tempo-change meta-events from all tracks in the midi file.
- Useful for finding the positions of all the tempo changes in a file.
- @param tempoChangeEvents a list to which all the events will be added
- */
- void findAllTempoEvents (MidiMessageSequence& tempoChangeEvents) const;
-
- /** Makes a list of all the time-signature meta-events from all tracks in the midi file.
- Useful for finding the positions of all the tempo changes in a file.
- @param timeSigEvents a list to which all the events will be added
- */
- void findAllTimeSigEvents (MidiMessageSequence& timeSigEvents) const;
-
- /** Makes a list of all the time-signature meta-events from all tracks in the midi file.
- @param keySigEvents a list to which all the events will be added
- */
- void findAllKeySigEvents (MidiMessageSequence& keySigEvents) const;
-
- /** Returns the latest timestamp in any of the tracks.
- (Useful for finding the length of the file).
- */
- double getLastTimestamp() const;
-
- //==============================================================================
- /** Reads a midi file format stream.
-
- After calling this, you can get the tracks that were read from the file by using the
- getNumTracks() and getTrack() methods.
-
- The timestamps of the midi events in the tracks will represent their positions in
- terms of midi ticks. To convert them to seconds, use the convertTimestampTicksToSeconds()
- method.
-
- @returns true if the stream was read successfully
- */
- bool readFrom (InputStream& sourceStream);
-
- /** Writes the midi tracks as a standard midi file.
- The midiFileType value is written as the file's format type, which can be 0, 1
- or 2 - see the midi file spec for more info about that.
- @returns true if the operation succeeded.
- */
- bool writeTo (OutputStream& destStream, int midiFileType = 1);
-
- /** Converts the timestamp of all the midi events from midi ticks to seconds.
-
- This will use the midi time format and tempo/time signature info in the
- tracks to convert all the timestamps to absolute values in seconds.
- */
- void convertTimestampTicksToSeconds();
-
-
-private:
- //==============================================================================
- OwnedArray tracks;
- short timeFormat;
-
- void readNextTrack (const uint8*, int size);
- bool writeTrack (OutputStream&, int trackNum);
-
- JUCE_LEAK_DETECTOR (MidiFile)
-};
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp b/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp
deleted file mode 100644
index 68b8db06b..000000000
--- a/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-MidiKeyboardState::MidiKeyboardState()
-{
- zerostruct (noteStates);
-}
-
-MidiKeyboardState::~MidiKeyboardState()
-{
-}
-
-//==============================================================================
-void MidiKeyboardState::reset()
-{
- const ScopedLock sl (lock);
- zerostruct (noteStates);
- eventsToAdd.clear();
-}
-
-bool MidiKeyboardState::isNoteOn (const int midiChannel, const int n) const noexcept
-{
- jassert (midiChannel >= 0 && midiChannel <= 16);
-
- return isPositiveAndBelow (n, 128)
- && (noteStates[n] & (1 << (midiChannel - 1))) != 0;
-}
-
-bool MidiKeyboardState::isNoteOnForChannels (const int midiChannelMask, const int n) const noexcept
-{
- return isPositiveAndBelow (n, 128)
- && (noteStates[n] & midiChannelMask) != 0;
-}
-
-void MidiKeyboardState::noteOn (const int midiChannel, const int midiNoteNumber, const float velocity)
-{
- jassert (midiChannel >= 0 && midiChannel <= 16);
- jassert (isPositiveAndBelow (midiNoteNumber, 128));
-
- const ScopedLock sl (lock);
-
- if (isPositiveAndBelow (midiNoteNumber, 128))
- {
- const int timeNow = (int) Time::getMillisecondCounter();
- eventsToAdd.addEvent (MidiMessage::noteOn (midiChannel, midiNoteNumber, velocity), timeNow);
- eventsToAdd.clear (0, timeNow - 500);
-
- noteOnInternal (midiChannel, midiNoteNumber, velocity);
- }
-}
-
-void MidiKeyboardState::noteOnInternal (const int midiChannel, const int midiNoteNumber, const float velocity)
-{
- if (isPositiveAndBelow (midiNoteNumber, 128))
- {
- noteStates [midiNoteNumber] |= (1 << (midiChannel - 1));
-
- for (int i = listeners.size(); --i >= 0;)
- listeners.getUnchecked(i)->handleNoteOn (this, midiChannel, midiNoteNumber, velocity);
- }
-}
-
-void MidiKeyboardState::noteOff (const int midiChannel, const int midiNoteNumber, const float velocity)
-{
- const ScopedLock sl (lock);
-
- if (isNoteOn (midiChannel, midiNoteNumber))
- {
- const int timeNow = (int) Time::getMillisecondCounter();
- eventsToAdd.addEvent (MidiMessage::noteOff (midiChannel, midiNoteNumber), timeNow);
- eventsToAdd.clear (0, timeNow - 500);
-
- noteOffInternal (midiChannel, midiNoteNumber, velocity);
- }
-}
-
-void MidiKeyboardState::noteOffInternal (const int midiChannel, const int midiNoteNumber, const float velocity)
-{
- if (isNoteOn (midiChannel, midiNoteNumber))
- {
- noteStates [midiNoteNumber] &= ~(1 << (midiChannel - 1));
-
- for (int i = listeners.size(); --i >= 0;)
- listeners.getUnchecked(i)->handleNoteOff (this, midiChannel, midiNoteNumber, velocity);
- }
-}
-
-void MidiKeyboardState::allNotesOff (const int midiChannel)
-{
- const ScopedLock sl (lock);
-
- if (midiChannel <= 0)
- {
- for (int i = 1; i <= 16; ++i)
- allNotesOff (i);
- }
- else
- {
- for (int i = 0; i < 128; ++i)
- noteOff (midiChannel, i, 0.0f);
- }
-}
-
-void MidiKeyboardState::processNextMidiEvent (const MidiMessage& message)
-{
- if (message.isNoteOn())
- {
- noteOnInternal (message.getChannel(), message.getNoteNumber(), message.getFloatVelocity());
- }
- else if (message.isNoteOff())
- {
- noteOffInternal (message.getChannel(), message.getNoteNumber(), message.getFloatVelocity());
- }
- else if (message.isAllNotesOff())
- {
- for (int i = 0; i < 128; ++i)
- noteOffInternal (message.getChannel(), i, 0.0f);
- }
-}
-
-void MidiKeyboardState::processNextMidiBuffer (MidiBuffer& buffer,
- const int startSample,
- const int numSamples,
- const bool injectIndirectEvents)
-{
- MidiBuffer::Iterator i (buffer);
- MidiMessage message;
- int time;
-
- const ScopedLock sl (lock);
-
- while (i.getNextEvent (message, time))
- processNextMidiEvent (message);
-
- if (injectIndirectEvents)
- {
- MidiBuffer::Iterator i2 (eventsToAdd);
- const int firstEventToAdd = eventsToAdd.getFirstEventTime();
- const double scaleFactor = numSamples / (double) (eventsToAdd.getLastEventTime() + 1 - firstEventToAdd);
-
- while (i2.getNextEvent (message, time))
- {
- const int pos = jlimit (0, numSamples - 1, roundToInt ((time - firstEventToAdd) * scaleFactor));
- buffer.addEvent (message, startSample + pos);
- }
- }
-
- eventsToAdd.clear();
-}
-
-//==============================================================================
-void MidiKeyboardState::addListener (MidiKeyboardStateListener* const listener)
-{
- const ScopedLock sl (lock);
- listeners.addIfNotAlreadyThere (listener);
-}
-
-void MidiKeyboardState::removeListener (MidiKeyboardStateListener* const listener)
-{
- const ScopedLock sl (lock);
- listeners.removeFirstMatchingValue (listener);
-}
-
-} // namespace juce
diff --git a/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h b/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h
deleted file mode 100644
index b3fc4e61e..000000000
--- a/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- ==============================================================================
-
- This file is part of the JUCE library.
- Copyright (c) 2017 - ROLI Ltd.
-
- JUCE is an open source library subject to commercial or open-source
- licensing.
-
- The code included in this file is provided under the terms of the ISC license
- http://www.isc.org/downloads/software-support-policy/isc-license. Permission
- To use, copy, modify, and/or distribute this software for any purpose with or
- without fee is hereby granted provided that the above copyright notice and
- this permission notice appear in all copies.
-
- JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
- EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
- DISCLAIMED.
-
- ==============================================================================
-*/
-
-namespace juce
-{
-
-class MidiKeyboardState;
-
-
-//==============================================================================
-/**
- Receives events from a MidiKeyboardState object.
-
- @see MidiKeyboardState
-*/
-class JUCE_API MidiKeyboardStateListener
-{
-public:
- //==============================================================================
- MidiKeyboardStateListener() noexcept {}
- virtual ~MidiKeyboardStateListener() {}
-
- //==============================================================================
- /** Called when one of the MidiKeyboardState's keys is pressed.
-
- This will be called synchronously when the state is either processing a
- buffer in its MidiKeyboardState::processNextMidiBuffer() method, or
- when a note is being played with its MidiKeyboardState::noteOn() method.
-
- Note that this callback could happen from an audio callback thread, so be
- careful not to block, and avoid any UI activity in the callback.
- */
- virtual void handleNoteOn (MidiKeyboardState* source,
- int midiChannel, int midiNoteNumber, float velocity) = 0;
-
- /** Called when one of the MidiKeyboardState's keys is released.
-
- This will be called synchronously when the state is either processing a
- buffer in its MidiKeyboardState::processNextMidiBuffer() method, or
- when a note is being played with its MidiKeyboardState::noteOff() method.
-
- Note that this callback could happen from an audio callback thread, so be
- careful not to block, and avoid any UI activity in the callback.
- */
- virtual void handleNoteOff (MidiKeyboardState* source,
- int midiChannel, int midiNoteNumber, float velocity) = 0;
-};
-
-
-//==============================================================================
-/**
- Represents a piano keyboard, keeping track of which keys are currently pressed.
-
- This object can parse a stream of midi events, using them to update its idea
- of which keys are pressed for each individiual midi channel.
-
- When keys go up or down, it can broadcast these events to listener objects.
-
- It also allows key up/down events to be triggered with its noteOn() and noteOff()
- methods, and midi messages for these events will be merged into the
- midi stream that gets processed by processNextMidiBuffer().
-*/
-class JUCE_API MidiKeyboardState
-{
-public:
- //==============================================================================
- MidiKeyboardState();
- ~MidiKeyboardState();
-
- //==============================================================================
- /** Resets the state of the object.
-
- All internal data for all the channels is reset, but no events are sent as a
- result.
-
- If you want to release any keys that are currently down, and to send out note-up
- midi messages for this, use the allNotesOff() method instead.
- */
- void reset();
-
- /** Returns true if the given midi key is currently held down for the given midi channel.
-
- The channel number must be between 1 and 16. If you want to see if any notes are
- on for a range of channels, use the isNoteOnForChannels() method.
- */
- bool isNoteOn (int midiChannel, int midiNoteNumber) const noexcept;
-
- /** Returns true if the given midi key is currently held down on any of a set of midi channels.
-
- The channel mask has a bit set for each midi channel you want to test for - bit
- 0 = midi channel 1, bit 1 = midi channel 2, etc.
-
- If a note is on for at least one of the specified channels, this returns true.
- */
- bool isNoteOnForChannels (int midiChannelMask, int midiNoteNumber) const noexcept;
-
- /** Turns a specified note on.
-
- This will cause a suitable midi note-on event to be injected into the midi buffer during the
- next call to processNextMidiBuffer().
-
- It will also trigger a synchronous callback to the listeners to tell them that the key has
- gone down.
- */
- void noteOn (int midiChannel, int midiNoteNumber, float velocity);
-
- /** Turns a specified note off.
-
- This will cause a suitable midi note-off event to be injected into the midi buffer during the
- next call to processNextMidiBuffer().
-
- It will also trigger a synchronous callback to the listeners to tell them that the key has
- gone up.
-
- But if the note isn't acutally down for the given channel, this method will in fact do nothing.
- */
- void noteOff (int midiChannel, int midiNoteNumber, float velocity);
-
- /** This will turn off any currently-down notes for the given midi channel.
-
- If you pass 0 for the midi channel, it will in fact turn off all notes on all channels.
-
- Calling this method will make calls to noteOff(), so can trigger synchronous callbacks
- and events being added to the midi stream.
- */
- void allNotesOff (int midiChannel);
-
- //==============================================================================
- /** Looks at a key-up/down event and uses it to update the state of this object.
-
- To process a buffer full of midi messages, use the processNextMidiBuffer() method
- instead.
- */
- void processNextMidiEvent (const MidiMessage& message);
-
- /** Scans a midi stream for up/down events and adds its own events to it.
-
- This will look for any up/down events and use them to update the internal state,
- synchronously making suitable callbacks to the listeners.
-
- If injectIndirectEvents is true, then midi events to produce the recent noteOn()
- and noteOff() calls will be added into the buffer.
-
- Only the section of the buffer whose timestamps are between startSample and
- (startSample + numSamples) will be affected, and any events added will be placed
- between these times.
-
- If you're going to use this method, you'll need to keep calling it regularly for
- it to work satisfactorily.
-
- To process a single midi event at a time, use the processNextMidiEvent() method
- instead.
- */
- void processNextMidiBuffer (MidiBuffer& buffer,
- int startSample,
- int numSamples,
- bool injectIndirectEvents);
-
- //==============================================================================
- /** Registers a listener for callbacks when keys go up or down.
- @see removeListener
- */
- void addListener (MidiKeyboardStateListener* listener);
-
- /** Deregisters a listener.
- @see addListener
- */
- void removeListener (MidiKeyboardStateListener* listener);
-
-private:
- //==============================================================================
- CriticalSection lock;
- uint16 noteStates [128];
- MidiBuffer eventsToAdd;
- Array