Commit ce4d4b35 authored by David Reid's avatar David Reid

More work on the new high level API:

  * Implement the notion of a virtual file system (VFS) which is used
    by the resource manager for loading sound files. The idea is that
    the application can implement these to support loading from custom
    packages, archives, etc.
  * Add a helper API for decoding a file from a VFS and a file name.
  * Add some symbols representing allocation types. These are not
    currently used, but I've added them in preparation for changes to
    the allocation callbacks. The idea is that an allocation type will
    be passed to the callbacks to give the allocator better intel as to
    what it's allocating which will give it a chance to optimize.
  * Add some placeholders for flags for controlling how to load a data
    source. Currently only MA_DATA_SOURCE_FLAG_DECODE is implemented
    which is used to indicate to the resource manager that it should
    store the decoded contents of the sound file in memory rather than
    the raw (encoded) file data.
  * Support has been added to the resource manager to load audio data
    into memory rather than naively reading straight from disk. This
    eliminates file IO from the audio thread, but comes at the expense
    of extra memory usage. Support for streaming is not implemented as
    of this commit. Early (largely untested) work has been implemented
    to avoid loading sound files multiple times. This is a simple ref
    count system for now, with hashed files paths being used for the
    key into a binary search tree. The BST is not fully tested and
    likely has bugs which will be ironed out in future commits.
  * Support has been added for configuring the stereo pan effect. Most
    audio engines use a simple balancing technique to implement the
    pan effect, but a true pan should "move" one side to the other
    rather than just simply making one side quieter. With this commit,
    the ma_panner effect can support both modes. The default mode will
    be set to ma_pan_mode_balance which is just a simple balancing and
    is consistent with most other audio engines. A true pan can be used
    by setting the mode to ma_pan_mode_pan.
parent 99fea233
...@@ -28,14 +28,14 @@ int main(int argc, char** argv) ...@@ -28,14 +28,14 @@ int main(int argc, char** argv)
return -1; return -1;
} }
result = ma_engine_sound_init_from_file(&engine, argv[1], NULL, &sound); result = ma_engine_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE, NULL, &sound);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_engine_uninit(&engine); ma_engine_uninit(&engine);
return -1; return -1;
} }
ma_engine_sound_set_pitch(&engine, &sound, 0.75f); ma_engine_sound_set_pitch(&engine, &sound, 1.0f);
ma_engine_sound_set_pan(&engine, &sound, 0.0f); ma_engine_sound_set_pan(&engine, &sound, -1.0f);
ma_engine_sound_set_looping(&engine, &sound, MA_TRUE); ma_engine_sound_set_looping(&engine, &sound, MA_TRUE);
ma_engine_sound_start(&engine, &sound); ma_engine_sound_start(&engine, &sound);
...@@ -55,7 +55,7 @@ int main(int argc, char** argv) ...@@ -55,7 +55,7 @@ int main(int argc, char** argv)
pitchStep = -pitchStep; pitchStep = -pitchStep;
} }
ma_engine_sound_set_pitch(&engine, &sound, pitch); //ma_engine_sound_set_pitch(&engine, &sound, pitch);
Sleep(1); Sleep(1);
} }
......
This diff is collapsed.
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