Commit Graph

3603 Commits

Author SHA1 Message Date
bjorn 8164e0b6e8 TextureData is now named Image!;
The existing Image construct was renamed StorageImage.
2021-02-08 20:17:47 -07:00
bjorn dca79f83f0 SoundData is now named Sound!; 2021-02-08 19:52:56 -07:00
bjorn 8c714c45b0 Clean up some includes; 2021-02-08 11:16:00 -07:00
bjorn 0e318aa46e Make Rasterizer opaque; 2021-02-08 10:58:39 -07:00
bjorn 6d92d54079 Try having arr_t in util; 2021-02-08 18:25:05 -07:00
bjorn bc4cde1653 Adjust lovrRelease signature; 2021-02-08 17:52:26 -07:00
bjorn 3ded60948f rm core/ref; rm lovrAlloc; util does refcounting; 2021-02-08 17:26:44 -07:00
bjorn 1c3e29b3e5 Start windows atomics; 2021-02-08 16:50:43 -07:00
bjorn 1db661f257 Add stdatomic shim to include path; 2021-02-08 16:50:43 -07:00
bjorn 4f5f5b2289 Start stdatomic.h shim; 2021-02-08 16:50:43 -07:00
bjorn ccc53a10aa Cleanup; 2021-02-08 16:08:29 -07:00
bjorn 0877edf9d1 Fix capture; 2021-02-08 16:08:29 -07:00
bjorn 8bf0acd2eb Add minimp3; 2021-02-08 16:08:29 -07:00
bjorn 2c37bd1a58 Only enable specific miniaudio backends;
Start with a conservative set, expand as needed.
2021-02-08 16:08:29 -07:00
bjorn 03f167c4c1 rm reference to openal; 2021-02-08 16:08:29 -07:00
bjorn 1995aae7e9 Simplify enumeration more; 2021-02-08 16:08:29 -07:00
bjorn d1801cfcde Fix Source:getTime; 2021-02-08 16:08:29 -07:00
bjorn ab81361494 Require an argument for an audio device id;
(It can still be nil or a non-userdata value to use the default)
2021-02-08 16:08:29 -07:00
bjorn 60809268e7 Add the ability to request exclusive access to an audio device; 2021-02-08 16:08:29 -07:00
bjorn 111a376a2e SoundData; 2021-02-08 16:08:29 -07:00
bjorn e0ac328a72 SoundData WIP; WAV importer; 2021-02-08 16:08:29 -07:00
bjorn e3e7b265a3 Add the ability to opt-out of default output device initialization; 2021-02-08 16:08:29 -07:00
bjorn 782c22448e Mixer fast paths;
- If no converter is needed, don't create/use it
- If no spatialization is needed, don't copy

In the best case, samples willi now be read into a buffer and immediately mixed into the output.
2021-02-08 16:08:29 -07:00
bjorn 177a94738d 48khz sample rate; fixes; 2021-02-08 16:08:29 -07:00
bjorn 93ea56155e scribbling; 2021-02-08 16:08:29 -07:00
bjorn 025865461c Cleanup; 2021-02-08 16:08:29 -07:00
bjorn 13e100275e Fix style issues; 2021-02-08 16:08:29 -07:00
bjorn 68f5bb3095 Fix style issues; 2021-02-08 16:08:29 -07:00
bjorn cb8e1b5b91 Fix compile errors; 2021-02-08 16:08:29 -07:00
bjorn a3a5b29d6d Minor style changes; 2021-02-08 16:08:29 -07:00
mcc f515d8e84f Code review adjustments (code clarity, constness) for oculus spatializer 2021-02-08 16:08:29 -07:00
mcc 46bb053e0f Late changes on oculus spatializer: Fix memory corruption bug on source delete, add comment 2021-02-08 16:08:29 -07:00
mcc 9ba4037e74 LOVR_USE_OCULUS_AUDIO
This is a large patch which adds a new Oculus Audio spatializer. Oculus Audio is slightly different from the dummy spatializer in a few ways:

    - It *must* receive fixed-size input buffers, every time, always.
    - It can only handle a fixed number of spatialized sound sources at a time.
    - It has a concept of "tails"; the spatialization of a sound can continue after the sound itself ends (eg echo).

Changes to audio.c were needed to support Oculus Audio's quirks:

    - audio.c now supports a "fixedBuffer" mode which invokes the generator/spatializer in fixed size chunks
    - Each source now has an intptr_t "memo" field that the spatializer may use to store whatever (Oculus spatializer uses this to handle the sound source limit).
    - The spatializer interface got a couple new methods: A "tail" method which returns a sound buffer after all sources are processed; and "create" and "destroy" methods that are called when a sound source is created or destroyed (Oculus spatializer uses this to populate/clear the "memo" field).

Along the way some other miscellaneous changes got made:

    - lovr.audio.getSpatializerName() returns the current spatializer
    - Spatializer init now takes in "config in" and "config out" structs (Spatializer changes fields in config out to request things, currently fixed buffer mode).
    - lovr.conf now takes t.audio.spatializer (string name of desired spatializer) and t.audio.spatializerMaxSourcesHint (Spatializers with max sources limits like Oculus will use this as the limit).
    - audio.c went back to tracking position/orientation as vectors rather than a matrix
    - A file oculus_spatializer_math_shim.h was added containing a minimal copypaste of OVR_CAPI.h from Oculus SDK to support a ovrPoseStatef the spatializer API needs. This may have license consequences but we are probably OK via a combination of fair use and the fact that a user cannot use this header file without accepting Oculus's license through other means.

Some work remains to be done, in particular there is an entire reverb feature I did not touch and LOVR_USE_OCULUS_AUDIO cannot be activated from tup. Oculus Spatializer works better when it has velocity and time information but this patch does not supply it.
2021-02-08 16:08:29 -07:00
mcc bbf26ad4eb LOVR_DEBUG_AUDIOTAP debug helper in audio.c 2021-02-08 16:08:29 -07:00
mcc fb2d4fe0ca Fix build on MSVC2019 (ptr arithmetic on void * is nonstandard) 2021-02-08 16:08:29 -07:00
mcc 061f613697 Remove unused openal-soft module
This was breaking mercurial.
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 5cc33b3ee5 oops, use capture device for capture, not playback 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson d618a2e629 lovr.audio.isRunning 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson f5a684f359 Fix broken listener orientation code in dummy spatializer
it's a quat, not an axis-angle. now it works :)
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 84bfac984c l_audio: less code
why is this so hard for my brain? :S
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 7f5e46ad0b audio: don't uninit device on stop
in case initing a device is expensive, don't do it
unnecessarily, and treat 'stop' as more of a 'pause'.
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson c542be254e setDevice fix on android 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 2719eba1ba lovrAudioSetCaptureFormat
instead of mixing up using device with using format
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 49288b7547 ma_result_descripion all the things 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson a7b0780bfc Don't allow invalid sample format 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 9ba8638028 Audio: Simplify enabled/started/reset
* Stop also uninitializes
* Reset doesn't exist. Just stop and start instead.
* lovrAudioInit no longer takes config, and config is now private.
  Call lovrAudioStart if you want to start.
* ma_device_{un}init and start/stop are only called from one place each,
  reducing the risk of dangling state
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 138853ef01 Fix getDevices API
* Takes device type, so you only get either playback or capture devices
* Doesn't store devices in state, reducing risk of dangling pointers
* Uses names instead of identifiers, since miniaudio identifiers become
  invalid if you call "getDevices" again
* Better diagnostics
* Split up lovrAudioInitDevice to be per-type, cleaner that way
* UseDevice now takes type and name, instead of just identifier
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 9c7bc7c8db stub out pico permissions so we can compile 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson a5d073c5db stop void* arith 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 9ea635199d Forgot a return... 2021-02-08 16:08:29 -07:00