TwoLAME  0.4.0
MPEG Audio Layer 2 encoder
twolame.h
Go to the documentation of this file.
1 /*
2  * TwoLAME: an optimized MPEG Audio Layer Two encoder
3  *
4  * Copyright (C) 2001-2004 Michael Cheng
5  * Copyright (C) 2004-2018 The TwoLAME Project
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 
23 #ifndef TWOLAME_H
24 #define TWOLAME_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
32 /*
33  * ATTENTION WIN32 USERS!
34  *
35  * By default, when you use this header file, it is configured to use
36  * symbols from the "twolame.dll" file. If you use the static version of
37  * the library, define LIBTWOLAME_STATIC prior to including this header.
38  */
39 
40 #ifdef TL_API
41 # undef TL_API
42 #endif
43 
44 #ifdef _WIN32
45 # ifdef LIBTWOLAME_BUILD
46 # ifdef DLL_EXPORT
47 # define TL_API __declspec(dllexport)
48 # else
49 # define TL_API
50 # endif
51 # else
52 # ifdef LIBTWOLAME_STATIC
53 # define TL_API
54 # else
55 # define TL_API __declspec(dllimport)
56 # endif
57 # endif
58 #else
59 # ifdef GNUC
60 # if GNUC >= 4
61 # define TL_API attribute ((visibility("default")))
62 # else
63 # define TL_API
64 # endif
65 # else
66 # define TL_API
67 # endif
68 #endif
69 
70 
71 #ifndef TRUE
72 #define TRUE (1)
73 #endif
74 
75 #ifndef FALSE
76 #define FALSE (0)
77 #endif
78 
79 
81 typedef enum {
90  TWOLAME_NOT_SET
92 
93 
98 typedef enum {
99  TWOLAME_MPEG_UNKNOWN = -1,
103 
104 
106 typedef enum {
109 // TWOLAME_PAD_ADJUST // unsupported by twolame
111 
113 typedef enum {
118 
119 
121 #define TWOLAME_SAMPLES_PER_FRAME (1152)
122 
123 
125 struct twolame_options_struct;
126 
128 typedef struct twolame_options_struct twolame_options;
129 
130 
131 
132 
133 
139 TL_API const char *get_twolame_version(void);
140 
141 
147 TL_API const char *get_twolame_url(void);
148 
149 
160 TL_API void twolame_print_config(twolame_options * glopts);
161 
162 
172 TL_API twolame_options *twolame_init(void);
173 
174 
186 TL_API int twolame_init_params(twolame_options * glopts);
187 
188 
203 TL_API int twolame_encode_buffer(twolame_options * glopts,
204  const short int leftpcm[],
205  const short int rightpcm[],
206  int num_samples,
207  unsigned char *mp2buffer, int mp2buffer_size);
208 
209 
224  const short int pcm[],
225  int num_samples,
226  unsigned char *mp2buffer, int mp2buffer_size);
227 
228 
247  const float leftpcm[],
248  const float rightpcm[],
249  int num_samples,
250  unsigned char *mp2buffer, int mp2buffer_size);
251 
252 
267  const float pcm[],
268  int num_samples,
269  unsigned char *mp2buffer, int mp2buffer_size);
270 
271 
284 TL_API int twolame_encode_flush(twolame_options * glopts,
285  unsigned char *mp2buffer, int mp2buffer_size);
286 
287 
297 TL_API void twolame_close(twolame_options ** glopts);
298 
299 
300 
315 TL_API int twolame_set_verbosity(twolame_options * glopts, int verbosity);
316 
317 
323 TL_API int twolame_get_verbosity(twolame_options * glopts);
324 
325 
335 TL_API int twolame_set_mode(twolame_options * glopts, TWOLAME_MPEG_mode mode);
336 
337 
344 
345 
351 TL_API const char *twolame_get_mode_name(twolame_options * glopts);
352 
353 
362 TL_API int twolame_set_version(twolame_options * glopts, TWOLAME_MPEG_version version);
363 
364 
371 
372 
378 TL_API const char *twolame_get_version_name(twolame_options * glopts);
379 
380 
387 TL_API int twolame_set_freeformat(twolame_options * glopts, int freef);
388 
389 
396 TL_API int twolame_get_framelength(twolame_options * glopts);
397 
398 
407 TL_API int twolame_set_psymodel(twolame_options * glopts, int psymodel);
408 
409 
415 TL_API int twolame_get_psymodel(twolame_options * glopts);
416 
417 
430 TL_API int twolame_set_num_channels(twolame_options * glopts, int num_channels);
431 
432 
438 TL_API int twolame_get_num_channels(twolame_options * glopts);
439 
440 
451 TL_API int twolame_set_scale(twolame_options * glopts, float scale);
452 
453 
459 TL_API float twolame_get_scale(twolame_options * glopts);
460 
471 TL_API int twolame_set_scale_left(twolame_options * glopts, float scale);
472 
473 
479 TL_API float twolame_get_scale_left(twolame_options * glopts);
480 
481 
492 TL_API int twolame_set_scale_right(twolame_options * glopts, float scale);
493 
494 
500 TL_API float twolame_get_scale_right(twolame_options * glopts);
501 
502 
511 TL_API int twolame_set_in_samplerate(twolame_options * glopts, int samplerate);
512 
513 
519 TL_API int twolame_get_in_samplerate(twolame_options * glopts);
520 
521 
530 TL_API int twolame_set_out_samplerate(twolame_options * glopts, int samplerate);
531 
532 
538 TL_API int twolame_get_out_samplerate(twolame_options * glopts);
539 
540 
549 TL_API int twolame_set_bitrate(twolame_options * glopts, int bitrate);
550 
551 
557 TL_API int twolame_get_bitrate(twolame_options * glopts);
558 
559 
564 TL_API int twolame_set_brate(twolame_options * glopts, int bitrate);
565 
566 
571 TL_API int twolame_get_brate(twolame_options * glopts);
572 
573 
584 TL_API int twolame_set_padding(twolame_options * glopts, TWOLAME_Padding padding);
585 
592 
593 
610 TL_API int twolame_set_energy_levels(twolame_options * glopts, int energylevels);
611 
612 
618 TL_API int twolame_get_energy_levels(twolame_options * glopts);
619 
620 
629 TL_API int twolame_set_num_ancillary_bits(twolame_options * glopts, int num);
630 
631 
638 
639 
640 
649 TL_API int twolame_set_emphasis(twolame_options * glopts, TWOLAME_Emphasis emphasis);
650 
651 
658 
659 
668 TL_API int twolame_set_error_protection(twolame_options * glopts, int err_protection);
669 
670 
676 TL_API int twolame_get_error_protection(twolame_options * glopts);
677 
678 
689 TL_API int twolame_set_copyright(twolame_options * glopts, int copyright);
690 
691 
697 TL_API int twolame_get_copyright(twolame_options * glopts);
698 
699 
708 TL_API int twolame_set_original(twolame_options * glopts, int original);
709 
710 
716 TL_API int twolame_get_original(twolame_options * glopts);
717 
718 
727 TL_API int twolame_set_extension(twolame_options * glopts, int extension);
728 
729 
735 TL_API int twolame_get_extension(twolame_options * glopts);
736 
737 
746 TL_API int twolame_set_VBR(twolame_options * glopts, int vbr);
747 
748 
754 TL_API int twolame_get_VBR(twolame_options * glopts);
755 
756 
768 TL_API int twolame_set_VBR_level(twolame_options * glopts, float level);
769 
770 
776 TL_API float twolame_get_VBR_level(twolame_options * glopts);
777 
778 
779 
780 /*
781  Using the twolame_set_VBR_q()/twolame_get_VBR_q functions
782  are deprecated, please use twolame_set_VBR_level() instead.
783 */
784 TL_API int twolame_set_VBR_q(twolame_options * glopts, float level);
785 TL_API float twolame_get_VBR_q(twolame_options * glopts);
786 
787 
796 TL_API int twolame_set_ATH_level(twolame_options * glopts, float level);
797 
798 
804 TL_API float twolame_get_ATH_level(twolame_options * glopts);
805 
806 
815 TL_API int twolame_set_VBR_max_bitrate_kbps(twolame_options * glopts, int bitrate);
816 
817 
824 
825 
834 TL_API int twolame_set_quick_mode(twolame_options * glopts, int quickmode);
835 
836 
842 TL_API int twolame_get_quick_mode(twolame_options * glopts);
843 
844 
853 TL_API int twolame_set_quick_count(twolame_options * glopts, int quickcount);
854 
855 
861 TL_API int twolame_get_quick_count(twolame_options * glopts);
862 
863 
872 TL_API int twolame_set_DAB(twolame_options * glopts, int dab);
873 
879 TL_API int twolame_get_DAB(twolame_options * glopts);
880 
881 
890 TL_API int twolame_set_DAB_xpad_length(twolame_options * glopts, int length);
891 
892 
898 TL_API int twolame_get_DAB_xpad_length(twolame_options * glopts);
899 
900 
910 TL_API int twolame_set_DAB_crc_length(twolame_options * glopts, int length);
911 
912 
921 
922 
928 TL_API int twolame_get_DAB_crc_length(twolame_options * glopts);
929 
930 
949 TL_API int twolame_set_DAB_scf_crc(twolame_options * glopts,
950  unsigned char *mp2buffer,
951  int mp2buffer_size);
952 
953 
954 #ifdef __cplusplus
955 }
956 #endif
957 #endif /* TWOLAME_H */
958 // vim:ts=4:sw=4:nowrap:
TL_API int twolame_set_VBR_max_bitrate_kbps(twolame_options *glopts, int bitrate)
TWOLAME_Padding
Definition: twolame.h:106
TL_API int twolame_get_original(twolame_options *glopts)
TL_API const char * twolame_get_version_name(twolame_options *glopts)
TWOLAME_MPEG_version
Definition: twolame.h:98
Definition: twolame.h:107
TL_API int twolame_get_out_samplerate(twolame_options *glopts)
TL_API int twolame_set_emphasis(twolame_options *glopts, TWOLAME_Emphasis emphasis)
TL_API int twolame_get_in_samplerate(twolame_options *glopts)
TL_API int twolame_set_version(twolame_options *glopts, TWOLAME_MPEG_version version)
TL_API int twolame_get_quick_mode(twolame_options *glopts)
TL_API int twolame_set_mode(twolame_options *glopts, TWOLAME_MPEG_mode mode)
TL_API int twolame_set_error_protection(twolame_options *glopts, int err_protection)
TL_API float twolame_get_VBR_level(twolame_options *glopts)
TL_API int twolame_get_num_channels(twolame_options *glopts)
TL_API int twolame_set_DAB_scf_crc_length(twolame_options *glopts)
TL_API int twolame_set_extension(twolame_options *glopts, int extension)
TL_API void twolame_print_config(twolame_options *glopts)
TL_API int twolame_set_scale_left(twolame_options *glopts, float scale)
TL_API int twolame_set_DAB(twolame_options *glopts, int dab)
TL_API const char * get_twolame_version(void)
TL_API int twolame_get_VBR(twolame_options *glopts)
TL_API int twolame_encode_buffer_interleaved(twolame_options *glopts, const short int pcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
TWOLAME_MPEG_mode
Definition: twolame.h:81
TL_API float twolame_get_scale_left(twolame_options *glopts)
Definition: twolame.h:115
Definition: twolame.h:116
TL_API int twolame_set_ATH_level(twolame_options *glopts, float level)
TL_API int twolame_encode_flush(twolame_options *glopts, unsigned char *mp2buffer, int mp2buffer_size)
TL_API int twolame_set_out_samplerate(twolame_options *glopts, int samplerate)
TL_API int twolame_set_psymodel(twolame_options *glopts, int psymodel)
TL_API int twolame_get_psymodel(twolame_options *glopts)
TL_API int twolame_get_brate(twolame_options *glopts)
TL_API int twolame_get_VBR_max_bitrate_kbps(twolame_options *glopts)
TL_API int twolame_encode_buffer(twolame_options *glopts, const short int leftpcm[], const short int rightpcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
Definition: twolame.h:100
TL_API int twolame_get_framelength(twolame_options *glopts)
TL_API float twolame_get_ATH_level(twolame_options *glopts)
TL_API int twolame_set_copyright(twolame_options *glopts, int copyright)
TL_API TWOLAME_MPEG_version twolame_get_version(twolame_options *glopts)
TL_API const char * twolame_get_mode_name(twolame_options *glopts)
TL_API int twolame_set_quick_mode(twolame_options *glopts, int quickmode)
Definition: twolame.h:114
TL_API TWOLAME_Padding twolame_get_padding(twolame_options *glopts)
TL_API int twolame_set_DAB_xpad_length(twolame_options *glopts, int length)
Definition: twolame.h:85
TL_API int twolame_set_in_samplerate(twolame_options *glopts, int samplerate)
TL_API int twolame_set_freeformat(twolame_options *glopts, int freef)
Definition: twolame.h:101
TWOLAME_Emphasis
Definition: twolame.h:113
Definition: twolame.h:87
TL_API int twolame_encode_buffer_float32(twolame_options *glopts, const float leftpcm[], const float rightpcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
TL_API twolame_options * twolame_init(void)
Definition: twolame.h:108
TL_API int twolame_set_brate(twolame_options *glopts, int bitrate)
TL_API TWOLAME_MPEG_mode twolame_get_mode(twolame_options *glopts)
TL_API int twolame_set_energy_levels(twolame_options *glopts, int energylevels)
TL_API float twolame_get_scale(twolame_options *glopts)
TL_API int twolame_get_error_protection(twolame_options *glopts)
TL_API int twolame_get_quick_count(twolame_options *glopts)
TL_API TWOLAME_Emphasis twolame_get_emphasis(twolame_options *glopts)
TL_API int twolame_get_DAB_xpad_length(twolame_options *glopts)
TL_API int twolame_get_bitrate(twolame_options *glopts)
Definition: twolame.h:89
TL_API int twolame_get_DAB(twolame_options *glopts)
TL_API float twolame_get_scale_right(twolame_options *glopts)
TL_API int twolame_set_VBR(twolame_options *glopts, int vbr)
TL_API int twolame_set_num_channels(twolame_options *glopts, int num_channels)
TL_API int twolame_set_bitrate(twolame_options *glopts, int bitrate)
TL_API int twolame_get_copyright(twolame_options *glopts)
TL_API int twolame_set_DAB_scf_crc(twolame_options *glopts, unsigned char *mp2buffer, int mp2buffer_size)
TL_API const char * get_twolame_url(void)
TL_API int twolame_set_padding(twolame_options *glopts, TWOLAME_Padding padding)
TL_API void twolame_close(twolame_options **glopts)
TL_API int twolame_init_params(twolame_options *glopts)
TL_API int twolame_set_num_ancillary_bits(twolame_options *glopts, int num)
struct twolame_options_struct twolame_options
Definition: twolame.h:128
TL_API int twolame_get_energy_levels(twolame_options *glopts)
TL_API int twolame_set_scale(twolame_options *glopts, float scale)
TL_API int twolame_get_extension(twolame_options *glopts)
TL_API int twolame_set_scale_right(twolame_options *glopts, float scale)
TL_API int twolame_get_DAB_crc_length(twolame_options *glopts)
int twolame_encode_buffer_float32_interleaved(twolame_options *glopts, const float pcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
Definition: twolame.h:84
TL_API int twolame_set_VBR_level(twolame_options *glopts, float level)
TL_API int twolame_set_original(twolame_options *glopts, int original)
TL_API int twolame_set_DAB_crc_length(twolame_options *glopts, int length)
Definition: twolame.h:82
TL_API int twolame_set_quick_count(twolame_options *glopts, int quickcount)
TL_API int twolame_get_num_ancillary_bits(twolame_options *glopts)
TL_API int twolame_set_verbosity(twolame_options *glopts, int verbosity)
TL_API int twolame_get_verbosity(twolame_options *glopts)