You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.1KB

  1. // Copyright 2016 Olivier Gillet.
  2. //
  3. // Author: Olivier Gillet (ol.gillet@gmail.com)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. // See http://creativecommons.org/licenses/MIT/ for more information.
  24. //
  25. // -----------------------------------------------------------------------------
  26. //
  27. // Settings storage.
  28. #include "plaits/settings.h"
  29. #include <algorithm>
  30. #include "stmlib/system/storage.h"
  31. namespace plaits {
  32. using namespace std;
  33. bool Settings::Init() {
  34. ChannelCalibrationData* c = persistent_data_.channel_calibration_data;
  35. c[CV_ADC_CHANNEL_MODEL].offset = 0.025f;
  36. c[CV_ADC_CHANNEL_MODEL].scale = -1.03f;
  37. c[CV_ADC_CHANNEL_MODEL].normalization_detection_threshold = 0;
  38. c[CV_ADC_CHANNEL_V_OCT].offset = 25.71;
  39. c[CV_ADC_CHANNEL_V_OCT].scale = -60.0f;
  40. c[CV_ADC_CHANNEL_V_OCT].normalization_detection_threshold = 0;
  41. c[CV_ADC_CHANNEL_FM].offset = 0.0f;
  42. c[CV_ADC_CHANNEL_FM].scale = -60.0f;
  43. c[CV_ADC_CHANNEL_FM].normalization_detection_threshold = -2945;
  44. c[CV_ADC_CHANNEL_HARMONICS].offset = 0.0f;
  45. c[CV_ADC_CHANNEL_HARMONICS].scale = -1.0f;
  46. c[CV_ADC_CHANNEL_HARMONICS].normalization_detection_threshold = 0;
  47. c[CV_ADC_CHANNEL_TIMBRE].offset = 0.0f;
  48. c[CV_ADC_CHANNEL_TIMBRE].scale = -1.6f;
  49. c[CV_ADC_CHANNEL_TIMBRE].normalization_detection_threshold = -2945;
  50. c[CV_ADC_CHANNEL_MORPH].offset = 0.0f;
  51. c[CV_ADC_CHANNEL_MORPH].scale = -1.6f;
  52. c[CV_ADC_CHANNEL_MORPH].normalization_detection_threshold = -2945;
  53. c[CV_ADC_CHANNEL_TRIGGER].offset = 0.4f;
  54. c[CV_ADC_CHANNEL_TRIGGER].scale = -0.6f;
  55. c[CV_ADC_CHANNEL_TRIGGER].normalization_detection_threshold = 13663;
  56. c[CV_ADC_CHANNEL_LEVEL].offset = 0.49f;
  57. c[CV_ADC_CHANNEL_LEVEL].scale = -0.6f;
  58. c[CV_ADC_CHANNEL_LEVEL].normalization_detection_threshold = 21403;
  59. state_.engine = 0;
  60. state_.lpg_colour = 0;
  61. state_.decay = 128;
  62. state_.octave = 255;
  63. state_.color_blind = 0;
  64. bool success = chunk_storage_.Init(&persistent_data_, &state_);
  65. CONSTRAIN(state_.engine, 0, 15);
  66. return success;
  67. }
  68. void Settings::SavePersistentData() {
  69. chunk_storage_.SavePersistentData();
  70. }
  71. void Settings::SaveState() {
  72. chunk_storage_.SaveState();
  73. }
  74. } // namespace plaits