foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Private Attributes
dsp_sample
+ Inheritance diagram for dsp_sample:

Public Member Functions

 dsp_sample (dsp_preset const &in)
 
void flush ()
 
double get_latency ()
 
bool need_track_change_mark ()
 
bool on_chunk (audio_chunk *chunk, abort_callback &)
 
void on_endofplayback (abort_callback &)
 
void on_endoftrack (abort_callback &)
 

Static Public Member Functions

static bool g_get_default_preset (dsp_preset &p_out)
 
static GUID g_get_guid ()
 
static void g_get_name (pfc::string_base &p_out)
 
static bool g_have_config_popup ()
 
static void g_show_config_popup (const dsp_preset &p_data, HWND p_parent, dsp_preset_edit_callback &p_callback)
 
static void make_preset (float gain, dsp_preset &out)
 
static void parse_preset (float &gain, const dsp_preset &in)
 

Private Attributes

float m_gain
 

Additional Inherited Members

- Protected Member Functions inherited from dsp_impl_base_t< t_baseclass >
 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)
 

Detailed Description

Definition at line 6 of file dsp.cpp.

Constructor & Destructor Documentation

dsp_sample::dsp_sample ( dsp_preset const &  in)
inline

Definition at line 9 of file dsp.cpp.

9  : m_gain(0) {
10  parse_preset(m_gain, in);
11  }
float m_gain
Definition: dsp.cpp:78
static void parse_preset(float &gain, const dsp_preset &in)
Definition: dsp.cpp:72

Member Function Documentation

void dsp_sample::flush ( )
inlinevirtual

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.

Implements dsp_impl_base_t< t_baseclass >.

Definition at line 46 of file dsp.cpp.

46  {
47  // If you have any audio data buffered, you should drop it immediately and reset the DSP to a freshly initialized state.
48  // Called after a seek etc.
49  }
static bool dsp_sample::g_get_default_preset ( dsp_preset p_out)
inlinestatic

Definition at line 61 of file dsp.cpp.

61  {
62  make_preset(0, p_out);
63  return true;
64  }
static void make_preset(float gain, dsp_preset &out)
Definition: dsp.cpp:69
static GUID dsp_sample::g_get_guid ( )
inlinestatic

Definition at line 13 of file dsp.cpp.

13  {
14  //This is our GUID. Generate your own one when reusing this code.
15  static const GUID guid = { 0x890827b, 0x67df, 0x4c27, { 0xba, 0x1a, 0x4f, 0x95, 0x8d, 0xf, 0xb5, 0xd0 } };
16  return guid;
17  }
Definition: pfc.h:71
static void dsp_sample::g_get_name ( pfc::string_base p_out)
inlinestatic

Definition at line 19 of file dsp.cpp.

19 { p_out = "Sample DSP";}
static bool dsp_sample::g_have_config_popup ( )
inlinestatic

Definition at line 68 of file dsp.cpp.

68 {return true;}
static void dsp_sample::g_show_config_popup ( const dsp_preset p_data,
HWND  p_parent,
dsp_preset_edit_callback p_callback 
)
inlinestatic

Definition at line 65 of file dsp.cpp.

65  {
66  ::RunDSPConfigPopup(p_data, p_parent, p_callback);
67  }
static void RunDSPConfigPopup(const dsp_preset &p_data, HWND p_parent, dsp_preset_edit_callback &p_callback)
Definition: dsp.cpp:147
double dsp_sample::get_latency ( )
inlinevirtual

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.

Implements dsp_impl_base_t< t_baseclass >.

Definition at line 51 of file dsp.cpp.

51  {
52  // If the DSP buffers some amount of audio data, it should return the duration of buffered data (in seconds) here.
53  return 0;
54  }
static void dsp_sample::make_preset ( float  gain,
dsp_preset out 
)
inlinestatic

Definition at line 69 of file dsp.cpp.

69  {
70  dsp_preset_builder builder; builder << gain; builder.finish(g_get_guid(), out);
71  }
static GUID g_get_guid()
Definition: dsp.cpp:13
Helper.
Definition: dsp.h:485
void finish(const GUID &id, dsp_preset &out)
Definition: dsp.h:488
bool dsp_sample::need_track_change_mark ( )
inlinevirtual

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.

Implements dsp_impl_base_t< t_baseclass >.

Definition at line 56 of file dsp.cpp.

56  {
57  // Return true if you need on_endoftrack() or need to accurately know which track we're currently processing
58  // WARNING: If you return true, the DSP manager will fire on_endofplayback() at DSPs that are before us in the chain on track change to ensure that we get an accurate mark, so use it only when needed.
59  return false;
60  }
bool dsp_sample::on_chunk ( audio_chunk p_chunk,
abort_callback p_abort 
)
inlinevirtual

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.

Implements dsp_impl_base_t< t_baseclass >.

Definition at line 21 of file dsp.cpp.

21  {
22  // Perform any operations on the chunk here.
23  // The most simple DSPs can just alter the chunk in-place here and skip the following functions.
24 
25 
26  // trivial DSP code: apply our gain to the audio data.
27  chunk->scale( audio_math::gain_to_scale( m_gain ) );
28 
29  // To retrieve the currently processed track, use get_cur_file().
30  // Warning: the track is not always known - it's up to the calling component to provide this data and in some situations we'll be working with data that doesn't originate from an audio file.
31  // If you rely on get_cur_file(), you should change need_track_change_mark() to return true to get accurate information when advancing between tracks.
32 
33  return true; //Return true to keep the chunk or false to drop it from the chain.
34  }
float m_gain
Definition: dsp.cpp:78
void dsp_sample::on_endofplayback ( abort_callback p_abort)
inlinevirtual

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.

Implements dsp_impl_base_t< t_baseclass >.

Definition at line 36 of file dsp.cpp.

36  {
37  // The end of playlist has been reached, we've already received the last decoded audio chunk.
38  // We need to finish any pending processing and output any buffered data through insert_chunk().
39  }
void dsp_sample::on_endoftrack ( abort_callback p_abort)
inlinevirtual

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.

Implements dsp_impl_base_t< t_baseclass >.

Definition at line 40 of file dsp.cpp.

40  {
41  // Should do nothing except for special cases where your DSP performs special operations when changing tracks.
42  // If this function does anything, you must change need_track_change_mark() to return true.
43  // If you have pending audio data that you wish to output, you can use insert_chunk() to do so.
44  }
static void dsp_sample::parse_preset ( float &  gain,
const dsp_preset in 
)
inlinestatic

Definition at line 72 of file dsp.cpp.

72  {
73  try {
74  dsp_preset_parser parser(in); parser >> gain;
75  } catch(exception_io_data) {gain = 0;}
76  }
Helper.
Definition: dsp.h:466

Field Documentation

float dsp_sample::m_gain
private

Definition at line 78 of file dsp.cpp.


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