Ardour  9.0-pre0-582-g084a23a80d
AudioGrapher::SilenceTrimmer< T > Class Template Reference

Removes and adds silent samples to beginning and/or end of stream. More...

#include <silence_trimmer.h>

Inheritance diagram for AudioGrapher::SilenceTrimmer< T >:
[legend]

Public Member Functions

 SilenceTrimmer (samplecnt_t silence_buffer_size_=1024, float thresh_dB=-INFINITY)
 Constructor,. More...
 
 ~SilenceTrimmer ()
 
void reset (samplecnt_t silence_buffer_size_=1024)
 
void add_silence_to_beginning (samplecnt_t samples_per_channel)
 
void add_silence_to_end (samplecnt_t samples_per_channel)
 
void set_trim_beginning (bool yn)
 
void set_trim_end (bool yn)
 
void process (ProcessContext< T > const &c)
 
- Public Member Functions inherited from AudioGrapher::ListedSource< DefaultSampleType >
void add_output (typename Source< DefaultSampleType >::SinkPtr output)
 
void clear_outputs ()
 Removes all outputs added. More...
 
void remove_output (typename Source< DefaultSampleType >::SinkPtr output)
 
- Public Member Functions inherited from AudioGrapher::Source< DefaultSampleType >
virtual ~Source ()
 
virtual void add_output (SinkPtr output)=0
 Adds an output to this source. All data generated is forwarded to output. More...
 
virtual void remove_output (SinkPtr output)=0
 Removes a specific output from this source. More...
 
- Public Member Functions inherited from AudioGrapher::Sink< DefaultSampleType >
virtual ~Sink ()
 
virtual void process (ProcessContext< DefaultSampleType > const &context)=0
 
virtual void process (ProcessContext< DefaultSampleType > &context)
 

Private Member Functions

bool find_first_non_silent_sample (ProcessContext< T > const &c, samplecnt_t &result_sample)
 
bool find_last_silent_sample_reverse (ProcessContext< T > const &c, samplecnt_t &result_sample)
 
void output_silence_samples (ProcessContext< T > const &c, samplecnt_t &total_samples)
 

Private Attributes

bool processed_data
 
bool processing_finished
 
bool trim_beginning
 
bool trim_end
 
samplecnt_t silence_samples
 
samplecnt_t max_output_frames
 
samplecnt_t add_to_beginning
 
samplecnt_t add_to_end
 
samplecnt_t silence_buffer_size
 
T * silence_buffer
 
SilenceTester< T > tester
 

Additional Inherited Members

- Public Types inherited from AudioGrapher::Source< DefaultSampleType >
typedef std::shared_ptr< Sink< DefaultSampleType > > SinkPtr
 
- Public Types inherited from AudioGrapher::FlagDebuggable< L >
typedef FlagField::Flag Flag
 
- Protected Types inherited from AudioGrapher::ListedSource< DefaultSampleType >
typedef std::list< typename Source< DefaultSampleType >::SinkPtrSinkList
 
- Protected Member Functions inherited from AudioGrapher::ListedSource< DefaultSampleType >
void output (ProcessContext< DefaultSampleType > const &c)
 Helper for derived classes. More...
 
void output (ProcessContext< DefaultSampleType > &c)
 
bool output_size_is_one ()
 
- Protected Member Functions inherited from AudioGrapher::FlagDebuggable< L >
void add_supported_flag (Flag flag)
 Adds a flag to the set of flags supported. More...
 
template<typename SelfType , typename ContextType >
void check_flags (SelfType &self, ProcessContext< ContextType > context)
 Prints debug output if context contains flags that are not supported by this class. More...
 
- Protected Member Functions inherited from AudioGrapher::Debuggable< DebugNone >
 Debuggable (std::ostream &debug_stream=std::cerr)
 
bool debug_level (DebugLevel level)
 
std::ostream & debug_stream ()
 
- Protected Member Functions inherited from AudioGrapher::Throwing< L >
 Throwing ()
 
bool throw_level (ThrowLevel level)
 
- Protected Attributes inherited from AudioGrapher::ListedSource< DefaultSampleType >
SinkList outputs
 

Detailed Description

template<typename T = DefaultSampleType>
class AudioGrapher::SilenceTrimmer< T >

Removes and adds silent samples to beginning and/or end of stream.

Definition at line 38 of file silence_trimmer.h.

Constructor & Destructor Documentation

◆ SilenceTrimmer()

template<typename T = DefaultSampleType>
AudioGrapher::SilenceTrimmer< T >::SilenceTrimmer ( samplecnt_t  silence_buffer_size_ = 1024,
float  thresh_dB = -INFINITY 
)
inline

Constructor,.

See also
reset()
Not RT safe

Definition at line 47 of file silence_trimmer.h.

◆ ~SilenceTrimmer()

template<typename T = DefaultSampleType>
AudioGrapher::SilenceTrimmer< T >::~SilenceTrimmer ( )
inline

Definition at line 56 of file silence_trimmer.h.

Member Function Documentation

◆ add_silence_to_beginning()

template<typename T = DefaultSampleType>
void AudioGrapher::SilenceTrimmer< T >::add_silence_to_beginning ( samplecnt_t  samples_per_channel)
inline

Tells that samples_per_channel samples of silence per channel should be added to beginning Needs to be called before starting processing.
RT safe

Definition at line 94 of file silence_trimmer.h.

◆ add_silence_to_end()

template<typename T = DefaultSampleType>
void AudioGrapher::SilenceTrimmer< T >::add_silence_to_end ( samplecnt_t  samples_per_channel)
inline

Tells that samples_per_channel samples of silence per channel should be added to end Needs to be called before end is reached.
RT safe

Definition at line 106 of file silence_trimmer.h.

◆ find_first_non_silent_sample()

template<typename T = DefaultSampleType>
bool AudioGrapher::SilenceTrimmer< T >::find_first_non_silent_sample ( ProcessContext< T > const &  c,
samplecnt_t result_sample 
)
inlineprivate

Definition at line 256 of file silence_trimmer.h.

◆ find_last_silent_sample_reverse()

template<typename T = DefaultSampleType>
bool AudioGrapher::SilenceTrimmer< T >::find_last_silent_sample_reverse ( ProcessContext< T > const &  c,
samplecnt_t result_sample 
)
inlineprivate

Reverse find the last silent sample index. If the last sample in the buffer is non-silent the index will be one past the end of the buffer and equal to c.samples(). e.g silent_end_samples = c.samples() - result_sample

Returns
true if result_sample index is valid, false if there were only silent samples in the context buffer

Definition at line 277 of file silence_trimmer.h.

◆ output_silence_samples()

template<typename T = DefaultSampleType>
void AudioGrapher::SilenceTrimmer< T >::output_silence_samples ( ProcessContext< T > const &  c,
samplecnt_t total_samples 
)
inlineprivate

Definition at line 294 of file silence_trimmer.h.

◆ process()

template<typename T = DefaultSampleType>
void AudioGrapher::SilenceTrimmer< T >::process ( ProcessContext< T > const &  c)
inline

Process stream according to current settings. Note that some calls will not produce any output, while others may produce many.

See also
reset()
RT safe

Definition at line 143 of file silence_trimmer.h.

◆ reset()

template<typename T = DefaultSampleType>
void AudioGrapher::SilenceTrimmer< T >::reset ( samplecnt_t  silence_buffer_size_ = 1024)
inline

Reset state
Not RT safe Allocates a buffer the size of silence_buffer_size_ This also defines the maximum length of output process context which can be output during long intermediate silence.

Definition at line 66 of file silence_trimmer.h.

◆ set_trim_beginning()

template<typename T = DefaultSampleType>
void AudioGrapher::SilenceTrimmer< T >::set_trim_beginning ( bool  yn)
inline

Tells whether ot nor silence should be trimmed from the beginning Has to be called before starting processing.
RT safe

Definition at line 118 of file silence_trimmer.h.

◆ set_trim_end()

template<typename T = DefaultSampleType>
void AudioGrapher::SilenceTrimmer< T >::set_trim_end ( bool  yn)
inline

Tells whether ot nor silence should be trimmed from the end Has to be called before the is reached.
RT safe

Definition at line 130 of file silence_trimmer.h.

Member Data Documentation

◆ add_to_beginning

template<typename T = DefaultSampleType>
samplecnt_t AudioGrapher::SilenceTrimmer< T >::add_to_beginning
private

Definition at line 320 of file silence_trimmer.h.

◆ add_to_end

template<typename T = DefaultSampleType>
samplecnt_t AudioGrapher::SilenceTrimmer< T >::add_to_end
private

Definition at line 321 of file silence_trimmer.h.

◆ max_output_frames

template<typename T = DefaultSampleType>
samplecnt_t AudioGrapher::SilenceTrimmer< T >::max_output_frames
private

Definition at line 318 of file silence_trimmer.h.

◆ processed_data

template<typename T = DefaultSampleType>
bool AudioGrapher::SilenceTrimmer< T >::processed_data
private

Definition at line 311 of file silence_trimmer.h.

◆ processing_finished

template<typename T = DefaultSampleType>
bool AudioGrapher::SilenceTrimmer< T >::processing_finished
private

Definition at line 312 of file silence_trimmer.h.

◆ silence_buffer

template<typename T = DefaultSampleType>
T* AudioGrapher::SilenceTrimmer< T >::silence_buffer
private

Definition at line 324 of file silence_trimmer.h.

◆ silence_buffer_size

template<typename T = DefaultSampleType>
samplecnt_t AudioGrapher::SilenceTrimmer< T >::silence_buffer_size
private

Definition at line 323 of file silence_trimmer.h.

◆ silence_samples

template<typename T = DefaultSampleType>
samplecnt_t AudioGrapher::SilenceTrimmer< T >::silence_samples
private

Definition at line 317 of file silence_trimmer.h.

◆ tester

template<typename T = DefaultSampleType>
SilenceTester<T> AudioGrapher::SilenceTrimmer< T >::tester
private

Definition at line 326 of file silence_trimmer.h.

◆ trim_beginning

template<typename T = DefaultSampleType>
bool AudioGrapher::SilenceTrimmer< T >::trim_beginning
private

Definition at line 314 of file silence_trimmer.h.

◆ trim_end

template<typename T = DefaultSampleType>
bool AudioGrapher::SilenceTrimmer< T >::trim_end
private

Definition at line 315 of file silence_trimmer.h.


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