From 216a6667fe3174943efadb137a70113075fbe399 Mon Sep 17 00:00:00 2001 From: patrick-radius Date: Sat, 31 Dec 2016 13:04:38 +0100 Subject: [PATCH 1/3] Added float audio multiply --- AudioMultiply_F32.cpp | 20 ++++++++++++++++++++ AudioMultiply_F32.h | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 AudioMultiply_F32.cpp create mode 100644 AudioMultiply_F32.h diff --git a/AudioMultiply_F32.cpp b/AudioMultiply_F32.cpp new file mode 100644 index 0000000..edca399 --- /dev/null +++ b/AudioMultiply_F32.cpp @@ -0,0 +1,20 @@ +#include "AudioMultiply_F32.h" + +void AudioMultiply_F32::update(void) { + audio_block_f32_t *block, *in; + + block = AudioStream_F32::receiveWritable_f32(0); + if (!block) return; + + in = AudioStream_F32::receiveReadOnly_f32(1); + if (!in) { + release(block); + return; + } + + arm_mult_f32(block->data, in->data, block->data, AUDIO_BLOCK_SAMPLES); + release(in); + + transmit(block); + release(block); +} diff --git a/AudioMultiply_F32.h b/AudioMultiply_F32.h new file mode 100644 index 0000000..08a2584 --- /dev/null +++ b/AudioMultiply_F32.h @@ -0,0 +1,12 @@ +#include +#include + +class AudioMultiply_F32 : public AudioStream_F32 +{ + public: + AudioMultiply_F32(void) : AudioStream_F32(2, inputQueueArray_f32) {}; + void update(void); + + private: + audio_block_f32_t *inputQueueArray_f32[2]; +}; From 211ee7a7a3c7fb6e4f7759e16101ce3ab52b7fd2 Mon Sep 17 00:00:00 2001 From: Patrick Radius Date: Mon, 2 Jan 2017 10:14:16 +0100 Subject: [PATCH 2/3] Added license header --- AudioMultiply_F32.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AudioMultiply_F32.h b/AudioMultiply_F32.h index 08a2584..55988ec 100644 --- a/AudioMultiply_F32.h +++ b/AudioMultiply_F32.h @@ -1,3 +1,15 @@ +/* + * AudioEffectsGain + * + * Created: Patrick Radius, December 2016 + * Purpose: Multiply two channels of audio data. Can be used for example as 'vca' or amplitude modulation. + * Assumes floating-point data. + * + * This processes a single stream fo audio data (ie, it is mono) + * + * MIT License. use at your own risk. +*/ + #include #include From 0476e187a318da2aaa431aac3054f65c3dfa2e0e Mon Sep 17 00:00:00 2001 From: Patrick Radius Date: Mon, 2 Jan 2017 10:25:47 +0100 Subject: [PATCH 3/3] Update AudioMultiply_F32.h Oops, forgot to edit the title in the comment. Also added guard block so there will be no problem including it in multiple places (i guess all .h files should have this) --- AudioMultiply_F32.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AudioMultiply_F32.h b/AudioMultiply_F32.h index 55988ec..aeaf284 100644 --- a/AudioMultiply_F32.h +++ b/AudioMultiply_F32.h @@ -1,5 +1,5 @@ /* - * AudioEffectsGain + * AudioMultiply * * Created: Patrick Radius, December 2016 * Purpose: Multiply two channels of audio data. Can be used for example as 'vca' or amplitude modulation. @@ -9,6 +9,8 @@ * * MIT License. use at your own risk. */ +#ifndef AUDIOMULTIPLYF32_H +#define AUDIOMULTIPLYF32_H #include #include @@ -22,3 +24,5 @@ class AudioMultiply_F32 : public AudioStream_F32 private: audio_block_f32_t *inputQueueArray_f32[2]; }; + +#endif