aconstlink / motor

Software Framework for Audio/Visual/Interactive Real-Time Applications
MIT License
1 stars 0 forks source link

Audio streaming from file #42

Open aconstlink opened 5 months ago

aconstlink commented 5 months ago

Ogg (or similar) files could have a huge memory footprint if PCM decoded. Currently, there is no streaming functionality in the engine. Streaming means that only parts of the data are read and decoded if required opposed to the whole file being decoded and storing in memory for playback.

This is mainly because there is no concept for having a persistent object that can range from a file system object to the audio engine. By range, Importing assets is directly done through the filesystem. This is done through the database system in the io layer and further processed in the format layer.

So streaming audio data would somehow require the data to flow through those layers . The format layer uses the io layer for accessing files either directly on the disc or being stored within a motor .db file with possible encryption. The format layer uses the loaded file content to decode the particular file format, e.g. .ogg, .wav, ... Then a decoded PCM buffer is returned asynchronously to the user ready for being used in the audio engine.

So streaming data would require an object to remember what's necessary to import a particular audio file and access the data fragmented so streaming would be possible.

At the moment, loading the whole file is ok if just one or two music tracks are used. But memory usage could definitely be improved here.