Takahiko Tsuchiya & Jason Freeman - Data-Driven Live Coding With DataToMusic API
Takahiko Tsuchiya & Jason Freeman - Data-Driven Live Coding With DataToMusic API
dtm . clock ( function () { var sin = dtm . gen ( ’ sine ’) . size (32) ;
// Note duration set to 0.25 seconds . s . lpf ( sin . range (200 ,2000) . logcurve (30) ) ;
dtm . synth () . play () }) ;
. notenum (60) . amp ( env ) ;
Code Example 5: Mapping Data to a dtm.synth
// Duration may also be manually
specified . One concern, however, is that the time scale of the
dtm . synth () . play () . dur (2.0) parameter curve is always relative to the duration of an
. notenum (67) . amp ( env ) ;
audio event (set by the clock interval or the duration
// Set the clock behavior parameter of the dtm.synth), which may require the user’s
}) . lookahead (0.1) . bpm (120) . time (1/8) ; attention on the resulting speed of modulation for the
temporal or rhythmic alignment in a musical structure.
Code Example 4: Automatic Duration and Lookahead Another potential inconvenience is that the dtm.synth
expects a certain range of numerical values for each
In the context of live coding, the clock may be used for parameter. A data input needs to be, therefore, converted
periodically (re-)evaluating the entire or a selected part of a accordingly to the input data type, range, distribution, as
script as well as managing the registered callback functions. well as the synth parameter ranges. Such requirements of
It keeps track of named and anonymous callback functions appropriating data format for various parameters is
using either the function name or the whole (stringified) sometimes not ideal for live-coding situations, as it slows
structure of the object, detects live modification in them, down the design process, data (re)mapping, and may also
and selectively retains, updates, or clears them. This helps cause semantic errors. We can automate the mapping
prevent registering the old and new versions of a callback process by using the previously-mentioned model system as
function separately. a simple scaler and type converter (Code Example 6).
11
This is done by using the Function.caller.arguments
property.
// Create a model object 4. CONCLUSION
var freqModel = dtm . model ( ’ array ’) We presented our approaches for implementing a
// Specify the type conversion method data-driven interface for a Web-Audio-based synthesizer,
. toNumeric ( ’ histogram ’) as well as a real-time clock system for controlling audio
// Modify the preset behavior
. domain ( function ( a ) { and non-audio events with fewer timing errors. In addition,
freqModel . params . domain = a . get ( ’ using the sample-level mapping and musical structure
extent ’) ; models, we described possibilities of complex musical
}) expressions in both symbolic and timbre-level time scales.
// Default behavior : freqModel ( data ) We experimented with these features in the DataToMusic
. output ( function (a , c ) { API, a data sonification library for web browsers capable of
return a . range (20 , 200)
. logcurve (30) live coding. The DataToMusic API is publicly available as
. fit ( c . get ( ’ div ’) ) ; a GitHub repository12 , and as a demo application for
}) ; on-line live coding13 .