Commit Graph

1209 Commits

Author SHA1 Message Date
bjorn e677006581 newSource: typecheck second arg;
Errors when using old syntax instead of silently working/failing
2021-03-18 13:00:23 -06:00
bjorn 2d43620d3c rm LOVR_ALIGN;
It isn't very portable, the effects aren't significant.
2021-03-15 18:56:02 -06:00
bjorn e63099ba6a Flatten api.h; 2021-03-15 18:54:27 -06:00
bjorn deb756392b Fix 'attempt to flush unmapped buffer' when creating empty Mesh; 2021-03-07 21:19:24 -07:00
bjorn 058700f970 Allow lovr.audio.setDevice(type, nil); 2021-03-04 18:19:05 -07:00
bjorn 0c3351331e Sink attempt; 2021-03-03 20:01:56 -07:00
bjorn 8188e51060 lovr.audio.get/setAbsorption;
I HOPE THIS LETS US DO UNDERWATER EFFECT
2021-03-03 15:40:27 -07:00
bjorn 2c0875087f Source:getSound; 2021-03-03 15:32:41 -07:00
bjorn dd98b11b3f Effect;
Basically replace each individual accessor with a general one.
2021-03-03 15:25:03 -07:00
bjorn cf4bb36d03 AudioMaterial; 2021-02-28 15:27:33 -07:00
bjorn 5f4e5c5721 rm Source:play loop shortcut; 2021-02-26 13:41:58 -07:00
bjorn 92492dcef1 rm spatial blend for now; 2021-02-26 13:24:01 -07:00
bjorn cb1b78f2cc Rename Source:get/setTime to Source:seek and Source:tell; 2021-02-26 13:21:40 -07:00
bjorn 7bb6861180 Source:get/setPosition; Source:get/setOrientation; 2021-02-26 13:10:59 -07:00
bjorn f3482fc15a lovr.audio.get/setPosition; lovr.audio.get/setOrientation; 2021-02-26 13:05:23 -07:00
bjorn d1a2ded4db Fix luaopen_lovr_filesystem stack index; 2021-02-25 16:29:52 -07:00
bjorn f82e8112fe Simplify filesystem arguments; 2021-02-25 10:45:45 -07:00
bjorn a09b7de545 lovr.system.getCoreCount; 2021-02-25 09:30:05 -07:00
bjorn 4f5adbc64c lovr.system; 2021-02-25 09:00:12 -07:00
bjorn 39a4d2c1d5 rm lovr.graphics.triangle; 2021-02-24 17:45:31 -07:00
bjorn 3055cd718c rm shared sources; 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 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 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 5d542eb2ea Minor Sound cleanup; 2021-02-24 14:11:49 -07:00
bjorn fb1447503b Fix gcc warnings; 2021-02-19 23:44:23 -07:00
bjorn 57a215a0aa Minor MeshShape cleanup;
- Fix memory leak
- Minor error message improvements
2021-02-19 17:28:04 -07:00
bjorn a0b2200bef Fix lovr.graphics.getBlendMode when blending is off; 2021-02-19 14:05:18 -07:00
bjorn 0365f51f9d Fix crash when drawing zero lines; 2021-02-19 08:38:45 -07:00
bjorn 36170678f0 Sound: Change channel count to channel layout; 2021-02-18 21:17:25 -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 0919da4091 Improve MSDF font shader; Add spread/padding settings to Font; 2021-02-10 07:08:29 -07:00
bjorn b343f50f1c mv l_data_textureData->l_data_image; 2021-02-09 21:14:09 -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 ccc53a10aa Cleanup; 2021-02-08 16:08:29 -07:00
bjorn 0877edf9d1 Fix capture; 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 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 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 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
Nevyn Bengtsson d618a2e629 lovr.audio.isRunning 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 2719eba1ba lovrAudioSetCaptureFormat
instead of mixing up using device with using 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 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 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 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 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 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 1e05f29da4 Fix broken SoundData _Reg 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 cdbefafc1a review: style fixes 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 a344acd84f SoundData:getBlob 2021-02-08 16:08:29 -07:00
Nevyn Bengtsson 033817bd74 audio capture stubs 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 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 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 0e375804fe Only include <lualib.h> when needed; 2021-02-07 16:51:31 -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
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
bjorn deeaff7a00 lovr.filesystem.write/append take Blobs; 2021-01-20 10:55:10 -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 3bc2c00b79 api doesn't include util; 2020-12-25 12:50:26 -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 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
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
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
bjornbytes 94e7bafe47 KeyCode -> KeyboardKey because X11 conflict; 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
bjornbytes 0b73e7d7a6 KeyCode -> KeyboardKey because X11 conflict; 2020-11-15 22:51:20 +00: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 b2cb2c8752 Fix l_event; 2020-11-12 18:08:05 -07:00
bjorn 276faf30ad l_event cleanup; 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
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
bjorn 0388213be4 Reset camera after lovr.headset.renderTo; 2020-10-02 19:50:00 -06:00
bjorn 51f470cf85 Easier enums; 2020-09-27 17:13:00 -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 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 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 2c979b1d9d Fix backwards type errors; 2020-09-21 17:32:53 -07:00
bjorn c7ca7eaa38 Add compute dispatch limit; 2020-09-18 15:19:34 -07:00