Browse Source

Update juce

tags/2018-04-16
falkTX 7 years ago
parent
commit
cdc0511f74
100 changed files with 6804 additions and 3066 deletions
  1. +2
    -1
      libs/drowaudio/build-drowaudio/premake.lua
  2. +7
    -11
      libs/juce-plugin/JucePluginMain.cpp
  3. +3
    -2
      libs/juce/build-juce/AppConfig.h
  4. +1
    -0
      libs/juce/build-juce/premake.lua
  5. +16
    -16
      libs/juce/source/README.txt
  6. +1
    -0
      libs/juce/source/doxygen/Doxyfile
  7. +336
    -0
      libs/juce/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp
  8. +361
    -0
      libs/juce/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h
  9. +2
    -2
      libs/juce/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h
  10. +11
    -6
      libs/juce/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp
  11. +0
    -1
      libs/juce/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp
  12. +0
    -1
      libs/juce/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h
  13. +117
    -16
      libs/juce/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp
  14. +39
    -0
      libs/juce/source/modules/juce_audio_basics/effects/juce_IIRFilter.h
  15. +0
    -1
      libs/juce/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h
  16. +2
    -2
      libs/juce/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h
  17. +10
    -0
      libs/juce/source/modules/juce_audio_basics/juce_audio_basics.cpp
  18. +28
    -2
      libs/juce/source/modules/juce_audio_basics/juce_audio_basics.h
  19. +1
    -1
      libs/juce/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp
  20. +74
    -67
      libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessage.cpp
  21. +21
    -13
      libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessage.h
  22. +1
    -1
      libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp
  23. +13
    -1
      libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h
  24. +1
    -2
      libs/juce/source/modules/juce_audio_basics/midi/juce_MidiRPN.cpp
  25. +182
    -172
      libs/juce/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp
  26. +1
    -30
      libs/juce/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.h
  27. +0
    -1
      libs/juce/source/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp
  28. +8
    -3
      libs/juce/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp
  29. +8
    -1
      libs/juce/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h
  30. +14
    -6
      libs/juce/source/modules/juce_audio_basics/mpe/juce_MPEZone.h
  31. +50
    -5
      libs/juce/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp
  32. +21
    -11
      libs/juce/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h
  33. +17
    -5
      libs/juce/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp
  34. +8
    -1
      libs/juce/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h
  35. +72
    -226
      libs/juce/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp
  36. +31
    -67
      libs/juce/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h
  37. +7
    -32
      libs/juce/source/modules/juce_audio_devices/juce_audio_devices.cpp
  38. +30
    -20
      libs/juce/source/modules/juce_audio_devices/juce_audio_devices.h
  39. +10
    -3
      libs/juce/source/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h
  40. +1
    -1
      libs/juce/source/modules/juce_audio_devices/native/juce_android_Midi.cpp
  41. +2
    -2
      libs/juce/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp
  42. +48
    -5
      libs/juce/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp
  43. +3
    -1
      libs/juce/source/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp
  44. +93
    -77
      libs/juce/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp
  45. +43
    -18
      libs/juce/source/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp
  46. +8
    -0
      libs/juce/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp
  47. +4
    -3
      libs/juce/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp
  48. +7
    -0
      libs/juce/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp
  49. +1
    -1
      libs/juce/source/modules/juce_audio_devices/sources/juce_AudioTransportSource.h
  50. +8
    -5
      libs/juce/source/modules/juce_audio_formats/codecs/flac/alloc.h
  51. +4
    -1
      libs/juce/source/modules/juce_audio_formats/codecs/flac/assert.h
  52. +4
    -1
      libs/juce/source/modules/juce_audio_formats/codecs/flac/callback.h
  53. +0
    -33
      libs/juce/source/modules/juce_audio_formats/codecs/flac/compat.h
  54. +3
    -1
      libs/juce/source/modules/juce_audio_formats/codecs/flac/endswap.h
  55. +0
    -1
      libs/juce/source/modules/juce_audio_formats/codecs/flac/metadata.h
  56. +0
    -1
      libs/juce/source/modules/juce_audio_formats/codecs/flac/stream_decoder.h
  57. +0
    -1
      libs/juce/source/modules/juce_audio_formats/codecs/flac/stream_encoder.h
  58. +0
    -5
      libs/juce/source/modules/juce_audio_formats/codecs/flac/win_utf8_io.h
  59. +6
    -8
      libs/juce/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp
  60. +67
    -2
      libs/juce/source/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp
  61. +1
    -1
      libs/juce/source/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp
  62. +7
    -21
      libs/juce/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp
  63. +2
    -0
      libs/juce/source/modules/juce_audio_formats/juce_audio_formats.cpp
  64. +27
    -1
      libs/juce/source/modules/juce_audio_formats/juce_audio_formats.h
  65. +41
    -0
      libs/juce/source/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h
  66. +555
    -335
      libs/juce/source/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp
  67. +5
    -5
      libs/juce/source/modules/juce_audio_plugin_client/AU/CoreAudioUtilityClasses/AUCarbonViewControl.cpp
  68. +500
    -764
      libs/juce/source/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm
  69. +1426
    -0
      libs/juce/source/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm
  70. +140
    -0
      libs/juce/source/modules/juce_audio_plugin_client/AUResources.r
  71. +14
    -0
      libs/juce/source/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp
  72. +13
    -0
      libs/juce/source/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp
  73. +13
    -3
      libs/juce/source/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp
  74. +2
    -1
      libs/juce/source/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h
  75. +35
    -12
      libs/juce/source/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp
  76. +110
    -0
      libs/juce/source/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp
  77. +68
    -14
      libs/juce/source/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h
  78. +1061
    -846
      libs/juce/source/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  79. +12
    -8
      libs/juce/source/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm
  80. +399
    -155
      libs/juce/source/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp
  81. +38
    -3
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client.h
  82. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.cpp
  83. +26
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.mm
  84. +69
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU.r
  85. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm
  86. +66
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_2.mm
  87. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm
  88. +6
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS.r
  89. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_1.cpp
  90. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_2.cpp
  91. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_3.cpp
  92. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_4.cpp
  93. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_utils.cpp
  94. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_utils.mm
  95. +33
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp
  96. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp
  97. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp
  98. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST_utils.mm
  99. +25
    -0
      libs/juce/source/modules/juce_audio_plugin_client/juce_audio_plugin_client_utils.cpp
  100. +2
    -1
      libs/juce/source/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h

+ 2
- 1
libs/drowaudio/build-drowaudio/premake.lua View File

@@ -5,7 +5,8 @@ package = make_library_project("drowaudio")
package.includepaths = {
".",
"../../juce/source"
"../../juce/source",
"../../juce/source/modules"
}
package.files = {


+ 7
- 11
libs/juce-plugin/JucePluginMain.cpp View File

@@ -16,13 +16,13 @@
#include "modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp"
#elif JucePlugin_Build_VST
// we need to include 'juce_VSTMidiEventList' before 'juce_VST_Wrapper'
#ifndef _MSC_VER
#define __cdecl
#endif
#include "pluginterfaces/vst2.x/aeffectx.h"
namespace juce {
#include "modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h"
}
// #ifndef _MSC_VER
// #define __cdecl
// #endif
// #include "pluginterfaces/vst2.x/aeffectx.h"
// namespace juce {
// #include "modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h"
// }
#ifdef JUCE_MAC
#include "modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm"
#else
@@ -37,7 +37,3 @@
#if ! JucePlugin_Build_Standalone
#include "modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp"
#endif

namespace juce {
#include "modules/juce_audio_processors/processors/juce_AudioProcessor_export.cpp"
}

+ 3
- 2
libs/juce/build-juce/AppConfig.h View File

@@ -28,6 +28,7 @@
//=============================================================================
#define JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED 1
#define JUCE_STANDALONE_APPLICATION 0
//=============================================================================
@@ -96,14 +97,14 @@
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 0
#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 0
#define JUCE_USE_OGGVORBIS 1
/** Config: JUCE_USE_MP3AUDIOFORMAT
Enables the software-based MP3AudioFormat class.


+ 1
- 0
libs/juce/build-juce/premake.lua View File

@@ -6,6 +6,7 @@ package = make_library_project("juce")
package.includepaths = {
".",
"../source",
"../source/modules",
"../../../sdks/vstsdk2.4/"
}


+ 16
- 16
libs/juce/source/README.txt View File

@@ -1,17 +1,17 @@
# The JUCE Library
JUCE (Jules' Utility Class Extensions) is an all-encompassing
C++ framework for developing cross-platform software.
It contains pretty much everything you're likely to need to create
most applications, and is particularly well-suited for building
highly-customised GUIs, and for handling graphics and sound.
Most JUCE modules are shared under the GNU Public Licence
(GPLv2, v3, and the AGPLv3). This means that the code can
be freely copied and distributed, and costs nothing to use
in other GPL applications. One module (the juce_core module)
is permissively licensed under the ISC.
For more information, visit the website:
# The JUCE Library
JUCE (Jules' Utility Class Extensions) is an all-encompassing
C++ framework for developing cross-platform software.
It contains pretty much everything you're likely to need to create
most applications, and is particularly well-suited for building
highly-customised GUIs, and for handling graphics and sound.
Most JUCE modules are shared under the GNU Public Licence
(GPLv2, v3, and the AGPLv3). This means that the code can
be freely copied and distributed, and costs nothing to use
in other GPL applications. One module (the juce_core module)
is permissively licensed under the ISC.
For more information, visit the website:
http://www.juce.com

+ 1
- 0
libs/juce/source/doxygen/Doxyfile View File

@@ -2060,6 +2060,7 @@ PREDEFINED = WIN32=1 \
JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS=1 \
JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES=1 \
JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL=1 \
JUCE_COMPILER_SUPPORTS_LAMBDAS=1 \
JUCE_MODAL_LOOPS_PERMITTED=1

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this


+ 336
- 0
libs/juce/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp View File

@@ -0,0 +1,336 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2015 - ROLI 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.
==============================================================================
*/
AudioChannelSet::AudioChannelSet (uint32 c) : channels (c) {}
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 String ("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");
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";
default: break;
}
return "";
}
String AudioChannelSet::getSpeakerArrangementAsString() const
{
StringArray speakerTypes;
Array<AudioChannelSet::ChannelType> speakers = getChannelTypes();
for (int i = 0; i < speakers.size(); ++i)
{
String name = getAbbreviatedChannelTypeName (speakers.getReference (i));
if (name.isNotEmpty())
speakerTypes.add (name);
}
return speakerTypes.joinIntoString (" ");
}
String AudioChannelSet::getDescription() const
{
if (isDiscreteLayout()) return String ("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.1 Surround";
if (*this == create5point1()) return "5.1 Surround (+Lfe)";
if (*this == create6point0()) return "6.1 Surround";
if (*this == create6point1()) return "6.1 Surround (+Lfe)";
if (*this == create6point0Music()) return "6.1 (Music) Surround";
if (*this == create6point1Music()) return "6.1 (Music) Surround (+Lfe)";
if (*this == create7point0()) return "7.1 Surround";
if (*this == create7point1()) return "7.1 Surround (Lfe)";
if (*this == create7point0SDDS()) return "7.1 Surround SDDS";
if (*this == create7point1SDDS()) return "7.1 Surround SDDS (+Lfe)";
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
{
Array<AudioChannelSet::ChannelType> speakers = getChannelTypes();
for (int i = 0; i < speakers.size(); ++i)
if (speakers.getReference (i) > ambisonicZ)
return true;
return false;
}
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<ChannelType> (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<ChannelType> (bit) == type)
return idx;
idx++;
}
return -1;
}
Array<AudioChannelSet::ChannelType> AudioChannelSet::getChannelTypes() const
{
Array<ChannelType> result;
for (int bit = channels.findNextSetBit(0); bit >= 0; bit = channels.findNextSetBit (bit + 1))
result.add (static_cast<ChannelType> (bit));
return result;
}
void AudioChannelSet::addChannel (ChannelType newChannel)
{
const int bit = static_cast<int> (newChannel);
jassert (bit >= 0 && bit < 1024);
channels.setBit (bit);
}
void AudioChannelSet::removeChannel (ChannelType newChannel)
{
const int bit = static_cast<int> (newChannel);
jassert (bit >= 0 && bit < 1024);
channels.clearBit (bit);
}
AudioChannelSet AudioChannelSet::disabled() { return AudioChannelSet(); }
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 << leftSurround) | (1u << rightSurround) | (1u << LFE)); }
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 << leftSurround) | (1u << rightSurround) | (1u << centreSurround) | (1u << LFE)); }
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 << leftSurround) | (1u << rightSurround) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << LFE)); }
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 << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear) | (1u << LFE)); }
AudioChannelSet AudioChannelSet::create7point1SDDS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftCentre) | (1u << rightCentre) | (1u << LFE)); }
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 << leftSurroundRear) | (1u << rightSurroundRear) | (1u << centre) | (1u << centreSurround)); }
AudioChannelSet AudioChannelSet::octagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << leftSurround) | (1u << rightSurround) | (1u << centre) | (1u << centreSurround) | (1u << wideLeft) | (1u << wideRight)); }
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 AudioChannelSet();
}
Array<AudioChannelSet> AudioChannelSet::channelSetsWithNumberOfChannels (int numChannels)
{
Array<AudioChannelSet> 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;
}

+ 361
- 0
libs/juce/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h View File

@@ -0,0 +1,361 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2015 - ROLI 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_AUDIOCHANNELSET_H_INCLUDED
#define JUCE_AUDIOCHANNELSET_H_INCLUDED
//==============================================================================
/**
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 disabled();
//==============================================================================
/** Creates a one-channel mono set (centre).
Is equivalent to: kMonoAAX (VST), AAX_eStemFormat_Mono (AAX), kAudioChannelLayoutTag_Mono (CoreAudio)
*/
static AudioChannelSet mono();
/** Creates a set containing a stereo set (left, right).
Is equivalent to: kStereo (VST), AAX_eStemFormat_Stereo (AAX), kAudioChannelLayoutTag_Stereo (CoreAudio)
*/
static AudioChannelSet 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 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 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 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 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 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 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 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 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 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 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 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 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 create7point1SDDS();
//==============================================================================
/** 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 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 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 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 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 octagonal();
//==============================================================================
/** Creates a set of untyped discrete channels. */
static AudioChannelSet 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 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 namedChannelSet (int numChannels);
/** Return an array of channel sets which have a given number of channels */
static Array<AudioChannelSet> 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,
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 getChannelTypeName (ChannelType);
/** Returns the abbreviated name of a channel type. For example, this method may return "Ls". */
static String getAbbreviatedChannelTypeName (ChannelType);
//==============================================================================
enum
{
maxChannelsOfNamedLayout = 8
};
/** 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<ChannelType> 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 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; }
//==============================================================================
bool operator== (const AudioChannelSet&) const noexcept;
bool operator!= (const AudioChannelSet&) const noexcept;
bool operator< (const AudioChannelSet&) const noexcept;
private:
BigInteger channels;
explicit AudioChannelSet (uint32);
};
#endif // JUCE_AUDIOCHANNELSET_H_INCLUDED

+ 2
- 2
libs/juce/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h View File

@@ -397,9 +397,9 @@ public:
convert between 32 and 64 bit float buffer types.
*/
template <typename OtherType>
void makeCopyOf (const AudioBuffer<OtherType>& other)
void makeCopyOf (const AudioBuffer<OtherType>& other, bool avoidReallocating = false)
{
setSize (other.getNumChannels(), other.getNumSamples());
setSize (other.getNumChannels(), other.getNumSamples(), false, false, avoidReallocating);
if (other.hasBeenCleared())
{


+ 11
- 6
libs/juce/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp View File

@@ -204,10 +204,11 @@ namespace FloatVectorHelpers
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 { union { ParallelType f; IntegerType i; } u; u.f = v; return u.i; }
static forcedinline ParallelType toflt (IntegerType v) noexcept { union { ParallelType f; IntegerType i; } u; u.i = v; return u.f; }
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); }
@@ -235,10 +236,11 @@ namespace FloatVectorHelpers
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 { union { ParallelType f; IntegerType i; } u; u.f = v; return u.i; }
static forcedinline ParallelType toflt (IntegerType v) noexcept { union { ParallelType f; IntegerType i; } u; u.i = v; return u.f; }
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; }
@@ -346,6 +348,9 @@ namespace FloatVectorHelpers
#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<int typeSize> struct ModeType { typedef BasicOps32 Mode; };
template<> struct ModeType<8> { typedef BasicOps64 Mode; };
@@ -806,7 +811,7 @@ void FloatVectorOperations::abs (float* dest, const float* src, int num) noexcep
#if JUCE_USE_VDSP_FRAMEWORK
vDSP_vabs ((float*) src, 1, dest, 1, (vDSP_Length) num);
#else
union { float f; uint32 i; } signMask;
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,
@@ -821,7 +826,7 @@ void FloatVectorOperations::abs (double* dest, const double* src, int num) noexc
#if JUCE_USE_VDSP_FRAMEWORK
vDSP_vabsD ((double*) src, 1, dest, 1, (vDSP_Length) num);
#else
union {double d; uint64 i;} signMask;
FloatVectorHelpers::signMask64 signMask;
signMask.i = 0x7fffffffffffffffULL;
JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = fabs (src[i]), Mode::bit_and (s, mask),


+ 0
- 1
libs/juce/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp View File

@@ -22,7 +22,6 @@
==============================================================================
*/
struct CatmullRomAlgorithm
{
static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept


+ 0
- 1
libs/juce/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h View File

@@ -22,7 +22,6 @@
==============================================================================
*/
/**
Interpolator for resampling a stream of floats using Catmull-Rom interpolation.


+ 117
- 16
libs/juce/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp View File

@@ -62,33 +62,131 @@ IIRCoefficients::IIRCoefficients (double c1, double c2, double c3,
IIRCoefficients IIRCoefficients::makeLowPass (const double sampleRate,
const double frequency) noexcept
{
jassert (sampleRate > 0);
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 + std::sqrt (2.0) * n + nSquared);
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 - std::sqrt (2.0) * n + 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 + std::sqrt (2.0) * n + nSquared);
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 - std::sqrt (2.0) * n + nSquared));
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,
@@ -96,8 +194,9 @@ IIRCoefficients IIRCoefficients::makeLowShelf (const double sampleRate,
const double Q,
const float gainFactor) noexcept
{
jassert (sampleRate > 0);
jassert (Q > 0);
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;
@@ -120,8 +219,9 @@ IIRCoefficients IIRCoefficients::makeHighShelf (const double sampleRate,
const double Q,
const float gainFactor) noexcept
{
jassert (sampleRate > 0);
jassert (Q > 0);
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;
@@ -140,15 +240,16 @@ IIRCoefficients IIRCoefficients::makeHighShelf (const double sampleRate,
}
IIRCoefficients IIRCoefficients::makePeakFilter (const double sampleRate,
const double centreFrequency,
const double frequency,
const double Q,
const float gainFactor) noexcept
{
jassert (sampleRate > 0);
jassert (Q > 0);
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 (centreFrequency, 2.0)) / sampleRate;
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;
@@ -164,12 +265,12 @@ IIRCoefficients IIRCoefficients::makePeakFilter (const double sampleRate,
//==============================================================================
IIRFilter::IIRFilter() noexcept
: v1 (0), v2 (0), active (false)
: v1 (0.0), v2 (0.0), active (false)
{
}
IIRFilter::IIRFilter (const IIRFilter& other) noexcept
: v1 (0), v2 (0), active (other.active)
: v1 (0.0), v2 (0.0), active (other.active)
{
const SpinLock::ScopedLockType sl (other.processLock);
coefficients = other.coefficients;
@@ -198,7 +299,7 @@ void IIRFilter::setCoefficients (const IIRCoefficients& newCoefficients) noexcep
void IIRFilter::reset() noexcept
{
const SpinLock::ScopedLockType sl (processLock);
v1 = v2 = 0;
v1 = v2 = 0.0;
}
float IIRFilter::processSingleSampleRaw (const float in) noexcept


+ 39
- 0
libs/juce/source/modules/juce_audio_basics/effects/juce_IIRFilter.h View File

@@ -55,14 +55,53 @@ public:
/** 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.


+ 0
- 1
libs/juce/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h View File

@@ -22,7 +22,6 @@
==============================================================================
*/
/**
Interpolator for resampling a stream of floats using 4-point lagrange interpolation.


+ 2
- 2
libs/juce/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h View File

@@ -33,8 +33,8 @@
*/
//==============================================================================
template<typename FloatType>
class JUCE_API LinearSmoothedValue
template <typename FloatType>
class LinearSmoothedValue
{
public:
/** Constructor. */


+ 10
- 0
libs/juce/source/modules/juce_audio_basics/juce_audio_basics.cpp View File

@@ -31,6 +31,8 @@
#error "Incorrect use of JUCE cpp file"
#endif
#include "AppConfig.h"
#include "juce_audio_basics.h"
#if JUCE_MINGW && ! defined (__SSE2__)
@@ -67,6 +69,13 @@
#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 <arm_neon.h>
#endif
@@ -76,6 +85,7 @@ namespace juce
#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"


+ 28
- 2
libs/juce/source/modules/juce_audio_basics/juce_audio_basics.h View File

@@ -22,12 +22,37 @@
==============================================================================
*/
/*******************************************************************************
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: 4.3.0
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: GPL/Commercial
dependencies: juce_core
OSXFrameworks: Accelerate
iOSFrameworks: Accelerate
END_JUCE_MODULE_DECLARATION
*******************************************************************************/
#ifndef JUCE_AUDIO_BASICS_H_INCLUDED
#define JUCE_AUDIO_BASICS_H_INCLUDED
#include "../juce_core/juce_core.h"
#include "juce_core/juce_core.h"
//==============================================================================
namespace juce
{
@@ -37,6 +62,7 @@ namespace juce
#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"


+ 1
- 1
libs/juce/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp View File

@@ -248,7 +248,7 @@ bool MidiFile::readFrom (InputStream& sourceStream)
clear();
MemoryBlock data;
const int maxSensibleMidiFileSize = 2 * 1024 * 1024;
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))


+ 74
- 67
libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessage.cpp View File

@@ -33,11 +33,23 @@ namespace MidiHelpers
{
return (uint8) jlimit (0, 127, v);
}
}
inline uint8 floatVelocityToByte (const float v) noexcept
{
return validVelocity (roundToInt (v * 127.0f));
}
//==============================================================================
uint8 MidiMessage::floatValueToMidiByte (const float v) noexcept
{
return MidiHelpers::validVelocity (roundToInt (v * 127.0f));
}
uint16 MidiMessage::pitchbendToPitchwheelPos (const float pitchbend,
const float pitchbendRange) noexcept
{
// can't translate a pitchbend value that is outside of the given range!
jassert (std::abs (pitchbend) <= pitchbendRange);
return static_cast<uint16> (pitchbend > 0.0f
? jmap (pitchbend, 0.0f, pitchbendRange, 8192.0f, 16383.0f)
: jmap (pitchbend, -pitchbendRange, 0.0f, 0.0f, 8192.0f));
}
//==============================================================================
@@ -84,25 +96,24 @@ int MidiMessage::getMessageLengthFromFirstByte (const uint8 firstByte) noexcept
MidiMessage::MidiMessage() noexcept
: timeStamp (0), size (2)
{
preallocatedData.asBytes[0] = 0xf0;
preallocatedData.asBytes[1] = 0xf7;
packedData.asBytes[0] = 0xf0;
packedData.asBytes[1] = 0xf7;
}
MidiMessage::MidiMessage (const void* const d, const int dataSize, const double t)
: timeStamp (t),
size (dataSize)
: timeStamp (t), size (dataSize)
{
jassert (dataSize > 0);
memcpy (allocateSpace (dataSize), d, (size_t) dataSize);
// this checks that the length matches the data..
jassert (dataSize > 3 || *(uint8*)d >= 0xf0 || getMessageLengthFromFirstByte (*(uint8*)d) == size);
// check that the length matches the data..
jassert (size > 3 || *(uint8*)d >= 0xf0 || getMessageLengthFromFirstByte (*(uint8*)d) == size);
memcpy (allocateSpace (dataSize), d, (size_t) dataSize);
}
MidiMessage::MidiMessage (const int byte1, const double t) noexcept
: timeStamp (t), size (1)
{
preallocatedData.asBytes[0] = (uint8) byte1;
packedData.asBytes[0] = (uint8) byte1;
// check that the length matches the data..
jassert (byte1 >= 0xf0 || getMessageLengthFromFirstByte ((uint8) byte1) == 1);
@@ -111,8 +122,8 @@ MidiMessage::MidiMessage (const int byte1, const double t) noexcept
MidiMessage::MidiMessage (const int byte1, const int byte2, const double t) noexcept
: timeStamp (t), size (2)
{
preallocatedData.asBytes[0] = (uint8) byte1;
preallocatedData.asBytes[1] = (uint8) byte2;
packedData.asBytes[0] = (uint8) byte1;
packedData.asBytes[1] = (uint8) byte2;
// check that the length matches the data..
jassert (byte1 >= 0xf0 || getMessageLengthFromFirstByte ((uint8) byte1) == 2);
@@ -121,9 +132,9 @@ MidiMessage::MidiMessage (const int byte1, const int byte2, const double t) noex
MidiMessage::MidiMessage (const int byte1, const int byte2, const int byte3, const double t) noexcept
: timeStamp (t), size (3)
{
preallocatedData.asBytes[0] = (uint8) byte1;
preallocatedData.asBytes[1] = (uint8) byte2;
preallocatedData.asBytes[2] = (uint8) byte3;
packedData.asBytes[0] = (uint8) byte1;
packedData.asBytes[1] = (uint8) byte2;
packedData.asBytes[2] = (uint8) byte3;
// check that the length matches the data..
jassert (byte1 >= 0xf0 || getMessageLengthFromFirstByte ((uint8) byte1) == 3);
@@ -132,29 +143,19 @@ MidiMessage::MidiMessage (const int byte1, const int byte2, const int byte3, con
MidiMessage::MidiMessage (const MidiMessage& other)
: timeStamp (other.timeStamp), size (other.size)
{
if (other.allocatedData != nullptr)
{
allocatedData.malloc ((size_t) size);
memcpy (allocatedData, other.allocatedData, (size_t) size);
}
if (isHeapAllocated())
memcpy (allocateSpace (size), other.getData(), (size_t) size);
else
{
preallocatedData.asInt32 = other.preallocatedData.asInt32;
}
packedData.allocatedData = other.packedData.allocatedData;
}
MidiMessage::MidiMessage (const MidiMessage& other, const double newTimeStamp)
: timeStamp (newTimeStamp), size (other.size)
{
if (other.allocatedData != nullptr)
{
allocatedData.malloc ((size_t) size);
memcpy (allocatedData, other.allocatedData, (size_t) size);
}
if (isHeapAllocated())
memcpy (allocateSpace (size), other.getData(), (size_t) size);
else
{
preallocatedData.asInt32 = other.preallocatedData.asInt32;
}
packedData.allocatedData = other.packedData.allocatedData;
}
MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const uint8 lastStatusByte,
@@ -229,16 +230,15 @@ MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const
}
else
{
preallocatedData.asInt32 = 0;
size = getMessageLengthFromFirstByte ((uint8) byte);
preallocatedData.asBytes[0] = (uint8) byte;
packedData.asBytes[0] = (uint8) byte;
if (size > 1)
{
preallocatedData.asBytes[1] = src[0];
packedData.asBytes[1] = src[0];
if (size > 2)
preallocatedData.asBytes[2] = src[1];
packedData.asBytes[2] = src[1];
}
}
@@ -246,7 +246,7 @@ MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const
}
else
{
preallocatedData.asInt32 = 0;
packedData.allocatedData = nullptr;
size = 0;
}
}
@@ -255,19 +255,25 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other)
{
if (this != &other)
{
timeStamp = other.timeStamp;
size = other.size;
if (other.allocatedData != nullptr)
if (other.isHeapAllocated())
{
allocatedData.malloc ((size_t) size);
memcpy (allocatedData, other.allocatedData, (size_t) size);
if (isHeapAllocated())
packedData.allocatedData = static_cast<uint8*> (std::realloc (packedData.allocatedData, (size_t) other.size));
else
packedData.allocatedData = static_cast<uint8*> (std::malloc ((size_t) other.size));
memcpy (packedData.allocatedData, other.packedData.allocatedData, (size_t) other.size);
}
else
{
allocatedData.free();
preallocatedData.asInt32 = other.preallocatedData.asInt32;
if (isHeapAllocated())
std::free (packedData.allocatedData);
packedData.allocatedData = other.packedData.allocatedData;
}
timeStamp = other.timeStamp;
size = other.size;
}
return *this;
@@ -277,36 +283,36 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other)
MidiMessage::MidiMessage (MidiMessage&& other) noexcept
: timeStamp (other.timeStamp), size (other.size)
{
if (other.allocatedData != nullptr)
allocatedData.swapWith (other.allocatedData);
else
preallocatedData.asInt32 = other.preallocatedData.asInt32;
packedData.allocatedData = other.packedData.allocatedData;
other.size = 0;
}
MidiMessage& MidiMessage::operator= (MidiMessage&& other) noexcept
{
jassert (this != &other); // shouldn't be possible
packedData.allocatedData = other.packedData.allocatedData;
timeStamp = other.timeStamp;
size = other.size;
allocatedData.swapWith (other.allocatedData);
preallocatedData.asInt32 = other.preallocatedData.asInt32;
other.size = 0;
return *this;
}
#endif
MidiMessage::~MidiMessage() {}
MidiMessage::~MidiMessage() noexcept
{
if (isHeapAllocated())
std::free (packedData.allocatedData);
}
uint8* MidiMessage::allocateSpace (int bytes)
{
if (bytes > 4)
if (bytes > (int) sizeof (packedData))
{
allocatedData.malloc ((size_t) bytes);
return allocatedData;
uint8* d = static_cast<uint8*> (std::malloc ((size_t) bytes));
packedData.allocatedData = d;
return d;
}
return preallocatedData.asBytes;
return packedData.asBytes;
}
String MidiMessage::getDescription() const
@@ -416,7 +422,7 @@ float MidiMessage::getFloatVelocity() const noexcept
void MidiMessage::setVelocity (const float newVelocity) noexcept
{
if (isNoteOnOrOff())
getData()[2] = MidiHelpers::floatVelocityToByte (newVelocity);
getData()[2] = floatValueToMidiByte (newVelocity);
}
void MidiMessage::multiplyVelocity (const float scaleFactor) noexcept
@@ -563,7 +569,7 @@ MidiMessage MidiMessage::noteOn (const int channel, const int noteNumber, const
MidiMessage MidiMessage::noteOn (const int channel, const int noteNumber, const float velocity) noexcept
{
return noteOn (channel, noteNumber, MidiHelpers::floatVelocityToByte (velocity));
return noteOn (channel, noteNumber, floatValueToMidiByte (velocity));
}
MidiMessage MidiMessage::noteOff (const int channel, const int noteNumber, uint8 velocity) noexcept
@@ -577,7 +583,7 @@ MidiMessage MidiMessage::noteOff (const int channel, const int noteNumber, uint8
MidiMessage MidiMessage::noteOff (const int channel, const int noteNumber, float velocity) noexcept
{
return noteOff (channel, noteNumber, MidiHelpers::floatVelocityToByte (velocity));
return noteOff (channel, noteNumber, floatValueToMidiByte (velocity));
}
MidiMessage MidiMessage::noteOff (const int channel, const int noteNumber) noexcept
@@ -722,9 +728,10 @@ MidiMessage MidiMessage::textMetaEvent (int type, StringRef text)
header[--n] = 0xff;
const size_t headerLen = sizeof (header) - n;
const int totalSize = (int) (headerLen + textSize);
uint8* const dest = result.allocateSpace ((int) (headerLen + textSize));
result.size = (int) (headerLen + textSize);
uint8* const dest = result.allocateSpace (totalSize);
result.size = totalSize;
memcpy (dest, header + n, headerLen);
memcpy (dest + headerLen, text.text.getAddress(), textSize);
@@ -841,7 +848,7 @@ bool MidiMessage::isKeySignatureMetaEvent() const noexcept
int MidiMessage::getKeySignatureNumberOfSharpsOrFlats() const noexcept
{
return (int) getMetaEventData()[0];
return (int) (int8) getMetaEventData()[0];
}
bool MidiMessage::isKeySignatureMajorKey() const noexcept
@@ -1010,7 +1017,7 @@ String MidiMessage::getMidiNoteName (int note, bool useSharps, bool includeOctav
return String();
}
double MidiMessage::getMidiNoteInHertz (int noteNumber, const double frequencyOfA) noexcept
double MidiMessage::getMidiNoteInHertz (const int noteNumber, const double frequencyOfA) noexcept
{
return frequencyOfA * pow (2.0, (noteNumber - 69) / 12.0);
}


+ 21
- 13
libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessage.h View File

@@ -104,7 +104,7 @@ public:
MidiMessage (const MidiMessage&, double newTimeStamp);
/** Destructor. */
~MidiMessage();
~MidiMessage() noexcept;
/** Copies this message from another one. */
MidiMessage& operator= (const MidiMessage& other);
@@ -118,7 +118,7 @@ public:
/** Returns a pointer to the raw midi data.
@see getRawDataSize
*/
const uint8* getRawData() const noexcept { return allocatedData != nullptr ? allocatedData.getData() : preallocatedData.asBytes; }
const uint8* getRawData() const noexcept { return getData(); }
/** Returns the number of bytes of data in the message.
@see getRawData
@@ -851,7 +851,7 @@ public:
The value passed in must be 0x80 or higher.
*/
static int getMessageLengthFromFirstByte (const uint8 firstByte) noexcept;
static int getMessageLengthFromFirstByte (uint8 firstByte) noexcept;
//==============================================================================
/** Returns the name of a midi note number.
@@ -878,7 +878,7 @@ public:
The frequencyOfA parameter is an optional frequency for 'A', normally 440-444Hz for concert pitch.
@see getMidiNoteName
*/
static double getMidiNoteInHertz (int noteNumber, const double frequencyOfA = 440.0) noexcept;
static double getMidiNoteInHertz (int noteNumber, double frequencyOfA = 440.0) noexcept;
/** Returns true if the given midi note number is a black key. */
static bool isMidiNoteBlack (int noteNumber) noexcept;
@@ -905,21 +905,29 @@ public:
*/
static const char* getControllerName (int controllerNumber);
/** Converts a floating-point value between 0 and 1 to a MIDI 7-bit value between 0 and 127. */
static uint8 floatValueToMidiByte (float valueBetween0and1) noexcept;
/** Converts a pitchbend value in semitones to a MIDI 14-bit pitchwheel position value. */
static uint16 pitchbendToPitchwheelPos (float pitchbendInSemitones,
float pitchbendRangeInSemitones) noexcept;
private:
//==============================================================================
double timeStamp;
HeapBlock<uint8> allocatedData;
int size;
#ifndef DOXYGEN
union
union PackedData
{
uint8 asBytes[4];
uint32 asInt32;
} preallocatedData;
uint8* allocatedData;
uint8 asBytes[sizeof (uint8*)];
};
PackedData packedData;
double timeStamp;
int size;
#endif
inline uint8* getData() noexcept { return allocatedData != nullptr ? allocatedData.getData() : preallocatedData.asBytes; }
inline bool isHeapAllocated() const noexcept { return size > (int) sizeof (packedData); }
inline uint8* getData() const noexcept { return isHeapAllocated() ? packedData.allocatedData : (uint8*) packedData.asBytes; }
uint8* allocateSpace (int);
};


+ 1
- 1
libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp View File

@@ -80,7 +80,7 @@ int MidiMessageSequence::getIndexOfMatchingKeyUp (const int index) const noexcep
return -1;
}
int MidiMessageSequence::getIndexOf (MidiEventHolder* const event) const noexcept
int MidiMessageSequence::getIndexOf (const MidiEventHolder* const event) const noexcept
{
return list.indexOf (event);
}


+ 13
- 1
libs/juce/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h View File

@@ -48,6 +48,18 @@ public:
/** Replaces this sequence with another one. */
MidiMessageSequence& operator= (const MidiMessageSequence&);
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
MidiMessageSequence (MidiMessageSequence&& other) noexcept
: list (static_cast<OwnedArray<MidiEventHolder>&&> (other.list))
{}
MidiMessageSequence& operator= (MidiMessageSequence&& other) noexcept
{
list = static_cast<OwnedArray<MidiEventHolder>&&> (other.list);
return *this;
}
#endif
/** Destructor. */
~MidiMessageSequence();
@@ -109,7 +121,7 @@ public:
int getIndexOfMatchingKeyUp (int index) const noexcept;
/** Returns the index of an event. */
int getIndexOf (MidiEventHolder* event) const noexcept;
int getIndexOf (const MidiEventHolder* event) const noexcept;
/** Returns the index of the first event on or after the given timestamp.
If the time is beyond the end of the sequence, this will return the


+ 1
- 2
libs/juce/source/modules/juce_audio_basics/midi/juce_MidiRPN.cpp View File

@@ -22,7 +22,6 @@
==============================================================================
*/
MidiRPNDetector::MidiRPNDetector() noexcept
{
}
@@ -55,7 +54,7 @@ void MidiRPNDetector::reset() noexcept
}
//==============================================================================
MidiRPNDetector::ChannelState::ChannelState () noexcept
MidiRPNDetector::ChannelState::ChannelState() noexcept
: parameterMSB (0xff), parameterLSB (0xff), valueMSB (0xff), valueLSB (0xff), isNRPN (false)
{
}


+ 182
- 172
libs/juce/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp View File

@@ -39,6 +39,9 @@ MPEInstrument::MPEInstrument() noexcept
pressureDimension.value = &MPENote::pressure;
timbreDimension.value = &MPENote::timbre;
// the default value for pressure is 0, for all other dimension it is centre (= default MPEValue)
std::fill_n (pressureDimension.lastValueReceivedOnChannel, 16, MPEValue::minValue());
legacyMode.isEnabled = false;
legacyMode.pitchbendRange = 2;
legacyMode.channelRange = Range<int> (1, 17);
@@ -271,22 +274,6 @@ void MPEInstrument::handleTimbreLSB (int midiChannel, int value) noexcept
lastTimbreLowerBitReceivedOnChannel[midiChannel - 1] = uint8 (value);
}
//==============================================================================
MPEValue MPEInstrument::getInitialPitchbendForNoteOn (int midiChannel, int /*midiNoteNumber*/, MPEValue /*midiNoteOnVelocity*/) const
{
return pitchbendDimension.lastValueReceivedOnChannel[midiChannel - 1];
}
MPEValue MPEInstrument::getInitialPressureForNoteOn (int /*midiChannel*/, int /*midiNoteNumber*/, MPEValue midiNoteOnVelocity) const
{
return midiNoteOnVelocity;
}
MPEValue MPEInstrument::getInitialTimbreForNoteOn (int midiChannel, int /*midiNoteNumber*/, MPEValue /*midiNoteOnVelocity*/) const
{
return timbreDimension.lastValueReceivedOnChannel[midiChannel - 1];
}
//==============================================================================
void MPEInstrument::noteOn (int midiChannel,
int midiNoteNumber,
@@ -298,9 +285,9 @@ void MPEInstrument::noteOn (int midiChannel,
MPENote newNote (midiChannel,
midiNoteNumber,
midiNoteOnVelocity,
getInitialPitchbendForNoteOn (midiChannel, midiNoteNumber, midiNoteOnVelocity),
getInitialPressureForNoteOn (midiChannel, midiNoteNumber, midiNoteOnVelocity),
getInitialTimbreForNoteOn (midiChannel, midiNoteNumber, midiNoteOnVelocity),
getInitialValueForNewNote (midiChannel, pitchbendDimension),
getInitialValueForNewNote (midiChannel, pressureDimension),
getInitialValueForNewNote (midiChannel, timbreDimension),
isNoteChannelSustained[midiChannel - 1] ? MPENote::keyDownAndSustained : MPENote::keyDown);
const ScopedLock sl (lock);
@@ -334,10 +321,11 @@ void MPEInstrument::noteOff (int midiChannel,
note->keyState = (note->keyState == MPENote::keyDownAndSustained) ? MPENote::sustained : MPENote::off;
note->noteOffVelocity = midiNoteOffVelocity;
// last pitchbend and timbre values received for this note should not be re-used for
// last dimension values received for this note should not be re-used for
// any new notes, so reset them:
pitchbendDimension.lastValueReceivedOnChannel[midiChannel - 1] = MPEValue();
timbreDimension.lastValueReceivedOnChannel[midiChannel - 1] = MPEValue();
pressureDimension.lastValueReceivedOnChannel[midiChannel - 1] = MPEValue::minValue();
pitchbendDimension.lastValueReceivedOnChannel[midiChannel - 1] = MPEValue::centreValue();
timbreDimension.lastValueReceivedOnChannel[midiChannel - 1] = MPEValue::centreValue();
if (note->keyState == MPENote::off)
{
@@ -370,6 +358,14 @@ void MPEInstrument::timbre (int midiChannel, MPEValue value)
updateDimension (midiChannel, timbreDimension, value);
}
MPEValue MPEInstrument::getInitialValueForNewNote (int midiChannel, MPEDimension& dimension) const
{
if (getLastNotePlayedPtr (midiChannel) != nullptr)
return &dimension == &pressureDimension ? MPEValue::minValue() : MPEValue::centreValue();
return dimension.lastValueReceivedOnChannel[midiChannel - 1];
}
//==============================================================================
void MPEInstrument::updateDimension (int midiChannel, MPEDimension& dimension, MPEValue value)
{
@@ -758,7 +754,7 @@ public:
test.noteOn (3, 60, MPEValue::from7BitInt (100));
expectEquals (test.getNumPlayingNotes(), 1);
expectEquals (test.noteAddedCallCounter, 1);
expectNote (test.getNote (3, 60), 100, 100, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 60), 100, 0, 8192, 64, MPENote::keyDown);
// note-off
test.noteOff (3, 60, MPEValue::from7BitInt (33));
@@ -774,13 +770,13 @@ public:
// note off with non-matching note number shouldn't do anything
test.noteOff (3, 61, MPEValue::from7BitInt (33));
expectEquals (test.getNumPlayingNotes(), 1);
expectNote (test.getNote (3, 60), 100, 100, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 60), 100, 0, 8192, 64, MPENote::keyDown);
expectEquals (test.noteReleasedCallCounter, 0);
// note off with non-matching midi channel shouldn't do anything
test.noteOff (2, 60, MPEValue::from7BitInt (33));
expectEquals (test.getNumPlayingNotes(), 1);
expectNote (test.getNote (3, 60), 100, 100, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 60), 100, 0, 8192, 64, MPENote::keyDown);
expectEquals (test.noteReleasedCallCounter, 0);
}
{
@@ -791,9 +787,9 @@ public:
test.noteOn (3, 1, MPEValue::from7BitInt (100));
test.noteOn (3, 2, MPEValue::from7BitInt (100));
expectEquals (test.getNumPlayingNotes(), 3);
expectNote (test.getNote (3, 0), 100, 100, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 1), 100, 100, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 2), 100, 100, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 0), 100, 0, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 1), 100, 0, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 2), 100, 0, 8192, 64, MPENote::keyDown);
}
{
// pathological case: second note-on for same note should retrigger it.
@@ -802,7 +798,7 @@ public:
test.noteOn (3, 0, MPEValue::from7BitInt (100));
test.noteOn (3, 0, MPEValue::from7BitInt (60));
expectEquals (test.getNumPlayingNotes(), 1);
expectNote (test.getNote (3, 0), 60, 60, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 0), 60, 0, 8192, 64, MPENote::keyDown);
}
}
@@ -844,42 +840,42 @@ public:
// sustain pedal on per-note channel shouldn't do anything.
test.sustainPedal (3, true);
expectNote (test.getNote (3, 60), 100, 100, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 60), 100, 0, 8192, 64, MPENote::keyDown);
expectNote (test.getNote (3, 60), 100, 100, 8192, 64, MPENote::keyDown);