Go to the documentation of this file.
15 #define _CRT_SECURE_NO_WARNINGS
17 #define DR_FLAC_IMPLEMENTATION
18 #include "../../extras/dr_flac.h"
19 #define DR_MP3_IMPLEMENTATION
20 #include "../../extras/dr_mp3.h"
21 #define DR_WAV_IMPLEMENTATION
22 #include "../../extras/dr_wav.h"
23 #define STB_VORBIS_HEADER_ONLY
24 #include "../../extras/stb_vorbis.c"
27 #if defined(ENABLE_SPEEX)
28 #define MINIAUDIO_SPEEX_RESAMPLER_IMPLEMENTATION
29 #include "../../extras/speex_resampler/ma_speex_resampler.h"
32 #define MINIAUDIO_IMPLEMENTATION
33 #include "../../miniaudio.h"
39 printf(
"USAGE: audioconverter [input file] [output file] [format] [channels] [rate]\n");
40 printf(
" [format] is optional and can be one of the following:\n");
41 printf(
" u8 8-bit unsigned integer\n");
42 printf(
" s16 16-bit signed integer\n");
43 printf(
" s24 24-bit signed integer (tightly packed)\n");
44 printf(
" s32 32-bit signed integer\n");
45 printf(
" f32 32-bit floating point\n");
49 printf(
"PARAMETERS:\n");
51 printf(
" --speex-quality [0..10]\n");
69 if (framesReadThisIteration == 0) {
77 if (framesReadThisIteration < framesToReadThisIteration) {
87 if (str ==
NULL || str[0] ==
'\0') {
91 while (str[0] !=
'\0') {
92 if (str[0] <
'0' || str[0] >
'9') {
111 if (x < lo || x > hi) {
115 if (pValue !=
NULL) {
126 if (strcmp(str,
"u8") == 0) {
128 }
else if (strcmp(str,
"s16") == 0) {
130 }
else if (strcmp(str,
"s24") == 0) {
132 }
else if (strcmp(str,
"s32") == 0) {
134 }
else if (strcmp(str,
"f32") == 0) {
140 if (pValue !=
NULL) {
161 if (strcmp(str,
"linear") == 0) {
163 }
else if (strcmp(str,
"speex") == 0) {
169 if (pValue !=
NULL) {
191 const char* pOutputFilePath;
197 if (strcmp(
argv[1],
"-h") == 0 || strcmp(
argv[1],
"--help") == 0) {
209 #if defined(ENABLE_SPEEX)
219 for (iarg = 3; iarg < argc; iarg += 1) {
220 if (strcmp(
argv[iarg],
"--linear-order") == 0) {
234 if (strcmp(
argv[iarg],
"--speex-quality") == 0) {
241 printf(
"Expecting a number between 0 and 10 for --speex-quality.\n");
265 printf(
"Warning: Unknown parameter \"%s\"",
argv[iarg]);
272 #if defined(ENABLE_SPEEX)
278 printf(
"Failed to open input file. Check the file exists and the format is supported. Supported input formats:\n");
279 #if defined(dr_opus_h)
282 #if defined(dr_mp3_h)
285 #if defined(dr_flac_h)
288 #if defined(STB_VORBIS_INCLUDE_STB_VORBIS_H)
291 #if defined(dr_wav_h)
298 pOutputFilePath =
argv[2];
304 printf(
"Warning: Unknown file extension \"%s\". Encoding as WAV.\n",
ma_path_extension(pOutputFilePath));
312 printf(
"Failed to open output file. Check that the directory exists and that the file is not already opened by another process.");
330 #undef STB_VORBIS_HEADER_ONLY
331 #include "../../extras/stb_vorbis.c"
static MA_INLINE ma_uint32 ma_get_bytes_per_frame(ma_format format, ma_uint32 channels)
ma_result ma_decoder_uninit(ma_decoder *pDecoder)
struct ma_decoder_config::@122 resampling
struct ma_decoder_config::@122::@123 linear
ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate)
struct ma_decoder_config::@122::@124 speex
ma_uint64 ma_encoder_write_pcm_frames(ma_encoder *pEncoder, const void *pFramesIn, ma_uint64 frameCount)
void ma_encoder_uninit(ma_encoder *pEncoder)
ma_result ma_encoder_init_file(const char *pFilePath, const ma_encoder_config *pConfig, ma_encoder *pEncoder)
ma_encoder_config ma_encoder_config_init(ma_resource_format resourceFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
#define MA_MAX_SAMPLE_RATE
ma_uint32 internalChannels
ma_uint64 ma_decoder_read_pcm_frames(ma_decoder *pDecoder, void *pFramesOut, ma_uint64 frameCount)
ma_resample_algorithm algorithm
@ ma_resample_algorithm_linear
ma_result ma_decoder_init_file(const char *pFilePath, const ma_decoder_config *pConfig, ma_decoder *pDecoder)
@ ma_resample_algorithm_speex
#define MA_MIN_SAMPLE_RATE
#define MA_MAX_FILTER_ORDER