Skip to content

Commit 90f96d3

Browse files
committed
AudioFaust use generic Print for output
1 parent a652a73 commit 90f96d3

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

src/AudioLibs/AudioFaust.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FaustStream : public AudioStreamX {
2020
}
2121

2222
/// Constructor for Faust as Singal Processor - changing an input signal and sending it to out
23-
FaustStream(AudioStream &out, bool useSeparateOutputBuffer=true){
23+
FaustStream(Print &out, bool useSeparateOutputBuffer=true){
2424
p_out = &out;
2525
with_output_buffer = useSeparateOutputBuffer;
2626
}
@@ -218,7 +218,7 @@ class FaustStream : public AudioStreamX {
218218
int buffer_allocated;
219219
DSP *p_dsp = nullptr;
220220
AudioBaseInfo cfg;
221-
AudioStream *p_out=nullptr;
221+
Print *p_out=nullptr;
222222
FAUSTFLOAT** p_buffer=nullptr;
223223
FAUSTFLOAT** p_buffer_out=nullptr;
224224
UI ui;

src/AudioLibs/AudioSTK.h

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
#pragma once
22

33
#include "AudioConfig.h"
4-
#ifdef USE_STK
54

65
#include "Arduino.h"
76
#include "freertos/FreeRTOS.h"
8-
#include "Stk.h"
9-
#include "Voicer.h"
10-
#include "Instrmnt.h"
7+
#include "StkAll.h"
118

129
namespace audio_tools {
1310

@@ -28,6 +25,8 @@ namespace audio_tools {
2825
template <class T>
2926
class STKGenerator : public SoundGenerator<T> {
3027
public:
28+
STKGenerator() = default;
29+
3130
// Creates an STKGenerator for an instrument
3231
STKGenerator(stk::Instrmnt &instrument) : SoundGenerator<T>() {
3332
this->p_instrument = &instrument;
@@ -38,6 +37,14 @@ class STKGenerator : public SoundGenerator<T> {
3837
this->p_voicer = &voicer;
3938
}
4039

40+
void setInput(stk::Instrmnt &instrument){
41+
this->p_instrument = &instrument;
42+
}
43+
44+
void setInput(stk::Voicer &voicer){
45+
this->p_voicer = &voicer;
46+
}
47+
4148
/// provides the default configuration
4249
AudioBaseInfo defaultConfig() {
4350
AudioBaseInfo info;
@@ -48,12 +55,13 @@ class STKGenerator : public SoundGenerator<T> {
4855
}
4956

5057
/// Starts the processing
51-
void begin(AudioBaseInfo cfg){
58+
bool begin(AudioBaseInfo cfg){
5259
LOGI(LOG_METHOD);
5360
cfg.logInfo();
5461
SoundGenerator<T>::begin(cfg);
5562
max_value = NumberConverter::maxValue(sizeof(T)*8);
5663
stk::Stk::setSampleRate(SoundGenerator<T>::info.sample_rate);
64+
return true;
5765
}
5866

5967
/// Provides a single sample
@@ -74,7 +82,27 @@ class STKGenerator : public SoundGenerator<T> {
7482

7583
};
7684

85+
/**
86+
* @brief STK Stream for Instrument or Voicer
87+
*
88+
* @tparam T
89+
*/
90+
template <class T>
91+
class STKStream : public GeneratedSoundStream<T> {
92+
public:
93+
STKStream(Instrmnt &instrument){
94+
generator.setInput(instrument);
95+
GeneratedSoundStream<T>::setInput(generator);
96+
}
97+
STKStream(Voicer &voicer){
98+
generator.setInput(voicer);
99+
GeneratedSoundStream<T>::setInput(generator);
100+
}
101+
protected:
102+
STKGenerator<T> generator;
103+
104+
};
105+
77106

78107
}
79108

80-
#endif

0 commit comments

Comments
 (0)