Version 8 of midistreamdll

Updated 2008-03-21 19:08:08 by jdc

This is a wrapper for the Windows Midi stream API. Online help can be found here .

News

  • jdc 20-mar-2008. Initial public release. The package can be downloaded from [L1 ].

Examples

Midi file sequencer

In the examples directory in the zips, you'll find seq.tcl, a midi file sequencer. This example uses the tclMIDI package to read Midi files.

package require midi
package require midistreamdll

# Create a midi stream header, this header will be used to send event to the
# sequencer.
set h [midistreamdll::header]

# Load the midi file specified on the command line
set mf [midi::file]
$mf read [lindex $argv 0]

# Add events to header, skip SysEx and non-tempo Meta events
set cnt 0
foreach te [$mf flatten -no_sys_ex 1 -include_meta {tempo}] {
    $h add event {*}$te
    incr cnt
}

puts "Streamed $cnt event"

# Open a midi stream device
set s [midistreamdll::open 0]

# Set the ticks per beat
if {[$mf cget -time_division_type] eq "ticks_per_beat"} {
    $s set timediv [$mf cget -ticks_per_beat]
}

# Send header to the device
$s out $h

# Sequence the events
$s play

# Wait until header is released by the sequencer
while 1 {
    if {![catch {$h destroy}]} {
	break
    }
    puts "@ [$s position]"
    after 1000
}

# Cleanup
$s close
$mf destroy

exit

Drum machine

In the examples directory in the zips, you'll find drums.tcl, a little drum machine.

http://jos.decoster.googlepages.com/drums.png

Questions / remarks

  • MiR 21. March 2008: Ok, actually the expamples from the packages are missing, otherwise its working fine on my WinXP machine. Thx for the work, please post the drum and seq. sample.... jdc The link was wrong, it's updated now.