muzic.kit playOn platforms without a built-in softsynth (e.g. Linux) a sample SoundFont will be used. To explicilty request that the sample SoundFont use
muzic.kit play defaultTo play using other SoundFonts list these as arguments to the play command
muzic.kit play Scc1t2.sf2 moog.sf2 ...If you want to see the source for the play command, use the following
muzic.kit playsrcAnd, if you're interested in seeing the Muzic source just unwrap the Starkit, or use the following command
muzic.kit srcUsing Muzic in your applicationTo use Muzic, either source this starkit or extract the compiled Muzic package from muzic.vfs/lib/muzic and add it to the lib directory of your application (i.e. a directory on your auto_path).The Muzic API contains just four procedures
muzic::init
- call once to initialize Muzic
muzic::soundfont file
- selects a SoundFont to use
- call with no arguments to use the built-in softsynth (if available)
- to use a SoundFont call with a single argument which is the path to the SoundFont file
muzic::channel chan inst
- assigns an instrument to a channel
- chan is an integer - usually from 0 to 15 (i.e. 16 channels are guaranteed to be supported but some SoundFonts may support more)
- inst is the instrument number - typically a MIDI instrument number from 0 to 127 (although this again may vary with specific SoundFonts)
- for an example run "muzic.kit playsrc" and look for the "chan_def" array and the muzic::channel call that uses it
muzic::playnote chan pitch volume <duration>
- plays a note on specified channel, at specified pitch and volume
- pitch is the raw MIDI pitch, as per the general midi standard - where middle C is 60 (see http://www.mozart.co.uk/information/articles/midinote.htm which has a table of MIDI pitch values)
- volume is a number between 0 and 100
- duration is optional, and defaults to 500 (i.e. 500 ms)
- on Linux it uses uses the Open Sound System (oss) driver
- on MacOS X it uses the Core Audio (coreaudio) driver
- on Windows it uses the DirectSound (dsound) driver
- HomeMusician.Net - http://soundfonts.homemusician.net
- HammerSound - http://www.hammersound.net/hs_sounds.html
- TuneSmith Central - http://www.ts-central.com/sounds.php
Having Fun with MuzicDKF: Note that this is really designed to be used interactively.
package require muzic muzic::init file copy muzic.kit/default.sf2 . muzic::soundfont default.sf2 catch {file delete default.sf2} proc playnotes {{idx 0}} { global notes chan stop offset if {$stop} return if {$idx>=[llength $notes]} {set idx 0} foreach c $chan { muzic::playnote $c [expr {$offset+[lindex $notes $idx]}] 70 250 } after 150 playnotes [incr idx] } set chan {0 2 3 4} set offset -5 set stop 0 set notes {48 52 48 55 48 57 60 48 52 48 55 48 50 48 47} playnotes after 30000 set stop 1Have fun!
Ro 2011 September: On debian squeeze I had to install the oss-compat package since muzic relies on OSS and /dev/dsp and after that all is well.