Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/dsp_manager.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #pragma once | |
| 2 | |
| 3 #ifdef FOOBAR2000_HAVE_DSP | |
| 4 #include "dsp.h" | |
| 5 | |
| 6 //! Helper class for running audio data through a DSP chain. | |
| 7 class dsp_manager { | |
| 8 public: | |
| 9 //! @param creationFlags See dsp_entry::flag_* | |
| 10 dsp_manager(unsigned creationFlags = 0) : m_creationFlags(creationFlags) {} | |
| 11 | |
| 12 //! Alters the DSP chain configuration. Should be called before the first run() to set the configuration but can be also called anytime later between run() calls. | |
| 13 void set_config( const dsp_chain_config & p_data ); | |
| 14 //! Runs DSP on the specified chunk list. | |
| 15 //! @returns Current DSP latency in seconds. | |
| 16 double run(dsp_chunk_list * p_list,dsp_track_t const & p_cur_file,unsigned p_flags,abort_callback & p_abort); | |
| 17 //! Flushes the DSP (e.g. when seeking). | |
| 18 void flush(); | |
| 19 | |
| 20 //! Equivalent to set_config() with empty configuration. | |
| 21 void close(); | |
| 22 | |
| 23 //! Returns whether there's at least one active DSP in the configuration. | |
| 24 bool is_active() const; | |
| 25 bool need_track_change_mark() const; | |
| 26 | |
| 27 private: | |
| 28 const unsigned m_creationFlags; | |
| 29 struct t_dsp_chain_entry { | |
| 30 service_ptr_t<dsp> m_dsp; | |
| 31 dsp_preset_impl m_preset; | |
| 32 bool m_recycle_flag; | |
| 33 }; | |
| 34 typedef pfc::chain_list_v2_t<t_dsp_chain_entry> t_dsp_chain; | |
| 35 | |
| 36 t_dsp_chain m_chain; | |
| 37 dsp_chain_config_impl m_config; | |
| 38 bool m_config_changed = false; | |
| 39 | |
| 40 void dsp_run(t_dsp_chain::const_iterator p_iter,dsp_chunk_list * list,const dsp_track_t & cur_file,unsigned flags,double & latency,abort_callback&); | |
| 41 | |
| 42 dsp_manager(const dsp_manager &) = delete; | |
| 43 const dsp_manager & operator=(const dsp_manager&) = delete; | |
| 44 }; | |
| 45 | |
| 46 //! Core API for accessing core playback DSP settings as well as spawning DSP configuration dialogs. \n | |
| 47 //! Use dsp_config_manager::get() to obtain an instance. | |
| 48 class dsp_config_manager : public service_base { | |
| 49 FB2K_MAKE_SERVICE_COREAPI(dsp_config_manager); | |
| 50 public: | |
| 51 //! Retrieves current core playback DSP settings. | |
| 52 virtual void get_core_settings(dsp_chain_config & p_out) = 0; | |
| 53 //! Changes current core playback DSP settings. | |
| 54 virtual void set_core_settings(const dsp_chain_config & p_data) = 0; | |
| 55 | |
| 56 #ifdef _WIN32 | |
| 57 //! Runs a modal DSP settings dialog. | |
| 58 //! @param p_data DSP chain configuration to edit - contains initial configuration to put in the dialog when called, receives the new configuration on successful edit. | |
| 59 //! @returns True when user approved DSP configuration changes (pressed the "OK" button), false when the user cancelled them ("Cancel" button). | |
| 60 virtual bool configure_popup(dsp_chain_config & p_data,fb2k::hwnd_t p_parent,const char * p_title) = 0; | |
| 61 | |
| 62 //! Spawns an embedded DSP settings dialog. | |
| 63 //! @param p_initdata Initial DSP chain configuration to put in the dialog. | |
| 64 //! @param p_parent Parent window to contain the embedded dialog. | |
| 65 //! @param p_id Control ID of the embedded dialog. The parent window will receive a WM_COMMAND with BN_CLICKED and this identifier when user changes settings in the embedded dialog. | |
| 66 //! @param p_from_modal Must be set to true when the parent window is a modal dialog, false otherwise. | |
| 67 virtual fb2k::hwnd_t configure_embedded(const dsp_chain_config & p_initdata,fb2k::hwnd_t p_parent,unsigned p_id,bool p_from_modal) = 0; | |
| 68 //! Retrieves current settings from an embedded DSP settings dialog. See also: configure_embedded(). | |
| 69 virtual void configure_embedded_retrieve(fb2k::hwnd_t wnd,dsp_chain_config & p_data) = 0; | |
| 70 //! Changes current settings in an embedded DSP settings dialog. See also: configure_embedded(). | |
| 71 virtual void configure_embedded_change(fb2k::hwnd_t wnd,const dsp_chain_config & p_data) = 0; | |
| 72 #endif | |
| 73 | |
| 74 enum default_insert_t { | |
| 75 default_insert_last, | |
| 76 default_insert_first, | |
| 77 }; | |
| 78 //! Helper - enables a DSP in core playback settings. | |
| 79 void core_enable_dsp(const dsp_preset & preset, default_insert_t insertWhere = default_insert_first ); | |
| 80 //! Helper - disables a DSP in core playback settings. | |
| 81 void core_disable_dsp(const GUID & id); | |
| 82 //! Helper - if a DSP with the specified identifier is present in playback settings, retrieves its configuration and returns true, otherwise returns false. | |
| 83 bool core_query_dsp(const GUID & id, dsp_preset & out); | |
| 84 }; | |
| 85 | |
| 86 //! \since 1.4 | |
| 87 //! Allows manipulation of DSP presets saved by user. \n | |
| 88 //! Note that there's no multi thread safety implemented, all methods are valid from main thread only. | |
| 89 class dsp_config_manager_v2 : public dsp_config_manager { | |
| 90 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(dsp_config_manager_v2, dsp_config_manager) | |
| 91 public: | |
| 92 virtual size_t get_preset_count() = 0; | |
| 93 virtual void get_preset_name( size_t index, pfc::string_base & out ) = 0; | |
| 94 virtual void get_preset_data( size_t index, dsp_chain_config & out ) = 0; | |
| 95 virtual void select_preset( size_t which ) = 0; | |
| 96 virtual size_t get_selected_preset() = 0; | |
| 97 }; | |
| 98 | |
| 99 //! Callback class for getting notified about core playback DSP settings getting altered. \n | |
| 100 //! Register your implementations with static service_factory_single_t<myclass> g_myclass_factory; | |
| 101 class NOVTABLE dsp_config_callback : public service_base { | |
| 102 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_config_callback); | |
| 103 public: | |
| 104 //! Called when core playback DSP settings change. \n | |
| 105 //! Note: you must not try to alter core playback DSP settings inside this callback, or call anything else that possibly alters core playback DSP settings. | |
| 106 virtual void on_core_settings_change(const dsp_chain_config & p_newdata) = 0; | |
| 107 }; | |
| 108 | |
| 109 #endif // FOOBAR2000_HAVE_DSP |
