libopenmpt  0.2.8190-autotools
cross-platform C++ and C library to decode tracked music files
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 class LIBOPENMPT_CXX_API exception : public std::exception {
152 private:
153  char * text;
154 public:
155  exception( const std::string & text ) LIBOPENMPT_NOEXCEPT;
156  virtual ~exception() LIBOPENMPT_NOEXCEPT;
157  virtual const char * what() const LIBOPENMPT_NOEXCEPT;
158 }; // class exception
159 
161 
165 LIBOPENMPT_CXX_API std::uint32_t get_library_version();
166 
168 
172 LIBOPENMPT_CXX_API std::uint32_t get_core_version();
173 
174 namespace string {
175 
177 LIBOPENMPT_DEPRECATED static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version";
179 LIBOPENMPT_DEPRECATED static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features";
181 LIBOPENMPT_DEPRECATED static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version";
183 LIBOPENMPT_DEPRECATED static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build";
185 LIBOPENMPT_DEPRECATED static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits";
187 LIBOPENMPT_DEPRECATED static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact";
189 LIBOPENMPT_DEPRECATED static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license";
190 
192 
211 LIBOPENMPT_CXX_API std::string get( const std::string & key );
212 
213 } // namespace string
214 
216 
219 LIBOPENMPT_CXX_API std::vector<std::string> get_supported_extensions();
220 
222 
226 LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension );
227 
229 
238 LIBOPENMPT_CXX_API double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog );
239 
240 class module_impl;
241 
242 class module_ext;
243 
244 namespace detail {
245 
246 typedef std::map< std::string, std::string > initial_ctls_map;
247 
248 } // namespace detail
249 
250 class LIBOPENMPT_CXX_API module {
251 
252  friend class module_ext;
253 
254 public:
255 
259 
264  RENDER_MASTERGAIN_MILLIBEL = 1,
266 
271  RENDER_STEREOSEPARATION_PERCENT = 2,
273 
284  RENDER_INTERPOLATIONFILTER_LENGTH = 3,
286 
293  RENDER_VOLUMERAMPING_STRENGTH = 4
294  };
295 
298  command_note = 0,
299  command_instrument = 1,
300  command_volumeffect = 2,
301  command_effect = 3,
302  command_volume = 4,
303  command_parameter = 5
304  };
305 
306 private:
307  module_impl * impl;
308 private:
309  // non-copyable
310  module( const module & );
311  void operator = ( const module & );
312 private:
313  // for module_ext
314  module();
315  void set_impl( module_impl * i );
316 public:
318 
326  module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
335  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() );
345  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() );
355  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() );
364  module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
374  module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
384  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() );
394  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() );
395  virtual ~module();
396 public:
397 
399 
405  void select_subsong( std::int32_t subsong );
407 
414  void set_repeat_count( std::int32_t repeat_count );
416 
423  std::int32_t get_repeat_count() const;
424 
426 
429  double get_duration_seconds() const;
430 
432 
437  double set_position_seconds( double seconds );
439 
443  double get_position_seconds() const;
444 
446 
454  double set_position_order_row( std::int32_t order, std::int32_t row );
455 
457 
464  std::int32_t get_render_param( int param ) const;
466 
473  void set_render_param( int param, std::int32_t value );
474 
476 
488  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono );
490 
502  std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right );
504 
518  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 );
520 
531  std::size_t read( std::int32_t samplerate, std::size_t count, float * mono );
533 
545  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right );
547 
561  std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right );
563 
574  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo );
576 
587  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad );
589 
600  std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo );
602 
613  std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad );
616 
621  std::vector<std::string> get_metadata_keys() const;
623 
640  std::string get_metadata( const std::string & key ) const;
641 
643 
646  std::int32_t get_current_speed() const;
648 
651  std::int32_t get_current_tempo() const;
653 
656  std::int32_t get_current_order() const;
658 
661  std::int32_t get_current_pattern() const;
663 
666  std::int32_t get_current_row() const;
668 
671  std::int32_t get_current_playing_channels() const;
672 
674 
679  float get_current_channel_vu_mono( std::int32_t channel ) const;
681 
686  float get_current_channel_vu_left( std::int32_t channel ) const;
688 
693  float get_current_channel_vu_right( std::int32_t channel ) const;
695 
700  float get_current_channel_vu_rear_left( std::int32_t channel ) const;
702 
707  float get_current_channel_vu_rear_right( std::int32_t channel ) const;
708 
710 
714  std::int32_t get_num_subsongs() const;
716 
720  std::int32_t get_num_channels() const;
722 
725  std::int32_t get_num_orders() const;
727 
730  std::int32_t get_num_patterns() const;
732 
735  std::int32_t get_num_instruments() const;
737 
740  std::int32_t get_num_samples() const;
741 
743 
747  std::vector<std::string> get_subsong_names() const;
749 
753  std::vector<std::string> get_channel_names() const;
755 
759  std::vector<std::string> get_order_names() const;
761 
765  std::vector<std::string> get_pattern_names() const;
767 
771  std::vector<std::string> get_instrument_names() const;
773 
777  std::vector<std::string> get_sample_names() const;
778 
780 
784  std::int32_t get_order_pattern( std::int32_t order ) const;
785 
787 
791  std::int32_t get_pattern_num_rows( std::int32_t pattern ) const;
792 
794 
801  std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
802 
804 
812  std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
813 
815 
834  std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const;
835 
837 
846  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;
848 
857  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;
858 
860 
879  std::vector<std::string> get_ctls() const;
880 
882 
887  std::string ctl_get( const std::string & ctl ) const;
889 
894  void ctl_set( const std::string & ctl, const std::string & value );
895 
896  // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR
897 
898 }; // class module
899 
900 } // namespace openmpt
901 
906 #endif // LIBOPENMPT_HPP
#define LIBOPENMPT_DEPRECATED
Definition: libopenmpt_config.h:120
command_index
Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format...
Definition: libopenmpt.hpp:297
static const char library_version LIBOPENMPT_ATTR_DEPRECATED[]
Return a verbose library version string from openmpt::string::get().
Definition: libopenmpt.hpp:177
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...
STL namespace.
Definition: libopenmpt.hpp:151
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.
render_param
Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param.
Definition: libopenmpt.hpp:257
Definition: libopenmpt_ext.hpp:59
Definition: libopenmpt.hpp:250
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions()
Get a list of supported file extensions.