PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

91 行
3.0KB

  1. /* Audio Library for Teensy 3.X
  2. * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com
  3. *
  4. * Development of this audio library was funded by PJRC.COM, LLC by sales of
  5. * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
  6. * open source software by purchasing Teensy or other PJRC products.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice, development funding notice, and this permission
  16. * notice shall be included in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #include <Arduino.h>
  27. #include "effect_multiply.h"
  28. void AudioEffectMultiply::update(void)
  29. {
  30. #if defined(__ARM_ARCH_7EM__)
  31. audio_block_t *blocka, *blockb;
  32. uint32_t *pa, *pb, *end;
  33. uint32_t a12, a34; //, a56, a78;
  34. uint32_t b12, b34; //, b56, b78;
  35. blocka = receiveWritable(0);
  36. blockb = receiveReadOnly(1);
  37. if (!blocka) {
  38. if (blockb) release(blockb);
  39. return;
  40. }
  41. if (!blockb) {
  42. release(blocka);
  43. return;
  44. }
  45. pa = (uint32_t *)(blocka->data);
  46. pb = (uint32_t *)(blockb->data);
  47. end = pa + AUDIO_BLOCK_SAMPLES/2;
  48. while (pa < end) {
  49. a12 = *pa;
  50. a34 = *(pa+1);
  51. //a56 = *(pa+2); // 8 samples/loop should work, but crashes.
  52. //a78 = *(pa+3); // why?! maybe a compiler bug??
  53. b12 = *pb++;
  54. b34 = *pb++;
  55. //b56 = *pb++;
  56. //b78 = *pb++;
  57. a12 = pack_16b_16b(
  58. signed_saturate_rshift(multiply_16tx16t(a12, b12), 16, 15),
  59. signed_saturate_rshift(multiply_16bx16b(a12, b12), 16, 15));
  60. a34 = pack_16b_16b(
  61. signed_saturate_rshift(multiply_16tx16t(a34, b34), 16, 15),
  62. signed_saturate_rshift(multiply_16bx16b(a34, b34), 16, 15));
  63. //a56 = pack_16b_16b(
  64. // signed_saturate_rshift(multiply_16tx16t(a56, b56), 16, 15),
  65. // signed_saturate_rshift(multiply_16bx16b(a56, b56), 16, 15));
  66. //a78 = pack_16b_16b(
  67. // signed_saturate_rshift(multiply_16tx16t(a78, b78), 16, 15),
  68. // signed_saturate_rshift(multiply_16bx16b(a78, b78), 16, 15));
  69. *pa++ = a12;
  70. *pa++ = a34;
  71. //*pa++ = a56;
  72. //*pa++ = a78;
  73. }
  74. transmit(blocka);
  75. release(blocka);
  76. release(blockb);
  77. #elif defined(KINETISL)
  78. audio_block_t *block;
  79. block = receiveReadOnly(0);
  80. if (block) release(block);
  81. block = receiveReadOnly(1);
  82. if (block) release(block);
  83. #endif
  84. }