You are here

midilib for Tcl/Tk

admin의 아바타

홈페이지 :
http://home.t-online.de/home/Steffen.Traeger/midi/index.htm

Midilib is a loadable module for Tcl/Tk 8.x on the MS Windows platform. With this addition, Tcl/Tk is capable of receiving and sending MIDI sysex messages from and to external MIDI devices. There is already an existing MIDI library for Tcl/Tk, called tclmidi , but it doesn't support low level access to MIDI devices.

Midilib mainly based on the RPMidi.dll by Bruce James written to support midi devices for his RPEdit, a nice Patch Editor for Guitar Multi-effects Processors. Thanks for doing this great job. I only less modified the code to make it suitable for other applications.
The package consists of C++ code included in a Visual C++ 6.0 project. This means that at present the library only supports Win32 platforms, line Windows 95/98/ME/NT/2000. But I'm looking forward to extend it for Linux.
BTW, MIDI sysex implemenation in Linux is very simple. Write all sysex messages as binary data to /dev/midiXX!

The source code should also be useful to someone wishing to extend Tcl with C language routines.

Here are small examples to show the easily use of the commands.

# get a list of MIDI Output devices 
set mididevs(out) {}
foreach device [midi::getoutdevs] {
    lappend mididevs(out) $device
    puts $device
}
 
# get a list of MIDI Input devices 
set mididevs(in) {}
foreach device [midi::getindevs] {
    lappend mididevs(in) $device
    puts $device
}
 
# get the number of MIDI Output devices 
set num [llength [midi::getoutdevs]]
 
# handle MIDI Output device 
set rc [catch {set id [midi::getoutid]} msg]
if {$rc} {
    set f [midi::openout $id]
} else {
    puts "Fatal error: $msg."
}
fconfigure $f -translation binary
puts -nonewline $f "xf0x41x10x00x02x12xf7"
flush $f
close $f

 
# playing a note number (middle C - 60) for just a second on the default MIDI device 
set f [midi::openout 0]
midi::sendshort 144 60 112
after 1000
midi::sendshort 144 60 0
close $f
  • midisrc.zip: Visual C++ 6.0 source project files and examples
  • midilib.zip: compiled midilib package for Win32
  • 첨부 파일파일 크기
    Package icon midilib.zip61 KB
    Package icon midisrc.zip84.77 KB