Commit Graph

3267 Commits

Author SHA1 Message Date
bjorn bec4fc3169 phonon: implement convolution reverb; 2021-02-24 17:43:42 -07:00
bjorn ec96a126d7 phonon: accessors; multiple sources; start reverb; 2021-02-24 17:43:42 -07:00
bjorn 5f2cdf0c22 phonon: Directivity adjustments; 2021-02-24 17:43:42 -07:00
bjorn f60d6c8900 phonon: I hate typing dipole; 2021-02-24 17:43:42 -07:00
bjorn 7f032b7a3e phonon: Change absorption to a boolean; 2021-02-24 17:43:42 -07:00
bjorn 90ca17c454 phonon: Change falloff to a boolean; 2021-02-24 17:43:42 -07:00
bjorn 87bbec7018 phonon: setGeometry test; 2021-02-24 17:43:42 -07:00
bjorn 16cfb7bad5 phonon: binaural renderer, binaural effect, HRTF; 2021-02-24 17:43:42 -07:00
bjorn ac96556a13 phonon: Source:get/setDirectivity; 2021-02-24 17:43:42 -07:00
bjorn 66e574baac phonon: Source:get/setAbsorption; 2021-02-24 17:43:42 -07:00
bjorn c531243d7d phonon: Source:get/setFalloff;
The falloff is the minimum distance at which inverse distance
attenuation takes place.

A non-positive value disables distance attenuation.

In the Lua API, nil can be used to disable attenuation, a boolean can be
used to enable attenuation with a default minimum distance, or a number
can be used for full control over the parameter.
2021-02-24 17:43:42 -07:00
bjorn 0af7e98fad phonon: rearrange Source accessors; 2021-02-24 17:43:42 -07:00
bjorn 584138c937 phonon: Compute listener/source basis vectors; 2021-02-24 17:43:42 -07:00
bjorn f4a8a4d388 WIP; 2021-02-24 17:43:42 -07:00
bjorn 8bbb092497 Start phonon spatializer; 2021-02-24 17:43:42 -07:00
bjorn 5d542eb2ea Minor Sound cleanup; 2021-02-24 14:11:49 -07:00
bjorn 7d0dfc9cdd Sound: Ambisonic support;
Add support for importing ambisonic WAV files and 24/32 bit PCM WAV files.

The standard ambisonic format used internally in LÖVR is ACN channel ordering with SN3D normalization.
Anything else will be converted to this form.

There are a few restrictions and assumptions:

- Only 1st order ambisonics are supported.  They need to have 4 channels.
- They can be in AMB format (Furse-Malham order/normalization), detected via WAVE_EXTENSIBLE GUID.
- Any other 4 channel file is assumed to be in "AmbiX" ACN/SN3D format.
  - It seems that most ambisonic files in the wild that claim to be AmbiX are just 4 channel WAVs without any metadata.
  - This means that non-ambisonic 4 channel WAVs could ambiguously be mistaken as ambisonic.  This is incurred as a limitation of LÖVR.
- Ambisonic files can not currently be played back.  SteamAudio currently has numerous bugs with this.
  - Perhaps it would be possible to write an ambisonic rotator/panning decoder to use as a default implementation.
2021-02-24 14:11:49 -07:00
bjorn 1d1a2de124 Only use CTZL in audio; 2021-02-24 14:11:49 -07:00
bjorn 72a54bce2f Support STL models;
Only binary STL files are supported right now, ASCII is more challenging.
2021-02-23 12:07:16 -07:00
bjorn a430ae06b8 Early-reject OBJ files;
OBJ files must start with a vertex, object, mtllib, or comment.
2021-02-23 12:05:11 -07:00
bjorn f1922e22c8 Sharpen nogame screen; 2021-02-22 17:53:47 -07:00
bjorn 1145085446 macOS fixes; 2021-02-22 17:07:28 -07:00
bjorn fb1447503b Fix gcc warnings; 2021-02-19 23:44:23 -07:00
bjorn ef438d48b3 Upgrade stb_vorbis; 2021-02-19 23:44:23 -07:00
mcc ffa63e9912 Allow the creation of a (potentially infinite-length) Sound created by a dynamically run callback 2021-02-19 21:30:16 -07:00
bjorn 57a215a0aa Minor MeshShape cleanup;
- Fix memory leak
- Minor error message improvements
2021-02-19 17:28:04 -07:00
bjorn 880d06a1d1 Only enable compute extensions on desktop GL; 2021-02-19 14:09:40 -07:00
bjorn 1757d30a59 Compute shader feature detection adjustment;
- Compute feature requires compute shaders, image load/store, and SSBOs.
- GLSL 330 is always used, instead of changing depending on compute shader extension.
- Explicitly enable compute shaders, image load/store, and SSBO extensions when needed.

This allows implementations that don't support GLSL 430 to run compute shaders,
and keeps the min supported GL version more consistently at GL3.3.
2021-02-19 14:07:27 -07:00
bjorn a0b2200bef Fix lovr.graphics.getBlendMode when blending is off; 2021-02-19 14:05:18 -07:00
bjorn 26d009aada Fix sample conversion when only channel count conversion is required; 2021-02-19 12:35:52 -07:00
bjorn 9c1af7427f Fix restart cookie on wasm; 2021-02-19 09:06:16 -07:00
bjorn a2b7e1619d Fix wasm compilation issues; 2021-02-19 09:05:57 -07:00
bjorn 0365f51f9d Fix crash when drawing zero lines; 2021-02-19 08:38:45 -07:00
bjorn 7ef215c312 simulator: fix aspect ratio; 2021-02-19 08:30:57 -07:00
bjorn 6c74a61ae3 simulator: Fix getDisplayDimensions;
getDisplayDimensions is supposed to return the dimensions of one eye.
2021-02-19 08:29:38 -07:00
bjorn 36170678f0 Sound: Change channel count to channel layout; 2021-02-18 21:17:25 -07:00
bjorn 08916df2f1 Tell spatializers about sources only when they're active;
apply will still only be called with sources after they have been created.
2021-02-18 20:49:20 -07:00
bjorn 952fee3bd1 Rework audio converters;
They are stored by value in the array so they are contiguous.

Source stores the index of its converter to save a bit of space and avoid realloc.
2021-02-17 22:47:50 -07:00
bjorn 7b7f6bbaeb Simplify FOREACH_SOURCE; 2021-02-17 22:36:24 -07:00
bjorn cb8a1e8962 Free playing Sources properly; 2021-02-17 22:31:03 -07:00
bjorn 75fda2336f Enforce strict limit of 64 active sources;
If 64 sources are playing and a new one is started, Source:play will
return false.

Instead of a linked list, a static list of 64 Sources is used.

Bit scanning intrinsics are used to efficiently iterate the list,
using a mask (still deciding on this).
2021-02-17 20:46:33 -07:00
bjorn ea64f32c1f Source:clone; 2021-02-16 21:34:53 -07:00
bjorn 8cc96847a8 Fix sign warnings; 2021-02-16 21:02:12 -07:00
mcc a3c76a95ab Two additional arguments to shaderBlock:send(): an offset and a size. If present, only part of the shaderBlock will be sent. 2021-02-16 17:26:18 -07:00
bjorn 72284c2c5b Merge branch 'master' into dev 2021-02-12 08:16:36 -07:00
bjorn 023067ec27 util.h no longer uses atomics; 2021-02-11 16:37:55 -07:00
bjorn 28e88d7598 Reorganize spatializer files/CMake; Oculus Audio tup support; 2021-02-10 12:41:15 -07:00
bjorn 5ae5acfb18 Make Font texture rgba16f;
Sampling from rg11b10f does not appear to work on mobile.
2021-02-10 15:22:30 -07:00
bjorn 0919da4091 Improve MSDF font shader; Add spread/padding settings to Font; 2021-02-10 07:08:29 -07:00
bjorn 7b136b914c Update msdfgen;
- Rasterizer (maybe temporarily) uses 32 bit float textures.
2021-02-10 04:03:43 -07:00
bjorn f8ed6c3a34 physics: Use dReal in more places;
This makes it easier to swap between float/double.
2021-02-09 23:24:27 -07:00
bjorn b343f50f1c mv l_data_textureData->l_data_image; 2021-02-09 21:14:09 -07:00
bjorn 351d1ae200 Fix vrapi includes; 2021-02-09 20:03:53 -07:00
bjorn 50ee404b91 Default lovr.run no longer requires timer and event modules; 2021-02-09 08:27:11 -07:00
bjorn 7db979b655 Fix arr_free;
realloc(NULL, 0) isn't valid.
2021-02-09 08:15:43 -07:00
bjorn 9377406854 Fix font wrap issue with spaces;
If a space starts before the wrap limit, but ends after it, the next
word won't wrap properly even though it should.
2021-02-09 08:06:37 -07:00
bjorn 39c0fa6e99 Don't set audio listener pose automatically;
It isn't always correct once you add locomotion to a project, and
it actually becomes harmful because the pose ping-pongs between
the default pose and the user pose, causing distortion.
2021-02-09 07:52:12 -07:00
bjorn 84f65c26e4 Move utf8 back into util; 2021-02-08 20:55:51 -07:00
bjorn 907cf35dda rm string.h from api.h; 2021-02-08 20:29:57 -07:00
bjorn 78ddcf7d6e rm extra reference to AudioStream; 2021-02-08 20:24:21 -07:00
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 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 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
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
Nevyn Bengtsson 10af0e5748 oops, capturing with wrong bytesPerFrame 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 46e9ae8ef5 oops 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 5fcaad9bde Change mic capture API to return SoundData stream instead of individual chunks 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 044a5a47d9 allow configuring sound format and sample rate 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 035f48927a fix various audio logging 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson f98140c601 make converters array one of pointers
so that converters are allocated on heap and the converters
array can be expanded later without moving the converter
itself
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson f8c29d1c79 bump to miniaudio with Quest fix
This is a WIP version v0.10.28 aka 6c60953e9cb587
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 8133966148 take out lovrDataNewSoundDataStream 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 0d36cdd443 nicer assert in sound data append 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 213c721d1f oops 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson eee1d09cc4 SoundDataSetSample: only allowed on raw; and check frames instead of blob size 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 5df40bb103 don't try to forward-declare mb_pcm_rb 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson e1c94c3084 stop depending on audio from data 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 8b594332dc Revert miniaudio to 0.10.12
aka a9541579f38a0c1bab4bba294f3602fa0b80f127, plus cherry-pick of
2dc604ecde0f02280690c72f943bfb8bf52dd820.

There is a crasher in 0.10.13 and newer on Oculus Quest
(See https://github.com/mackron/miniaudio/issues/247)
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson d8dd09eb8d oops, initialize source's transform
otherwise we'll get NaNs up in here
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 6d62e634d4 oops 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson e46079b368 lovrAudioUseDevice 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 9381e2027d audio.getDevices full impl 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson ebcc5f51d7 Devices WIP 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 53d3568528 don't assert on audio thread 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 3e003d55b9 Separate SoundData and SoundDataStrema constructors
they take the same arguments so we can't overload
the function parameterically.
also I find it pretty confusing that lovr uses
overloads so much in the api,
so I really don't mind having
a separate constructor :S
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 35ac33f184 SoundData:setSample 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson f5fcb73324 duration and time for stream sounddata 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 8c1aa5a8ef lua API for SoundData:append 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 2a875b129b Fix a few bugs and style fixes
* We can't realloc converters, that'll break internal pointers
* inverted condition in an assert
* less magic numbers
* can't loop streams
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 3c535986f0 SoundData: deallocate rb 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson d1f6e27437 SoundData stream lua API 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 7b58561c03 lovrSoundFormat 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson cd1cddcd93 WIP streaming SoundData
It seems Bjorn had the idea to back SoundData with
an array of buffers, so I'm running
with that but changing the array
into a ringbuffer.
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 55b5a9947c audio_internal.h with some shared utilities 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 381e3f3850 Bump miniaudio to 0.10.27
aka caad0bc436ade1633cdc47892bd0d9a36623a298
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson f7d027a3ce Audio permissions seem to work without AppCompat 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 7efc855929 Fix various Capture bugs 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 1e05f29da4 Fix broken SoundData _Reg 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 33e4524fd8 oops, this method can't use assert...
because then mic capture can't use the failure to trigger a permissions check
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 8678414628 audio_capture -> audiocapture
to follow ENTRY naming standard
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson d4a5e06932 no need for a capture lock 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson e05d554528 review: fprintf -> lovrAssert 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson ebf5fbef24 state.spatializer must never be null 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson cdbefafc1a review: style fixes 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 5e66ecf000 lovrPlatformRequest{AudioCapture->Permission}(Perm) + platform stubs 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 084ac9d880 review: newSource() gets options table 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson b7b63a268b review: getSpatial > isSpatial 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 0265babef4 Android: Ask for permissions on demand
By looking for failed start and requesting then;
and then emitting a new event type when
permission has been granted or rejected;
and then using that event in the default
boot.lua to re-start capture.
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson aa3dc76176 Audio: Don't open capture at start, allow it to be enabled later
So that we can try once on demand,
and again when permissions are granted
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson a941c5b02a record audio permission in manifest 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 1b8a951007 magic numbers and typos 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 2a3526bcd7 Android: Ask for audio permissions on startup
Will change this to ask on demand in an upcoming commit
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson e54629dfb0 Android: Link appcompat so we can ask for audio capture permissions 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 6f803ad3f0 filesystem.append didn't append in Unix 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 2317ae31cd miniaudio: cherry-pick 2dc604ecde0f02280690c72f943bfb8bf52dd820
This fixes capture on linux/pulseaudio
2021-02-08 16:08:29 -07:00
Nevyn Bengtsson a344acd84f SoundData:getBlob 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 139c80fc28 Capture audio (and remove more magic numbers, and clean up some misconceptions) 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 033817bd74 audio capture stubs 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 5c2e270c3f audio: clean up some magic numbers 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 407742e8b5 make Source:setSpatial a constructor option instead 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 8403c9bd70 just a super dummy spatializer 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 01b8a6baa6 spatializer hooks to mixer 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson fe8a6e8612 expose Source:{get|set}Spatial 2021-02-08 16:08:29 -07:00
bjorn 533939e673 Source:getDuration; Source:get/setTime; 2021-02-08 16:08:29 -07:00
bjorn f7169ec236 Source:pause; Source:stop; Source:isPlaying; 2021-02-08 16:08:29 -07:00
bjorn cbf0416988 Update to new enum system; 2021-02-08 16:08:29 -07:00
bjorn 70839535f3 WIP; 2021-02-08 16:08:29 -07:00
bjorn 121a4f7108 Start spatialization and data conversion systems; 2021-02-08 16:08:29 -07:00
bjorn 40cffbe590 Remove integer conversion APIs from stb_vorbis; 2021-02-08 16:08:29 -07:00
bjorn 1eb4070c92 Mixing; 2021-02-08 16:08:29 -07:00
bjorn 205e9404e0 Looping, playback; 2021-02-08 16:08:29 -07:00
bjorn c92b47e3a6 Another miniaudio attempt WIP; 2021-02-08 16:08:29 -07:00
bjorn ed09bc3cfa rm unnecessary newlines in assert messages; 2021-02-07 16:58:50 -07:00
bjorn 1dd692a009 lovrPlatformGetWindow -> lovrPlatformGetWin32Window; 2021-02-07 16:57:08 -07:00
bjorn 0e375804fe Only include <lualib.h> when needed; 2021-02-07 16:51:31 -07:00
bjorn 323436898a Add WIN32_LEAN_AND_MEAN; 2021-02-07 16:49:34 -07:00
bjorn d2ff6c29ac Change inclusive module defines to exclusive;
This reduces the number of flags needed to get a regular build.
2021-02-07 16:45:03 -07:00
bjorn 709a41a352 Do more rendering work when lovr.draw is missing;
- The lovr.headset.renderTo callback can now be nil, causing an empty frame to be submitted to the compositor.
- lovr.mirror will still be called if lovr.draw is nil.  This means the window will be (correctly?) cleared to the background color now if lovr.draw is nil.

This prevents runtimes from thinking the app is missing/unresponsive when lovr.draw is absent.  To get the old behavior, just don't call lovr.headset.renderTo.
2021-02-05 15:03:06 -07:00
bjorn cf2ab46bef Fix arr_splice; 2021-02-04 01:41:35 -07:00
bjorn 0cb8a004d3 webxr.js: update emscripten dynCall syntax; 2021-01-25 14:02:15 -07:00
bjorn 24484f3930 Fix lovrInstanceID on Android; 2021-01-25 13:10:25 -07:00
Bjorn e2bda48739
Merge pull request #364 from jmiskovic/fix/lookat
Add mat4:targetAt and modify the mat4:lookAt
2021-01-22 08:28:38 -07:00
Josip Miskovic 944a6029f0 Add mat4:targetAt and modify the mat4:lookAt
lookAt() returns view matrix that can be used to transform the camera
perspective. target() returns model matrix that is used to change
model transform. Results are matrix inversions of one another. Now both
functions exist it is possible to use right one and avoid extra matrix
inversion.
2021-01-22 16:01:27 +01:00
Christoph Haag 394759c1ab initialize XrSystemProperties type 2021-01-22 15:43:01 +01:00
bjorn deeaff7a00 lovr.filesystem.write/append take Blobs; 2021-01-20 10:55:10 -07:00
bjorn 522987c211 64 bit nightly builds; 2021-01-08 21:26:03 -07:00
bjorn f1a5887133 WIP holographic_controller bindings; 2021-01-08 21:18:03 -07:00
bjorn 0c03be1090 tup updates;
- rm json and enet (they're plugins now)
- ignore a warning in stb_image
2021-01-07 14:35:28 -07:00
Bjorn 10cc0011a5
Merge pull request #338 from bferguson3/master
Removed erroneous manifest entry
2020-12-28 15:55:48 -07:00
bjorn 3f975bcc8f Android plugin support;
- Link against dl (this was probably why ffi.load didn't work)
- Store shared libraries in the apk uncompressed
  - Libraries are added during the "package" aapt call instead of "add".
    - Because -0 (used to store uncompressed) only works during package.
    - classes.dex is added here too now.
    - There's only one aapt invocation now, which is kinda nice.
  - The lib folder needs to be in a subfolder now ("raw" was chosen).
    - Because "package" and "add" subcommands work differently.
  - Store shared libraries in the apk page aligned
    - Required passing -p to the zipalign invocation.
    - This is needed because dlopen("zip!path") needs it.
  - android:extractNativeLibs="false" is added to the XML manifest.
  - apk sizes are bigger, but disk usage and install time should improve.
- Fix a bug with moving plugin libraries into the lib folder with CMake.
- Use lovrFilesystemGetSource instead of lovrFilesystemGetExecutablePath
  to get the proper path to the apk.
2020-12-28 14:45:56 -07:00
bjorn 5fdf88224d Plugin loader uses platform-native path separator; 2020-12-28 12:37:35 -07:00
bjorn b356ce2546 Plugins;
- The plugins folder can contain native plugins.
- CMake will build plugins with CMakeLists in them
  - They can check the LOVR variable to see if they are being built inside LOVR.
  - They can set the LOVR_PLUGIN_TARGETS variable to a list of targets they build.
    - If blank, all non-imported targets added in the folder will be used.
  - The libraries built by their targets will be moved next to the executable or into the apk.
- The library loader now tries to load libraries next to the executable or in the APK.
  - It is "fixed function" now, this may be improved in the future.
- The lovr.filesystem C require path has been removed.
- enet and cjson have been removed.  Use plugins.
2020-12-28 12:37:35 -07:00
bjorn 31defbe145 maf windows PI fix; 2020-12-28 12:37:19 -07:00
bjorn 32fb7a7cb2 rm --root arg; 2020-12-25 16:52:06 -07:00
bjorn 30e01f94a3 Upgrade stb_image; rm stb_image threadlocal patch;
stb_image's vertical flip flag was not thread safe in the version
of stb_image we were using.  We patched stb_image to use a thread
local variable for the flag.  stb_image has since been upgraded to
expose a thread local version of the flag, so our patch is no longer
necessary after upgrading.

The CMake flag to enable the thread local patch did not make very much
sense because thread local stuff is unconditionally used elsewhere.
2020-12-25 16:43:25 -07:00
bjorn 6cf74a976d Spacing; 2020-12-25 12:51:18 -07:00
bjorn d81a822bbc rm dead lovrMathOrientationToDirection declaration; 2020-12-25 12:50:50 -07:00
bjorn 3bc2c00b79 api doesn't include util; 2020-12-25 12:50:26 -07:00
bjorn 9bdceb0094 rm LOVR_INLINE;
Just use the inline keyword which is C99.  Getting util.h out of
maf.h is nice.
2020-12-25 12:29:22 -07:00
bjorn 1a8f972f39 rm MAF_EXPORT;
It was only used when exporting functions for JavaScript.
2020-12-25 12:22:42 -07:00
bjorn 1fc1af8203 rm LOVR_EXPORT from luaopen_lovr definition;
It's only needed on the declaration.
2020-12-25 12:22:10 -07:00
bjorn 25811f1c01 Change default require paths;
The lua_modules+deps paths were added for a LuaRocks experiment.
2020-12-25 12:20:58 -07:00
bjorn 96839c5181 Slightly better error messages on image load failure; 2020-12-15 20:20:25 -07:00
bjorn e887d46256 Fix crash on non-string thread errors;
Non-string errors are currently ignored.  This is consistent with
love, and is pretty obscure, but maybe it can be improved at some point.
2020-12-11 04:41:48 -07:00
Bjorn 1513191660
Merge pull request #335 from bjornbytes/trackers
Support Vive Trackers;
2020-12-10 21:49:26 -07:00
bjorn d33053cd01 Add comment; 2020-12-03 09:03:43 -07:00
bjorn 8ef50b5f6a lovr.mirror: don't call lovr.headset.getMirrorTexture twice; 2020-12-02 14:46:37 -07:00
Bjorn c1b3bc61b1
Merge pull request #340 from alloverse/fix/append
filesystem.append didn't append in Unix
2020-11-27 18:53:44 -07:00
Colby Klein 08025b9ac0
fix mat4_lookAt translation offset
need to dot with the axes to not have bizarre results.
2020-11-27 17:48:33 -08:00
Piotr Łabuda f60441d905 Reverting binding to base 2020-11-27 21:06:26 +01:00
Nevyn Bengtsson c557a8585f filesystem.append didn't append in Unix 2020-11-26 22:54:41 +01:00
Ben Ferguson 0ef23bb7e2 Removed erroneous manifest entry 2020-11-23 16:21:22 -05:00
bjornbytes eb319fdade Fix trailing whitespace; 2020-11-21 14:37:47 -07:00
bjornbytes 80a33c0544 mat4_multiply -> mat4_mul;
quat_mul vs. mat4_multiply is inconsistent.  Going with mul over
multiply is consistent with vec3_sub and Lua's __mul metamethod.
2020-11-21 14:32:59 -07:00
bjornbytes 314a5a9a2d vrapi: cleanup; fix getPose for non-head/hands devices; 2020-11-21 14:24:20 -07:00
bjornbytes 842efe36c7 Handle openvr-specific warnings more precisely;
Instead of disabling a warning for the entire project, it is only
disabled while processing the OpenVR header.
2020-11-21 14:09:51 -07:00
bjorn 1ff94bc29a Default errhand agnostic to t.math.globals; 2020-11-20 19:23:42 -07:00
Piotr Łabuda d65c72d7c6 Added bindings to pose/base 2020-11-21 00:37:32 +01:00
Nevyn Bengtsson dfacb6408b on lodr restart, make sure lovr.headset is nil'd if none is available
In boot.lua, it assumes that lovr.headset.init will assert if no driver
is available. This was previously only true on the first call to it,
since after it's initialized, it'll just return early and won't assert.
This will later crash since your lua code will now see a lovr.headset
being available, but calling anything in it will crash since
lovrHeadsetDisplayDriver is NULL

After this fix, initialized becomes false before boot sets up the
headset module again, so that the assertion fires correctly.
2020-11-20 10:04:01 +01:00
bjorn ad42609b1d Support Vive Trackers; 2020-11-19 00:39:38 -07:00
Jakob Bornecrantz cf22c11dd5 Do not try to create hand tracking devices if handTracking is not supported 2020-11-18 21:31:09 +00:00
Nevyn Bengtsson 220aa70d7c fix crash in error handler when running out of vectors 2020-11-18 21:38:04 +01:00
Jakob Bornecrantz ca04882093 OpenXR: Add support for X11 and EGL on Linux 2020-11-16 17:02:51 -07:00
bjornbytes 94e7bafe47 KeyCode -> KeyboardKey because X11 conflict; 2020-11-16 17:02:51 -07:00
bjorn c6b4981389 Fix OpenXR view matrix; 2020-11-16 17:02:51 -07:00
Bjorn 8a3d365268
Merge pull request #299 from Wallbraker/linux-openxr
Linux OpenXR support
2020-11-16 13:51:41 -07:00
Josip Miskovic ceaac78439 Fix NaN return from mat4 unpacking
The caluclated angle is forced to PI if cos(angle) falls outside the
[-1, +1] range due to floating point precision error.
2020-11-16 19:03:52 +01:00
Jakob Bornecrantz 1400cd201a OpenXR: Add support for X11 and EGL on Linux 2020-11-15 22:51:20 +00:00
bjornbytes 0b73e7d7a6 KeyCode -> KeyboardKey because X11 conflict; 2020-11-15 22:51:20 +00:00
bjorn a139ed33e5 Fix OpenXR view matrix; 2020-11-15 22:49:00 +00:00
Ben Ferguson 63a141dc54 Add Quest 2 90hz to android manifest 2020-11-14 09:21:01 -05:00
Bjorn df3b918f74
Merge pull request #327 from jmiskovic/feature/curve-empty
Create empty curve with specified number of points
2020-11-13 12:33:48 -07:00
Josip Miskovic 1defba8f24 Create empty curve with specified number of points
This `lovr.math.newCurve(n)` variant is already described in API
documentation, now it is implemented.
2020-11-13 17:53:37 +01:00
Bjorn 4ec1494d29
Merge pull request #329 from jmiskovic/fix/damping-threshold
Change default damping threshold to zero
2020-11-12 18:09:17 -07:00
Nevyn Bengtsson 453d348fdc Stack trace when background thread crashes
Without this, the error handler only prints the _main thread's
error handler's_ stack trace
2020-11-12 18:08:05 -07:00
bjorn e8db2f8187 Basic cylinder uvs; 2020-11-12 18:08:05 -07:00
bjorn 43d5bc78f0 lovr.mirror disables blending when drawing headset texture;
This is so transparent headset textures (when rendering overlays)
don't ghost.  Alternatively, clear could be used.
2020-11-12 18:08:05 -07:00
bjorn b2cb2c8752 Fix l_event; 2020-11-12 18:08:05 -07:00
bjorn 1a1605f9ce rm textureData include; 2020-11-12 18:08:05 -07:00
bjorn 75c37bf7e9 rm trailing whitespace; 2020-11-12 18:08:05 -07:00
bjorn 276faf30ad l_event cleanup; 2020-11-12 18:08:05 -07:00
bjorn e533adf649 openxr indentation; 2020-11-12 18:08:05 -07:00
bjorn cdac6bf146 Fix textureData include; 2020-11-12 18:08:05 -07:00
bjorn 5f0542cc43 Fix util declspec spacing; 2020-11-12 18:08:05 -07:00
bjorn 827dfda748 TextureData:encode returns Blob; rm core/png; 2020-11-12 18:08:05 -07:00
bjorn 1e7749a58a Fix MSVC warnings;
It's that time of year.
2020-11-12 18:08:05 -07:00
bjornbytes a81cd0d731 KeyCode -> KeyboardKey because X11 conflict; 2020-11-12 18:08:04 -07:00
bjorn 362e5525e7 Fix OpenXR view matrix; 2020-11-12 18:08:04 -07:00
bjorn 81065a6e6b Ref overflow no longer prints filename;
It was an absolute path.
2020-11-12 18:08:04 -07:00
bjorn 4ef944d7c1 lovrDestroy calls lovrPlatformDestroy; 2020-11-12 18:08:04 -07:00
bjorn f472f0161c os_web: Unregister callbacks in lovrPlatformDestroy; 2020-11-12 18:08:04 -07:00
Josip Miskovic b4d391f45f Change default damping threshold to zero
Zero as default makes more sense. Colliders can come to full stop which
allows them to go to sleep for CPU optimization. Also in zero gravity
colliders crawling through air with 0.01 velocity are infuriating.
2020-11-12 18:28:59 +01:00
Josip Miskovic b735015f6e Check if shape can be positioned and oriented
Shape without attached collider cannot be positioned or oriented. Trying
to do so results in ODE crash. Better to throw a more descriptive error.
2020-11-12 17:18:40 +01:00
Patrik Sjöberg ec501903d5 Correct the argument indices for Source:setCone 2020-11-11 22:17:10 +01:00
bjorn 61eaf579cd Thread local vector metatable refs; 2020-11-06 13:12:57 -07:00
Nevyn Bengtsson 326d275424 don't free window icon before it's used
It seems to me like that lovrRelease will delete textureData->blob immediately,
which means the windowing system later can't use it because it's already freed.
There's already a free on line 378 which looks more correct.

Also, icon appears flipped if 'flipped' is set to true here on Linux. Is GLFW
inconsistent between linux and windows, or should it indeed be false?
2020-11-06 21:00:38 +01:00
bjornbytes 5c381ead34 Force set vsync in lovrGraphicsCreateWindow;
Headset drivers are allowed to override the vsync setting if vsync
messes up their frame timing.  The vsync property is effectively a
global piece of state in core/os and doesn't change across restarts
because the window is persistent.  This can mean that if you switch
from a headset driver that wants vsync off (anything except desktop)
to a headset driver that doesn't care what the vsync is (desktop),
you could end up with a vsync setting that doesn't match t.window.vsync.
I think this is a symptom of poor design somewhere and the best solution
to this probem is "to just not have it".  Similar issues exist for, e.g.
the window size (but that one is less weird because at least you were
the one who changed it).  For now we are just going to ensure that
lovr.graphics.createWindow always modifies the vsync property.
Untested, may need to adjust this fix later.
2020-11-02 11:57:02 -07:00
bjorn e12a6b7dc4 Fix WebGL; 2020-11-01 23:11:35 -07:00
Nevyn Bengtsson a321d997a1
network permissions for pico too 2020-11-01 22:54:02 +01:00
Ben Ferguson efe143bf55 enet and hand tracking permissions fix 2020-11-01 16:43:03 -05:00
bjorn 38875cb399 Fix buffer flushing;
lovrGraphicsMapBuffer had the potential to cause a flush.  Flushing
unmaps buffers.  This meant that during any of the calls to map while
creating a Batch, it was possible to cause a flush and unmap other
buffers that expected to be mapped.  This caused writes to unmapped
pointers and subsequent skipping of calls to glFlushMappedBufferRange.

The fix is to figure out if we need to flush upfront and get it out
of the way before mapping any buffers.
2020-10-29 12:12:34 -06:00
Jakob Bornecrantz 22a14e1013 OpenXR: Make sure to set types for XrActionState[Boolean|Float] structs 2020-10-25 01:20:44 +01:00
Jakob Bornecrantz e7d0a73353 OpenXR: Fix right actions not being marked as active in xrSyncActions call 2020-10-25 00:14:17 +01:00
Jakob Bornecrantz b8e3c187ed OpenXR: Fixes for implementations that are more strict with validation 2020-10-24 18:13:41 +01:00
Nevyn Bengtsson 57827eed3c Quest: Make tracked hands have a pose facing -Z
To be consistent with the pose for controllers.
2020-10-21 22:44:57 +02:00
bjorn 6a4779e899 Pico: Reset index buffer binding using vao; 2020-10-19 19:24:18 -06:00
Nevyn Bengtsson 0b9f4d30fd pico: start each eye from origin 2020-10-16 09:29:29 +02:00
bjorn 85cc82d8cb v0.14.0; 2020-10-05 16:40:27 -06:00
bjorn 0388213be4 Reset camera after lovr.headset.renderTo; 2020-10-02 19:50:00 -06:00
bjorn 98f481e941 WebXR input fixes; 2020-10-02 15:57:42 -06:00
Nevyn Bengtsson da79a87328 Allow lovr.headset.init to fail
with a pcall, like the requires above. so if there
is no matching headset driver, the module is just
turned off.
2020-10-01 22:43:57 +02:00
bjorn e14db6c671 Fixes from webxr testing; 2020-09-29 23:41:42 -06:00
bjorn f70201240a nogame fix; 2020-09-29 22:24:40 -06:00
bjorn 96fee538b9 Revert "More strict compute shader test;"
This reverts commit 61abb6f02b.
2020-09-29 17:30:50 -06:00
bjorn 92936f6977 Fix possible double-free of event data; 2020-09-29 16:57:41 -06:00
bjorn b139500864 Upgrade OpenVR; 2020-09-29 16:34:44 -06:00
bjorn 8db2f67b45 headset_openxr fix; 2020-09-29 02:49:17 -06:00
bjorn 80c1c2b4a7 headset_oculus fix; 2020-09-29 02:40:07 -06:00
bjorn 51f470cf85 Easier enums; 2020-09-27 17:13:00 -07:00
bjorn 9ce5e9e625 os_web: Use correct selector for resize target; 2020-09-26 13:56:52 -07:00
Bjorn 477b70156f
Merge pull request #287 from jmiskovic/trimesh-support
Support for trimesh shape colliders
2020-09-25 18:29:09 -07:00
bjorn f7476416ab nogame; 2020-09-25 17:08:51 -07:00
bjorn caca0ef71c t.headset.supersample;
Can be used to change the size of the headset texture that gets
submitted to the VR runtime.  It can be a boolean or a number.
2020-09-25 15:41:30 -07:00
bjorn b864f74be1 vrapi: fix getSkeleton joint poses; 2020-09-25 14:49:00 -07:00
bjorn a61291e453 Fix vrapi missing Oculus Go device type;
- Backported the OCULUSGO device type enumerant.  Need to test to
  determine if the Oculus Go still reports this device type or if
  it just reports unknown.
- A more involved fix will be to use JNI to discover the build model
  from the Android settings.
2020-09-25 14:08:13 -07:00
bjorn dd6e05cf32 Fix timers feature being true on GLES; 2020-09-24 19:04:50 -07:00
bjorn f1447fd69a lovr.graphics.get/setViewPose; lovr.graphics.get/setProjection; 2020-09-24 19:03:37 -07:00
Josip Miskovic 75591fde42 Support for trimesh shape colliders 2020-09-24 20:58:28 +02:00
bjorn 61abb6f02b More strict compute shader test;
Some hardware supports ARB_compute_shader but not 4.3, causing
shader compilation failures because currently we switch to GLSL 430
if compute shaders are detected.

Instead, just detect GL 4.3 instead of looking for the compute shader
extension.  This means that compute shaders will sometimes be
unavailable even when they're supported.

It would be possible to improve this by modifying the way shaders
are compiled.  Maybe the highest supported GLSL version should be used,
but this makes shader authoring somewhat more difficult.
2020-09-24 05:29:35 -07:00
bjorn 48a347ad01 mat4_fromQuat; mat4_getFov; getViewPose/Angles fixes; 2020-09-24 04:59:53 -07:00
bjorn 9f302c2314 Set default OpenVR far plane to 100.; 2020-09-22 01:33:05 -07:00
bjorn 2c979b1d9d Fix backwards type errors; 2020-09-21 17:32:53 -07:00
bjorn d28d96008c Windows: Thread:wait no longer destroys thread; 2020-09-19 17:42:55 -07:00
bjorn 92ef5ee02d Fix lovrInstanceID on non-singlepass setups; 2020-09-19 17:33:49 -07:00
bjorn 9b0812c4f9 Disable timer queries on GLES;
They aren't compatible with multiview.
2020-09-19 17:25:54 -07:00
bjorn 2e65d71a74 Prevent mapped buffers from being discarded;
We never try to do this anyway, and the unmapping code in discard
doesn't flush contents so it's better for people to unmap the
buffer themselves before calling discard.
2020-09-19 17:21:37 -07:00
bjorn 61e9c746a8 Buffer sync fix;
It appears that GL_MAP_UNSYNCHRONIZED_BIT interferes with
GL_MAP_INVALIDATE_BUFFER_BIT's ability to discard buffer
contents.  Removing the unsynchronized bit fixes visual
glitches on Intel HD GPUs.
2020-09-19 17:19:34 -07:00