Commit Graph

207 Commits

Author SHA1 Message Date
bjorn d097d9819d Add wrappers for malloc functions; 2024-03-11 14:38:00 -07:00
bjorn 2d7b636a90 Change more asserts to checks; 2024-03-11 00:58:21 -07:00
bjorn 08d6b2ad28 Refcounted modules;
This allows them to be initialized/destroyed from multiple threads in
any order.  Previously, the first thread to require a module had to be
the last thread to use the module, otherwise it would be destroyed too
early.

There are still a few issues.  If the main thread doesn't require a
module, it won't pick up the conf.lua settings.  Also graphics isn't
handling the shader cache writing properly.  And I think this breaks the
headset-graphics refcounting.  But these will be fixed in future
commits.
2023-11-23 17:07:44 -08:00
bjorn be795c0ebd Change vec3 back to 3 floats; Clean up maf/vectors;
The "vec3 is 4 floats" thing was consistently confusing to people.  It's
reverted everywhere except for Curve.

maf now has full sets of methods for vec2/vec3/vec4, for consistency.

Vector bindings now use luax_readvec* helper functions for the
number/vector variants, and use maf for most functionality, which cleans
things up a lot.
2023-07-10 17:51:24 -07:00
bjorn 2bc90d2106 Add lovr.audio.getDevice; 2023-07-06 13:50:34 -07:00
bjorn cb44549205 Fix more prototypes; 2023-04-25 21:45:30 -07:00
mcc 52a7a51b8e Silence spurious function-pointer mismatch warning 2023-03-01 19:14:22 -05:00
bjorn 27b2d111c1 Merge branch 'master' into dev 2022-11-07 20:45:58 -08:00
bjorn d8c23bacec Source:setPitch;
Co-authored-by: Nevyn Bengtsson <nevyn@alloverse.com>
2022-09-11 20:41:58 -07:00
mcc 2a0f9bb36c Minor comments on audio.c 2022-08-27 08:44:24 -07:00
bjorn 917b97ca2d Adjust; 2022-07-03 21:48:43 -07:00
mcc 28d64b6ced Fix various compiler warnings in MSVC (non graphics edition)
- Put in casts/checks in audio code when assigning size_t to 32 bit
- () is different from (void)
- Turned off warnings for anonymous unions and negating unsigned integers which were technically accurate but unhelpful (and interfered with bit conversion and a weird bit math construct in audio.c) (CMakeLists only)
2022-07-03 21:34:16 -07:00
bjorn aa929482cd Fix default air absorption; 2022-05-31 13:55:38 -07:00
bjorn d70619ec96 Source:isSpatial; Separate spatial from effects; 2022-03-27 19:09:25 -07:00
bjorn a1d0b2fa11 Use fixed-size audio callbacks;
WebAudio may need...attention.
2022-03-23 10:57:30 -07:00
bjorn 20caeca69a Upgrade miniaudio; 2022-03-23 10:57:30 -07:00
bjorn b7527c3584 More people use COUNTOF; 2022-03-22 17:56:26 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn 6f3e46d8cf Fix some pointer formatting; 2022-02-02 12:01:38 -08:00
bjorn 998b355e30 Make some private functions static; 2021-10-31 12:35:49 -07:00
bjorn ebeee33298 Fix lovrAudioGetSampleRate prototype; 2021-10-31 12:09:33 -07:00
bjorn 1fdaa797ac Error on enabling an effect on a Source with effects disabled; 2021-08-12 11:25:51 -07:00
mcc 9f96917d91 Fix horizontal rotation bug in Oculus spatializer 2021-07-26 11:24:04 -07:00
mcc db28be591a Fix incomplete LOVR_ENABLE PHONON/OCULUS define change 2021-07-23 09:55:16 -07:00
mcc 52db969622 Remove DEFAULT_SAMPLE_RATE 2021-07-20 11:28:48 -07:00
mcc a0a242a610 Fix types/naming to standard style 2021-07-20 11:28:48 -07:00
mcc 56138492f2 Allow get sample rate in conf.lua, read back with lovr.audio.getSampleRate() 2021-07-20 11:28:48 -07:00
mcc 2a73310198 Fix distance attenuation in Oculus spatializer 2021-07-20 11:23:32 -07:00
bjorn ecd7769ba0 Convert Tupfile to Lua; 2021-07-18 22:24:00 -07:00
mcc 39dca2f093 Fix lovr.audio.setPose() in oculus spatializer mode 2021-07-18 20:39:46 -07:00
bjorn 0a9956db60 phonon: Fix crash when setGeometry fails;
The call to `free` above was fixed, but the one in the error case
was not.
2021-04-27 22:15:15 -06:00
mcc d558996206 Hold lock when changing geometry (prevents crash, see issue #403) 2021-04-12 13:01:54 -06:00
bjorn 5106aaf74c Audio listener/source default to identity orientations; 2021-04-03 18:38:27 -06:00
bjorn 609d7e05ce simple spatializer supports directivity;
Also coming soon to an oculus spatializer near you.
2021-04-03 18:22:23 -06:00
bjorn 19620c7682 wasm: Use default miniaudio buffer size.
Audio currently stutters on the wasm build.  It is much more severe
in Chrome than in Firefox (very rare/subtle in Firefox).  miniaudio
is currently using ScriptProcessorNode, which is deprecated because
it processes audio on the main thread.  There's a new API that lets
you programmatically process audio on a thread called AudioWorklet,
but it's hella complicated.  miniaudio doesn't want to support this
because it's complicated and requires a separate JavaScript request
but it seems like it would be possible to work around using a Blob.
In the meantime, miniaudio bumps up the buffer size on WebAudio, so
let's just use that in hope that it helps.
2021-04-03 18:04:26 -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 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 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 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 eb8b559e88 phonon: Fix freeing incorrect variable; 2021-03-30 12:45:24 -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 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
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