Commit Graph

34 Commits (bb7e45b9a3fa65e0670d237a66643a3f0efd1052)

Author SHA1 Message Date
cosmonaut 4dbd5a2cbe MSDF font rendering + improved resource tracking (#52)
This is a major rewrite of the Font system. MoonWorks now uses MSDF font rendering, which allows high quality rendering of fonts at arbitrary sizes.

We now ship default embedded shader binaries for Video and Font. If you replace them with shader binaries of the same name located in your base directory, those will be used instead.

Many improvements have been made to resource tracking to prevent memory corruption, particularly on shutdown.

You must be careful not to leak AudioResource classes in particular, as there isn't much we can automatically do to recover from this without potentially crashing your game.

Reviewed-on: #52
2023-12-15 18:46:43 +00:00
cosmonaut 528fb7ac7c fix potential heap corruption on audio shutdown 2023-12-08 15:06:17 -08:00
cosmonaut e961a18a83 UpdatingSourceVoice + warn on audio leak 2023-11-20 18:56:22 -08:00
cosmonaut 772a0378bb avoid calling Thread.Join from finalizer 2023-11-20 17:59:26 -08:00
cosmonaut 40fb313d12 change AudioResource WeakRef to GCHandle 2023-11-20 17:52:44 -08:00
cosmonaut abdcac1608 change AudioDevice constructor to internal 2023-09-19 17:04:03 -07:00
cosmonaut b026b9e81f add lots more doc comments 2023-09-19 13:19:41 -07:00
cosmonaut 7f6b6a7bae fix voices not respecting the faux mastering voice 2023-08-10 10:46:19 -07:00
cosmonaut e77c87c772 register new SourceVoices as active 2023-08-09 15:58:18 -07:00
cosmonaut 0cd2c799ee Audio Restructuring (#50)
This is a complete redesign of the MoonWorks Audio API.

Voices are the new major concept. All Voices can be configured with volume, pitch, filters, panning and reverb. SourceVoices take in AudioBuffers and use them to play sound. They contain their own playback state.

There are multiple kinds of SourceVoices:
TransientVoice: Used for short sound effects where the client will not be keeping track of a reference over multiple frames.
PersistentVoice: Used when the client needs to hold on to a Voice reference long-term.
StreamingVoice: Used for playing back AudioDataStreamable objects.
SoundSequence: Used to play back a series of AudioBuffers in sequence. They have a callback so that AudioBuffers can be added dynamically by the client.

SourceVoices are intended to be pooled. You can obtain one from the AudioDevice pool by calling AudioDevice.Obtain<T> where T is the type of SourceVoice you wish to obtain. When you call Return on the voice it will be returned to the pool. TransientVoices are automatically returned to the pool when they have finished playing back their AudioBuffer.

SourceVoices can send audio to SubmixVoices. This is a convenient way to manage categories of audio. For example the client could have a MusicSubmix that all music-related voices send to. Then the volume of all music can be changed at once without the client having to manage all the individual music voices.

By default all voices send audio to AudioDevice.MasteringVoice. This is also a SubmixVoice that can be controlled like any other voice.

AudioDataStreamable is used in conjunction with a StreamingVoice to play back streaming audio from an ogg or qoa file.

AudioDataWav, AudioDataOgg, and AudioDataQoa all have a static CreateBuffer method that can be used to create an AudioBuffer from an audio file.

Reviewed-on: #50
2023-08-03 19:54:02 +00:00
cosmonaut 81cd397013 fix AudioDevice crash on shutdown 2023-07-28 15:02:20 -07:00
cosmonaut e73c7ede55 rename SoundQueue to SoundSequence 2023-07-28 13:21:50 -07:00
cosmonaut 1d86d0c210 add SoundQueue 2023-07-28 13:02:50 -07:00
cosmonaut 5ff7da927a try-catch inside AudioThreadMain 2023-06-28 13:20:18 -07:00
cosmonaut fc0937b2ff fix crash caused by audio weak references 2023-06-14 18:22:49 -07:00
cosmonaut 5df08727c1 Sound instancing rework 2023-05-11 17:56:40 -07:00
cosmonaut 1f0e3b5040 Audio Improvements (#47)
- Audio is now processed on a background thread instead of the main thread
- Audio tick rate is now ~200Hz
- MoonWorks.Math.Easings class completely rewritten to be easier to understand and use
- SoundInstance properties no longer call into FAudio unless the value actually changed
- SoundInstance property values can now be interpolated over time (tweens)
- SoundInstance tweens can be delayed
- SoundInstance sets a sane filter frequency default when switching filter type
- StreamingSound classes can be designated to update automatically on the audio thread or manually
- StreamingSound buffer consumption should now set Stopped state in a more sane way
- Added ReverbEffect, which creates a submix voice for a reverb effect
- SoundInstance can apply a ReverbEffect, which enables the Reverb property
- Audio resource tracking improvements
- Some tweaks to VideoPlayer to make its behavior more consistent

Reviewed-on: #47
2023-03-07 23:28:57 +00:00
cosmonaut f8b14ea94f add ReverbEffect 2023-03-01 17:47:09 -08:00
cosmonaut e9aacb44da Add synchronized audio playback mechanism 2023-02-16 15:12:35 -08:00
cosmonaut d76633bdfc change sizeof calls to Marshal.SizeOf in interop situations 2022-12-13 19:01:40 -08:00
cosmonaut 751b8310ce Fix crash when no audio device found 2022-11-30 09:43:49 -08:00
cosmonaut ea86212199 add AudioDevice.MasteringVolume property 2022-10-20 15:00:25 -07:00
TheSpydog eb8c350a47 Fix debug assertion in AudioDevice constructor (#25)
Let's try this again...

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #25
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2022-08-30 17:09:32 +00:00
cosmonaut 4756fe2b14 add SetMasteringVolume method to AudioDevice 2022-05-23 19:11:48 -07:00
cosmonaut a0082bcec6 change Marshal.SizeOf to sizeof 2022-04-27 14:14:15 -07:00
cosmonaut be4b5cf2c7 fix audio not being disposed in correct order 2022-04-20 14:57:24 -07:00
cosmonaut 8973b3e658 Formatting pass 2022-02-22 21:14:32 -08:00
cosmonaut a0c57c7a59 Cleanup fixes 2022-02-22 16:44:39 -08:00
cosmonaut 5eb5027bf1 initial 3D audio implementation 2021-02-26 16:17:26 -08:00
cosmonaut eda1efedbe properly destroy audio 2021-01-28 18:01:42 -08:00
cosmonaut 58427b8c90 refactor sound API to support generic decoding 2021-01-20 12:39:31 -08:00
cosmonaut ec09a5952b attach reverb 2021-01-19 22:06:23 -08:00
cosmonaut ec28d17a75 fix static sound loading + window title 2021-01-19 21:33:25 -08:00
cosmonaut 768bf38e3f starting audio implementation 2021-01-19 18:06:10 -08:00