parent
2541535f11
commit
92442b5699
@ -0,0 +1,13 @@ |
|||||||
|
#include "AudioMathConstant_F32.h" |
||||||
|
|
||||||
|
void AudioMathConstant_F32::update(void) { |
||||||
|
audio_block_f32_t *block; |
||||||
|
|
||||||
|
block = AudioStream_F32::allocate_f32(); |
||||||
|
if (!block) return; |
||||||
|
|
||||||
|
for(int i=0; i<128; i++) |
||||||
|
block->data[i] = constant; |
||||||
|
AudioStream_F32::transmit(block); |
||||||
|
AudioStream_F32::release(block); |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
/*
|
||||||
|
* AudioMathConstant_F32 |
||||||
|
* |
||||||
|
* Created: Bob Larkin, March 2023 |
||||||
|
* Purpose: Outputs a block of floating point numbers, all the same. |
||||||
|
* Default value is 0.0f |
||||||
|
* |
||||||
|
* This outputs a single, constant stream of audio data (ie, it is mono) |
||||||
|
* |
||||||
|
* MIT License. use at your own risk. |
||||||
|
*/ |
||||||
|
#ifndef _AudioMathConstant_F32_H |
||||||
|
#define _AudioMathConstant_F32_H |
||||||
|
|
||||||
|
#include "AudioStream_F32.h" |
||||||
|
|
||||||
|
class AudioMathConstant_F32 : public AudioStream_F32 |
||||||
|
{ |
||||||
|
//GUI: inputs:0, outputs:1 //this line used for automatic generation of GUI node
|
||||||
|
public: |
||||||
|
AudioMathConstant_F32(void) : AudioStream_F32(0, NULL) {}; |
||||||
|
AudioMathConstant_F32(const AudioSettings_F32 &settings) : AudioStream_F32(0, NULL) { |
||||||
|
sample_rate_Hz = settings.sample_rate_Hz; |
||||||
|
block_size = settings.audio_block_samples; |
||||||
|
}; |
||||||
|
|
||||||
|
void setConstant(float32_t _constant) { constant = _constant; } |
||||||
|
|
||||||
|
virtual void update(void); |
||||||
|
|
||||||
|
private: |
||||||
|
float sample_rate_Hz = AUDIO_SAMPLE_RATE; |
||||||
|
uint16_t block_size = AUDIO_BLOCK_SAMPLES; |
||||||
|
float32_t constant = 0.0f; |
||||||
|
}; |
||||||
|
#endif |
Loading…
Reference in new issue