Audio plugin host https://kx.studio/carla
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.

ysfx_eel_utils.hpp 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2021 Jean Pierre Cimalando
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // SPDX-License-Identifier: Apache-2.0
  16. //
  17. #pragma once
  18. #include "WDL/eel2/ns-eel.h"
  19. #include "WDL/eel2/ns-eel-int.h"
  20. #include <type_traits>
  21. #include <cstdint>
  22. template <class T>
  23. inline typename std::enable_if<std::is_integral<T>::value, T>::type
  24. ysfx_eel_round(EEL_F value)
  25. {
  26. return (T)(value + (EEL_F)0.0001); // same one as used in eel2 everywhere
  27. }
  28. //------------------------------------------------------------------------------
  29. class ysfx_eel_ram_reader {
  30. public:
  31. ysfx_eel_ram_reader() = default;
  32. ysfx_eel_ram_reader(NSEEL_VMCTX vm, int64_t addr);
  33. EEL_F read_next();
  34. private:
  35. NSEEL_VMCTX m_vm{};
  36. int64_t m_addr = 0;
  37. const EEL_F *m_block = nullptr;
  38. uint32_t m_block_avail = 0;
  39. };
  40. //------------------------------------------------------------------------------
  41. class ysfx_eel_ram_writer {
  42. public:
  43. ysfx_eel_ram_writer() = default;
  44. ysfx_eel_ram_writer(NSEEL_VMCTX vm, int64_t addr);
  45. bool write_next(EEL_F value);
  46. private:
  47. NSEEL_VMCTX m_vm{};
  48. int64_t m_addr = 0;
  49. EEL_F *m_block = nullptr;
  50. uint32_t m_block_avail = 0;
  51. };