arduino-audio-tools
Loading...
Searching...
No Matches
FaustStream< DSP > Class Template Reference

Integration into Faust DSP see https://faust.grame.fr/ To generate code from faust, select src and cpp. More...

#include <AudioFaust.h>

Inheritance diagram for FaustStream< DSP >:
AudioStream BaseStream AudioInfoSupport AudioInfoSource BaseStream AudioInfoSupport AudioInfoSource Stream Stream Stream Stream Print Print Print Print Print Print Print Print

Public Member Functions

 FaustStream (bool useSeparateOutputBuffer=true)
 Constructor for Faust as Audio Source.
 FaustStream (Print &out, bool useSeparateOutputBuffer=true)
 Constructor for Faust as signal Processor - changing an input signal and sending it to out.
 ~FaustStream ()
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfoOut ()
virtual AudioInfo audioInfoOut ()
int available () override
int availableForWrite () override
virtual bool begin ()
bool begin (AudioInfo cfg)
 Checks the parameters and starts the processing.
virtual float bend ()
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
AudioInfo defaultConfig ()
void end ()
 Ends the processing.
virtual void flush () override
virtual void flush () override
virtual float frequency ()
virtual float gain ()
dsp * getDSP ()
 Provides a pointer to the actual dsp object.
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
virtual float labelValue (const char *label)
 Determines the value of a parameter.
virtual bool midiOff (int note)
virtual bool midiOn (int note, float gain)
virtual operator bool ()
virtual operator bool ()
size_t readBytes (uint8_t *data, size_t len) override
 Used if FaustStream is used as audio source.
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
virtual bool setBend (float bend)
virtual bool setFrequency (float freq)
virtual bool setGain (float gain)
virtual bool setLabelValue (const char *label, float value)
 Defines the value of a parameter.
virtual bool setMidiNote (int note)
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active).
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active).
void setWriteBufferSize (int size)
void setWriteBufferSize (int size)
virtual size_t write (uint8_t ch) override
size_t write (const uint8_t *data, size_t len) override
 Used if FaustStream is used as audio sink or filter.
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).

Protected Member Functions

void allocateFloatBuffer (int samples, bool allocate_out)
 Allocate the buffer that is needed by faust.
bool checkChannels ()
 Checks the input and output channels and updates the is_write or is_read scenario flags.
template<class T>
void convertFloatBufferToInt (int samples, float **p_float_in, void *data_out)
 Converts the float buffer to int values.
template<class T>
void convertIntBufferToFloat (int samples, void *data_in, float **p_float_out)
 Converts the int buffer to float values.
void deleteFloatBuffer ()
virtual int not_supported (int out, const char *msg="")
virtual int not_supported (int out, const char *msg="")
float noteToFrequency (uint8_t x)
void notifyAudioChange (AudioInfo info)
void notifyAudioChange (AudioInfo info)
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().
template<class T>
size_t writeT (const uint8_t *write_data, size_t len)
 Used if FaustStream is used as audio sink or filter.

Protected Attributes

int _timeout = 10
int buffer_allocated
int bytes_per_frame
int bytes_per_sample
AudioInfo cfg
float float_to_int_factor = 32767
bool gate_exists = false
AudioInfo info
bool is_init = false
bool is_notify_active = true
bool is_read = false
bool is_write = false
Vector< AudioInfoSupport * > notify_vector
float ** p_buffer =nullptr
float ** p_buffer_out =nullptr
DSP * p_dsp = nullptr
Print * p_out =nullptr
RingBuffer< uint8_t > tmp_in {0}
RingBuffer< uint8_t > tmp_out {0}
UI ui
bool with_output_buffer
int write_buffer_size = 8

Detailed Description

template<class DSP>
class audio_tools::FaustStream< DSP >

Integration into Faust DSP see https://faust.grame.fr/ To generate code from faust, select src and cpp.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ FaustStream() [1/2]

template<class DSP>
FaustStream ( bool useSeparateOutputBuffer = true)
inline

Constructor for Faust as Audio Source.

◆ FaustStream() [2/2]

template<class DSP>
FaustStream ( Print & out,
bool useSeparateOutputBuffer = true )
inline

Constructor for Faust as signal Processor - changing an input signal and sending it to out.

◆ ~FaustStream()

template<class DSP>
~FaustStream ( )
inline

Member Function Documentation

◆ addNotifyAudioChange() [1/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ addNotifyAudioChange() [2/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ allocateFloatBuffer()

template<class DSP>
void allocateFloatBuffer ( int samples,
bool allocate_out )
inlineprotected

Allocate the buffer that is needed by faust.

◆ audioInfo() [1/2]

◆ audioInfo() [2/2]

◆ audioInfoOut() [1/2]

◆ audioInfoOut() [2/2]

◆ available()

template<class DSP>
int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

template<class DSP>
int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [1/2]

virtual bool begin ( )
inlinevirtualinherited

Reimplemented in AdapterAudioOutputToAudioStream, AdaptiveResamplingStream, AnalogAudioStream, AdapterAudioOutputToAudioStream, AudioInputMonitor, AudioInputMonitor, AudioStreamWrapper, AudioStreamWrapper, AudioTimeSourceStream, CallbackStream, CallbackStream, CatStream, CatStream, DynamicMemoryStream, DynamicMemoryStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, MemoryStream, MemoryStream, ProgressStream, ProgressStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, Throttle, Throttle, TimedStream, TimerCallbackAudioStream, TimerCallbackAudioStream, VolumeMeter, VolumeMeter, AudioBoardStream, AudioEffectStream, AudioEffectStreamT< T >, AudioFFTBase, AudioInputMonitor, AudioKitStream, AudioLoRa, AudioMP34DT05, AudioOutputWithCallback, AudioStreamWrapper, AudioTimeSourceStream, AutomaticGainControlStream, CallbackStream, CatStream, ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, DynamicMemoryStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, ESPNowStream, FileLoopT< FileType >, FileLoopT< File >, FilteredStream< T, TF >, FormatConverterStream, FrequencyDetectorAutoCorrelation, GeneratedSoundStream< T >, GoertzelStream, HLSStreamT< URLStream >, HLSStreamT< URLStreamESP32 >, I2SCodecStream, I2SStream, InputMerge< T >, MeasuringStream, MemoryStream, MiniAudioStream, MozziStream, NRF24Stream, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, Pipeline, Pipeline::ModifyingStreamAdapter, PortAudioStream, ProgressStream, PureDataStream, QualityAnalysisStream, QueueStream< T >, ResampleStream, ResampleStreamT< TInterpolator >, SPDIFOutput, StdioStream, SupportedRatesStream, Throttle, TimedStream, TimerCallbackAudioStream, USBAudioDeviceBase, USBAudioHostBase, VBANStream, VolumeMeter, VolumeStream, VS1053Stream, and WM8960Stream.

◆ begin() [2/2]

template<class DSP>
bool begin ( AudioInfo cfg)
inline

Checks the parameters and starts the processing.

◆ bend()

template<class DSP>
virtual float bend ( )
inlinevirtual

◆ checkChannels()

template<class DSP>
bool checkChannels ( )
inlineprotected

Checks the input and output channels and updates the is_write or is_read scenario flags.

◆ clearNotifyAudioChange() [1/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ clearNotifyAudioChange() [2/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ convertFloatBufferToInt()

template<class DSP>
template<class T>
void convertFloatBufferToInt ( int samples,
float ** p_float_in,
void * data_out )
inlineprotected

Converts the float buffer to int values.

◆ convertIntBufferToFloat()

template<class DSP>
template<class T>
void convertIntBufferToFloat ( int samples,
void * data_in,
float ** p_float_out )
inlineprotected

Converts the int buffer to float values.

◆ defaultConfig()

template<class DSP>
AudioInfo defaultConfig ( )
inline

◆ deleteFloatBuffer()

template<class DSP>
void deleteFloatBuffer ( )
inlineprotected

◆ end()

template<class DSP>
void end ( )
inlinevirtual

Ends the processing.

Reimplemented from BaseStream.

◆ flush() [1/2]

◆ flush() [2/2]

◆ frequency()

template<class DSP>
virtual float frequency ( )
inlinevirtual

◆ gain()

template<class DSP>
virtual float gain ( )
inlinevirtual

◆ getDSP()

template<class DSP>
dsp * getDSP ( )
inline

Provides a pointer to the actual dsp object.

◆ isNotifyActive() [1/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isNotifyActive() [2/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ labelValue()

template<class DSP>
virtual float labelValue ( const char * label)
inlinevirtual

Determines the value of a parameter.

◆ midiOff()

template<class DSP>
virtual bool midiOff ( int note)
inlinevirtual

◆ midiOn()

template<class DSP>
virtual bool midiOn ( int note,
float gain )
inlinevirtual

◆ not_supported() [1/2]

virtual int not_supported ( int out,
const char * msg = "" )
inlineprotectedvirtualinherited

◆ not_supported() [2/2]

virtual int not_supported ( int out,
const char * msg = "" )
inlineprotectedvirtualinherited

◆ noteToFrequency()

template<class DSP>
float noteToFrequency ( uint8_t x)
inlineprotected

◆ notifyAudioChange() [1/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ notifyAudioChange() [2/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ operator bool() [1/2]

◆ operator bool() [2/2]

◆ readBytes()

template<class DSP>
size_t readBytes ( uint8_t * data,
size_t len )
inlineoverridevirtual

Used if FaustStream is used as audio source.

Reimplemented from AudioStream.

◆ readSilence() [1/2]

virtual size_t readSilence ( uint8_t * buffer,
size_t length )
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ readSilence() [2/2]

virtual size_t readSilence ( uint8_t * buffer,
size_t length )
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ refillReadBuffer() [1/2]

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

◆ refillReadBuffer() [2/2]

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

◆ removeNotifyAudioChange() [1/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

◆ removeNotifyAudioChange() [2/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

◆ setAudioInfo() [1/2]

◆ setAudioInfo() [2/2]

◆ setBend()

template<class DSP>
virtual bool setBend ( float bend)
inlinevirtual

◆ setFrequency()

template<class DSP>
virtual bool setFrequency ( float freq)
inlinevirtual

◆ setGain()

template<class DSP>
virtual bool setGain ( float gain)
inlinevirtual

◆ setLabelValue()

template<class DSP>
virtual bool setLabelValue ( const char * label,
float value )
inlinevirtual

Defines the value of a parameter.

◆ setMidiNote()

template<class DSP>
virtual bool setMidiNote ( int note)
inlinevirtual

◆ setNotifyActive() [1/2]

void setNotifyActive ( bool flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active).

◆ setNotifyActive() [2/2]

void setNotifyActive ( bool flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active).

◆ setWriteBufferSize() [1/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ setWriteBufferSize() [2/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ write() [1/2]

◆ write() [2/2]

template<class DSP>
size_t write ( const uint8_t * data,
size_t len )
inlineoverridevirtual

Used if FaustStream is used as audio sink or filter.

Reimplemented from AudioStream.

◆ writeSilence() [1/2]

virtual void writeSilence ( size_t len)
inlinevirtualinherited

Writes len bytes of silence (=0).

◆ writeSilence() [2/2]

virtual void writeSilence ( size_t len)
inlinevirtualinherited

Writes len bytes of silence (=0).

◆ writeT()

template<class DSP>
template<class T>
size_t writeT ( const uint8_t * write_data,
size_t len )
inlineprotected

Used if FaustStream is used as audio sink or filter.

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ buffer_allocated

template<class DSP>
int buffer_allocated
protected

◆ bytes_per_frame

template<class DSP>
int bytes_per_frame
protected

◆ bytes_per_sample

template<class DSP>
int bytes_per_sample
protected

◆ cfg

template<class DSP>
AudioInfo cfg
protected

◆ float_to_int_factor

template<class DSP>
float float_to_int_factor = 32767
protected

◆ gate_exists

template<class DSP>
bool gate_exists = false
protected

◆ info

AudioInfo info
protectedinherited

◆ is_init

template<class DSP>
bool is_init = false
protected

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ is_read

template<class DSP>
bool is_read = false
protected

◆ is_write

template<class DSP>
bool is_write = false
protected

◆ notify_vector

Vector< AudioInfoSupport * > notify_vector
protectedinherited

◆ p_buffer

template<class DSP>
float** p_buffer =nullptr
protected

◆ p_buffer_out

template<class DSP>
float** p_buffer_out =nullptr
protected

◆ p_dsp

template<class DSP>
DSP* p_dsp = nullptr
protected

◆ p_out

template<class DSP>
Print* p_out =nullptr
protected

◆ tmp_in

RingBuffer< uint8_t > tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer< uint8_t > tmp_out {0}
protectedinherited

◆ ui

template<class DSP>
UI ui
protected

◆ with_output_buffer

template<class DSP>
bool with_output_buffer
protected

◆ write_buffer_size

int write_buffer_size = 8
protectedinherited

The documentation for this class was generated from the following file: