libopenmpt  0.2.6611
cross-platform C++ and C library to decode tracked music files
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
libopenmpt.hpp
Go to the documentation of this file.
1 /*
2  * libopenmpt.hpp
3  * --------------
4  * Purpose: libopenmpt public c++ interface
5  * Notes : (currently none)
6  * Authors: OpenMPT Devs
7  * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
8  */
9 
10 #ifndef LIBOPENMPT_HPP
11 #define LIBOPENMPT_HPP
12 
13 #include "libopenmpt_config.h"
14 
15 #include <exception>
16 #include <iosfwd>
17 #include <iostream>
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 #ifndef LIBOPENMPT_ANCIENT_COMPILER_STDINT
23 #include <cstdint>
24 #endif
25 
127 namespace openmpt {
128 
129 class LIBOPENMPT_CXX_API exception : public std::exception {
130 private:
131  char * text;
132 public:
133  exception( const std::string & text ) throw();
134  virtual ~exception() throw();
135  virtual const char * what() const throw();
136 }; // class exception
137 
139 
143 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
144 
146 
150 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
151 
152 namespace string {
153 
155 LIBOPENMPT_DEPRECATED static const char library_version [] = "library_version";
157 LIBOPENMPT_DEPRECATED static const char library_features[] = "library_features";
159 LIBOPENMPT_DEPRECATED static const char core_version [] = "core_version";
161 LIBOPENMPT_DEPRECATED static const char build [] = "build";
163 LIBOPENMPT_DEPRECATED static const char credits [] = "credits";
165 LIBOPENMPT_DEPRECATED static const char contact [] = "contact";
167 LIBOPENMPT_DEPRECATED static const char license [] = "license";
168 
170 
189 LIBOPENMPT_CXX_API std::string get( const std::string & key );
190 
191 } // namespace string
192 
194 
197 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
198 
200 
204 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
205 
207 
216 LIBOPENMPT_CXX_API double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
217 
218 class module_impl;
219 
220 class module_ext;
221 
222 namespace detail {
223 
224 typedef std::map< std::string, std::string > initial_ctls_map;
225 
226 } // namespace detail
227 
228 class LIBOPENMPT_CXX_API module {
229 
230  friend class module_ext;
231 
232 public:
233 
237 
242  RENDER_MASTERGAIN_MILLIBEL = 1,
244 
249  RENDER_STEREOSEPARATION_PERCENT = 2,
251 
262  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
264 
271  RENDER_VOLUMERAMPING_STRENGTH = 4
272  };
273 
276  command_note = 0,
277  command_instrument = 1,
278  command_volumeffect = 2,
279  command_effect = 3,
280  command_volume = 4,
281  command_parameter = 5
282  };
283 
284 private:
285  module_impl * impl;
286 private:
287  // non-copyable
288  module( const module & );
289  void operator = ( const module & );
290 private:
291  // for module_ext
292  module();
293  void set_impl( module_impl * i );
294 public:
296 
304  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
313  module( const std::vector<std::uint8_t> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
323  module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
333  module( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
342  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
352  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
362  module( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
372  module( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
373  virtual ~module();
374 public:
375 
377 
383  void select_subsong( std::int32_t subsong );
385 
392  void set_repeat_count( std::int32_t repeat_count );
394 
401  std::int32_t get_repeat_count() const;
402 
404 
407  double get_duration_seconds() const;
408 
410 
415  double set_position_seconds( double seconds );
417 
421  double get_position_seconds() const;
422 
424 
432  double set_position_order_row( std::int32_t order, std::int32_t row );
433 
435 
442  std::int32_t get_render_param( int param ) const;
444 
451  void set_render_param( int param, std::int32_t value );
452 
454 
466  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
468 
480  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
482 
496  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right );
498 
509  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
511 
523  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
525 
539  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
541 
552  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
554 
565  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
567 
578  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
580 
591  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
594 
599  std::vector<std::string> get_metadata_keys() const;
601 
618  std::string get_metadata( const std::string & key ) const;
619 
621 
624  std::int32_t get_current_speed() const;
626 
629  std::int32_t get_current_tempo() const;
631 
634  std::int32_t get_current_order() const;
636 
639  std::int32_t get_current_pattern() const;
641 
644  std::int32_t get_current_row() const;
646 
649  std::int32_t get_current_playing_channels() const;
650 
652 
657  float get_current_channel_vu_mono( std::int32_t channel ) const;
659 
664  float get_current_channel_vu_left( std::int32_t channel ) const;
666 
671  float get_current_channel_vu_right( std::int32_t channel ) const;
673 
678  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
680 
685  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
686 
688 
692  std::int32_t get_num_subsongs() const;
694 
698  std::int32_t get_num_channels() const;
700 
703  std::int32_t get_num_orders() const;
705 
708  std::int32_t get_num_patterns() const;
710 
713  std::int32_t get_num_instruments() const;
715 
718  std::int32_t get_num_samples() const;
719 
721 
725  std::vector<std::string> get_subsong_names() const;
727 
731  std::vector<std::string> get_channel_names() const;
733 
737  std::vector<std::string> get_order_names() const;
739 
743  std::vector<std::string> get_pattern_names() const;
745 
749  std::vector<std::string> get_instrument_names() const;
751 
755  std::vector<std::string> get_sample_names() const;
756 
758 
762  std::int32_t get_order_pattern( std::int32_t order ) const;
763 
765 
769  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
770 
772 
779  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
780 
782 
790  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
791 
793 
812  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
813 
815 
824  std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const;
826 
835  std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const;
836 
838 
856  std::vector<std::string> get_ctls() const;
857 
859 
864  std::string ctl_get( const std::string & ctl ) const;
866 
871  void ctl_set( const std::string & ctl, const std::string & value );
872 
873  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
874 
875 }; // class module
876 
877 } // namespace openmpt
878 
883 #endif // LIBOPENMPT_HPP
#define LIBOPENMPT_DEPRECATED
Definition: libopenmpt_config.h:168
static const char library_features[]
Return a verbose library features string from openmpt::string::get().
Definition: libopenmpt.hpp:157
LIBOPENMPT_CXX_API double could_open_propability(std::istream &stream, double effort=1.0, std::ostream &log=std::clog)
Roughly scan the input stream to find out whether libopenmpt might be able to open it...
render_param
Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param.
Definition: libopenmpt.hpp:235
static const char build[]
Return information about the current build (e.g. the build date or compiler used) from openmpt::strin...
Definition: libopenmpt.hpp:161
Definition: libopenmpt.hpp:129
static const char core_version[]
Return a verbose OpenMPT core version string from openmpt::string::get().
Definition: libopenmpt.hpp:159
LIBOPENMPT_CXX_API std::uint32_t get_core_version()
Get the core version number.
static const char library_version[]
Return a verbose library version string from openmpt::string::get().
Definition: libopenmpt.hpp:155
static const char license[]
Return the libopenmpt license from openmpt::string::get().
Definition: libopenmpt.hpp:167
Definition: libopenmpt.hpp:127
LIBOPENMPT_CXX_API std::uint32_t get_library_version()
Get the libopenmpt version number.
LIBOPENMPT_CXX_API bool is_extension_supported(const std::string &extension)
Query whether a file extension is supported.
static const char credits[]
Return all contributors from openmpt::string::get().
Definition: libopenmpt.hpp:163
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:275
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:228
static const char contact[]
Return contact information about libopenmpt from openmpt::string::get().
Definition: libopenmpt.hpp:165
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.