ChucKML

From CSWiki
Revision as of 14:48, 23 February 2006 by Nferraz (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ChucKML is a XML-based ChucK preprocessor. It reads XML and prints ChucK code.

Usage

   $ ./chuckml sample.xml # print the code to the standard output.

You'll probably want to redirect the output to a file:

   $ ./chuckml sample.xml > sample.ck # create sample.ck
   $ chuck sample.ck # play sample.ck

Sample code

Sample 1

This sample only tells which files should be played, and when:

   <chuckml>
       <wave src="wav/wave.wav"                                        repeat_every="9::second"/>
       <wave src="wav/beat1.wav"       start_after="3::second"         repeat_every="3::second"/>
       <wave src="wav/beat2.wav"       start_after="3::second"         repeat_every="3::second"/>
   </chuckml>

Sample 2

You can use filename patterns, like in "wav/beat*.wav":

   <chuckml>
       <wave src="wav/wave.wav" repeat_every="9::second"/>
       <wave src="wav/beat*.wav" start_after="3::second" repeat_every="3::second"/>
   </chuckml>

Sample 3

Of course, you can include ChucK code in ChucKML:

   <chuckml>
       <wave src="wav/wave.wav"                                        repeat_every="9::second"/>
       <wave src="wav/beat1.wav"       start_after="3::second"         repeat_every="3::second"/>
       <wave src="wav/beat2.wav"       start_after="6::second"         repeat_every="9::second"/>
       <patch set="Sitar sit => PRCRev r => Echo a => dac"/>
       <spork name="play_sitar">
       while( true )
       {
           // freq
           std.rand2( 0, 11 ) => float winner;
           std.mtof( 57 + std.rand2(0,3) * 12 + winner ) => sit.freq;
           // pluck!
           std.rand2f( 0.4, 0.9 ) => sit.noteOn;
           // advance time
           if ( std.randf() > 0.0 ) {
               .5::second => now;
           } else {
               0.25::second => now;
           }
       }
       </spork>
   </chuckml>