PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

81 行
2.3KB

  1. /*
  2. * Copyright (c) 2018 John-Michael Reed
  3. * bleeplabs.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 all
  13. * 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 THE
  21. * SOFTWARE.
  22. */
  23. // Combine analog signals with bitwise expressions like XOR.
  24. // Combining two simple oscillators results in interesting new waveforms,
  25. // Combining white noise or dynamic incoming audio results in aggressive digital distortion.
  26. #include <Arduino.h>
  27. #include "effect_combine.h"
  28. void AudioEffectDigitalCombine::update(void)
  29. {
  30. audio_block_t *blocka, *blockb;
  31. uint32_t *pa, *pb, *end;
  32. uint32_t a12, a34; //, a56, a78;
  33. uint32_t b12, b34; //, b56, b78;
  34. blocka = receiveWritable(0);
  35. blockb = receiveReadOnly(1);
  36. if (!blocka) {
  37. if (blockb) release(blockb);
  38. return;
  39. }
  40. if (!blockb) {
  41. release(blocka);
  42. return;
  43. }
  44. pa = (uint32_t *)(blocka->data);
  45. pb = (uint32_t *)(blockb->data);
  46. end = pa + AUDIO_BLOCK_SAMPLES / 2;
  47. while (pa < end) {
  48. a12 = *pa;
  49. a34 = *(pa + 1);
  50. b12 = *pb++;
  51. b34 = *pb++;
  52. if (mode_sel == OR) {
  53. a12 = a12 | b12;
  54. a34 = a34 | b34;
  55. }
  56. if (mode_sel == XOR) {
  57. a12 = a12 ^ b12;
  58. a34 = a34 ^ b34;
  59. }
  60. if (mode_sel == AND) {
  61. a12 = a12 & b12;
  62. a34 = a34 & b34;
  63. }
  64. if (mode_sel == MODULO) {
  65. a12 = a12 % b12;
  66. a34 = a34 % b34;
  67. }
  68. *pa++ = a12;
  69. *pa++ = a34;
  70. }
  71. transmit(blocka);
  72. release(blocka);
  73. release(blockb);
  74. }