Commit Graph

5 Commits (4dbd5a2cbeab38f78274644f3b44fe1fa727f304)

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 385783a846 restructure audio cleanup 2023-12-08 16:33:52 -08:00
cosmonaut e961a18a83 UpdatingSourceVoice + warn on audio leak 2023-11-20 18:56:22 -08:00
cosmonaut f298a5ec11 fix StreamingVoice loop behavior 2023-08-04 12:14:14 -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