mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Have decoders use their native channel count in the high level API.
This is required so we can do different spatialization logic depending on the channel count of the audio source.
This commit is contained in:
+17
-23
@@ -15,42 +15,36 @@ int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_engine engine;
|
||||
ma_sound sound1;
|
||||
ma_sound sound;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
if (argc < 2) {
|
||||
printf("No input file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = ma_engine_init(NULL, &engine);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize audio engine.\n");
|
||||
return (int)result;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We can load our resource after starting the engine - the engine will deal with loading everything properly. */
|
||||
if (argc > 1) {
|
||||
result = ma_engine_create_sound_from_file(&engine, argv[1], NULL, &sound1);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_engine_uninit(&engine);
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
ma_engine_sound_set_pitch(&engine, &sound1, 0.75f);
|
||||
ma_engine_sound_set_pan(&engine, &sound1, 0.0f);
|
||||
ma_engine_sound_set_looping(&engine, &sound1, MA_TRUE);
|
||||
ma_engine_sound_start(&engine, &sound1);
|
||||
|
||||
|
||||
/*result = ma_engine_play_sound(&engine, argv[1], NULL);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("ma_engine_play_sound() failed with: %s\n", ma_result_description(result));
|
||||
}*/
|
||||
result = ma_engine_create_sound_from_file(&engine, argv[1], NULL, &sound);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_engine_uninit(&engine);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ma_engine_sound_set_pitch(&engine, &sound, 0.75f);
|
||||
ma_engine_sound_set_pan(&engine, &sound, 0.0f);
|
||||
ma_engine_sound_set_looping(&engine, &sound, MA_TRUE);
|
||||
ma_engine_sound_start(&engine, &sound);
|
||||
|
||||
|
||||
|
||||
printf("Press Enter to quit...");
|
||||
getchar();
|
||||
|
||||
/* Normally you would uninitialize and clean up all of your sounds manually because ma_engine_uninit() will _not_ do it for you. */
|
||||
ma_engine_delete_sound(&engine, &sound);
|
||||
ma_engine_uninit(&engine);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user