Difference between revisions of "ChucKML"

From CSWiki
Jump to: navigation, search
(Sample 3)
 
(4 intermediate revisions by the same user not shown)
Line 27: Line 27:
  
 
     <chuckml>
 
     <chuckml>
         <wave src="wav/wave.wav" repeat_every="9::second"/>
+
         <wave src="wav/wave.wav"                                       repeat_every="9::second"/>
         <wave src="wav/beat*.wav" start_after="3::second" repeat_every="3::second"/>
+
         <wave src="wav/beat*.wav"       start_after="3::second"         repeat_every="3::second"/>
 
     </chuckml>
 
     </chuckml>
  
Line 43: Line 43:
 
      
 
      
 
         <spork name="play_sitar">
 
         <spork name="play_sitar">
        while( true )
+
            while( true )
        {
+
            {
            // freq
+
                // freq
            std.rand2( 0, 11 ) => float winner;
+
                std.rand2( 0, 11 ) => float winner;
            std.mtof( 57 + std.rand2(0,3) * 12 + winner ) => sit.freq;
+
                std.mtof( 57 + std.rand2(0,3) * 12 + winner ) => sit.freq;
   
+
       
            // pluck!
+
                // pluck!
            std.rand2f( 0.4, 0.9 ) => sit.noteOn;
+
                std.rand2f( 0.4, 0.9 ) => sit.noteOn;
   
+
       
            // advance time
+
                // advance time
            if ( std.randf() > 0.0 ) {
+
                if ( std.randf() > 0.0 ) {
                .5::second => now;
+
                    .5::second => now;
            } else {
+
                } else {
                0.25::second => now;
+
                    0.25::second => now;
 +
                }
 
             }
 
             }
        }
 
 
         </spork>
 
         </spork>
 
     </chuckml>
 
     </chuckml>
 +
 +
== License ==
 +
 +
This program is free software; you can redistribute it and/or modify
 +
it under the terms of the GNU General Public License as published by
 +
the Free Software Foundation; either version 2 of the License, or
 +
(at your option) any later version.
 +
 +
This program is distributed in the hope that it will be useful,
 +
but WITHOUT ANY WARRANTY; without even the implied warranty of
 +
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +
GNU General Public License for more details.
 +
 +
You should have received a copy of the GNU General Public License
 +
along with this program; if not, write to the Free Software
 +
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

Latest revision as of 15:02, 23 February 2006

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>

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA