Commit 31f08287 authored by David Reid's avatar David Reid

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.
parent c0ebf416
...@@ -15,42 +15,36 @@ int main(int argc, char** argv) ...@@ -15,42 +15,36 @@ int main(int argc, char** argv)
{ {
ma_result result; ma_result result;
ma_engine engine; ma_engine engine;
ma_sound sound1; ma_sound sound;
(void)argc; if (argc < 2) {
(void)argv; printf("No input file.\n");
return -1;
}
result = ma_engine_init(NULL, &engine); result = ma_engine_init(NULL, &engine);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize audio engine.\n"); 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. */ result = ma_engine_create_sound_from_file(&engine, argv[1], NULL, &sound);
if (argc > 1) { if (result != MA_SUCCESS) {
result = ma_engine_create_sound_from_file(&engine, argv[1], NULL, &sound1); ma_engine_uninit(&engine);
if (result != MA_SUCCESS) { return -1;
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);
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);
/*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));
}*/
}
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); 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); ma_engine_uninit(&engine);
return 0; return 0;
......
...@@ -30,9 +30,6 @@ subtle bugs there. ...@@ -30,9 +30,6 @@ subtle bugs there.
Some things haven't yet been fully decided on. The following things in particular are some of the things I'm considering. If you have any opinions, feel free Some things haven't yet been fully decided on. The following things in particular are some of the things I'm considering. If you have any opinions, feel free
to send me a message and give me your opinions/advice: to send me a message and give me your opinions/advice:
- You need to explicitly start playback with `ma_engine_start()`. I'm considering making the default behaviour cause it to auto-start when the first sound
is started. The question then is do we automatically stop it when the last sound is stopped? If so, would we still auto-stop it if the user explicitly
called `ma_engine_start()`?
- I haven't yet got spatialization working. I'm expecting it may be required to use an acceleration structure for querying audible sounds and only mixing - I haven't yet got spatialization working. I'm expecting it may be required to use an acceleration structure for querying audible sounds and only mixing
those which can be heard by the listener, but then that will cause problems in the mixing thread because that should, ideally, not have any locking. those which can be heard by the listener, but then that will cause problems in the mixing thread because that should, ideally, not have any locking.
- No caching or background loading is implemented in the resource manager. This is planned. - No caching or background loading is implemented in the resource manager. This is planned.
...@@ -417,7 +414,7 @@ MA_API ma_result ma_resource_manager_create_data_source(ma_resource_manager* pRe ...@@ -417,7 +414,7 @@ MA_API ma_result ma_resource_manager_create_data_source(ma_resource_manager* pRe
return MA_OUT_OF_MEMORY; return MA_OUT_OF_MEMORY;
} }
decoderConfig = ma_decoder_config_init(pResourceManager->config.decodedFormat, pResourceManager->config.decodedChannels, pResourceManager->config.decodedSampleRate); decoderConfig = ma_decoder_config_init(pResourceManager->config.decodedFormat, 0, pResourceManager->config.decodedSampleRate);
result = ma_decoder_init_file(pName, &decoderConfig, pDecoder); result = ma_decoder_init_file(pName, &decoderConfig, pDecoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_free(pDecoder, NULL); ma_free(pDecoder, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment