| 27 | #include "effect_multiply.h" |
| 28 | |
| 29 | void AudioEffectMultiply::update(void) |
| 30 | { |
| 31 | #if defined(KINETISK) |
| 32 | audio_block_t *blocka, *blockb; |
| 33 | uint32_t *pa, *pb, *end; |
| 34 | uint32_t a12, a34; //, a56, a78; |
| 35 | uint32_t b12, b34; //, b56, b78; |
| 36 | |
| 37 | blocka = receiveWritable(0); |
| 38 | blockb = receiveReadOnly(1); |
| 39 | if (!blocka) { |
| 40 | if (blockb) release(blockb); |
| 41 | return; |
| 42 | } |
| 43 | if (!blockb) { |
| 44 | release(blocka); |
| 45 | return; |
| 46 | } |
| 47 | pa = (uint32_t *)(blocka->data); |
| 48 | pb = (uint32_t *)(blockb->data); |
| 49 | end = pa + AUDIO_BLOCK_SAMPLES/2; |
| 50 | while (pa < end) { |
| 51 | a12 = *pa; |
| 52 | a34 = *(pa+1); |
| 53 | //a56 = *(pa+2); // 8 samples/loop should work, but crashes. |
| 54 | //a78 = *(pa+3); // why?! maybe a compiler bug?? |
| 55 | b12 = *pb++; |
| 56 | b34 = *pb++; |
| 57 | //b56 = *pb++; |
| 58 | //b78 = *pb++; |
| 59 | a12 = pack_16b_16b( |
| 60 | signed_saturate_rshift(multiply_16tx16t(a12, b12), 16, 15), |
| 61 | signed_saturate_rshift(multiply_16bx16b(a12, b12), 16, 15)); |
| 62 | a34 = pack_16b_16b( |
| 63 | signed_saturate_rshift(multiply_16tx16t(a34, b34), 16, 15), |
| 64 | signed_saturate_rshift(multiply_16bx16b(a34, b34), 16, 15)); |
| 65 | //a56 = pack_16b_16b( |
| 66 | // signed_saturate_rshift(multiply_16tx16t(a56, b56), 16, 15), |
| 67 | // signed_saturate_rshift(multiply_16bx16b(a56, b56), 16, 15)); |
| 68 | //a78 = pack_16b_16b( |
| 69 | // signed_saturate_rshift(multiply_16tx16t(a78, b78), 16, 15), |
| 70 | // signed_saturate_rshift(multiply_16bx16b(a78, b78), 16, 15)); |
| 71 | *pa++ = a12; |
| 72 | *pa++ = a34; |
| 73 | //*pa++ = a56; |
| 74 | //*pa++ = a78; |
| 75 | } |
| 76 | transmit(blocka); |
| 77 | release(blocka); |
| 78 | release(blockb); |
| 79 | |
| 80 | #elif defined(KINETISL) |
| 81 | audio_block_t *block; |
| 82 | |
| 83 | block = receiveReadOnly(0); |
| 84 | if (block) release(block); |
| 85 | block = receiveReadOnly(1); |
| 86 | if (block) release(block); |
nothing calls this directly
no test coverage detected