Coder Social home page Coder Social logo

pre.uumu's Introduction

Per Vognsen's Mu API

Per Vognsen designed the Mu API as an alternative to libraries like SDL, SML. I find myself agreeing with many of its design decisions.

He documented it at:

He also responded with another iteration called Noir: https://github.com/pervognsen/bitwise/blob/master/noir/noir/noir.ion

Goals and pinciples

His goals:

  • minimal platform layer for multimedia apps (in terms of binary/source size)

  • not industrial-strengh, but excellent for small apps

  • experiment with API design:

    • good, ritual-free, defaults
    • eschews the many granular calls these libraries tend to have to set it up or get information from it
    • instead, provide data in/out through datastructure and a minimal set of functions
    • dialogue between the app and the library as if the library was a resumable coroutine, to minimize callbacks, which disrupt normal code flow
  • extension API with media file loading (image, sound, video)

This is achieved with a global datastructure, whose entries serve as much as possible as both input and output.

Precompute redundant data that is most often useful to users, rather than doing it lazilly and potentially too often. Even if that's increasing the surface area of the API.

Provide state of controls rather than exposing an event queue to its users, since since multimedia applications would anyway have to sample/refresh at a high enough rate anyway.

In cases where naïve state-capture would lose events, such as for text, the API prepares buffers of prepared data representing the aggregate input between two frames.

Compromises:

As of stream #2, audio has been implemented via a callback, pulling samples regularly from the high priority audio thread.

Is this an alternative to SDL?

You could see it like that, however this idea is more useful as a seed for your own application's platform layer. It's a reusable idea first, and an implementation second.

Take it, add more things to the Mu structure as needed by your application.

Experiments to try:

  • The input/output struct is plain old data (if you except the platform specific handles) ; which means it should be trivial to record sequence of values to replay back the application eventually.

Some other personal comments:

A push API for audio is certainly possible, however I personally think if it make sense, it should prevent gaps in audio as the result of a late frame. It does simplify the usual, simple cases because it removes the need for thread-safe code.

Another comment I can make is that the choice of int16_t for audio samples, while convenient for mixing in samples coming from audio files, make synthesis cases less natural. It's easier and less error prone to use float within the 0..1 interval as a generic representation of audio samples.

@todo @idea in the same spirit of the redundant converted time values found in the main part of the api, it would be logical to precompute the number of frames of interleaved samples and put it in the audiobuffer structure

pre.uumu's People

Contributors

uucidl avatar

Stargazers

 avatar Ethan Jackwitz avatar Michael Labbe avatar Cap Petschulat avatar Francisco José Marín Pérez avatar C.T. Matthews avatar kai avatar

Watchers

 avatar James Cloos avatar

Forkers

tannerrogalsky

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.