I have a working, but incomplete API wrapper for the engine.* API
and thought I would send out this email to get some feedback.

  The API consists of a single javascript file. This file contains
several classes. The class MixxxAPI allows access to each Deck as an
object. This Deck object can be used to play, pause, set and jump to
hotcues, etc... Other parts of Mixxx's functionality are also exposed
as child objects, such as Mixxx::Deck::Hotcues, which returns an
object for accessing a deck's hotcues and Mixxx::Deck::EQ for
accessing the Equalizer.

  My goals for this API are:

    * Make it Easy to Learn: this API should be easier to learn since .
    * Readability: the code should be easier to read since there is
less string concatenation.
    * Flexibility: pass a deck as a parameter to a function, or just
the equalizer, etc...

The general look & feel of this API can be seen in this small snippet
used to test the code (available in test.js):

------------------------------------------------------------------------------------------
Mixxx = new MixxxAPI();

for (var i = 1; i <= 2; i++)
{
        var deck = Mixxx.Deck(i);
        
        deck.Play();
        deck.Play(1);
        
        deck.Duration();
        
        for (var x = 0; x < 5; x++)
        {
                deck.Hotcue(x).Set();
                deck.Hotcue(x).Goto();
        }
        
        var eq = deck.EQ();
        
        eq.Low(1);
        eq.Mid(2);
        eq.High(3);
        
        eq.LowKill(1);
        eq.MidKill(2);
        eq.HighKill(3);
}
------------------------------------------------------------------------------------------


Since the hotcue API is chainable, it is possible to make calls in the
following manner:

------------------------------------------------------------------------------------------
Mixxx.Deck(1).Hotcue(1).Set().Goto();
------------------------------------------------------------------------------------------

  The rest of the API is largely not chainable. This is because I have
no elegant solution yet for making calls that both get and set
properties. Possible solutions are:

    * Separate getter and setter functions.
    * Create a Command stack to be executed by a 'query' or 'exec' method.

  With separate getter and setter functions the code is more tedious
to maintain. Any change in the calling convention has to be replicated
through the entire file.

  The command stack solution would require saving the return values on
a stack. This would add another API that needs to be maintained.

That's all I have to say about this for now...


Seasons Greetings to the Mixxx team.


- Phillip Whelan, Mixxx Contributor

Attachment: mixxx-api.js
Description: JavaScript source

Attachment: test.js
Description: JavaScript source

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Mixxx-devel mailing list
Mixxx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to