GeekyEggo / SoundDeck

Sound Deck is a powerful audio-focused plugin for the Elgato Stream Deck.
GNU General Public License v3.0
45 stars 5 forks source link

Reduce memory usage requires of audio buffers (clip audio) #49

Closed GeekyEggo closed 2 years ago

GeekyEggo commented 2 years ago

Setup

Background

Given the above scenario, the memory usage of Sound Deck is ~240MB to ~260MB, which is quite high given that the average 30 second clip requires approximately 10-15MB of uncompressed bytes.

Change

Sound Deck currently uses a buffer based on time; instead, it should use the AverageBytesPerSecond property provided by NAudio to determine how many bytes should be stored within a fixed sized circular buffer for a given time frame. Additionally, if possible, Sound Deck should utilize Span<byte> to improve memory management.

GeekyEggo commented 2 years ago

Results

With the above setup applied, the new memory usage is ~68MB. There is also more aggressive garbage collection for the LOH as this does not require persistence after the file has been saved.