clownacy / clownaudio Goto Github PK
View Code? Open in Web Editor NEWSound engine that is suitable for video games and other multimedia applications.
License: zlib License
Sound engine that is suitable for video games and other multimedia applications.
License: zlib License
clownaudio should negotiate with the decoder and playback backends over what formats and sample rates to use. For example, SDL2 allows you to fetch a 'preferred' output sample rate, but right now clownaudio just forces a default of 48000Hz. Likewise, the libxmp-lite and PxTone decoder backends are also locked to 48000Hz, when they can just be set to whatever the mixer is using.
Apparently using mutexes in an audio callback is a stupid idea, because of stuff like priority-inversion. I never liked using them anyway, since the ones in clownaudio are locked to Windows and POSIX.
Supposedly I should look into lock-free buffers or something. Maybe I can set up a kind of communication system where the main thread only gives commands to the audio callback, instead of modifying shared data - that way, the audio callback is solely-responsible for modifying its private data, avoiding conflicts.
If you load sound data, create a sound from it, play the sound, and then free the sound data while it's playing, the sound will continue trying to play and cause a crash.
Right now clownaudio just uses the backend's 'Create' function to see if the loaded file is in that backend's format, but that's a whole lot of overhead.
Certain libraries (I think libVorbis is one of them) have specific functions for testing if the provided buffer contains valid data. Using those would be nice.
Backends whose libraries don't provide such a feature can still rely on the old 'just try opening the file' trick.
clownaudio shouldn't assume all audio data will be sent through file I/O - instead, it should support data being passed as memory buffers.
This will completely-break the file-type auto-detection, which relied on reading the file extension. It didn't work that great anyway: for example, '.ogg' specifies the Ogg container, but not what encoding format is used (Vorbis and FLAC are just two possibilities), so I'm not too upset about that. Maybe the user should specify the file format instead.
Supporting panning and sample-rate-overriding would make clownaudio suitable for sequenced file formats, like Organya.
Maybe make it so you can explicitly define whether a sound can be dynamically-resampled or not, so that the resampler can be configured appropriately, potentially-reducing overhead.
Also, this would allow the synthesised backends to use the native sample rate, instead of a hardcoded one, in the event that they're not dynamically-resampled.
Using free
in the middle of the mixer isn't a great idea: there's no guarantee free
isn't super slow and won't stall the audio thread. Rather, it might be worth looking into allocating sound objects from a memory pool. The size of this memory pool can be specified by the user during initialisation.
However, there is the issue of multiple threads accessing the pool at once, so mutexes might be needed. But as I went over in #1, mutexes are bad. I'll have to come up with a mutex-less solution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.