From: <sv...@op...> - 2024-12-01 18:14:52
|
Author: manx Date: Sun Dec 1 19:14:39 2024 New Revision: 22433 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22433 Log: [Mod] examples: Use float32 instead of int16. Modified: trunk/OpenMPT/examples/libopenmpt_example_c.c trunk/OpenMPT/examples/libopenmpt_example_c_mem.c trunk/OpenMPT/examples/libopenmpt_example_c_unsafe.c Modified: trunk/OpenMPT/examples/libopenmpt_example_c.c ============================================================================== --- trunk/OpenMPT/examples/libopenmpt_example_c.c Sun Dec 1 19:14:07 2024 (r22432) +++ trunk/OpenMPT/examples/libopenmpt_example_c.c Sun Dec 1 19:14:39 2024 (r22433) @@ -72,10 +72,10 @@ #define BUFFERSIZE 480 #define SAMPLERATE 48000 -static int16_t left[BUFFERSIZE]; -static int16_t right[BUFFERSIZE]; -static int16_t * const buffers[2] = { left, right }; -static int16_t interleaved_buffer[BUFFERSIZE * 2]; +static float left[BUFFERSIZE]; +static float right[BUFFERSIZE]; +static float * const buffers[2] = { left, right }; +static float interleaved_buffer[BUFFERSIZE * 2]; static int is_interleaved = 0; static void libopenmpt_example_logfunc( const char * message, void * userdata ) { @@ -208,10 +208,10 @@ } pa_initialized = 1; - pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paInt16 | paNonInterleaved, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); + pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paFloat32 | paNonInterleaved, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); if ( pa_error == paSampleFormatNotSupported ) { is_interleaved = 1; - pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paInt16, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); + pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paFloat32, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); } if ( pa_error != paNoError ) { fprintf( stderr, "Error: %s\n", "Pa_OpenStream() failed." ); @@ -231,7 +231,7 @@ while ( 1 ) { openmpt_module_error_clear( mod ); - count = is_interleaved ? openmpt_module_read_interleaved_stereo( mod, SAMPLERATE, BUFFERSIZE, interleaved_buffer ) : openmpt_module_read_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); + count = is_interleaved ? openmpt_module_read_interleaved_float_stereo( mod, SAMPLERATE, BUFFERSIZE, interleaved_buffer ) : openmpt_module_read_float_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); mod_err = openmpt_module_error_get_last( mod ); mod_err_str = openmpt_module_error_get_last_message( mod ); if ( mod_err != OPENMPT_ERROR_OK ) { Modified: trunk/OpenMPT/examples/libopenmpt_example_c_mem.c ============================================================================== --- trunk/OpenMPT/examples/libopenmpt_example_c_mem.c Sun Dec 1 19:14:07 2024 (r22432) +++ trunk/OpenMPT/examples/libopenmpt_example_c_mem.c Sun Dec 1 19:14:39 2024 (r22433) @@ -44,10 +44,10 @@ #define BUFFERSIZE 480 #define SAMPLERATE 48000 -static int16_t left[BUFFERSIZE]; -static int16_t right[BUFFERSIZE]; -static int16_t * const buffers[2] = { left, right }; -static int16_t interleaved_buffer[BUFFERSIZE * 2]; +static float left[BUFFERSIZE]; +static float right[BUFFERSIZE]; +static float * const buffers[2] = { left, right }; +static float interleaved_buffer[BUFFERSIZE * 2]; static int is_interleaved = 0; static void libopenmpt_example_logfunc( const char * message, void * userdata ) { @@ -254,10 +254,10 @@ pa_initialized = 1; is_interleaved = 0; - pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paInt16 | paNonInterleaved, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); + pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paFloat32 | paNonInterleaved, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); if ( pa_error == paSampleFormatNotSupported ) { is_interleaved = 1; - pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paInt16, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); + pa_error = Pa_OpenDefaultStream( &stream, 0, 2, paFloat32, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); } if ( pa_error != paNoError ) { fprintf( stderr, "Error: %s\n", "Pa_OpenStream() failed." ); @@ -277,7 +277,7 @@ while ( 1 ) { openmpt_module_error_clear( mod ); - count = is_interleaved ? openmpt_module_read_interleaved_stereo( mod, SAMPLERATE, BUFFERSIZE, interleaved_buffer ) : openmpt_module_read_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); + count = is_interleaved ? openmpt_module_read_interleaved_float_stereo( mod, SAMPLERATE, BUFFERSIZE, interleaved_buffer ) : openmpt_module_read_float_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); mod_err = openmpt_module_error_get_last( mod ); mod_err_str = openmpt_module_error_get_last_message( mod ); if ( mod_err != OPENMPT_ERROR_OK ) { Modified: trunk/OpenMPT/examples/libopenmpt_example_c_unsafe.c ============================================================================== --- trunk/OpenMPT/examples/libopenmpt_example_c_unsafe.c Sun Dec 1 19:14:07 2024 (r22432) +++ trunk/OpenMPT/examples/libopenmpt_example_c_unsafe.c Sun Dec 1 19:14:39 2024 (r22433) @@ -46,9 +46,9 @@ #define BUFFERSIZE 480 #define SAMPLERATE 48000 -static int16_t left[BUFFERSIZE]; -static int16_t right[BUFFERSIZE]; -static int16_t * const buffers[2] = { left, right }; +static float left[BUFFERSIZE]; +static float right[BUFFERSIZE]; +static float * const buffers[2] = { left, right }; #if defined( __DJGPP__ ) /* clang-format off */ @@ -88,10 +88,10 @@ #endif fclose( file ); Pa_Initialize(); - Pa_OpenDefaultStream( &stream, 0, 2, paInt16 | paNonInterleaved, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); + Pa_OpenDefaultStream( &stream, 0, 2, paFloat32 | paNonInterleaved, SAMPLERATE, paFramesPerBufferUnspecified, NULL, NULL ); Pa_StartStream( stream ); while ( 1 ) { - count = openmpt_module_read_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); + count = openmpt_module_read_float_stereo( mod, SAMPLERATE, BUFFERSIZE, left, right ); if ( count == 0 ) { break; } |