libopenmpt  0.3.0-pre.3+r8100
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_QUIRK_NO_CSTDINT
23 #include <cstdint>
24 #else
25 #include <stdint.h>
26 namespace openmpt {
27 namespace std {
28 typedef ::int8_t int8_t;
29 typedef ::int16_t int16_t;
30 typedef ::int32_t int32_t;
31 typedef ::int64_t int64_t;
32 typedef ::uint8_t uint8_t;
33 typedef ::uint16_t uint16_t;
34 typedef ::uint32_t uint32_t;
35 typedef ::uint64_t uint64_t;
36 using namespace ::std;
37 }
38 }
39 #endif
40 
149 namespace openmpt {
150 
151 #if defined(_MSC_VER)
152 #pragma warning(push)
153 #pragma warning(disable:4275)
154 #endif
155 class LIBOPENMPT_CXX_API exception : public std::exception {
156 private:
157  char * text;
158 public:
159  exception( const std::string & text ) LIBOPENMPT_NOEXCEPT;
160  virtual ~exception() LIBOPENMPT_NOEXCEPT;
161  virtual const char * what() const LIBOPENMPT_NOEXCEPT;
162 }; // class exception
163 #if defined(_MSC_VER)
164 #pragma warning(pop)
165 #endif
166 
168 
173 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
174 
176 
180 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
181 
182 namespace string {
183 
185 LIBOPENMPT_DEPRECATED static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version";
187 LIBOPENMPT_DEPRECATED static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features";
189 LIBOPENMPT_DEPRECATED static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version";
191 LIBOPENMPT_DEPRECATED static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build";
193 LIBOPENMPT_DEPRECATED static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits";
195 LIBOPENMPT_DEPRECATED static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact";
197 LIBOPENMPT_DEPRECATED static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license";
198 
200 
228 LIBOPENMPT_CXX_API std::string get( const std::string & key );
229 
230 } // namespace string
231 
233 
236 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
237 
239 
243 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
244 
246 
256 LIBOPENMPT_CXX_API double could_open_probability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
257 
259 
262 LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API LIBOPENMPT_DEPRECATED double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
263 
264 class module_impl;
265 
266 class module_ext;
267 
268 namespace detail {
269 
270 typedef std::map< std::string, std::string > initial_ctls_map;
271 
272 } // namespace detail
273 
274 class LIBOPENMPT_CXX_API module {
275 
276  friend class module_ext;
277 
278 public:
279 
283 
288  RENDER_MASTERGAIN_MILLIBEL = 1,
290 
295  RENDER_STEREOSEPARATION_PERCENT = 2,
297 
308  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
310 
317  RENDER_VOLUMERAMPING_STRENGTH = 4
318  };
319 
322  command_note = 0,
323  command_instrument = 1,
324  command_volumeffect = 2,
325  command_effect = 3,
326  command_volume = 4,
327  command_parameter = 5
328  };
329 
330 private:
331  module_impl * impl;
332 private:
333  // non-copyable
334  module( const module & );
335  void operator = ( const module & );
336 private:
337  // for module_ext
338  module();
339  void set_impl( module_impl * i );
340 public:
342 
350  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
359  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() );
369  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() );
379  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() );
388  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
398  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
408  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() );
418  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() );
419  virtual ~module();
420 public:
421 
423 
429  void select_subsong( std::int32_t subsong );
431 
436  std::int32_t get_selected_subsong() const;
438 
445  void set_repeat_count( std::int32_t repeat_count );
447 
454  std::int32_t get_repeat_count() const;
455 
457 
460  double get_duration_seconds() const;
461 
463 
468  double set_position_seconds( double seconds );
470 
474  double get_position_seconds() const;
475 
477 
485  double set_position_order_row( std::int32_t order, std::int32_t row );
486 
488 
495  std::int32_t get_render_param( int param ) const;
497 
504  void set_render_param( int param, std::int32_t value );
505 
507 
519  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
521 
533  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
535 
549  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 );
551 
562  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
564 
576  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
578 
592  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
594 
605  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
607 
618  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
620 
631  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
633 
644  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
647 
652  std::vector<std::string> get_metadata_keys() const;
654 
671  std::string get_metadata( const std::string & key ) const;
672 
674 
677  std::int32_t get_current_speed() const;
679 
682  std::int32_t get_current_tempo() const;
684 
687  std::int32_t get_current_order() const;
689 
692  std::int32_t get_current_pattern() const;
694 
697  std::int32_t get_current_row() const;
699 
702  std::int32_t get_current_playing_channels() const;
703 
705 
710  float get_current_channel_vu_mono( std::int32_t channel ) const;
712 
717  float get_current_channel_vu_left( std::int32_t channel ) const;
719 
724  float get_current_channel_vu_right( std::int32_t channel ) const;
726 
731  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
733 
738  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
739 
741 
745  std::int32_t get_num_subsongs() const;
747 
751  std::int32_t get_num_channels() const;
753 
756  std::int32_t get_num_orders() const;
758 
761  std::int32_t get_num_patterns() const;
763 
766  std::int32_t get_num_instruments() const;
768 
771  std::int32_t get_num_samples() const;
772 
774 
778  std::vector<std::string> get_subsong_names() const;
780 
784  std::vector<std::string> get_channel_names() const;
786 
790  std::vector<std::string> get_order_names() const;
792 
796  std::vector<std::string> get_pattern_names() const;
798 
802  std::vector<std::string> get_instrument_names() const;
804 
808  std::vector<std::string> get_sample_names() const;
809 
811 
815  std::int32_t get_order_pattern( std::int32_t order ) const;
816 
818 
822  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
823 
825 
832  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
833 
835 
843  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
844 
846 
865  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
866 
868 
877  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;
879 
888  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;
889 
891 
910  std::vector<std::string> get_ctls() const;
911 
913 
918  std::string ctl_get( const std::string & ctl ) const;
920 
925  void ctl_set( const std::string & ctl, const std::string & value );
926 
927  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
928 
929 }; // class module
930 
931 } // namespace openmpt
932 
937 #endif // LIBOPENMPT_HPP
#define LIBOPENMPT_DEPRECATED
Definition: libopenmpt_config.h:149
static const char library_version LIBOPENMPT_ATTR_DEPRECATED[]
Return a verbose library version string from openmpt::string::get().
Definition: libopenmpt.hpp:185
render_param
Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param.
Definition: libopenmpt.hpp:281
STL namespace.
Definition: libopenmpt.hpp:155
LIBOPENMPT_CXX_API std::uint32_t get_core_version()
Get the core version number.
Definition: libopenmpt.hpp:149
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.
LIBOPENMPT_CXX_API double could_open_probability(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...
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:321
LIBOPENMPT_ATTR_DEPRECATED 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...
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:274
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.