Added new version of ArduinoJson.

Removed effect_freeverb_simd.
Removed teensy_board_detection.h and exchanged checing for macros from TeensyDuino.
dev
Holger Wirtz 3 years ago
parent ad88b684c1
commit 8f4b1f65ce
  1. 37
      MicroDexed.ino
  2. 8
      UI.hpp
  3. 54
      config.h
  4. 848
      effect_freeverb_simd.cpp
  5. 185
      effect_freeverb_simd.h
  6. 50
      teensy_board_detection.h
  7. 2
      third-party/ArduinoJson/ArduinoJson.h
  8. 454
      third-party/ArduinoJson/CHANGELOG.md
  9. 7
      third-party/ArduinoJson/CMakeLists.txt
  10. 2
      third-party/ArduinoJson/LICENSE.md
  11. 43
      third-party/ArduinoJson/README.md
  12. 31
      third-party/ArduinoJson/appveyor.yml
  13. 2
      third-party/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino
  14. 2
      third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino
  15. 2
      third-party/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino
  16. 2
      third-party/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino
  17. 2
      third-party/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino
  18. 2
      third-party/ArduinoJson/examples/JsonServer/JsonServer.ino
  19. 2
      third-party/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino
  20. 2
      third-party/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino
  21. 10
      third-party/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino
  22. 2
      third-party/ArduinoJson/examples/StringExample/StringExample.ino
  23. 2
      third-party/ArduinoJson/extras/ci/espidf/CMakeLists.txt
  24. 2
      third-party/ArduinoJson/extras/ci/espidf/main/CMakeLists.txt
  25. 2
      third-party/ArduinoJson/extras/ci/espidf/main/main.cpp
  26. 16
      third-party/ArduinoJson/extras/conf_test/avr.cpp
  27. 16
      third-party/ArduinoJson/extras/conf_test/esp8266.cpp
  28. 15
      third-party/ArduinoJson/extras/conf_test/x64.cpp
  29. 15
      third-party/ArduinoJson/extras/conf_test/x86.cpp
  30. 2
      third-party/ArduinoJson/extras/fuzzing/CMakeLists.txt
  31. 2
      third-party/ArduinoJson/extras/fuzzing/reproducer.cpp
  32. 2
      third-party/ArduinoJson/extras/scripts/get-release-body.sh
  33. 13
      third-party/ArduinoJson/extras/scripts/publish.sh
  34. 2
      third-party/ArduinoJson/extras/scripts/wandbox/JsonGeneratorExample.cpp
  35. 2
      third-party/ArduinoJson/extras/scripts/wandbox/JsonParserExample.cpp
  36. 2
      third-party/ArduinoJson/extras/scripts/wandbox/MsgPackParserExample.cpp
  37. 4
      third-party/ArduinoJson/extras/scripts/wandbox/publish.sh
  38. 2
      third-party/ArduinoJson/extras/tests/CMakeLists.txt
  39. 2
      third-party/ArduinoJson/extras/tests/Cpp11/CMakeLists.txt
  40. 2
      third-party/ArduinoJson/extras/tests/Cpp17/CMakeLists.txt
  41. 21
      third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp
  42. 2
      third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt
  43. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt
  44. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/Issue1189.cpp
  45. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/Issue978.cpp
  46. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/assign_char.cpp
  47. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/delete_jsondocument.cpp
  48. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/read_long_long.cpp
  49. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/variant_as_char.cpp
  50. 2
      third-party/ArduinoJson/extras/tests/FailingBuilds/write_long_long.cpp
  51. 5
      third-party/ArduinoJson/extras/tests/Helpers/Arduino.h
  52. 2
      third-party/ArduinoJson/extras/tests/Helpers/CustomReader.hpp
  53. 2
      third-party/ArduinoJson/extras/tests/Helpers/api/Print.h
  54. 2
      third-party/ArduinoJson/extras/tests/Helpers/api/Stream.h
  55. 13
      third-party/ArduinoJson/extras/tests/Helpers/api/String.h
  56. 17
      third-party/ArduinoJson/extras/tests/Helpers/progmem_emulation.hpp
  57. 2
      third-party/ArduinoJson/extras/tests/IntegrationTests/CMakeLists.txt
  58. 2
      third-party/ArduinoJson/extras/tests/IntegrationTests/gbathree.cpp
  59. 2
      third-party/ArduinoJson/extras/tests/IntegrationTests/issue772.cpp
  60. 2
      third-party/ArduinoJson/extras/tests/IntegrationTests/openweathermap.cpp
  61. 2
      third-party/ArduinoJson/extras/tests/IntegrationTests/round_trip.cpp
  62. 4
      third-party/ArduinoJson/extras/tests/JsonArray/CMakeLists.txt
  63. 2
      third-party/ArduinoJson/extras/tests/JsonArray/add.cpp
  64. 2
      third-party/ArduinoJson/extras/tests/JsonArray/clear.cpp
  65. 69
      third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp
  66. 2
      third-party/ArduinoJson/extras/tests/JsonArray/createNested.cpp
  67. 2
      third-party/ArduinoJson/extras/tests/JsonArray/equals.cpp
  68. 2
      third-party/ArduinoJson/extras/tests/JsonArray/get.cpp
  69. 2
      third-party/ArduinoJson/extras/tests/JsonArray/isNull.cpp
  70. 2
      third-party/ArduinoJson/extras/tests/JsonArray/iterator.cpp
  71. 2
      third-party/ArduinoJson/extras/tests/JsonArray/memoryUsage.cpp
  72. 2
      third-party/ArduinoJson/extras/tests/JsonArray/nesting.cpp
  73. 2
      third-party/ArduinoJson/extras/tests/JsonArray/remove.cpp
  74. 2
      third-party/ArduinoJson/extras/tests/JsonArray/size.cpp
  75. 2
      third-party/ArduinoJson/extras/tests/JsonArray/std_string.cpp
  76. 2
      third-party/ArduinoJson/extras/tests/JsonArray/subscript.cpp
  77. 35
      third-party/ArduinoJson/extras/tests/JsonArray/unbound.cpp
  78. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/CMakeLists.txt
  79. 44
      third-party/ArduinoJson/extras/tests/JsonDeserializer/DeserializationError.cpp
  80. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/array.cpp
  81. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/array_static.cpp
  82. 16
      third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp
  83. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/incomplete_input.cpp
  84. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp
  85. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/invalid_input.cpp
  86. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/misc.cpp
  87. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/nestingLimit.cpp
  88. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/number.cpp
  89. 18
      third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp
  90. 2
      third-party/ArduinoJson/extras/tests/JsonDeserializer/object_static.cpp
  91. 32
      third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp
  92. 40
      third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp
  93. 3
      third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt
  94. 15
      third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp
  95. 2
      third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp
  96. 2
      third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp
  97. 2
      third-party/ArduinoJson/extras/tests/JsonDocument/StaticJsonDocument.cpp
  98. 2
      third-party/ArduinoJson/extras/tests/JsonDocument/add.cpp
  99. 2
      third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp
  100. 2
      third-party/ArduinoJson/extras/tests/JsonDocument/containsKey.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

@ -22,6 +22,17 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
/*
TODO
#if defined(ARDUINO_TEENSY41)
#define NUM_DRUMSET_CONFIG 71
#elif defined(ARDUINO_TEENSY40)
#define NUM_DRUMSET_CONFIG 47
#else
#define NUM_DRUMSET_CONFIG 19
#endif
*/
#include <limits.h> #include <limits.h>
#include "config.h" #include "config.h"
#include <Audio.h> #include <Audio.h>
@ -41,8 +52,6 @@ using namespace TeensyTimerTool;
#include "effect_mono_stereo.h" #include "effect_mono_stereo.h"
#if defined(USE_PLATEREVERB) #if defined(USE_PLATEREVERB)
#include "effect_platervbstereo.h" #include "effect_platervbstereo.h"
#elif defined(USE_FREEVERB_SIMD)
#include "effect_freeverb_simd.h"
#else #else
#include "effect_freeverbf.h" #include "effect_freeverbf.h"
#endif #endif
@ -102,8 +111,6 @@ AudioMixer<3> reverb_mixer_l;
#endif #endif
#if defined(USE_PLATEREVERB) #if defined(USE_PLATEREVERB)
AudioEffectPlateReverb reverb; AudioEffectPlateReverb reverb;
#elif defined(USE_FREEVERB_SIMD)
AudioEffectFreeverbSIMDStereo freeverb;
#else #else
AudioEffectFreeverbStereoFloat freeverb; AudioEffectFreeverbStereoFloat freeverb;
#endif #endif
@ -384,7 +391,7 @@ char g_bank_name[NUM_DEXED][BANK_NAME_LEN];
char receive_bank_filename[FILENAME_LEN]; char receive_bank_filename[FILENAME_LEN];
uint8_t selected_instance_id = 0; uint8_t selected_instance_id = 0;
uint8_t seq_UI_last_step = 0; uint8_t seq_UI_last_step = 0;
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#if NUM_DEXED>1 #if NUM_DEXED>1
int8_t midi_decay[NUM_DEXED] = { -1, -1}; int8_t midi_decay[NUM_DEXED] = { -1, -1};
#else #else
@ -449,7 +456,7 @@ void setup()
#endif #endif
#endif #endif
#if defined(DEBUG) && defined(TEENSY_4) #if defined(DEBUG) && (defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41))
Serial.println(F("-------------------------------------------------------------------------------")); Serial.println(F("-------------------------------------------------------------------------------"));
Serial.println(F("Latest crash report:")); Serial.println(F("Latest crash report:"));
Serial.println(CrashReport); Serial.println(CrashReport);
@ -836,7 +843,7 @@ void loop()
{ {
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
if (midi_decay_timer > MIDI_DECAY_TIMER && midi_decay[instance_id] > 0) if (midi_decay_timer > MIDI_DECAY_TIMER && midi_decay[instance_id] > 0)
{ {
midi_decay[instance_id]--; midi_decay[instance_id]--;
@ -866,7 +873,7 @@ void loop()
} }
#endif #endif
} }
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
if (midi_decay_timer > MIDI_DECAY_LEVEL_TIME) if (midi_decay_timer > MIDI_DECAY_LEVEL_TIME)
{ {
midi_decay_timer = 0; midi_decay_timer = 0;
@ -1077,7 +1084,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
MicroDexed[instance_id]->keydown(inNumber, uint8_t(float(configuration.dexed[instance_id].velocity_level / 127.0)*inVelocity + 0.5)); MicroDexed[instance_id]->keydown(inNumber, uint8_t(float(configuration.dexed[instance_id].velocity_level / 127.0)*inVelocity + 0.5));
midi_voices[instance_id]++; midi_voices[instance_id]++;
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select)) if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select))
{ {
midi_decay_timer = 0; midi_decay_timer = 0;
@ -2868,13 +2875,11 @@ void generate_version_string(char* buffer, uint8_t len)
memset(buffer, 0, len); memset(buffer, 0, len);
strncat(buffer, VERSION, len); strncat(buffer, VERSION, len);
#if defined(TEENSY3_5) #if defined(ARDUINO_TEENSY36)
strncat(buffer, "-3.5", 4);
#elif defined(TEENSY3_6)
strncat(buffer, "-3.6", 4); strncat(buffer, "-3.6", 4);
#elif defined(TEENSY4_0) #elif defined(ARDUINO_TEENSY40)
strncat(buffer, "-4.0", 4); strncat(buffer, "-4.0", 4);
#elif defined(TEENSY4_1) #elif defined(ARDUINO_TEENSY41)
strncat(buffer, "-4.1", 4); strncat(buffer, "-4.1", 4);
#endif #endif
#if defined(USE_FX) #if defined(USE_FX)
@ -3154,7 +3159,7 @@ void show_cpu_and_mem_usage(void)
Serial.print(AudioProcessorUsageMax(), 2); Serial.print(AudioProcessorUsageMax(), 2);
Serial.print(F("%|CPUMAXCNT:")); Serial.print(F("%|CPUMAXCNT:"));
Serial.print(cpumax, DEC); Serial.print(cpumax, DEC);
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
Serial.print(F("|CPUTEMP:")); Serial.print(F("|CPUTEMP:"));
Serial.print(tempmonGetTemp(), 2); Serial.print(tempmonGetTemp(), 2);
Serial.print(F("C|MEM:")); Serial.print(F("C|MEM:"));
@ -3393,7 +3398,7 @@ void SerialPrintFormatInt3(uint8_t num)
Serial.print(buf); Serial.print(buf);
} }
#ifdef TEENSY3_6 #if defined(ARDUINO_TEENSY36)
/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */ /* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */
extern "C" char* sbrk(int incr); extern "C" char* sbrk(int incr);
uint32_t FreeMem(void) uint32_t FreeMem(void)

@ -35,8 +35,6 @@
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
#if defined(USE_PLATEREVERB) #if defined(USE_PLATEREVERB)
#include "effect_platervbstereo.h" #include "effect_platervbstereo.h"
#elif defined(USE_FREEVERB_SIMD)
#include "effect_freeverb_simd.h"
#else #else
#include "effect_freeverbf.h" #include "effect_freeverbf.h"
#endif #endif
@ -117,8 +115,6 @@ extern AudioMixer<3> reverb_mixer_l;
#endif #endif
#if defined(USE_PLATEREVERB) #if defined(USE_PLATEREVERB)
extern AudioEffectPlateReverb reverb; extern AudioEffectPlateReverb reverb;
#elif defined(USE_FREEVERB_SIMD)
extern AudioEffectFreeverbSIMDStereo freeverb;
#else #else
extern AudioEffectFreeverbStereoFloat freeverb; extern AudioEffectFreeverbStereoFloat freeverb;
#endif #endif
@ -410,7 +406,7 @@ LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do
LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control);
#if defined(USE_FX) #if defined(USE_FX)
#if defined(TEENSY4) #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#include "UI_FX_T4.h" #include "UI_FX_T4.h"
#else #else
#include "UI_FX_T3_6.h" #include "UI_FX_T3_6.h"
@ -7757,7 +7753,7 @@ void UI_func_voice_select(uint8_t param)
display.createChar(2, (uint8_t*)special_chars[18]); // favorites symbol display.createChar(2, (uint8_t*)special_chars[18]); // favorites symbol
#ifdef TEENSY3_6 #if defined(TEENSY36)
display.createChar(6, (uint8_t*)special_chars[16]); // MIDI activity note symbol display.createChar(6, (uint8_t*)special_chars[16]); // MIDI activity note symbol
display.createChar(7, (uint8_t*)special_chars[16]); // MIDI activity note symbol display.createChar(7, (uint8_t*)special_chars[16]); // MIDI activity note symbol
#endif #endif

@ -28,7 +28,6 @@
#include <Arduino.h> #include <Arduino.h>
#include "midinotes.h" #include "midinotes.h"
#include "teensy_board_detection.h"
// If you want to test the system with Linux and without any keyboard and/or audio equipment, you can do the following: // If you want to test the system with Linux and without any keyboard and/or audio equipment, you can do the following:
// 1. In Arduino-IDE enable "Tools->USB-Type->Serial + MIDI + Audio" // 1. In Arduino-IDE enable "Tools->USB-Type->Serial + MIDI + Audio"
@ -101,7 +100,7 @@
//* DEXED SEQUENCER, EPIANO AND EFFECTS SETTINGS //* DEXED SEQUENCER, EPIANO AND EFFECTS SETTINGS
//************************************************************************************************* //*************************************************************************************************
// Number of Dexed instances // Number of Dexed instances
#if defined(TEENSY3_6) #if defined(ARDUINO_TEENSY36)
#warning >>> Sorry, only one instance possible for Teensy-3.6 #warning >>> Sorry, only one instance possible for Teensy-3.6
#define NUM_DEXED 1 // 1 or 2 - nothing else! #define NUM_DEXED 1 // 1 or 2 - nothing else!
#else #else
@ -112,7 +111,7 @@
#define USE_FX 1 #define USE_FX 1
// NUMBER OF PARALLEL SAMPLEDRUMS // NUMBER OF PARALLEL SAMPLEDRUMS
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#define NUM_DRUMS 8 #define NUM_DRUMS 8
#else #else
#define NUM_DRUMS 4 #define NUM_DRUMS 4
@ -124,7 +123,7 @@
// NUMBER OF SAMPLES IN DRUMSET // NUMBER OF SAMPLES IN DRUMSET
#if defined(ARDUINO_TEENSY41) #if defined(ARDUINO_TEENSY41)
#define NUM_DRUMSET_CONFIG 71 #define NUM_DRUMSET_CONFIG 71
#elif defined(TEENSY4) #elif defined(ARDUINO_TEENSY40)
#define NUM_DRUMSET_CONFIG 47 #define NUM_DRUMSET_CONFIG 47
#else #else
#define NUM_DRUMSET_CONFIG 19 #define NUM_DRUMSET_CONFIG 19
@ -133,7 +132,7 @@
// SEQUENCER // SEQUENCER
#define NUM_SEQ_PATTERN 24 #define NUM_SEQ_PATTERN 24
#define NUM_SEQ_TRACKS 6 #define NUM_SEQ_TRACKS 6
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#define USE_SEQUENCER #define USE_SEQUENCER
#endif #endif
@ -156,25 +155,28 @@
//#define SGTL5000_AUDIO_THRU 1 //#define SGTL5000_AUDIO_THRU 1
#define SGTL5000_HEADPHONE_VOLUME 0.8 #define SGTL5000_HEADPHONE_VOLUME 0.8
#endif #endif
#if defined(TEENSY4) #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#define USE_PLATEREVERB 1 #define USE_PLATEREVERB 1
#else #else
//#define USE_FREEVERB_SIMD
#define USE_FREEVERB_FP #define USE_FREEVERB_FP
#endif #endif
// DELAYTIME // DELAYTIME
#if NUM_DEXED > 1 #if NUM_DEXED > 1
# if defined(TEENSY4) # if defined(ARDUINO_TEENSY41)
# define DELAY_MAX_TIME 500 # define DELAY_MAX_TIME 500
# elif defined(ARDUINO_TEENSY41)
# define DELAY_MAX_TIME 250
# else # else
# define DELAY_MAX_TIME 100 # define DELAY_MAX_TIME 100
# endif # endif
#else #else
# if defined(TEENSY3_6) # if defined(ARDUINO_TEENSY36)
# define DELAY_MAX_TIME 400 # define DELAY_MAX_TIME 400
# elif defined(TEENSY4) # elif defined(ARDUINO_TEENSY41)
# define DELAY_MAX_TIME 1000 # define DELAY_MAX_TIME 1000
# elif defined(ARDUINO_TEENSY41)
# define DELAY_MAX_TIME 500
# else # else
# define DELAY_MAX_TIME 200 # define DELAY_MAX_TIME 200
# endif # endif
@ -278,7 +280,7 @@
#define SDCARD_AUDIO_CS_PIN 10 #define SDCARD_AUDIO_CS_PIN 10
#define SDCARD_AUDIO_MOSI_PIN 7 #define SDCARD_AUDIO_MOSI_PIN 7
#define SDCARD_AUDIO_SCK_PIN 14 #define SDCARD_AUDIO_SCK_PIN 14
#if defined(ARDUINO_TEENSY41) || defined(TEENSY3_6) // new detection logic to also find on board SD Card from Teensy 4.1 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY36) // new detection logic to also find on board SD Card from Teensy 4.1
// Teensy 3.6 & 4.1 internal SD card // Teensy 3.6 & 4.1 internal SD card
#define SDCARD_TEENSY_CS_PIN BUILTIN_SDCARD #define SDCARD_TEENSY_CS_PIN BUILTIN_SDCARD
#define SDCARD_TEENSY_MOSI_PIN 11 #define SDCARD_TEENSY_MOSI_PIN 11
@ -295,19 +297,19 @@
#define ENC_L_PIN_A 3 #define ENC_L_PIN_A 3
#define ENC_L_PIN_B 2 #define ENC_L_PIN_B 2
#define BUT_L_PIN 4 #define BUT_L_PIN 4
#if defined(TEENSY3_6) #if defined(ARDUINO_TEENSY36)
#define ENC_R_PIN_A 28 #define ENC_R_PIN_A 28
#define ENC_R_PIN_B 29 #define ENC_R_PIN_B 29
#define BUT_R_PIN 30 #define BUT_R_PIN 30
#else #else
#if defined(TEENSY4_0) #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#define ENC_R_PIN_A 6 #define ENC_R_PIN_A 6
#define ENC_R_PIN_B 5 #define ENC_R_PIN_B 5
#define BUT_R_PIN 8 #define BUT_R_PIN 8
//#define ENC_R_PIN_A 17 //#define ENC_R_PIN_A 17
//#define ENC_R_PIN_B 16 //#define ENC_R_PIN_B 16
//#define BUT_R_PIN 5 //#define BUT_R_PIN 5
#else // ARDUINO_TEENSY41 #else // ARDUINO_ARDUINO_TEENSY41
#define ENC_R_PIN_A 24 #define ENC_R_PIN_A 24
#define ENC_R_PIN_B 5 #define ENC_R_PIN_B 5
#define BUT_R_PIN 9 #define BUT_R_PIN 9
@ -362,13 +364,13 @@
// MAX_NOTES SETTINGS // MAX_NOTES SETTINGS
// Teensy-4.x settings // Teensy-4.x settings
#ifdef TEENSY4 #if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#define MAX_NOTES 32 #define MAX_NOTES 32
#define MIDI_DECAY_LEVEL_TIME 500 #define MIDI_DECAY_LEVEL_TIME 500
#endif #endif
// Teensy-3.6 settings // Teensy-3.6 settings
#if defined(TEENSY3_6) #if defined(ARDUINO_TEENSY36)
#undef USE_SEQUENCER #undef USE_SEQUENCER
# if defined(USE_FX) # if defined(USE_FX)
# warning >>> With enabled FX a maximum of 12 voices is possible (due to RAM and CPU limitations) # warning >>> With enabled FX a maximum of 12 voices is possible (due to RAM and CPU limitations)
@ -398,7 +400,7 @@
# endif # endif
#endif #endif
#ifdef TEENSY3_5 #if defined(ARDUINO_TEENSY35)
#error >>> Not supported anymore!!! #error >>> Not supported anymore!!!
#endif #endif
@ -942,3 +944,21 @@ inline float mapfloat(float val, float in_min, float in_max, float out_min, floa
return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
} }
#endif #endif
/* From: https://forum.pjrc.com/threads/68048-Predefined-Macros
ARDUINO_ARCH_AVR - Avr Architecture / (all Teensy < 3.0)
TEENSYDUINO=Version - Is a Teensy + gives TD version
KINETISL - Teensy LC
KINETISK - All Teensy 3.x
__MK20DX128__ - Teensy 3.0
__MK20DX256__ - Teensy 3.1, 3.2
__MK64FX512__ - Teensy 3.5
__MK66FX1M0__ - Teensy 3.6
__IMXRT1062__ - all Teensy 4.x + Teensy 4 MM
ARDUINO_TEENSY2 - Teensy 2
ARDUINO_TEENSY30 - Teensy 3.0
[...]
ARDUINO_TEENSY40 - Teensy 4.0
ARDUINO_TEENSY41 - Teensy 4.1
ARDUINO_TEENSYMM - Teensy 4 MM
*/

@ -1,848 +0,0 @@
/* Audio Library for Teensy 3.X
Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
Development of this audio library was funded by PJRC.COM, LLC by sales of
Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
open source software by purchasing Teensy or other PJRC products.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction (c)2021 H. Wirtz <wirtz@parasitstudio.de>, M. Koslowski <positionhigh@gmx.de>
, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice, development funding notice, and this permission
notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifdef USE_FREEVERB_SIMD
// A fixed point implementation of Freeverb by Jezar at Dreampoint
// http://blog.bjornroche.com/2012/06/freeverb-original-public-domain-code-by.html
// https://music.columbia.edu/pipermail/music-dsp/2001-October/045433.html
#include <Arduino.h>
#include "effect_freeverb_simd.h"
#include "utility/dspinst.h"
AudioEffectFreeverbSIMD::AudioEffectFreeverbSIMD() : AudioStream(1, inputQueueArray)
{
memset(comb1buf, 0, sizeof(comb1buf));
memset(comb2buf, 0, sizeof(comb2buf));
memset(comb3buf, 0, sizeof(comb3buf));
memset(comb4buf, 0, sizeof(comb4buf));
memset(comb5buf, 0, sizeof(comb5buf));
memset(comb6buf, 0, sizeof(comb6buf));
memset(comb7buf, 0, sizeof(comb7buf));
memset(comb8buf, 0, sizeof(comb8buf));
comb1index = 0;
comb2index = 0;
comb3index = 0;
comb4index = 0;
comb5index = 0;
comb6index = 0;
comb7index = 0;
comb8index = 0;
comb1filter = 0;
comb2filter = 0;
comb3filter = 0;
comb4filter = 0;
comb5filter = 0;
comb6filter = 0;
comb7filter = 0;
comb8filter = 0;
combdamp1 = 6553;
combdamp2 = 26215;
combfeeback = 27524;
memset(allpass1buf, 0, sizeof(allpass1buf));
memset(allpass2buf, 0, sizeof(allpass2buf));
memset(allpass3buf, 0, sizeof(allpass3buf));
memset(allpass4buf, 0, sizeof(allpass4buf));
allpass1index = 0;
allpass2index = 0;
allpass3index = 0;
allpass4index = 0;
}
// cleaner sat16 by http://www.moseleyinstruments.com/
__attribute__((unused))
static int16_t sat16(int32_t n, int rshift) {
// we should always round towards 0
// to avoid recirculating round-off noise
//
// a 2s complement positive number is always
// rounded down, so we only need to take
// care of negative numbers
if (n < 0) {
n = n + (~(0xFFFFFFFFUL << rshift));
}
n = n >> rshift;
if (n > 32767) {
return 32767;
}
if (n < -32768) {
return -32768;
}
return n;
}
// TODO: move this to one of the data files, use in output_adat.cpp, output_tdm.cpp, etc
static const audio_block_t zeroblock = {
0, 0, 0, {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#if AUDIO_BLOCK_SAMPLES > 16
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 32
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 48
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 64
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 96
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
#if AUDIO_BLOCK_SAMPLES > 112
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
#endif
}
};
void AudioEffectFreeverbSIMD::update()
{
#if defined(__ARM_ARCH_7EM__)
const audio_block_t *block;
audio_block_t *outblock;
int i;
int16_t input, bufout, output;
int32_t sum;
uint32_t PackA, PackB;
outblock = allocate();
if (!outblock) {
audio_block_t *tmp = receiveReadOnly(0);
if (tmp) release(tmp);
return;
}
block = receiveReadOnly(0);
if (!block) block = &zeroblock;
for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) {
// TODO: scale numerical range depending on roomsize & damping
asm volatile(
"MUL %[RESULT], %[BLOCK], %[CONST]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(input)
:[BLOCK]"r"((int32_t)block->data[i]), [CONST]"r"(8738), [R_RND]"r"(0x1FFFF), [I_SHIFT]"i"(17)
:
);
sum = 0;
/*
asm volatile (
"QADD %[SUM], %[C1], %[C2]\n"
"QADD %[SUM], %[C3], %[C4]\n"
"QADD %[SUM], %[C5], %[C6]\n"
"QADD %[SUM], %[C7], %[C8]\n"
:[SUM]"=r"(sum)
:[C1]"r"((int32_t)comb1buf[comb1index]),[C2]"r"((int32_t)comb2buf[comb2index]),[C3]"r"((int32_t)comb3buf[comb3index]),[C4]"r"((int32_t)comb4buf[comb4index]),[C5]"r"((int32_t)comb5buf[comb5index]),[C6]"r"((int32_t)comb6buf[comb6index]),[C7]"r"((int32_t)comb7buf[comb7index]),[C8]"r"((int32_t)comb8buf[comb8index])
:
);
*/
asm volatile (
"QADD %[SUM], %[C1], %[C2]\n"
"QADD %[SUM], %[C3], %[SUM]\n"
"QADD %[SUM], %[C4], %[SUM]\n"
"QADD %[SUM], %[C5], %[SUM]\n"
"QADD %[SUM], %[C6], %[SUM]\n"
"QADD %[SUM], %[C7], %[SUM]\n"
"QADD %[SUM], %[C8], %[SUM]\n"
:[SUM]"=r"(sum)
:[C1]"r"((int32_t)comb1buf[comb1index]), [C2]"r"((int32_t)comb2buf[comb2index]), [C3]"r"((int32_t)comb3buf[comb3index]), [C4]"r"((int32_t)comb4buf[comb4index]), [C5]"r"((int32_t)comb5buf[comb5index]), [C6]"r"((int32_t)comb6buf[comb6index]), [C7]"r"((int32_t)comb7buf[comb7index]), [C8]"r"((int32_t)comb8buf[comb8index])
:
);
//output = asm_sat16((sum * 31457), 0x1FFFF, 17);
asm volatile (
"MUL %[RESULT], %[SUM], %[CONST]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(output)
:[SUM]"r"((int32_t)sum), [CONST]"r"(31457), [R_RND]"r"(0x1FFFF), [I_SHIFT]"i"(17)
:
);
// Comb1
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb1buf[comb1index]), [INBOT]"r"(comb1filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb1filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile (
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb1buf[comb1index])
:[FIL]"r"(comb1filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
// Comb2
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb2buf[comb2index]), [INBOT]"r"(comb2filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb2filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile (
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb2buf[comb2index])
:[FIL]"r"(comb2filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
// Comb3
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb3buf[comb3index]), [INBOT]"r"(comb3filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb3filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile (
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb3buf[comb3index])
:[FIL]"r"(comb3filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
// Comb4
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb4buf[comb4index]), [INBOT]"r"(comb4filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb4filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile (
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb4buf[comb4index])
:[FIL]"r"(comb4filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
// Comb5
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb5buf[comb5index]), [INBOT]"r"(comb5filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb5filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile (
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb5buf[comb5index])
:[FIL]"r"(comb5filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
// Comb6
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb6buf[comb6index]), [INBOT]"r"(comb6filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb6filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile (
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb6buf[comb6index])
:[FIL]"r"(comb6filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
// Comb7
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb7buf[comb7index]), [INBOT]"r"(comb7filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb7filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile (
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb7buf[comb7index])
:[FIL]"r"(comb7filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
// Comb8
asm volatile (
"PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n"
:[PACKA]"=&r"(PackA)
:[INTOP]"r"(comb8buf[comb8index]), [INBOT]"r"(comb8filter)
:
);
asm volatile (
"PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n"
:[PACKB]"=&r"(PackB)
:[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1)
:
);
asm volatile(
"BIC %[RESULT], %[RESULT], #0\n"
"SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(comb8filter)
:[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:"memory"
);
asm volatile(
"MUL %[RESULT], %[FIL], %[FB]\n"
"CMN %[RESULT], #0\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
"ADD %[RESULT], %[RESULT], %[IN]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(comb8buf[comb8index])
:[FIL]"r"(comb8filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15)
:
);
bufout = allpass1buf[allpass1index];
allpass1buf[allpass1index] = output + (bufout >> 1);
asm volatile(
"SUBS %[RESULT], %[BUF], %[OUT]\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(output)
:[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1)
:
);
bufout = allpass2buf[allpass2index];
allpass2buf[allpass2index] = output + (bufout >> 1);
asm volatile(
"SUBS %[RESULT], %[BUF], %[OUT]\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(output)
:[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1)
:
);
bufout = allpass3buf[allpass3index];
allpass3buf[allpass3index] = output + (bufout >> 1);
asm volatile(
"SUBS %[RESULT], %[BUF], %[OUT]\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(output)
:[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1)
:
);
bufout = allpass4buf[allpass4index];
allpass4buf[allpass4index] = output + (bufout >> 1);
asm volatile(
"SUBS %[RESULT], %[BUF], %[OUT]\n"
"IT MI\n"
"ADDMI %[RESULT], %[RESULT], %[R_RND]\n"
"SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n"
:[RESULT]"=&r"(output)
:[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1)
:
);
asm volatile(
"MUL %[RESULT], %[OUT], %[CONST]\n"
"SSAT %[RESULT], #16, %[RESULT]\n"
:[RESULT]"=&r"(outblock->data[i])
:[OUT]"r"((int32_t)output), [CONST]"r"(30)
:
);
if (++allpass1index >= sizeof(allpass1buf) / sizeof(int16_t)) allpass1index = 0;
if (++allpass2index >= sizeof(allpass2buf) / sizeof(int16_t)) allpass2index = 0;
if (++allpass3index >= sizeof(allpass3buf) / sizeof(int16_t)) allpass3index = 0;
if (++allpass4index >= sizeof(allpass4buf) / sizeof(int16_t)) allpass4index = 0;
if (++comb1index >= sizeof(comb1buf) / sizeof(int16_t)) comb1index = 0;
if (++comb2index >= sizeof(comb2buf) / sizeof(int16_t)) comb2index = 0;
if (++comb3index >= sizeof(comb3buf) / sizeof(int16_t)) comb3index = 0;
if (++comb4index >= sizeof(comb4buf) / sizeof(int16_t)) comb4index = 0;
if (++comb5index >= sizeof(comb5buf) / sizeof(int16_t)) comb5index = 0;
if (++comb6index >= sizeof(comb6buf) / sizeof(int16_t)) comb6index = 0;
if (++comb7index >= sizeof(comb7buf) / sizeof(int16_t)) comb7index = 0;
if (++comb8index >= sizeof(comb8buf) / sizeof(int16_t)) comb8index = 0;
}
transmit(outblock);
release(outblock);
if (block != &zeroblock) release((audio_block_t *)block);
#elif defined(KINETISL)
audio_block_t *block;
block = receiveReadOnly(0);
if (block) release(block);
#endif
}
AudioEffectFreeverbSIMDStereo::AudioEffectFreeverbSIMDStereo() : AudioStream(1, inputQueueArray)
{
memset(comb1bufL, 0, sizeof(comb1bufL));
memset(comb2bufL, 0, sizeof(comb2bufL));
memset(comb3bufL, 0, sizeof(comb3bufL));
memset(comb4bufL, 0, sizeof(comb4bufL));
memset(comb5bufL, 0, sizeof(comb5bufL));
memset(comb6bufL, 0, sizeof(comb6bufL));
memset(comb7bufL, 0, sizeof(comb7bufL));
memset(comb8bufL, 0, sizeof(comb8bufL));
comb1indexL = 0;
comb2indexL = 0;
comb3indexL = 0;
comb4indexL = 0;
comb5indexL = 0;
comb6indexL = 0;
comb7indexL = 0;
comb8indexL = 0;
comb1filterL = 0;
comb2filterL = 0;
comb3filterL = 0;
comb4filterL = 0;
comb5filterL = 0;
comb6filterL = 0;
comb7filterL = 0;
comb8filterL = 0;
memset(comb1bufR, 0, sizeof(comb1bufR));
memset(comb2bufR, 0, sizeof(comb2bufR));
memset(comb3bufR, 0, sizeof(comb3bufR));
memset(comb4bufR, 0, sizeof(comb4bufR));
memset(comb5bufR, 0, sizeof(comb5bufR));
memset(comb6bufR, 0, sizeof(comb6bufR));
memset(comb7bufR, 0, sizeof(comb7bufR));
memset(comb8bufR, 0, sizeof(comb8bufR));
comb1indexR = 0;
comb2indexR = 0;
comb3indexR = 0;
comb4indexR = 0;
comb5indexR = 0;
comb6indexR = 0;
comb7indexR = 0;
comb8indexR = 0;
comb1filterR = 0;
comb2filterR = 0;
comb3filterR = 0;
comb4filterR = 0;
comb5filterR = 0;
comb6filterR = 0;
comb7filterR = 0;
comb8filterR = 0;
combdamp1 = 6553;
combdamp2 = 26215;
combfeeback = 27524;
memset(allpass1bufL, 0, sizeof(allpass1bufL));
memset(allpass2bufL, 0, sizeof(allpass2bufL));
memset(allpass3bufL, 0, sizeof(allpass3bufL));
memset(allpass4bufL, 0, sizeof(allpass4bufL));
allpass1indexL = 0;
allpass2indexL = 0;
allpass3indexL = 0;
allpass4indexL = 0;
memset(allpass1bufR, 0, sizeof(allpass1bufR));
memset(allpass2bufR, 0, sizeof(allpass2bufR));
memset(allpass3bufR, 0, sizeof(allpass3bufR));
memset(allpass4bufR, 0, sizeof(allpass4bufR));
allpass1indexR = 0;
allpass2indexR = 0;
allpass3indexR = 0;
allpass4indexR = 0;
}
void AudioEffectFreeverbSIMDStereo::update()
{
#if defined(__ARM_ARCH_7EM__)
const audio_block_t *block;
audio_block_t *outblockL;
audio_block_t *outblockR;
int i;
int16_t input, bufout, outputL, outputR;
int32_t sum;
block = receiveReadOnly(0);
outblockL = allocate();
outblockR = allocate();
if (!outblockL || !outblockR) {
if (outblockL) release(outblockL);
if (outblockR) release(outblockR);
if (block) release((audio_block_t *)block);
return;
}
if (!block) block = &zeroblock;
for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) {
// TODO: scale numerical range depending on roomsize & damping
input = sat16(block->data[i] * 8738, 17); // for numerical headroom
sum = 0;
bufout = comb1bufL[comb1indexL];
sum += bufout;
comb1filterL = sat16(bufout * combdamp2 + comb1filterL * combdamp1, 15);
comb1bufL[comb1indexL] = sat16(input + sat16(comb1filterL * combfeeback, 15), 0);
if (++comb1indexL >= sizeof(comb1bufL) / sizeof(int16_t)) comb1indexL = 0;
bufout = comb2bufL[comb2indexL];
sum += bufout;
comb2filterL = sat16(bufout * combdamp2 + comb2filterL * combdamp1, 15);
comb2bufL[comb2indexL] = sat16(input + sat16(comb2filterL * combfeeback, 15), 0);
if (++comb2indexL >= sizeof(comb2bufL) / sizeof(int16_t)) comb2indexL = 0;
bufout = comb3bufL[comb3indexL];
sum += bufout;
comb3filterL = sat16(bufout * combdamp2 + comb3filterL * combdamp1, 15);
comb3bufL[comb3indexL] = sat16(input + sat16(comb3filterL * combfeeback, 15), 0);
if (++comb3indexL >= sizeof(comb3bufL) / sizeof(int16_t)) comb3indexL = 0;
bufout = comb4bufL[comb4indexL];
sum += bufout;
comb4filterL = sat16(bufout * combdamp2 + comb4filterL * combdamp1, 15);
comb4bufL[comb4indexL] = sat16(input + sat16(comb4filterL * combfeeback, 15), 0);
if (++comb4indexL >= sizeof(comb4bufL) / sizeof(int16_t)) comb4indexL = 0;
bufout = comb5bufL[comb5indexL];
sum += bufout;
comb5filterL = sat16(bufout * combdamp2 + comb5filterL * combdamp1, 15);
comb5bufL[comb5indexL] = sat16(input + sat16(comb5filterL * combfeeback, 15), 0);
if (++comb5indexL >= sizeof(comb5bufL) / sizeof(int16_t)) comb5indexL = 0;
bufout = comb6bufL[comb6indexL];
sum += bufout;
comb6filterL = sat16(bufout * combdamp2 + comb6filterL * combdamp1, 15);
comb6bufL[comb6indexL] = sat16(input + sat16(comb6filterL * combfeeback, 15), 0);
if (++comb6indexL >= sizeof(comb6bufL) / sizeof(int16_t)) comb6indexL = 0;
bufout = comb7bufL[comb7indexL];
sum += bufout;
comb7filterL = sat16(bufout * combdamp2 + comb7filterL * combdamp1, 15);
comb7bufL[comb7indexL] = sat16(input + sat16(comb7filterL * combfeeback, 15), 0);
if (++comb7indexL >= sizeof(comb7bufL) / sizeof(int16_t)) comb7indexL = 0;
bufout = comb8bufL[comb8indexL];
sum += bufout;
comb8filterL = sat16(bufout * combdamp2 + comb8filterL * combdamp1, 15);
comb8bufL[comb8indexL] = sat16(input + sat16(comb8filterL * combfeeback, 15), 0);
if (++comb8indexL >= sizeof(comb8bufL) / sizeof(int16_t)) comb8indexL = 0;
outputL = sat16(sum * 31457, 17);
sum = 0;
bufout = comb1bufR[comb1indexR];
sum += bufout;
comb1filterR = sat16(bufout * combdamp2 + comb1filterR * combdamp1, 15);
comb1bufR[comb1indexR] = sat16(input + sat16(comb1filterR * combfeeback, 15), 0);
if (++comb1indexR >= sizeof(comb1bufR) / sizeof(int16_t)) comb1indexR = 0;
bufout = comb2bufR[comb2indexR];
sum += bufout;
comb2filterR = sat16(bufout * combdamp2 + comb2filterR * combdamp1, 15);
comb2bufR[comb2indexR] = sat16(input + sat16(comb2filterR * combfeeback, 15), 0);
if (++comb2indexR >= sizeof(comb2bufR) / sizeof(int16_t)) comb2indexR = 0;
bufout = comb3bufR[comb3indexR];
sum += bufout;
comb3filterR = sat16(bufout * combdamp2 + comb3filterR * combdamp1, 15);
comb3bufR[comb3indexR] = sat16(input + sat16(comb3filterR * combfeeback, 15), 0);
if (++comb3indexR >= sizeof(comb3bufR) / sizeof(int16_t)) comb3indexR = 0;
bufout = comb4bufR[comb4indexR];
sum += bufout;
comb4filterR = sat16(bufout * combdamp2 + comb4filterR * combdamp1, 15);
comb4bufR[comb4indexR] = sat16(input + sat16(comb4filterR * combfeeback, 15), 0);
if (++comb4indexR >= sizeof(comb4bufR) / sizeof(int16_t)) comb4indexR = 0;
bufout = comb5bufR[comb5indexR];
sum += bufout;
comb5filterR = sat16(bufout * combdamp2 + comb5filterR * combdamp1, 15);
comb5bufR[comb5indexR] = sat16(input + sat16(comb5filterR * combfeeback, 15), 0);
if (++comb5indexR >= sizeof(comb5bufR) / sizeof(int16_t)) comb5indexR = 0;
bufout = comb6bufR[comb6indexR];
sum += bufout;
comb6filterR = sat16(bufout * combdamp2 + comb6filterR * combdamp1, 15);
comb6bufR[comb6indexR] = sat16(input + sat16(comb6filterR * combfeeback, 15), 0);
if (++comb6indexR >= sizeof(comb6bufR) / sizeof(int16_t)) comb6indexR = 0;
bufout = comb7bufR[comb7indexR];
sum += bufout;
comb7filterR = sat16(bufout * combdamp2 + comb7filterR * combdamp1, 15);
comb7bufR[comb7indexR] = sat16(input + sat16(comb7filterR * combfeeback, 15), 0);
if (++comb7indexR >= sizeof(comb7bufR) / sizeof(int16_t)) comb7indexR = 0;
bufout = comb8bufR[comb8indexR];
sum += bufout;
comb8filterR = sat16(bufout * combdamp2 + comb8filterR * combdamp1, 15);
comb8bufR[comb8indexR] = sat16(input + sat16(comb8filterR * combfeeback, 15), 0);
if (++comb8indexR >= sizeof(comb8bufR) / sizeof(int16_t)) comb8indexR = 0;
outputR = sat16(sum * 31457, 17);
bufout = allpass1bufL[allpass1indexL];
allpass1bufL[allpass1indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass1indexL >= sizeof(allpass1bufL) / sizeof(int16_t)) allpass1indexL = 0;
bufout = allpass2bufL[allpass2indexL];
allpass2bufL[allpass2indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass2indexL >= sizeof(allpass2bufL) / sizeof(int16_t)) allpass2indexL = 0;
bufout = allpass3bufL[allpass3indexL];
allpass3bufL[allpass3indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass3indexL >= sizeof(allpass3bufL) / sizeof(int16_t)) allpass3indexL = 0;
bufout = allpass4bufL[allpass4indexL];
allpass4bufL[allpass4indexL] = outputL + (bufout >> 1);
outputL = sat16(bufout - outputL, 1);
if (++allpass4indexL >= sizeof(allpass4bufL) / sizeof(int16_t)) allpass4indexL = 0;
outblockL->data[i] = sat16(outputL * 30, 0);
bufout = allpass1bufR[allpass1indexR];
allpass1bufR[allpass1indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass1indexR >= sizeof(allpass1bufR) / sizeof(int16_t)) allpass1indexR = 0;
bufout = allpass2bufR[allpass2indexR];
allpass2bufR[allpass2indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass2indexR >= sizeof(allpass2bufR) / sizeof(int16_t)) allpass2indexR = 0;
bufout = allpass3bufR[allpass3indexR];
allpass3bufR[allpass3indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass3indexR >= sizeof(allpass3bufR) / sizeof(int16_t)) allpass3indexR = 0;
bufout = allpass4bufR[allpass4indexR];
allpass4bufR[allpass4indexR] = outputR + (bufout >> 1);
outputR = sat16(bufout - outputR, 1);
if (++allpass4indexR >= sizeof(allpass4bufR) / sizeof(int16_t)) allpass4indexR = 0;
outblockR->data[i] = sat16(outputL * 30, 0);
}
transmit(outblockL, 0);
transmit(outblockR, 1);
release(outblockL);
release(outblockR);
if (block != &zeroblock) release((audio_block_t *)block);
#elif defined(KINETISL)
audio_block_t *block;
block = receiveReadOnly(0);
if (block) release(block);
#endif
}
#endif

@ -1,185 +0,0 @@
/* Audio Library for Teensy 3.X
Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
Development of this audio library was funded by PJRC.COM, LLC by sales of
Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
open source software by purchasing Teensy or other PJRC products.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice, development funding notice, and this permission
notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifdef USE_FREEVERB_SIMD
#ifndef effect_freeverb_simd_h_
#define effect_freeverb_simd_h_
#include <Arduino.h>
#include "AudioStream.h"
class AudioEffectFreeverbSIMD : public AudioStream
{
public:
AudioEffectFreeverbSIMD();
virtual void update();
void roomsize(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0f) n = 0.0f;
combfeeback = (int)(n * 9175.04f) + 22937;
}
void damping(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0f) n = 0.0f;
int x1 = (int)(n * 13107.2f);
int x2 = 32768 - x1;
__disable_irq();
combdamp1 = x1;
combdamp2 = x2;
__enable_irq();
}
private:
audio_block_t *inputQueueArray[1];
int16_t comb1buf[1116];
int16_t comb2buf[1188];
int16_t comb3buf[1277];
int16_t comb4buf[1356];
int16_t comb5buf[1422];
int16_t comb6buf[1491];
int16_t comb7buf[1557];
int16_t comb8buf[1617];
uint16_t comb1index;
uint16_t comb2index;
uint16_t comb3index;
uint16_t comb4index;
uint16_t comb5index;
uint16_t comb6index;
uint16_t comb7index;
uint16_t comb8index;
int16_t comb1filter;
int16_t comb2filter;
int16_t comb3filter;
int16_t comb4filter;
int16_t comb5filter;
int16_t comb6filter;
int16_t comb7filter;
int16_t comb8filter;
int16_t combdamp1;
int16_t combdamp2;
int16_t combfeeback;
int16_t allpass1buf[556];
int16_t allpass2buf[441];
int16_t allpass3buf[341];
int16_t allpass4buf[225];
uint16_t allpass1index;
uint16_t allpass2index;
uint16_t allpass3index;
uint16_t allpass4index;
};
class AudioEffectFreeverbSIMDStereo : public AudioStream
{
public:
AudioEffectFreeverbSIMDStereo();
virtual void update();
void roomsize(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0f) n = 0.0f;
combfeeback = (int)(n * 9175.04f) + 22937;
}
void damping(float n) {
if (n > 1.0f) n = 1.0f;
else if (n < 0.0f) n = 0.0f;
int x1 = (int)(n * 13107.2f);
int x2 = 32768 - x1;
__disable_irq();
combdamp1 = x1;
combdamp2 = x2;
__enable_irq();
}
private:
audio_block_t *inputQueueArray[1];
int16_t comb1bufL[1116];
int16_t comb2bufL[1188];
int16_t comb3bufL[1277];
int16_t comb4bufL[1356];
int16_t comb5bufL[1422];
int16_t comb6bufL[1491];
int16_t comb7bufL[1557];
int16_t comb8bufL[1617];
uint16_t comb1indexL;
uint16_t comb2indexL;
uint16_t comb3indexL;
uint16_t comb4indexL;
uint16_t comb5indexL;
uint16_t comb6indexL;
uint16_t comb7indexL;
uint16_t comb8indexL;
int16_t comb1filterL;
int16_t comb2filterL;
int16_t comb3filterL;
int16_t comb4filterL;
int16_t comb5filterL;
int16_t comb6filterL;
int16_t comb7filterL;
int16_t comb8filterL;
int16_t comb1bufR[1139];
int16_t comb2bufR[1211];
int16_t comb3bufR[1300];
int16_t comb4bufR[1379];
int16_t comb5bufR[1445];
int16_t comb6bufR[1514];
int16_t comb7bufR[1580];
int16_t comb8bufR[1640];
uint16_t comb1indexR;
uint16_t comb2indexR;
uint16_t comb3indexR;
uint16_t comb4indexR;
uint16_t comb5indexR;
uint16_t comb6indexR;
uint16_t comb7indexR;
uint16_t comb8indexR;
int16_t comb1filterR;
int16_t comb2filterR;
int16_t comb3filterR;
int16_t comb4filterR;
int16_t comb5filterR;
int16_t comb6filterR;
int16_t comb7filterR;
int16_t comb8filterR;
int16_t combdamp1;
int16_t combdamp2;
int16_t combfeeback;
int16_t allpass1bufL[556];
int16_t allpass2bufL[441];
int16_t allpass3bufL[341];
int16_t allpass4bufL[225];
uint16_t allpass1indexL;
uint16_t allpass2indexL;
uint16_t allpass3indexL;
uint16_t allpass4indexL;
int16_t allpass1bufR[579];
int16_t allpass2bufR[464];
int16_t allpass3bufR[364];
int16_t allpass4bufR[248];
uint16_t allpass1indexR;
uint16_t allpass2indexR;
uint16_t allpass3indexR;
uint16_t allpass4indexR;
};
#endif
#endif

@ -1,50 +0,0 @@
/*
MicroDexed
MicroDexed is a port of the Dexed sound engine
(https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6/4.x with audio shield.
Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android
(c)2018-2022 H. Wirtz <wirtz@parasitstudio.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TEENSY_BOARD_DETECTION_H_INCLUDED
#define TEENSY_BOARD_DETECTION_H_INCLUDED
// Teensy-4.x
#if defined(__IMXRT1062__) || defined (ARDUINO_TEENSY40) || defined (ARDUINO_TEENSY41)
#define TEENSY4
#if defined (ARDUINO_TEENSY40)
#define TEENSY4_0
#elif defined (ARDUINO_TEENSY41)
#define TEENSY4_1
#endif
#endif
// Teensy-3.6
#if defined(__MK66FX1M0__)
# define TEENSY3_6
#endif
// Teensy-3.5
#if defined (__MK64FX512__)
#define TEENSY3_5
#endif
#endif

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include "src/ArduinoJson.h" #include "src/ArduinoJson.h"

@ -1,6 +1,40 @@
ArduinoJson: change log ArduinoJson: change log
======================= =======================
v6.19.2 (2022-02-14)
-------
* Fix `cannot convert 'pgm_p' to 'const void*'` (issue #1707)
v6.19.1 (2022-01-14)
-------
* Fix crash when adding an object member in a too small `JsonDocument`
* Fix filter not working in zero-copy mode (issue #1697)
v6.19.0 (2022-01-08)
-------
* Remove `ARDUINOJSON_EMBEDDED_MODE` and assume we run on an embedded platform.
Dependent settings (like `ARDUINOJSON_DEFAULT_NESTING_LIMIT`) must be set individually.
* Change the default of `ARDUINOJSON_USE_DOUBLE` to `1`
* Change the default of `ARDUINOJSON_USE_LONG_LONG` to `1` on 32-bit platforms
* Add `as<JsonString>()` and `is<JsonString>()`
* Add safe bool idiom in `JsonString`
* Add support for NUL in string values (issue #1646)
* Add support for arbitrary array rank in `copyArray()`
* Add support for `char[][]` in `copyArray()`
* Remove `DeserializationError == bool` and `DeserializationError != bool`
* Renamed undocumented function `isUndefined()` to `isUnbound()`
* Fix `JsonVariant::memoryUsage()` for raw strings
* Fix `call of overloaded 'swap(BasicJsonDocument&, BasicJsonDocument&)' is ambiguous` (issue #1678)
* Fix inconsistent pool capacity between `BasicJsonDocument`'s copy and move constructors
* Fix inconsistent pool capacity between `BasicJsonDocument`'s copy and move assignments
* Fix return type of `StaticJsonDocument::operator=`
* Avoid pool reallocation in `BasicJsonDocument`'s copy assignment if capacity is the same
* Avoid including `Arduino.h` when all its features are disabled (issue #1692, PR #1693 by @paulocsanz)
* Assume `PROGMEM` is available as soon as `ARDUINO` is defined (consequence of #1693)
v6.18.5 (2021-09-28) v6.18.5 (2021-09-28)
------- -------
@ -731,423 +765,3 @@ v6.0.0-beta (2018-06-07)
> obj["key"] = "value"; > obj["key"] = "value";
> serializeJson(doc, Serial); > serializeJson(doc, Serial);
> ``` > ```
v5.13.2
-------
* Fixed `JsonBuffer::parse()` not respecting nesting limit correctly (issue #693)
* Fixed inconsistencies in nesting level counting (PR #695 from Zhenyu Wu)
* Fixed null values that could be pass to `strcmp()` (PR #745 from Mike Karlesky)
* Added macros `ARDUINOJSON_VERSION`, `ARDUINOJSON_VERSION_MAJOR`...
v5.13.1
-------
* Fixed `JsonVariant::operator|(int)` that returned the default value if the variant contained a double (issue #675)
* Allowed non-quoted key to contain underscores (issue #665)
v5.13.0
-------
* Changed the rules of string duplication (issue #658)
* `RawJson()` accepts any kind of string and obeys to the same rules for duplication
* Changed the return type of `strdup()` to `const char*` to prevent double duplication
* Marked `strdup()` as deprecated
> ### New rules for string duplication
>
> | type | duplication |
> |:---------------------------|:------------|
> | const char* | no |
> | char* | ~~no~~ yes |
> | String | yes |
> | std::string | yes |
> | const __FlashStringHelper* | yes |
>
> These new rules make `JsonBuffer::strdup()` useless.
v5.12.0
-------
* Added `JsonVariant::operator|` to return a default value (see below)
* Added a clear error message when compiled as C instead of C++ (issue #629)
* Added detection of MPLAB XC compiler (issue #629)
* Added detection of Keil ARM Compiler (issue #629)
* Added an example that shows how to save and load a configuration file
* Reworked all other examples
> ### How to use the new feature?
>
> If you have a block like this:
>
> ```c++
> const char* ssid = root["ssid"];
> if (!ssid)
> ssid = "default ssid";
> ```
>
> You can simplify like that:
>
> ```c++
> const char* ssid = root["ssid"] | "default ssid";
> ```
v5.11.2
-------
* Fixed `DynamicJsonBuffer::clear()` not resetting allocation size (issue #561)
* Fixed incorrect rounding for float values (issue #588)
v5.11.1
-------
* Removed dependency on `PGM_P` as Particle 0.6.2 doesn't define it (issue #546)
* Fixed warning "dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]"
* Fixed warning "floating constant exceeds range of 'float' [-Woverflow]" (issue #544)
* Fixed warning "this statement may fall through" [-Wimplicit-fallthrough=] (issue #539)
* Removed `ARDUINOJSON_DOUBLE_IS_64BITS` as it became useless.
* Fixed too many decimals places in float serialization (issue #543)
v5.11.0
-------
* Made `JsonBuffer` non-copyable (PR #524 by @luisrayas3)
* Added `StaticJsonBuffer::clear()`
* Added `DynamicJsonBuffer::clear()`
v5.10.1
-------
* Fixed IntelliSense errors in Visual Micro (issue #483)
* Fixed compilation in IAR Embedded Workbench (issue #515)
* Fixed reading "true" as a float (issue #516)
* Added `ARDUINOJSON_DOUBLE_IS_64BITS`
* Added `ARDUINOJSON_EMBEDDED_MODE`
v5.10.0
-------
* Removed configurable number of decimal places (issues #288, #427 and #506)
* Changed exponentiation thresholds to `1e7` and `1e-5` (issues #288, #427 and #506)
* `JsonVariant::is<double>()` now returns `true` for integers
* Fixed error `IsBaseOf is not a member of ArduinoJson::TypeTraits` (issue #495)
* Fixed error `forming reference to reference` (issue #495)
> ### BREAKING CHANGES :warning:
>
> | Old syntax | New syntax |
> |:--------------------------------|:--------------------|
> | `double_with_n_digits(3.14, 2)` | `3.14` |
> | `float_with_n_digits(3.14, 2)` | `3.14f` |
> | `obj.set("key", 3.14, 2)` | `obj["key"] = 3.14` |
> | `arr.add(3.14, 2)` | `arr.add(3.14)` |
>
> | Input | Old output | New output |
> |:----------|:-----------|:-----------|
> | `3.14159` | `3.14` | `3.14159` |
> | `42.0` | `42.00` | `42` |
> | `0.0` | `0.00` | `0` |
>
> | Expression | Old result | New result |
> |:-------------------------------|:-----------|:-----------|
> | `JsonVariant(42).is<int>()` | `true` | `true` |
> | `JsonVariant(42).is<float>()` | `false` | `true` |
> | `JsonVariant(42).is<double>()` | `false` | `true` |
v5.9.0
------
* Added `JsonArray::remove(iterator)` (issue #479)
* Added `JsonObject::remove(iterator)`
* Renamed `JsonArray::removeAt(size_t)` into `remove(size_t)`
* Renamed folder `include/` to `src/`
* Fixed warnings `floating constant exceeds range of float`and `floating constant truncated to zero` (issue #483)
* Removed `Print` class and converted `printTo()` to a template method (issue #276)
* Removed example `IndentedPrintExample.ino`
* Now compatible with Particle 0.6.1, thanks to Jacob Nite (issue #294 and PR #461 by @foodbag)
v5.8.4
------
* Added custom implementation of `strtod()` (issue #453)
* Added custom implementation of `strtol()` (issue #465)
* `char` is now treated as an integral type (issue #337, #370)
v5.8.3
------
* Fixed an access violation in `DynamicJsonBuffer` when memory allocation fails (issue #433)
* Added operators `==` and `!=` for two `JsonVariant`s (issue #436)
* Fixed `JsonVariant::operator[const FlashStringHelper*]` (issue #441)
v5.8.2
------
* Fixed parsing of comments (issue #421)
* Fixed ignored `Stream` timeout (issue #422)
* Made sure we don't read more that necessary (issue #422)
* Fixed error when the key of a `JsonObject` is a `char[]` (issue #423)
* Reduced code size when using `const` references
* Fixed error with string of type `unsigned char*` (issue #428)
* Added `deprecated` attribute on `asArray()`, `asObject()` and `asString()` (issue #420)
v5.8.1
------
* Fixed error when assigning a `volatile int` to a `JsonVariant` (issue #415)
* Fixed errors with Variable Length Arrays (issue #416)
* Fixed error when both `ARDUINOJSON_ENABLE_STD_STREAM` and `ARDUINOJSON_ENABLE_ARDUINO_STREAM` are set to `1`
* Fixed error "Stream does not name a type" (issue #412)
v5.8.0
------
* Added operator `==` to compare `JsonVariant` and strings (issue #402)
* Added support for `Stream` (issue #300)
* Reduced memory consumption by not duplicating spaces and comments
> ### BREAKING CHANGES :warning:
>
> `JsonBuffer::parseObject()` and `JsonBuffer::parseArray()` have been pulled down to the derived classes `DynamicJsonBuffer` and `StaticJsonBufferBase`.
>
> This means that if you have code like:
>
> ```c++
> void myFunction(JsonBuffer& jsonBuffer);
> ```
>
> you need to replace it with one of the following:
>
> ```c++
> void myFunction(DynamicJsonBuffer& jsonBuffer);
> void myFunction(StaticJsonBufferBase& jsonBuffer);
> template<typename TJsonBuffer> void myFunction(TJsonBuffer& jsonBuffer);
> ```
v5.7.3
------
* Added an `printTo(char[N])` and `prettyPrintTo(char[N])` (issue #292)
* Added ability to set a nested value like this: `root["A"]["B"] = "C"` (issue #352)
* Renamed `*.ipp` to `*Impl.hpp` because they were ignored by Arduino IDE (issue #396)
v5.7.2
------
* Made PROGMEM available on more platforms (issue #381)
* Fixed PROGMEM causing an exception on ESP8266 (issue #383)
v5.7.1
------
* Added support for PROGMEM (issue #76)
* Fixed compilation error when index is not an `int` (issue #381)
v5.7.0
------
* Templatized all functions using `String` or `std::string`
* Removed `ArduinoJson::String`
* Removed `JsonVariant::defaultValue<T>()`
* Removed non-template `JsonObject::get()` and `JsonArray.get()`
* Fixed support for `StringSumHelper` (issue #184)
* Replaced `ARDUINOJSON_USE_ARDUINO_STRING` by `ARDUINOJSON_ENABLE_STD_STRING` and `ARDUINOJSON_ENABLE_ARDUINO_STRING` (issue #378)
* Added example `StringExample.ino` to show where `String` can be used
* Increased default nesting limit to 50 when compiled for a computer (issue #349)
> ### BREAKING CHANGES :warning:
>
> The non-template functions `JsonObject::get()` and `JsonArray.get()` have been removed. This means that you need to explicitely tell the type you expect in return.
>
> Old code:
>
> ```c++
> #define ARDUINOJSON_USE_ARDUINO_STRING 0
> JsonVariant value1 = myObject.get("myKey");
> JsonVariant value2 = myArray.get(0);
> ```
>
> New code:
>
> ```c++
> #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0
> #define ARDUINOJSON_ENABLE_STD_STRING 1
> JsonVariant value1 = myObject.get<JsonVariant>("myKey");
> JsonVariant value2 = myArray.get<JsonVariant>(0);
> ```
v5.6.7
------
* Fixed `array[idx].as<JsonVariant>()` and `object[key].as<JsonVariant>()`
* Fixed return value of `JsonObject::set()` (issue #350)
* Fixed undefined behavior in `Prettyfier` and `Print` (issue #354)
* Fixed parser that incorrectly rejected floats containing a `+` (issue #349)
v5.6.6
------
* Fixed `-Wparentheses` warning introduced in v5.6.5 (PR #335 by @nuket)
* Added `.mbedignore` for ARM mbdeb (PR #334 by @nuket)
* Fixed `JsonVariant::success()` which didn't propagate `JsonArray::success()` nor `JsonObject::success()` (issue #342).
v5.6.5
------
* `as<char*>()` now returns `true` when input is `null` (issue #330)
v5.6.4
------
* Fixed error in float serialization (issue #324)
v5.6.3
------
* Improved speed of float serialization (about twice faster)
* Added `as<JsonArray>()` as a synonym for `as<JsonArray&>()`... (issue #291)
* Fixed `call of overloaded isinf(double&) is ambiguous` (issue #284)
v5.6.2
------
* Fixed build when another lib does `#undef isnan` (issue #284)
v5.6.1
------
* Added missing `#pragma once` (issue #310)
v5.6.0
------
* ArduinoJson is now a header-only library (issue #199)
v5.5.1
------
* Fixed compilation error with Intel Galileo (issue #299)
v5.5.0
------
* Added `JsonVariant::success()` (issue #279)
* Renamed `JsonVariant::invalid<T>()` to `JsonVariant::defaultValue<T>()`
v5.4.0
------
* Changed `::String` to `ArduinoJson::String` (issue #275)
* Changed `::Print` to `ArduinoJson::Print` too
v5.3.0
------
* Added custom implementation of `ftoa` (issues #266, #267, #269 and #270)
* Added `JsonVariant JsonBuffer::parse()` (issue #265)
* Fixed `unsigned long` printed as `signed long` (issue #170)
v5.2.0
------
* Added `JsonVariant::as<char*>()` as a synonym for `JsonVariant::as<const char*>()` (issue #257)
* Added example `JsonHttpClient` (issue #256)
* Added `JsonArray::copyTo()` and `JsonArray::copyFrom()` (issue #254)
* Added `RawJson()` to insert pregenerated JSON portions (issue #259)
v5.1.1
------
* Removed `String` duplication when one replaces a value in a `JsonObject` (PR #232 by @ulion)
v5.1.0
------
* Added support of `long long` (issue #171)
* Moved all build settings to `ArduinoJson/Configuration.hpp`
> ### BREAKING CHANGE :warning:
>
> If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`.
v5.0.8
------
* Made the library compatible with [PlatformIO](http://platformio.org/) (issue #181)
* Fixed `JsonVariant::is<bool>()` that was incorrectly returning false (issue #214)
v5.0.7
------
* Made library easier to use from a CMake project: simply `add_subdirectory(ArduinoJson/src)`
* Changed `String` to be a `typedef` of `std::string` (issues #142 and #161)
> ### BREAKING CHANGES :warning:
>
> - `JsonVariant(true).as<String>()` now returns `"true"` instead of `"1"`
> - `JsonVariant(false).as<String>()` now returns `"false"` instead of `"0"`
v5.0.6
------
* Added parameter to `DynamicJsonBuffer` constructor to set initial size (issue #152)
* Fixed warning about library category in Arduino 1.6.6 (issue #147)
* Examples: Added a loop to wait for serial port to be ready (issue #156)
v5.0.5
------
* Added overload `JsonObjectSuscript::set(value, decimals)` (issue #143)
* Use `float` instead of `double` to reduce the size of `JsonVariant` (issue #134)
v5.0.4
------
* Fixed ambiguous overload with `JsonArraySubscript` and `JsonObjectSubscript` (issue #122)
v5.0.3
------
* Fixed `printTo(String)` which wrote numbers instead of strings (issue #120)
* Fixed return type of `JsonArray::is<T>()` and some others (issue #121)
v5.0.2
------
* Fixed segmentation fault in `parseObject(String)` and `parseArray(String)`, when the
`StaticJsonBuffer` is too small to hold a copy of the string
* Fixed Clang warning "register specifier is deprecated" (issue #102)
* Fixed GCC warning "declaration shadows a member" (issue #103)
* Fixed memory alignment, which made ESP8266 crash (issue #104)
* Fixed compilation on Visual Studio 2010 and 2012 (issue #107)
v5.0.1
------
* Fixed compilation with Arduino 1.0.6 (issue #99)
v5.0.0
------
* Added support of `String` class (issues #55, #56, #70, #77)
* Added `JsonBuffer::strdup()` to make a copy of a string (issues #10, #57)
* Implicitly call `strdup()` for `String` but not for `char*` (issues #84, #87)
* Added support of non standard JSON input (issue #44)
* Added support of comments in JSON input (issue #88)
* Added implicit cast between numerical types (issues #64, #69, #93)
* Added ability to read number values as string (issue #90)
* Redesigned `JsonVariant` to leverage converting constructors instead of assignment operators (issue #66)
* Switched to new the library layout (requires Arduino 1.0.6 or above)
> ### BREAKING CHANGES :warning:
>
> - `JsonObject::add()` was renamed to `set()`
> - `JsonArray::at()` and `JsonObject::at()` were renamed to `get()`
> - Number of digits of floating point value are now set with `double_with_n_digits()`
**Personal note about the `String` class**:
Support of the `String` class has been added to the library because many people use it in their programs.
However, you should not see this as an invitation to use the `String` class.
The `String` class is **bad** because it uses dynamic memory allocation.
Compared to static allocation, it compiles to a bigger, slower program, and is less predictable.
You certainly don't want that in an embedded environment!

@ -1,17 +1,16 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.15)
if(ESP_PLATFORM) if(ESP_PLATFORM)
# Build ArduinoJson as an ESP-IDF component # Build ArduinoJson as an ESP-IDF component
idf_component_register(INCLUDE_DIRS src) idf_component_register(INCLUDE_DIRS src)
target_compile_definitions(${COMPONENT_LIB} INTERFACE ARDUINOJSON_EMBEDDED_MODE=1)
return() return()
endif() endif()
project(ArduinoJson VERSION 6.18.5) project(ArduinoJson VERSION 6.19.2)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest) include(CTest)

@ -1,7 +1,7 @@
The MIT License (MIT) The MIT License (MIT)
--------------------- ---------------------
Copyright © 2014-2021 Benoit BLANCHON Copyright © 2014-2022, Benoit BLANCHON
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@ -5,15 +5,13 @@
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/bblanchon/ArduinoJson/Continuous%20Integration?logo=github)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/bblanchon/ArduinoJson/Continuous%20Integration?logo=github)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x)
[![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
[![Coverage Status](https://coveralls.io/repos/github/bblanchon/ArduinoJson/badge.svg?branch=6.x)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) [![LGTM Grade](https://img.shields.io/lgtm/grade/cpp/github/bblanchon/ArduinoJson?label=quality&logo=lgtm)](https://lgtm.com/projects/g/bblanchon/ArduinoJson/)
[![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/6.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.19.2&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.19.2)
[![Discord](https://img.shields.io/discord/844900310409150494.svg?logo=discord&logoColor=white&color=007ec6)](https://discord.gg/DzN6hHHD4h) [![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.19.2)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.19.2)
[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github)](https://github.com/bblanchon/ArduinoJson/stargazers) [![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github)](https://github.com/bblanchon/ArduinoJson/stargazers)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github)](https://github.com/sponsors/bblanchon) [![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github)](https://github.com/sponsors/bblanchon)
[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.18.5)](https://www.ardu-badge.com/ArduinoJson/6.18.5)
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
## Features ## Features
@ -36,10 +34,10 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/?utm_source=github&utm_medium=readme) * [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/?utm_source=github&utm_medium=readme)
* [Fixed memory allocation, no heap fragmentation](https://arduinojson.org/v6/api/jsondocument/?utm_source=github&utm_medium=readme) * [Fixed memory allocation, no heap fragmentation](https://arduinojson.org/v6/api/jsondocument/?utm_source=github&utm_medium=readme)
* [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/?utm_source=github&utm_medium=readme) * [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/?utm_source=github&utm_medium=readme)
* Deduplicates strings * [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/?utm_source=github&utm_medium=readme)
* Versatile * Versatile
* Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/?utm_source=github&utm_medium=readme) * Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/?utm_source=github&utm_medium=readme)
* Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/?utm_source=github&utm_medium=readme), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme) and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/?utm_source=github&utm_medium=readme) * Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/?utm_source=github&utm_medium=readme), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme), and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/?utm_source=github&utm_medium=readme)
* Supports [`Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/?utm_source=github&utm_medium=readme) and [`std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/?utm_source=github&utm_medium=readme) * Supports [`Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/?utm_source=github&utm_medium=readme) and [`std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/?utm_source=github&utm_medium=readme)
* Supports [Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme) * Supports [Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme)
* Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme#custom-writer) * Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme#custom-writer)
@ -56,6 +54,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj) * Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj)
* Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)... * Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)...
* Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)... * Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)...
* Soft cores: [Nios II](https://en.wikipedia.org/wiki/Nios_II)...
* Tested on all major development environments * Tested on all major development environments
* [Arduino IDE](https://www.arduino.cc/en/Main/Software) * [Arduino IDE](https://www.arduino.cc/en/Main/Software)
* [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/) * [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/)
@ -82,7 +81,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* Well tested * Well tested
* [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
* Continuously tested on * Continuously tested on
* [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) * [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
* [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) * [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
* [Clang 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) * [Clang 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
* [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
@ -99,6 +98,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories)
* [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson)
* [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed) * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed)
* [Discord server](https://discord.gg/DzN6hHHD4h)
## Quickstart ## Quickstart
@ -139,11 +139,24 @@ serializeJson(doc, Serial);
See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme) See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme)
## Support the project ❤ ## Sponsors
ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it!
<p>
<a href="https://techexplorations.com/" rel="sponsored">
<img alt="Tech Explorations" src="https://arduinojson.org/images/2021/10/techexplorations.png" width="200">
</a>
<a href="https://www.programmingelectronics.com/" rel="sponsored">
<img src="https://arduinojson.org/images/2021/10/programmingeleactronicsacademy.png" alt="Programming Electronics Academy" width="200">
</a>
</p>
<p>
<a href="https://github.com/1technophile" rel="sponsored">
<img alt="1technophile" src="https://avatars.githubusercontent.com/u/12672732?s=40&v=4">
</a>
</p>
Do you like this library? If you run a commercial project that embeds ArduinoJson, think about [sponsoring the library's development](https://github.com/sponsors/bblanchon): it ensures the code that your products rely on stays actively maintained. It can also give your project some exposure to the makers' community.
Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)!
What? You don't like it but you *love* it? If you are an individual user and want to support the development (or give a sign of appreciation), consider purchasing the book [Mastering ArduinoJson](https://arduinojson.org/book/)&nbsp;❤, or simply [cast a star](https://github.com/bblanchon/ArduinoJson/stargazers)&nbsp;⭐.
You can support the project by [purchasing my book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme).
Alternatively, you can make a recurring donation via [GitHub Sponsors](https://github.com/sponsors/bblanchon).

@ -1,22 +1,37 @@
version: 6.18.5.{build} version: 6.19.2.{build}
environment: environment:
matrix: matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
CMAKE_GENERATOR: Visual Studio 17 2022
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
CMAKE_GENERATOR: Visual Studio 16 2019 CMAKE_GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: Visual Studio 15 2017 CMAKE_GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_GENERATOR: Visual Studio 14 2015 CMAKE_GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - CMAKE_GENERATOR: Visual Studio 12 2013
CMAKE_GENERATOR: Visual Studio 12 2013
- CMAKE_GENERATOR: Visual Studio 11 2012 - CMAKE_GENERATOR: Visual Studio 11 2012
- CMAKE_GENERATOR: Visual Studio 10 2010 - CMAKE_GENERATOR: Visual Studio 10 2010
- CMAKE_GENERATOR: MinGW Makefiles - CMAKE_GENERATOR: Ninja
MINGW: MinGW # MinGW 32-bit 5.3.0
- CMAKE_GENERATOR: Ninja
MINGW32: i686-5.3.0-posix-dwarf-rt_v4-rev0 # MinGW-w64 5.3.0
- CMAKE_GENERATOR: Ninja
MINGW32: i686-6.3.0-posix-dwarf-rt_v5-rev1 # MinGW-w64 6.3.0 i686
- CMAKE_GENERATOR: Ninja
MINGW64: x86_64-6.3.0-posix-seh-rt_v5-rev1 # MinGW-w64 6.3.0 x86_64
- CMAKE_GENERATOR: Ninja
MINGW64: x86_64-7.3.0-posix-seh-rt_v5-rev0 # MinGW-w64 7.3.0 x86_64
- CMAKE_GENERATOR: Ninja
MINGW64: x86_64-8.1.0-posix-seh-rt_v6-rev0 # MinGW-w64 8.1.0 x86_64
configuration: Debug configuration: Debug
before_build: before_build:
- set PATH=C:\MinGW\bin;%PATH:C:\Program Files\Git\usr\bin;=% # Workaround for CMake not wanting sh.exe on PATH for MinGW - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% # Workaround for CMake not wanting sh.exe on PATH for MinGW
- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" . - if defined MINGW set PATH=C:\%MINGW%\bin;%PATH%
- if defined MINGW32 set PATH=C:\mingw-w64\%MINGW32%\mingw32\bin;%PATH%
- if defined MINGW64 set PATH=C:\mingw-w64\%MINGW64%\mingw64\bin;%PATH%
- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" .
build_script: build_script:
- cmake --build . --config %CONFIGURATION% - cmake --build . --config %CONFIGURATION%
test_script: test_script:
- ctest -C %CONFIGURATION% --output-on-failure . - ctest -C %CONFIGURATION% --output-on-failure .

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to store your project configuration in a file. // This example shows how to store your project configuration in a file.

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to use DeserializationOpion::Filter // This example shows how to use DeserializationOpion::Filter

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to generate a JSON document with ArduinoJson. // This example shows how to generate a JSON document with ArduinoJson.

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to parse a JSON document in an HTTP response. // This example shows how to parse a JSON document in an HTTP response.

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to deserialize a JSON document with ArduinoJson. // This example shows how to deserialize a JSON document with ArduinoJson.

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to implement an HTTP server that sends a JSON document // This example shows how to implement an HTTP server that sends a JSON document

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to send a JSON document to a UDP socket. // This example shows how to send a JSON document to a UDP socket.

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to deserialize a MessagePack document with // This example shows how to deserialize a MessagePack document with

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows the different ways you can use Flash strings with // This example shows the different ways you can use Flash strings with
@ -14,8 +14,6 @@
#include <ArduinoJson.h> #include <ArduinoJson.h>
void setup() { void setup() {
#ifdef PROGMEM // <- check that Flash strings are supported
DynamicJsonDocument doc(1024); DynamicJsonDocument doc(1024);
// You can use a Flash String as your JSON input. // You can use a Flash String as your JSON input.
@ -46,12 +44,6 @@ void setup() {
if (obj["sensor"] == F("gps")) { if (obj["sensor"] == F("gps")) {
// ... // ...
} }
#else
#warning PROGMEM is not supported on this platform
#endif
} }
void loop() { void loop() {

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows the different ways you can use String with ArduinoJson. // This example shows the different ways you can use String with ArduinoJson.

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
idf_component_register(SRCS "main.cpp" idf_component_register(SRCS "main.cpp"

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -0,0 +1,16 @@
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_USE_LONG_LONG == 0, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 1,
"ARDUINOJSON_SLOT_OFFSET_SIZE");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 8,
"sizeof(VariantSlot)");
void setup() {}
void loop() {}

@ -0,0 +1,16 @@
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 2,
"ARDUINOJSON_SLOT_OFFSET_SIZE");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 16,
"sizeof(VariantSlot)");
void setup() {}
void loop() {}

@ -0,0 +1,15 @@
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 4,
"ARDUINOJSON_SLOT_OFFSET_SIZE");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 32,
"sizeof(VariantSlot)");
int main() {}

@ -0,0 +1,15 @@
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 2,
"ARDUINOJSON_SLOT_OFFSET_SIZE");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 16,
"sizeof(VariantSlot)");
int main() {}

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
if(MSVC) if(MSVC)

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// This file is NOT use by Google's OSS fuzz // This file is NOT use by Google's OSS fuzz

@ -8,7 +8,7 @@ CHANGELOG="$2"
cat << END cat << END
## Changes ## Changes
$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG") $(awk '/\* /{ FOUND=1 } /^[[:space:]]*$/ { if(FOUND) exit } { if(FOUND) print }' "$CHANGELOG")
[View version history](https://github.com/bblanchon/ArduinoJson/blob/$TAG/CHANGELOG.md) [View version history](https://github.com/bblanchon/ArduinoJson/blob/$TAG/CHANGELOG.md)
END END

@ -2,18 +2,25 @@
set -eu set -eu
which awk sed jq 7z curl perl >/dev/null
cd "$(dirname "$0")/../.." cd "$(dirname "$0")/../.."
if ! git diff --quiet --exit-code; then
echo "Repository contains uncommitted changes"
exit
fi
VERSION="$1" VERSION="$1"
DATE=$(date +%F) DATE=$(date +%F)
TAG="v$VERSION" TAG="v$VERSION"
VERSION_REGEX="[0-9a-z\\.\\-]+" VERSION_REGEX='[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9]+)?'
update_version_in_source () { update_version_in_source () {
IFS=".-" read MAJOR MINOR REVISION EXTRA < <(echo "$VERSION") IFS=".-" read MAJOR MINOR REVISION EXTRA < <(echo "$VERSION")
UNDERLINE=$(printf -- '-%.0s' $(seq 1 ${#TAG})) UNDERLINE=$(printf -- '-%.0s' $(seq 1 ${#TAG}))
sed -i~ -bE "s/version=$VERSION_REGEX/version=$VERSION/; s|ardu-badge.com/ArduinoJson/$VERSION_REGEX|ardu-badge.com/ArduinoJson/$VERSION|; " README.md sed -i~ -bE "1,20{s/$VERSION_REGEX/$VERSION/g}" README.md
rm README.md~ rm README.md~
sed -i~ -bE "4s/HEAD/$TAG ($DATE)/; 5s/-+/$UNDERLINE/" CHANGELOG.md sed -i~ -bE "4s/HEAD/$TAG ($DATE)/; 5s/-+/$UNDERLINE/" CHANGELOG.md
@ -62,7 +69,7 @@ push
extras/scripts/build-arduino-package.sh . "../ArduinoJson-$TAG.zip" extras/scripts/build-arduino-package.sh . "../ArduinoJson-$TAG.zip"
extras/scripts/build-single-header.sh "src/ArduinoJson.h" "../ArduinoJson-$TAG.h" extras/scripts/build-single-header.sh "src/ArduinoJson.h" "../ArduinoJson-$TAG.h"
extras/scripts/build-single-header.sh "src/ArduinoJson.hpp" "../ArduinoJson-$TAG.hpp" extras/scripts/build-single-header.sh "src/ArduinoJson.hpp" "../ArduinoJson-$TAG.hpp"
extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h" > "../ArduinoJson-$TAG-wandbox.txt" extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h" > "../ArduinoJson-$TAG-wandbox.txt" || echo "Wandbox failed!"
extras/scripts/get-release-page.sh "$VERSION" "CHANGELOG.md" "../ArduinoJson-$TAG-wandbox.txt" > "../ArduinoJson-$TAG.md" extras/scripts/get-release-page.sh "$VERSION" "CHANGELOG.md" "../ArduinoJson-$TAG-wandbox.txt" > "../ArduinoJson-$TAG.md"
echo "You can now copy ../ArduinoJson-$TAG.md into arduinojson.org/collections/_versions/$VERSION.md" echo "You can now copy ../ArduinoJson-$TAG.md into arduinojson.org/collections/_versions/$VERSION.md"

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to generate a JSON document with ArduinoJson. // This example shows how to generate a JSON document with ArduinoJson.

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to deserialize a JSON document with ArduinoJson. // This example shows how to deserialize a JSON document with ArduinoJson.

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
// //
// This example shows how to generate a JSON document with ArduinoJson. // This example shows how to generate a JSON document with ArduinoJson.

@ -15,13 +15,13 @@ compile() {
"code":$(read_string "$FILE_PATH"), "code":$(read_string "$FILE_PATH"),
"codes": [{"file":"ArduinoJson.h","code":$(read_string "$ARDUINOJSON_H")}], "codes": [{"file":"ArduinoJson.h","code":$(read_string "$ARDUINOJSON_H")}],
"options": "warning", "options": "warning",
"compiler": "gcc-4.9.3", "compiler": "gcc-4.9.4",
"save": true "save": true
} }
END END
URL=$(curl -sS -H "Content-type: application/json" -d @parameters.json https://wandbox.org/api/compile.json | jq --raw-output .url) URL=$(curl -sS -H "Content-type: application/json" -d @parameters.json https://wandbox.org/api/compile.json | jq --raw-output .url)
rm parameters.json rm parameters.json
echo "$1: $URL" [ -n "$URL" ] && echo "$1: $URL"
} }
compile "JsonGeneratorExample" compile "JsonGeneratorExample"

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
set(CMAKE_CXX_STANDARD 98) set(CMAKE_CXX_STANDARD 98)

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
if("cxx_nullptr" IN_LIST CMAKE_CXX_COMPILE_FEATURES) if("cxx_nullptr" IN_LIST CMAKE_CXX_COMPILE_FEATURES)

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
if(MSVC_VERSION LESS 1910) if(MSVC_VERSION LESS 1910)

@ -8,7 +8,7 @@
#endif #endif
TEST_CASE("string_view") { TEST_CASE("string_view") {
StaticJsonDocument<128> doc; StaticJsonDocument<256> doc;
JsonVariant variant = doc.to<JsonVariant>(); JsonVariant variant = doc.to<JsonVariant>();
SECTION("deserializeJson()") { SECTION("deserializeJson()") {
@ -57,6 +57,12 @@ TEST_CASE("string_view") {
doc.add(std::string_view("example two", 7)); doc.add(std::string_view("example two", 7));
REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(2) + 8); REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(2) + 8);
doc.add(std::string_view("example\0tree", 12));
REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(3) + 21);
doc.add(std::string_view("example\0tree and a half", 12));
REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(4) + 21);
} }
SECTION("as<std::string_view>()") { SECTION("as<std::string_view>()") {
@ -72,6 +78,12 @@ TEST_CASE("string_view") {
REQUIRE(doc["s"].is<std::string_view>() == true); REQUIRE(doc["s"].is<std::string_view>() == true);
REQUIRE(doc["i"].is<std::string_view>() == false); REQUIRE(doc["i"].is<std::string_view>() == false);
} }
SECTION("String containing NUL") {
doc.set(std::string("hello\0world", 11));
REQUIRE(doc.as<std::string_view>().size() == 11);
REQUIRE(doc.as<std::string_view>() == std::string_view("hello\0world", 11));
}
} }
using ARDUINOJSON_NAMESPACE::adaptString; using ARDUINOJSON_NAMESPACE::adaptString;
@ -80,10 +92,9 @@ TEST_CASE("StringViewAdapter") {
std::string_view str("bravoXXX", 5); std::string_view str("bravoXXX", 5);
auto adapter = adaptString(str); auto adapter = adaptString(str);
CHECK(adapter.compare(NULL) > 0); CHECK(stringCompare(adapter, adaptString("alpha", 5)) > 0);
CHECK(adapter.compare("alpha") > 0); CHECK(stringCompare(adapter, adaptString("bravo", 5)) == 0);
CHECK(adapter.compare("bravo") == 0); CHECK(stringCompare(adapter, adaptString("charlie", 7)) < 0);
CHECK(adapter.compare("charlie") < 0);
CHECK(adapter.size() == 5); CHECK(adapter.size() == 5);
} }

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
if(MSVC_VERSION LESS 1910) if(MSVC_VERSION LESS 1910)

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
macro(build_should_fail target) macro(build_should_fail target)

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#define ARDUINOJSON_USE_LONG_LONG 0 #define ARDUINOJSON_USE_LONG_LONG 0

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#define ARDUINOJSON_USE_LONG_LONG 0 #define ARDUINOJSON_USE_LONG_LONG 0

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#pragma once #pragma once
@ -7,3 +7,6 @@
#include "api/Print.h" #include "api/Print.h"
#include "api/Stream.h" #include "api/Stream.h"
#include "api/String.h" #include "api/String.h"
#include "progmem_emulation.hpp"
#define ARDUINO_H_INCLUDED 1

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#pragma once #pragma once

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#pragma once #pragma once

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#pragma once #pragma once

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#pragma once #pragma once
@ -32,6 +32,17 @@ class String {
return _str == s; return _str == s;
} }
String& operator=(const char* s) {
_str.assign(s);
return *this;
}
char operator[](unsigned int index) const {
if (index >= _str.size())
return 0;
return _str[index];
}
friend std::ostream& operator<<(std::ostream& lhs, const ::String& rhs) { friend std::ostream& operator<<(std::ostream& lhs, const ::String& rhs) {
lhs << rhs._str; lhs << rhs._str;
return lhs; return lhs;

@ -1,9 +1,8 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <stdint.h> // uint8_t #include <stdint.h> // uint8_t
#include <string.h> // strcmp, strlen...
#define PROGMEM #define PROGMEM
@ -24,19 +23,7 @@ inline uint8_t pgm_read_byte(const void* p) {
return *reinterpret_cast<const uint8_t*>(convertFlashToPtr(p)); return *reinterpret_cast<const uint8_t*>(convertFlashToPtr(p));
} }
inline void* pgm_read_ptr(const void* p) { #define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \
return *reinterpret_cast<void* const*>(convertFlashToPtr(p));
}
inline float pgm_read_float(const void* p) {
return *reinterpret_cast<const float*>(convertFlashToPtr(p));
}
inline uint32_t pgm_read_dword(const void* p) {
return *reinterpret_cast<const uint32_t*>(convertFlashToPtr(p));
}
#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \
static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \ static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \
static type const* name = reinterpret_cast<type const*>( \ static type const* name = reinterpret_cast<type const*>( \
convertPtrToFlash(ARDUINOJSON_CONCAT2(name, _progmem))); convertPtrToFlash(ARDUINOJSON_CONCAT2(name, _progmem)));

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
add_executable(IntegrationTests add_executable(IntegrationTests

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
add_executable(JsonArrayTests add_executable(JsonArrayTests
@ -17,7 +17,7 @@ add_executable(JsonArrayTests
size.cpp size.cpp
std_string.cpp std_string.cpp
subscript.cpp subscript.cpp
undefined.cpp unbound.cpp
) )
add_test(JsonArray JsonArrayTests) add_test(JsonArray JsonArrayTests)

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -32,6 +32,56 @@ TEST_CASE("copyArray()") {
CHECK(std::string("[\"a\",\"b\",\"c\"]") == json); CHECK(std::string("[\"a\",\"b\",\"c\"]") == json);
} }
SECTION("const char*[] -> JsonArray") {
DynamicJsonDocument doc(4096);
JsonArray array = doc.to<JsonArray>();
char json[32];
const char* source[] = {"a", "b", "c"};
bool ok = copyArray(source, array);
CHECK(ok);
serializeJson(array, json);
CHECK(std::string("[\"a\",\"b\",\"c\"]") == json);
}
SECTION("const char[][] -> JsonArray") {
DynamicJsonDocument doc(4096);
JsonArray array = doc.to<JsonArray>();
char json[32];
char source[][2] = {"a", "b", "c"};
bool ok = copyArray(source, array);
CHECK(ok);
serializeJson(array, json);
CHECK(std::string("[\"a\",\"b\",\"c\"]") == json);
}
SECTION("const char[][] -> JsonDocument") {
DynamicJsonDocument doc(4096);
char json[32];
char source[][2] = {"a", "b", "c"};
bool ok = copyArray(source, doc);
CHECK(ok);
serializeJson(doc, json);
CHECK(std::string("[\"a\",\"b\",\"c\"]") == json);
}
SECTION("const char[][] -> MemberProxy") {
DynamicJsonDocument doc(4096);
char json[32];
char source[][2] = {"a", "b", "c"};
bool ok = copyArray(source, doc["data"]);
CHECK(ok);
serializeJson(doc, json);
CHECK(std::string("{\"data\":[\"a\",\"b\",\"c\"]}") == json);
}
SECTION("int[] -> JsonDocument") { SECTION("int[] -> JsonDocument") {
DynamicJsonDocument doc(4096); DynamicJsonDocument doc(4096);
char json[32]; char json[32];
@ -174,6 +224,23 @@ TEST_CASE("copyArray()") {
CHECK("" == destination[3]); CHECK("" == destination[3]);
} }
SECTION("JsonArray -> char[N][]") {
DynamicJsonDocument doc(4096);
char json[] = "[\"a12345\",\"b123456\",\"c1234567\"]";
DeserializationError err = deserializeJson(doc, json);
CHECK(err == DeserializationError::Ok);
JsonArray array = doc.as<JsonArray>();
char destination[4][8] = {{0}};
size_t result = copyArray(array, destination);
CHECK(3 == result);
CHECK(std::string("a12345") == destination[0]);
CHECK(std::string("b123456") == destination[1]);
CHECK(std::string("c123456") == destination[2]); // truncated
CHECK(std::string("") == destination[3]);
}
SECTION("JsonDocument -> int[]") { SECTION("JsonDocument -> int[]") {
DynamicJsonDocument doc(4096); DynamicJsonDocument doc(4096);
char json[] = "[1,2,3]"; char json[] = "[1,2,3]";

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -0,0 +1,35 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("Unbound JsonArray") {
JsonArray array;
SECTION("SubscriptFails") {
REQUIRE(array[0].isNull());
}
SECTION("AddFails") {
array.add(1);
REQUIRE(0 == array.size());
}
SECTION("CreateNestedArrayFails") {
REQUIRE(array.createNestedArray().isNull());
}
SECTION("CreateNestedObjectFails") {
REQUIRE(array.createNestedObject().isNull());
}
SECTION("PrintToWritesBrackets") {
char buffer[32];
serializeJson(array, buffer, sizeof(buffer));
REQUIRE_THAT(buffer, Equals("null"));
}
}

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
add_executable(JsonDeserializerTests add_executable(JsonDeserializerTests

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -11,14 +11,14 @@ void testStringification(DeserializationError error, std::string expected) {
void testBoolification(DeserializationError error, bool expected) { void testBoolification(DeserializationError error, bool expected) {
// DeserializationError on left-hand side // DeserializationError on left-hand side
CHECK(error == expected); CHECK(bool(error) == expected);
CHECK(error != !expected); CHECK(bool(error) != !expected);
CHECK(!error == !expected); CHECK(!bool(error) == !expected);
// DeserializationError on right-hand side // DeserializationError on right-hand side
CHECK(expected == error); CHECK(expected == bool(error));
CHECK(!expected != error); CHECK(!expected != bool(error));
CHECK(!expected == !error); CHECK(!expected == !bool(error));
} }
#define TEST_STRINGIFICATION(symbol) \ #define TEST_STRINGIFICATION(symbol) \
@ -70,34 +70,24 @@ TEST_CASE("DeserializationError") {
} }
} }
SECTION("Comparisons") { SECTION("Use in a condition") {
DeserializationError invalidInput(DeserializationError::InvalidInput); DeserializationError invalidInput(DeserializationError::InvalidInput);
DeserializationError ok(DeserializationError::Ok); DeserializationError ok(DeserializationError::Ok);
SECTION("DeserializationError == bool") { SECTION("if (!err)") {
REQUIRE(invalidInput == true); if (!invalidInput)
REQUIRE(ok == false); FAIL();
}
SECTION("bool == DeserializationError") {
REQUIRE(true == invalidInput);
REQUIRE(false == ok);
} }
SECTION("DeserializationError != bool") { SECTION("if (err)") {
REQUIRE(invalidInput != false); if (ok)
REQUIRE(ok != true); FAIL();
} }
SECTION("bool != DeserializationError") {
REQUIRE(false != invalidInput);
REQUIRE(true != ok);
} }
SECTION("Negations") { SECTION("Comparisons") {
REQUIRE(!invalidInput == false); DeserializationError invalidInput(DeserializationError::InvalidInput);
REQUIRE(!ok == true); DeserializationError ok(DeserializationError::Ok);
}
SECTION("DeserializationError == Code") { SECTION("DeserializationError == Code") {
REQUIRE(invalidInput == DeserializationError::InvalidInput); REQUIRE(invalidInput == DeserializationError::InvalidInput);

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#define ARDUINOJSON_ENABLE_COMMENTS 1 #define ARDUINOJSON_ENABLE_COMMENTS 1
@ -667,6 +667,20 @@ TEST_CASE("Filtering") {
} }
} }
TEST_CASE("Zero-copy mode") { // issue #1697
char input[] = "{\"include\":42,\"exclude\":666}";
StaticJsonDocument<256> filter;
filter["include"] = true;
StaticJsonDocument<256> doc;
DeserializationError err =
deserializeJson(doc, input, DeserializationOption::Filter(filter));
REQUIRE(err == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"include\":42}");
}
TEST_CASE("Overloads") { TEST_CASE("Overloads") {
StaticJsonDocument<256> doc; StaticJsonDocument<256> doc;
StaticJsonDocument<256> filter; StaticJsonDocument<256> filter;

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#define ARDUINOJSON_DECODE_UNICODE 1 #define ARDUINOJSON_DECODE_UNICODE 1

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#define ARDUINOJSON_DECODE_UNICODE 1 #define ARDUINOJSON_DECODE_UNICODE 1

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#define ARDUINOJSON_USE_LONG_LONG 0 #define ARDUINOJSON_USE_LONG_LONG 0

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -279,6 +279,22 @@ TEST_CASE("deserialize JSON object") {
REQUIRE(err == DeserializationError::Ok); REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc["a"] == 2); REQUIRE(doc["a"] == 2);
} }
SECTION("Repeated key with zero copy mode") { // issue #1697
char input[] = "{a:{b:{c:1}},a:2}";
DeserializationError err = deserializeJson(doc, input);
REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc["a"] == 2);
}
SECTION("NUL in keys") { // we don't support NULs in keys
DeserializationError err =
deserializeJson(doc, "{\"x\\u0000a\":1,\"x\\u0000b\":2}");
REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc.as<std::string>() == "{\"x\":2}");
}
} }
SECTION("Should clear the JsonObject") { SECTION("Should clear the JsonObject") {

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#define ARDUINOJSON_DECODE_UNICODE 1 #define ARDUINOJSON_DECODE_UNICODE 1
@ -60,9 +60,8 @@ TEST_CASE("\\u0000") {
CHECK(result[4] == 'z'); CHECK(result[4] == 'z');
CHECK(result[5] == 0); CHECK(result[5] == 0);
// ArduinoJson strings doesn't store string length, so the following returns 2 CHECK(doc.as<JsonString>().size() == 5);
// instead of 5 (issue #1646) CHECK(doc.as<std::string>().size() == 5);
CHECK(doc.as<std::string>().size() == 2);
} }
TEST_CASE("Truncated JSON string") { TEST_CASE("Truncated JSON string") {
@ -97,12 +96,37 @@ TEST_CASE("Not enough room to save the key") {
DynamicJsonDocument doc(JSON_OBJECT_SIZE(1) + 8); DynamicJsonDocument doc(JSON_OBJECT_SIZE(1) + 8);
SECTION("Quoted string") { SECTION("Quoted string") {
REQUIRE(deserializeJson(doc, "{\"example\":1}") ==
DeserializationError::Ok);
REQUIRE(deserializeJson(doc, "{\"accuracy\":1}") == REQUIRE(deserializeJson(doc, "{\"accuracy\":1}") ==
DeserializationError::NoMemory); DeserializationError::NoMemory);
REQUIRE(deserializeJson(doc, "{\"hello\":1,\"world\"}") ==
DeserializationError::NoMemory); // fails in the second string
} }
SECTION("Non-quoted string") { SECTION("Non-quoted string") {
REQUIRE(deserializeJson(doc, "{example:1}") == DeserializationError::Ok);
REQUIRE(deserializeJson(doc, "{accuracy:1}") == REQUIRE(deserializeJson(doc, "{accuracy:1}") ==
DeserializationError::NoMemory); DeserializationError::NoMemory);
REQUIRE(deserializeJson(doc, "{hello:1,world}") ==
DeserializationError::NoMemory); // fails in the second string
}
}
TEST_CASE("Empty memory pool") {
// NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI)
DynamicJsonDocument doc(0);
SECTION("Input is const char*") {
REQUIRE(deserializeJson(doc, "\"hello\"") ==
DeserializationError::NoMemory);
REQUIRE(deserializeJson(doc, "\"\"") == DeserializationError::NoMemory);
}
SECTION("Input is const char*") {
char hello[] = "\"hello\"";
REQUIRE(deserializeJson(doc, hello) == DeserializationError::Ok);
char empty[] = "\"hello\"";
REQUIRE(deserializeJson(doc, empty) == DeserializationError::Ok);
} }
} }

@ -1,14 +1,14 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <stdlib.h> // malloc, free #include <stdlib.h> // malloc, free
#include <catch.hpp> #include <catch.hpp>
#include <sstream> #include <sstream>
#include <utility>
using ARDUINOJSON_NAMESPACE::addPadding; using ARDUINOJSON_NAMESPACE::addPadding;
using ARDUINOJSON_NAMESPACE::move;
class SpyingAllocator { class SpyingAllocator {
public: public:
@ -78,7 +78,7 @@ TEST_CASE("BasicJsonDocument") {
BasicJsonDocument<SpyingAllocator> doc1(4096, log); BasicJsonDocument<SpyingAllocator> doc1(4096, log);
doc1.set(std::string("The size of this string is 32!!")); doc1.set(std::string("The size of this string is 32!!"));
BasicJsonDocument<SpyingAllocator> doc2(move(doc1)); BasicJsonDocument<SpyingAllocator> doc2(std::move(doc1));
REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!"); REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
REQUIRE(doc1.as<std::string>() == "null"); REQUIRE(doc1.as<std::string>() == "null");
@ -89,7 +89,7 @@ TEST_CASE("BasicJsonDocument") {
} }
#endif #endif
SECTION("Copy assign") { SECTION("Copy assign larger") {
{ {
BasicJsonDocument<SpyingAllocator> doc1(4096, log); BasicJsonDocument<SpyingAllocator> doc1(4096, log);
doc1.set(std::string("The size of this string is 32!!")); doc1.set(std::string("The size of this string is 32!!"));
@ -104,6 +104,36 @@ TEST_CASE("BasicJsonDocument") {
REQUIRE(log.str() == "A4096A8FA4096FF"); REQUIRE(log.str() == "A4096A8FA4096FF");
} }
SECTION("Copy assign smaller") {
{
BasicJsonDocument<SpyingAllocator> doc1(1024, log);
doc1.set(std::string("The size of this string is 32!!"));
BasicJsonDocument<SpyingAllocator> doc2(4096, log);
doc2 = doc1;
REQUIRE(doc1.as<std::string>() == "The size of this string is 32!!");
REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
REQUIRE(doc2.capacity() == 1024);
}
REQUIRE(log.str() == "A1024A4096FA1024FF");
}
SECTION("Copy assign same size") {
{
BasicJsonDocument<SpyingAllocator> doc1(1024, log);
doc1.set(std::string("The size of this string is 32!!"));
BasicJsonDocument<SpyingAllocator> doc2(1024, log);
doc2 = doc1;
REQUIRE(doc1.as<std::string>() == "The size of this string is 32!!");
REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
REQUIRE(doc2.capacity() == 1024);
}
REQUIRE(log.str() == "A1024A1024FF");
}
#if ARDUINOJSON_HAS_RVALUE_REFERENCES #if ARDUINOJSON_HAS_RVALUE_REFERENCES
SECTION("Move assign") { SECTION("Move assign") {
{ {
@ -111,7 +141,7 @@ TEST_CASE("BasicJsonDocument") {
doc1.set(std::string("The size of this string is 32!!")); doc1.set(std::string("The size of this string is 32!!"));
BasicJsonDocument<SpyingAllocator> doc2(8, log); BasicJsonDocument<SpyingAllocator> doc2(8, log);
doc2 = move(doc1); doc2 = std::move(doc1);
REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!"); REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
REQUIRE(doc1.as<std::string>() == "null"); REQUIRE(doc1.as<std::string>() == "null");

@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org # ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021 # Copyright © 2014-2022, Benoit BLANCHON
# MIT License # MIT License
add_executable(JsonDocumentTests add_executable(JsonDocumentTests
@ -19,6 +19,7 @@ add_executable(JsonDocumentTests
size.cpp size.cpp
StaticJsonDocument.cpp StaticJsonDocument.cpp
subscript.cpp subscript.cpp
swap.cpp
) )
add_test(JsonDocument JsonDocumentTests) add_test(JsonDocument JsonDocumentTests)

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -138,27 +138,26 @@ TEST_CASE("DynamicJsonDocument constructor") {
} }
TEST_CASE("DynamicJsonDocument assignment") { TEST_CASE("DynamicJsonDocument assignment") {
SECTION("Copy assignment preserves the buffer when capacity is sufficient") { SECTION("Copy assignment reallocates when capacity is smaller") {
DynamicJsonDocument doc1(1234); DynamicJsonDocument doc1(1234);
deserializeJson(doc1, "{\"hello\":\"world\"}"); deserializeJson(doc1, "{\"hello\":\"world\"}");
DynamicJsonDocument doc2(8);
DynamicJsonDocument doc2(doc1.capacity());
doc2 = doc1; doc2 = doc1;
REQUIRE_JSON(doc2, "{\"hello\":\"world\"}"); REQUIRE_JSON(doc2, "{\"hello\":\"world\"}");
REQUIRE(doc2.capacity() == doc1.capacity()); REQUIRE(doc2.capacity() == doc1.capacity());
} }
SECTION("Copy assignment realloc the buffer when capacity is insufficient") { SECTION("Copy assignment reallocates when capacity is larger") {
DynamicJsonDocument doc1(1234); DynamicJsonDocument doc1(100);
deserializeJson(doc1, "{\"hello\":\"world\"}"); deserializeJson(doc1, "{\"hello\":\"world\"}");
DynamicJsonDocument doc2(8); DynamicJsonDocument doc2(1234);
REQUIRE(doc2.capacity() < doc1.memoryUsage());
doc2 = doc1; doc2 = doc1;
REQUIRE(doc2.capacity() >= doc1.memoryUsage());
REQUIRE_JSON(doc2, "{\"hello\":\"world\"}"); REQUIRE_JSON(doc2, "{\"hello\":\"world\"}");
REQUIRE(doc2.capacity() == doc1.capacity());
} }
SECTION("Assign from StaticJsonDocument") { SECTION("Assign from StaticJsonDocument") {

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org // ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021 // Copyright © 2014-2022, Benoit BLANCHON
// MIT License // MIT License
#include <ArduinoJson.h> #include <ArduinoJson.h>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save