Commit Graph

147 Commits

Author SHA1 Message Date
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 1fdaa797ac Error on enabling an effect on a Source with effects disabled; 2021-08-12 11:25:51 -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
bjorn ecd7769ba0 Convert Tupfile to Lua; 2021-07-18 22:24:00 -07: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 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
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 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 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 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 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 e1e21def82 More consistent spatializer symbol names; 2021-03-01 17:53:49 -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 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 4f5adbc64c lovr.system; 2021-02-25 09:00:12 -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 8bbb092497 Start phonon spatializer; 2021-02-24 17:43:42 -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