Commit Graph

3151 Commits

Author SHA1 Message Date
bjorn efa48bda70 Manually disable a few miniaudio features; 2021-04-03 13:57:13 -06:00
bjorn d32d9f6d67 Source directivity power defaults to 1; 2021-04-03 11:22:23 -06:00
bjorn 15975343ea Sound:get/setFrames respects channel count; 2021-04-03 10:28:03 -06:00
bjorn 024498b964 Source:clone fixes;
Clones no longer try to create converters if they aren't needed, which
was causing an error.

Also handle malloc failure.
2021-04-03 09:49:27 -06:00
bjorn 4469fc99e8 Fix mixer bug; Refactor mixer;
- Sources without converters always read into the beginning of the
  raw buffer, overwriting previous frames if the source was rewound
  due to looping.  This resulted in an audible click whenever the
  source was rewound.
- After looping, Sources without converters would try to read too
  many frames -- they would read a full buffer instead of only the
  necessary number of frames.
2021-04-02 23:36:30 -06:00
bjorn 69b5c51388 Fix Sound:setFrames; 2021-04-02 23:35:18 -06:00
bjorn 6f6e7eea1b Better newSound error messages; 2021-04-02 23:35:18 -06:00
bjorn 6ae0d9f96a phonon works by default when no mesh is provided; 2021-04-02 23:35:18 -06:00
mcc 6b099e467f Encapsulate "uses spatializer?" nature in lovrSourceUsesSpatializer
Also, remove accessor prototype for old IsSpatial() function
2021-04-02 14:16:39 -06:00
bjorn 0021c70f9f luax_readmesh supports nested tables; 2021-04-01 18:48:37 -06:00
bjorn 82a309a56d Draft new effects API;
- A list or map of effects can be provided to newSource.
- false can be used to bypass effects.
- All effects are enabled by default.
  - Occlusion-y effects should only take effect when setGeometry is called
    - Spatializer is responsible for ensuring this.
2021-04-01 16:46:16 -06:00
bjorn 923498a927 webxr: also support velocity of head device; 2021-03-31 22:47:26 -06:00
bjorn 72403de209 webxr: Add support for lovr.headset.getVelocity; 2021-03-31 22:37:29 -06:00
bjorn 35032bb21c Upgrade miniaudio; 2021-03-31 22:32:16 -06:00
bjorn 441039db19 miniadio: Enable WebAudio backend; 2021-03-31 14:30:06 -06:00
bjorn cfe0d71520 audio: throw if miniaudio fails to initialize;
This prevents a situation where miniaudio fails to initialize but the
audio module is still usable.
2021-03-31 14:01:30 -06:00
bjorn 0ef48d3d26 os_web: fix mouse support;
Not sure why this got removed.
2021-03-31 11:24:52 -06:00
bjorn 4a2c315bdb Fix luax_readmesh with Model; 2021-03-30 12:48:18 -06:00
bjorn eb8b559e88 phonon: Fix freeing incorrect variable; 2021-03-30 12:45:24 -06:00
Josip Miskovic f6fbc2ad17 Route ODE messages into LOVR log system
ODE errors, debugs and messages are redirected into LOVR's log system
by a callback mechanism for each.

The ODE submodule is updated to revision that does not crash when error
or debug occurs.
2021-03-28 17:34:11 -06:00
bjorn 0daaca7a4f Merge branch 'master' into dev 2021-03-28 10:09:58 -06:00
bjorn e346c3f807 Fix standard shader precision issues;
- Reduce epsilon
- Also use epsilon in D_GGX
- Reduce shader string length to the minimum required supported length
2021-03-28 10:08:10 -06:00
bjorn 2b1b777e84 Fix crash when passing nothing to newTexture; 2021-03-26 20:02:38 -06:00
bjorn 948b77b7fa phonon doesn't try to make a mesh if there are no vertices; 2021-03-26 10:30:08 -06:00
bjorn 0dfc80e42e luax_readmesh assert for index range; 2021-03-26 10:23:24 -06:00
bjorn 61ef2747ee World:newMeshCollider uses luax_readmesh;
This is a breaking API change -- instead of a table of tables, a flat
table of coordinates must be used.
2021-03-25 12:29:11 -06:00
bjorn 6413a6eda2 Fix Model:getTriangles; Add Lua API; 2021-03-25 12:29:11 -06:00
bjorn fe0eedea20 luax_readtriangles -> luax_readmesh; Model support; 2021-03-25 12:29:11 -06:00
bjorn e1195a92a0 lovrModelGetTriangles; 2021-03-25 12:29:11 -06:00
bjorn 3a35f81918 Fix underscores not printing;
Signed arithmetic strikes again.  Before the padding was configurable,
padding was just a #define'd constant, so signedness didn't matter.
2021-03-25 12:18:48 -06:00
bjorn 895589c914 Add even more padding to stb zlib; 2021-03-24 21:13:04 -06:00
bjorn fd39ed9420 os_android: fix improper cast; 2021-03-24 14:32:56 -06:00
bjorn 634e7210bf Make Source:clone suck less; 2021-03-23 14:31:04 -06:00
bjorn 5ef5ac5f22 I am once again fixing the mixer EOF case; 2021-03-23 14:31:04 -06:00
bjorn 6a79ffb34a rm Source::blend; 2021-03-23 14:31:04 -06:00
bjorn de5099badd rm SourceInterpolation; 2021-03-23 14:31:04 -06:00
bjorn 98f33dc131 mv falloff attenuation; 2021-03-23 14:31:04 -06:00
mcc e3c2b5b865 Fix Android build
- Fix typos after refactor
- Fix CMake when using ANDROID_PACKAGE
2021-03-22 14:09:16 -06:00
bjorn a1f768e1a3 lovr.audio.stop properly returns success; 2021-03-20 11:57:46 -06:00
bjorn b1f7a6c11d Add optional VolumeUnit to get/setVolume functions;
Volume can be specified in linear units or dB.
2021-03-19 17:20:48 -06:00
bjorn c1c15c46db Don't share ma_data_converters between Sources;
It causes distortions when resampling is involved.
2021-03-18 16:31:14 -06:00
bjorn 96e0cc8b9b Fix mixer bug when reaching end of source; 2021-03-18 13:47:04 -06:00
bjorn 369bd5d8b4 Clamp source/listener volumes to 0-1 range;
Prevents miniaudio errors and horrible clipping on bad input.
2021-03-18 13:06:11 -06:00
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 e008dd2323 Fix stb_vorbis bug with empty comment list files; 2021-03-18 12:43:36 -06:00
bjorn 0bb556554d Probably work around stb_image bug that breaks zips;
30e01f upgraded stb_image to include its 95560b commit from its #960
pull request.  This made stb_image fail more aggressively on EOF
conditions when refilling huffman buffers in deflate streams.  I think
it might be failing _too_ aggressively, though.  We are able to pad our
input compressed buffers since the zip file format is guaranteed to have
extra data at the end (for, e.g., the end of central directory record).
This appears to be sufficient to fix compressed zip archives for the
time being.  It's possible that more virtual padding needs to be added,
and it may be good to try to fix this in stb_image itself.
2021-03-18 00:05:34 -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 f9f4907a50 phonon fixes; 2021-03-07 22:42:54 -07:00
bjorn 45e43bacb3 os_web fixes; 2021-03-07 22:04:23 -07:00
bjorn 0435694225 simple spatializer interpolation;
prevents snaps, crackles, and pops
2021-03-07 21:19:25 -07:00
bjorn 30a0556f1d Fix oculus spatializer; 2021-03-07 21:19:24 -07:00
bjorn deb756392b Fix 'attempt to flush unmapped buffer' when creating empty Mesh; 2021-03-07 21:19:24 -07:00
bjorn a3b791a7e7 Fix Canvas flushing; 2021-03-07 21:19:24 -07:00
mcc 9f0826e3b7 Add missing header in headset_oculus, this fixes a warning. 2021-03-05 15:07:18 -08:00
mcc 4bed6f6834 Fix crash on startup on Oculus driver 2021-03-05 15:07:18 -08:00
bjorn 6de00cf2b8 crush ico; 2021-03-04 19:24:33 -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 f806c07bfa Simplify spatializer interface temporarily; 2021-03-03 15:49:28 -07:00
bjorn bc41eecf09 oculus spatializer: free memory; use MAX_SOURCES 2021-03-03 15:46:01 -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 746735259c Windows: Always use WinMain for UTF8 command line arguments;
This fixes problems with paths containing special characters on windows.
2021-03-02 11:49:08 -07:00
bjorn dd0891d087 Fix simple spatializer; 2021-03-02 11:49:00 -07:00
bjorn e1e21def82 More consistent spatializer symbol names; 2021-03-01 17:53:49 -07:00
bjorn 1c3a01de2a Add windows icon; 2021-03-01 17:45:12 -07:00
bjorn bb302c3336 Fix OpenXR hand tracking on Quest; 2021-03-01 11:55:27 -07:00
bjorn cf4bb36d03 AudioMaterial; 2021-02-28 15:27:33 -07:00
mcc d233d5ccd3 Fix MSVC build
- stdatomic.h had not defined ATOMIC_INT_LOCK_FREE, but it is now required
- It's _MSC_VER, not _MSVC_VER
2021-02-28 14:12:16 -08: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 a94a1c22bf simple spatializer uses physically correct attenuation;
This matches phonon.
2021-02-24 17:51:44 -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 f47a688d53 phonon: configuration options; 2021-02-24 17:43:42 -07:00
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