A core package that manages and plays back dynamic music objects (dymos) and their renderings.
You can add dymo-core to any web app using either NPM
$ npm install dymo-core
$ bower install dymo-core
Then, simply include
[bower_components]/dymo-core/dist/dymo-core.min.js in your code.
DymoManager class allows you to easily load and playback dymos. First you need to create a Web Audio API audio context and pass it to the constructor:
var dymoManager = audioContext;
Then, you can load and play a dymo and it's rendering as follows (indicating either relative local paths or uris):
The callback tells you when the dymo, its audio files, and the rendering are done loading, so that you can start playing it back. You can stop the dymo analogously using
If you plan on using custom UI controls in your application, the dymo manager can provide you with the corresponding UI controls you added to your dymo spec (see next section). The following method takes the name you gave it in the json definition as a parameter.
You can also use the Semantic Player framework to create generic user interfaces more easily.
In this section you'll learn how to define dymos manually using json-ld. This can be quite tedious once dymos get more complex or once they include analytical features and semantic annotations. In that case you might prefer to use the Dymo Designer or the Dymo Generator. Finally, instead of using json-ld, you can also define them directly in RDF which won't be described here. You can refer to this paper for some examples.
The most basic dymo that can be played back is just a single object with an associated audio file. You can define one as follows:
In the first line you refer to the json-ld context, which is necessary for the dymo to become linked data and which allows you to use all the keywords necessary to define dymos. Then you define an id which can be chosen freely but has to be unique within the structure. The third line tells the system that it is indeed a dymo that you're defining here. Finally, you specify a relative local path or a uri that points to the dymo's audio file.
In order to make the dymo dynamic, adaptive, or interactive you can define a rendering as follows:
a coming from the random control with an identity function.
parameter define where the result of the function is mapped to, in this case the
Amplitude parameter of the
exampleDymo defined in the previous section.
Within dymo-core you can use any of the auto controls defined by the ontology, as well as custom UI controls, which you can manipulate yourself within your app. You can define a custom UI control as follows
You can also use the predefined types
Button if you want them to behave respectively. Any of these UI controls can then be obtained from the
DymoManager as explained above.
For now, sensor controls and automatically generated UI controls can only be used within the Semantic Player framework.