Overview Clamps Packages CM Dictionary Clamps Dictionary Fomus
Next: Import from SVG , Previous: cm-svg , Up: cm-svg , Home: General

Clamps Packages

Export to SVG

Exporting to SVG is done with the events function. As different event types are supported by Clamps, any combination of MIDI, SFZ, Poolevt or custom declared event types can be integrated into a single sequence and exported to SVG with a single call to events.

The exported SVG elements are displayed in a 2-dimensional grid with the x-axis denoting musical time, although any other mapping can easily be applied to the im/exported data if deemed appropriate. The exported graphical objects can be considered as typed output1, with their type and additional custom properties defined in an attributes tag of each SVG element (see Fig. 4).

Example

(events
  (append
   (loop
     for time below 3 by 2/8
     collect (new sfz :time time :keynum (between 60.0 84.0) :duration 1/2))
   (loop
     for time from 1/8 below 3 by 2/8
     collect (new midi :time time :keynum (between 60 84)
               :amplitude 1.0 :channel (between 1 16) :duration 1/2)))
 (svg-gui-path "svg-xml-example.svg")
 :showgrid nil
 :staff-system-vis nil)
svg-xml-example.png
Figure 4: Attributes of a selected event in SVG file generated with the Lisp Code above

Footnotes:

1

The idea of typed output is inspired by CLIM, the Common Lisp Interface Manager, a central part of the Gui implementation of Lisp Machines.