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.cpp 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "ysfx_eel_utils.hpp"
  18. ysfx_eel_ram_reader::ysfx_eel_ram_reader(NSEEL_VMCTX vm, int64_t addr)
  19. : m_vm(vm),
  20. m_addr(addr)
  21. {
  22. }
  23. EEL_F ysfx_eel_ram_reader::read_next()
  24. {
  25. if (m_block_avail == 0) {
  26. m_block = (m_addr < 0 || m_addr > 0xFFFFFFFFu) ? nullptr :
  27. NSEEL_VM_getramptr_noalloc(m_vm, (uint32_t)m_addr, (int32_t *)&m_block_avail);
  28. if (m_block)
  29. m_addr += m_block_avail;
  30. else {
  31. m_addr += 1;
  32. m_block_avail = 1;
  33. }
  34. }
  35. EEL_F value = m_block ? *m_block++ : 0;
  36. m_block_avail -= 1;
  37. return value;
  38. }
  39. //------------------------------------------------------------------------------
  40. ysfx_eel_ram_writer::ysfx_eel_ram_writer(NSEEL_VMCTX vm, int64_t addr)
  41. : m_vm(vm),
  42. m_addr(addr)
  43. {
  44. }
  45. bool ysfx_eel_ram_writer::write_next(EEL_F value)
  46. {
  47. if (m_block_avail == 0) {
  48. m_block = (m_addr < 0 || m_addr > 0xFFFFFFFFu) ? nullptr :
  49. NSEEL_VM_getramptr(m_vm, (uint32_t)m_addr, (int32_t *)&m_block_avail);
  50. if (m_block)
  51. m_addr += m_block_avail;
  52. else {
  53. m_addr += 1;
  54. m_block_avail = 1;
  55. }
  56. }
  57. if (m_block)
  58. *m_block++ = value;
  59. m_block_avail -= 1;
  60. return true;
  61. }