Version 21 of Tclmod

Updated 2011-06-17 04:03:50 by RLE

Googie Tcl extension which provides support for music modules under Tcl.

Music modules are usually files with extensions *.mod, *.s3m, *.it, *.xm but also many others.

Full manual page is placed here:

Homepage of extension is:

The extension requires libmikmod - [L1 ]. It's quite popular on most systems. Check if you haven't it yet, before you install it.

LV I'm uncertain what that last sentence means...

Googie To compile extension (and make it work) you'll need library called libmikmod - I've put link to the library homepage above. Pay attention that this library presents on most linux distributions and unixes. I'm not sure how is it with Windows...

I've just installed VMWare and Win98 under it. I'll try to compile and run the extension under Windows. (After few minutes) Well, it seems to package is not portable for windows, becouse libmikmod is not ported to windows. There is mikwin library, which is based on libmikmod, but it's not the same and couses lot of errors while trying to compile Tclmod with it :(

Some examples.

Simply playing modules is pretty easy:

 package require Tclmod
 set mod [::tclmod::player load music.mod]
 ::tclmod::player start $mod

and here is little more advanced code, which builds a simple GUI module player:

 package require Tk
 package require Tclmod
 wm title . "Modules player"
 entry .module -textvariable mod -width 50 -state disabled -bd 1
 button .browse -text "Browse" -bd 1 -command {
     set types {
         {{Module} {.mod .s3m .xm .it .669 .apun .dsm .far .amf 
         .gdm .imf .med .mtm .okt .stm .stx .ult .uni}}
     set mod [tk_getOpenFile -filetypes $types \
             -title "Choose module file"]
     .module configure -state normal
     .module configure -state disabled
     if {[info exists module]} {
         ::tclmod::player stop
         ::tclmod::player unload $module
     set module [::tclmod::player load $mod]
 button .play -text "Play!" -bd 1 -command {
     if {[info exists module]} {
         ::tclmod::player start $module
 button .stop -text "Stop" -bd 1 -command {::tclmod::player stop}
 grid .module -column 0 -row 0 -sticky we -columnspan 3
 grid .browse -column 3 -row 0
 grid .play -column 2 -row 1 -sticky we
 grid .stop -column 3 -row 1 -sticky we

Known bugs

  • Loading several modules at the same time and trying to playback any one but the last one causes an application crash - it's also a libmikmod bug (I've sent notice to authors).

DKF: They (modules) originated on the Amiga, and are basically like a combination of a MIDI instrument bank (sample set) and a MIDI file in one. (Well, the formats are completely different, but they are conceptually very similar). The formats are very good at representing complex pieces of instrumental music, but are really quite hostile to "consumer" use. They've fallen a lot out of favour due to being used a lot for doing knock-offs of copyrighted music, even though that was usually a really poor use of the format's power.

GPS: There are lots of unique artists too. The scene is rather interesting. It's like a subculture that flourishes on IRC and elsewhere. An archive I like is . BTW; I usually play the files with mikmod or xmp (in pkgsrc), but that may change with this tclmod package :)

Googie: Fresh (not from '80 and beginning of '90) modules are made with excellent quality. They are less-sized because of their structure. 3-6MB, hi-quality modules can contain 40 minutes of music! This is very good for games, demos, etc, where music usually steals much of one's hard disc.

Btw. can anyone try to compile it under windows and other systems (eventually put here links to binaries)? I've got only Linux. If someone would do it, then let's put the link just below extension homepage link. Thanks :)

LV Any thought to the flip side - updating Snack or whatever so that one could create modules from Tcl? And what about some code to convert between MP3 and other popular formats to the .mod format?

Googie Firstly I was trying to mix this extension with snack package, but the fact is that music modules works more like MIDI files, than typical audio files (such as mp3, wav). These are two completly different ideas. Converting from modules to wav files can be done - just use [tclmod::driver set 4] (where 4th driver is Wav disk writer (music.wav) v1.2 for me, see [tclmod::driver info] for list of drivers). Converting from wav to modules is impossible, at least for now and I think that it will never be possible.

LV Okay, I can understand what you are saying. Is there a way via Tclmod to create new mod files?

Googie No, because libmikmod doesn't support this. Only playback is supported.

DKF: Just noting that you could reasonably claim that converting from a WAV to a MOD is an interesting AI problem...

Googie: I don't get what you mean, hm?