foobar2000 SDK  2015-01-14
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
dsp_impl_base_t< t_baseclass >abstract

#include <dsp.h>

+ Inheritance diagram for dsp_impl_base_t< t_baseclass >:

Public Member Functions

virtual void flush ()=0
 
virtual double get_latency ()=0
 
virtual bool need_track_change_mark ()=0
 

Protected Member Functions

 dsp_impl_base_t ()
 
bool get_cur_file (metadb_handle_ptr &p_out)
 
audio_chunkinsert_chunk (t_size p_hint_size=0)
 
audio_chunkinsert_chunk (const audio_chunk &sourceCopy)
 
virtual bool on_chunk (audio_chunk *p_chunk, abort_callback &p_abort)=0
 
virtual void on_endofplayback (abort_callback &p_abort)=0
 
virtual void on_endoftrack (abort_callback &p_abort)=0
 

Private Types

typedef dsp_impl_base_t< t_baseclasst_self
 

Private Member Functions

 dsp_impl_base_t (const t_self &)
 
const t_selfoperator= (const t_self &)
 
void run_v2 (dsp_chunk_list *p_list, const metadb_handle_ptr &p_cur_file, int p_flags, abort_callback &p_abort)
 

Private Attributes

t_size m_chunk_ptr
 
metadb_handlem_cur_file
 
dsp_chunk_listm_list
 

Detailed Description

template<class t_baseclass>
class dsp_impl_base_t< t_baseclass >

Helper class for implementing dsps. You should derive from dsp_impl_base instead of from dsp directly.
The dsp_impl_base_t template allows you to use a custom interface class as a base class for your implementation, in case you provide extended functionality.
Use dsp_factory_t<> template to register your dsp implementation. The implementation - as required by dsp_factory_t<> template - must also provide following methods:
A constructor taking const dsp_preset&, initializing the DSP with specified preset data.
static void g_get_name(pfc::string_base &); - retrieving human-readable name of the DSP to display.
static bool g_get_default_preset(dsp_preset &); - retrieving default preset for this DSP. Return value is reserved for future use and should always be true.
static GUID g_get_guid(); - retrieving GUID of your DSP implementation, to be used to identify it when storing DSP chain configuration.
static bool g_have_config_popup(); - retrieving whether your DSP implementation supplies a popup dialog for configuring it.
static void g_show_config_popup(const dsp_preset & p_data,HWND p_parent, dsp_preset_edit_callback & p_callback); - displaying your DSP's settings dialog; called only when g_have_config_popup() returns true; call p_callback.on_preset_changed() whenever user has made adjustments to the preset data.
.

Definition at line 100 of file dsp.h.

Member Typedef Documentation

template<class t_baseclass >
typedef dsp_impl_base_t<t_baseclass> dsp_impl_base_t< t_baseclass >::t_self
private

Definition at line 102 of file dsp.h.

Constructor & Destructor Documentation

template<class t_baseclass >
dsp_impl_base_t< t_baseclass >::dsp_impl_base_t ( )
inlineprotected

Definition at line 112 of file dsp.h.

112 : m_list(NULL), m_cur_file(NULL), m_chunk_ptr(0) {}
metadb_handle * m_cur_file
Definition: dsp.h:105
dsp_chunk_list * m_list
Definition: dsp.h:103
t_size m_chunk_ptr
Definition: dsp.h:104
template<class t_baseclass >
dsp_impl_base_t< t_baseclass >::dsp_impl_base_t ( const t_self )
private

Member Function Documentation

template<class t_baseclass >
virtual void dsp_impl_base_t< t_baseclass >::flush ( )
pure virtual

To be overridden by a DSP implementation.
Flushes the DSP (drops any buffered data). The implementation should reset the DSP to the same state it was in before receiving any audio data.
Called after seeking, etc.

Implemented in dsp_sample.

template<class t_baseclass >
bool dsp_impl_base_t< t_baseclass >::get_cur_file ( metadb_handle_ptr p_out)
inlineprotected

Call only from on_chunk / on_endoftrack (on_endoftrack will give info on track being finished).
May return false when there's no known track and the metadb_handle ptr will be empty/null.

Definition at line 110 of file dsp.h.

110 {p_out = m_cur_file; return p_out.is_valid();}
metadb_handle * m_cur_file
Definition: dsp.h:105
bool is_valid() const
Definition: service.h:119
template<class t_baseclass >
virtual double dsp_impl_base_t< t_baseclass >::get_latency ( )
pure virtual

To be overridden by a DSP implementation.
Retrieves amount of data buffered by the DSP, for syncing visualisation.

Returns
Amount of buffered audio data, in seconds.

Implemented in dsp_sample.

template<class t_baseclass >
audio_chunk* dsp_impl_base_t< t_baseclass >::insert_chunk ( t_size  p_hint_size = 0)
inlineprotected

Inserts a new chunk of audio data.
You can call this only from on_chunk(), on_endofplayback() and on_endoftrack(). You're NOT allowed to call this from flush() which should just drop any queued data.

Parameters
hint_sizeOptional, amount of buffer space that you require (in audio_samples). This is just a hint for memory allocation logic and will not cause the framework to allocate the chunk for you.
Returns
A pointer to the newly allocated chunk. Pass the audio data you want to insert to this chunk object. The chunk is owned by the framework, you can't delete it etc.

Definition at line 118 of file dsp.h.

118  {
119  PFC_ASSERT(m_list != NULL);
120  return m_list->insert_item(m_chunk_ptr++,p_hint_size);
121  }
dsp_chunk_list * m_list
Definition: dsp.h:103
virtual audio_chunk * insert_item(t_size idx, t_size hint_size=0)=0
t_size m_chunk_ptr
Definition: dsp.h:104
template<class t_baseclass >
audio_chunk* dsp_impl_base_t< t_baseclass >::insert_chunk ( const audio_chunk sourceCopy)
inlineprotected

Definition at line 122 of file dsp.h.

122  {
123  audio_chunk * c = insert_chunk( sourceCopy.get_used_size() );
124  c->copy( sourceCopy );
125  return c;
126  }
Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation.
Definition: audio_chunk.h:5
void copy(const audio_chunk &p_source)
Helper; copies content of another audio chunk to this chunk.
Definition: audio_chunk.h:212
audio_chunk * insert_chunk(t_size p_hint_size=0)
Inserts a new chunk of audio data. You can call this only from on_chunk(), on_endofplayback() and on...
Definition: dsp.h:118
size_t get_used_size() const
Returns actual amount of audio data contained in the buffer (sample count * channel count)...
Definition: audio_chunk.h:134
template<class t_baseclass >
virtual bool dsp_impl_base_t< t_baseclass >::need_track_change_mark ( )
pure virtual

To be overridden by a DSP implementation.
Returns true if DSP needs to know exact track change point (eg. for crossfading, removing silence).
Signaling this will force-flush any DSPs placed before this DSP so when it gets on_endoftrack(), relevant chunks contain last samples of the track.
Signaling this may interfere with gapless playback in certain scenarios (forces flush of DSPs placed before you) so don't use it unless you have reasons to.

Implemented in dsp_sample.

template<class t_baseclass >
virtual bool dsp_impl_base_t< t_baseclass >::on_chunk ( audio_chunk p_chunk,
abort_callback p_abort 
)
protectedpure virtual

To be overridden by a DSP implementation.
Processes a chunk of audio data.
You can call insert_chunk() from inside on_chunk() to insert any audio data before currently processed chunk.
.

Parameters
p_chunkCurrent chunk being processed. You can alter it in any way you like.
Returns
True to keep p_chunk (with alterations made inside on_chunk()) in the stream, false to remove it.

Implemented in dsp_sample.

template<class t_baseclass >
virtual void dsp_impl_base_t< t_baseclass >::on_endofplayback ( abort_callback p_abort)
protectedpure virtual

To be overridden by a DSP implementation.
Called at the end of played stream, typically at the end of last played track, to allow the DSP to return all data it has buffered-ahead.
Use insert_chunk() to return any data you have buffered.
Note that this call does not imply that the DSP will be destroyed next.
This is also called on track changes if some DSP placed after your DSP requests track change marks.

Implemented in dsp_sample.

template<class t_baseclass >
virtual void dsp_impl_base_t< t_baseclass >::on_endoftrack ( abort_callback p_abort)
protectedpure virtual

To be overridden by a DSP implementation.
Called on track change. You can use insert_chunk() to dump any data you have to flush.
Note that you must implement need_track_change_mark() to return true if you need this method called.

Implemented in dsp_sample.

template<class t_baseclass >
const t_self& dsp_impl_base_t< t_baseclass >::operator= ( const t_self )
private
template<class t_baseclass >
void dsp_impl_base_t< t_baseclass >::run_v2 ( dsp_chunk_list p_list,
const metadb_handle_ptr p_cur_file,
int  p_flags,
abort_callback p_abort 
)
private

Definition at line 166 of file dsp.h.

166  {
167  pfc::vartoggle_t<dsp_chunk_list*> l_list_toggle(m_list,p_list);
168  pfc::vartoggle_t<metadb_handle*> l_cur_file_toggle(m_cur_file,p_cur_file.get_ptr());
169 
172  if (c->is_empty() || !on_chunk(c,p_abort))
174  }
175 
176  if (p_flags & dsp::FLUSH) {
177  on_endofplayback(p_abort);
178  } else if (p_flags & dsp::END_OF_TRACK) {
179  if (need_track_change_mark()) on_endoftrack(p_abort);
180  }
181 }
metadb_handle * m_cur_file
Definition: dsp.h:105
virtual bool need_track_change_mark()=0
To be overridden by a DSP implementation. Returns true if DSP needs to know exact track change point ...
virtual bool on_chunk(audio_chunk *p_chunk, abort_callback &p_abort)=0
To be overridden by a DSP implementation. Processes a chunk of audio data. You can call insert_chunk(...
virtual void on_endofplayback(abort_callback &p_abort)=0
To be overridden by a DSP implementation. Called at the end of played stream, typically at the end of...
T * get_ptr() const
Definition: service.h:117
Flush everything.
Definition: dsp.h:52
virtual audio_chunk * get_item(t_size n) const =0
dsp_chunk_list * m_list
Definition: dsp.h:103
Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation.
Definition: audio_chunk.h:5
virtual t_size get_count() const =0
virtual void on_endoftrack(abort_callback &p_abort)=0
To be overridden by a DSP implementation. Called on track change. You can use insert_chunk() to dump ...
Flush whatever you need to when tracks change.
Definition: dsp.h:50
virtual void remove_by_idx(t_size idx)=0
t_size m_chunk_ptr
Definition: dsp.h:104
bool is_empty() const
Returns whether the chunk is empty (contains no audio data).
Definition: audio_chunk.h:125

Field Documentation

template<class t_baseclass >
t_size dsp_impl_base_t< t_baseclass >::m_chunk_ptr
private

Definition at line 104 of file dsp.h.

template<class t_baseclass >
metadb_handle* dsp_impl_base_t< t_baseclass >::m_cur_file
private

Definition at line 105 of file dsp.h.

template<class t_baseclass >
dsp_chunk_list* dsp_impl_base_t< t_baseclass >::m_list
private

Definition at line 103 of file dsp.h.


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