Has anyone been able to build the midi package for windows, found at,
http://www.uttis.de/midi/index.htm
This was built was for tcl 8.3 and so the binary package no longer
works. The wiki page
https://wiki.tcl-lang.org/page/MIDI
mentions the problem but the solutions aren't working for me. The source
zip is a vis c++ 6.0 project.
I tried to build it using the free 2022 visual studio with no success. I installed an old vis c++ 6.0 but it failed to build a usable .dll plus
it's only 32 bit.
I have a spare laptop where I've installed Ashok's Magicsplat distro but
it seems it must be 64 bit to work on 64 bit windows. This might be a
nice addition to a future Magicsplat, which would likely build correctly under Visual Studio 2017.
-------
Midi controllers are fast being adapted for use beyond just music DAWs.
Just about every controller now also works over usb.
Midi would be a great interface, perhaps built into Tk 9.0. Tk bindings
to use midi knobs and faders could operate spinboxes, scrollbars, and notebook tabs. Drum pads could be bound like gui buttons plus they
generally support RGB as output.
Perhaps 3d graphics programs might use the knobs for rotate, zoom, and
other transformations. Since Tk is used in several other languages, this could be a rather nice addition to Tk in general. I'm considering
writing up a TIP.
Here's a relatively low cost controller I've considered, by Behringer,
the X-Touch Mini
https://www.amazon.com/gp/product/B012CSKTYY
Am 17.12.2022 um 23:46 schrieb et4:
Has anyone been able to build the midi package for windows, found at,
http://www.uttis.de/midi/index.htm
This was built was for tcl 8.3 and so the binary package no longer works. The wiki page
https://wiki.tcl-lang.org/page/MIDI
mentions the problem but the solutions aren't working for me. The source zip is a vis c++ 6.0 project.
I tried to build it using the free 2022 visual studio with no success. I installed an old vis c++ 6.0 but it failed to build a usable .dll plus it's only 32 bit.
I have a spare laptop where I've installed Ashok's Magicsplat distro but it seems it must be 64 bit to work on 64 bit windows. This might be a nice addition to a future Magicsplat, which would likely build correctly under Visual Studio 2017.
-------
Midi controllers are fast being adapted for use beyond just music DAWs. Just about every controller now also works over usb.
Midi would be a great interface, perhaps built into Tk 9.0. Tk bindings to use midi knobs and faders could operate spinboxes, scrollbars, and notebook tabs. Drum pads could be bound like gui buttons plus they generally support RGB as output.
Perhaps 3d graphics programs might use the knobs for rotate, zoom, and other transformations. Since Tk is used in several other languages, this could be a rather nice addition to Tk in general. I'm considering writing up a TIP.
Here's a relatively low cost controller I've considered, by Behringer, the X-Touch Mini
https://www.amazon.com/gp/product/B012CSKTYY
Hi !
I have quickly slipped over the code. Internal TCL headers version 8.3 are used. I suppose, due to the use of the channels.
I saw no reason for it. The code should be changed a bit.
I don't want to dive in this adventure. I already crashed tdbc::MySQL by trying to help.
Take care,
Harald
* Harald Oehlmann <wortkarg3@yahoo.com>
| Am 17.12.2022 um 23:46 schrieb et4:
| > Has anyone been able to build the midi package for windows, found at,
| > http://www.uttis.de/midi/index.htm
--<snip-snip>--
| I have quickly slipped over the code. Internal TCL headers version 8.3
| are used. I suppose, due to the use of the channels.
| I saw no reason for it. The code should be changed a bit.
I have downloaded the src-package, the only file you need is midi.c.
Apply these changes to make it compile with tcl 8.6 (and probably 8.7 too):
diff -u midi.c\~ midi.c
--- midi.c~ 2022-12-19 15:43:46.054717000 +0100
+++ midi.c 2022-12-19 15:51:07.066234640 +0100
@@ -48,7 +48,7 @@
//#define USE_TCL_STUBS
#include "tcl.h"
-#include "tclerrno.h"
+// #include "tclerrno.h"
EXTERN void TclWinConvertError _ANSI_ARGS_((DWORD errCode));
@@ -813,7 +813,8 @@
DebugLog( "Rpmidi_InOpen #8\n" );
// Return channel name
- strcpy( interp->result, channelName );
+ // strcpy( interp->result, channelName );
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(channelName, -1));
return TCL_OK;
}
@@ -1050,7 +1051,8 @@
DebugLog("Rpmidi_OutOpen #4\n");
// Return channel name
- strcpy( interp->result, channelName );
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(channelName, -1));
+ // strcpy( interp->result, channelName );
return TCL_OK;
}
Diff finished. Mon Dec 19 16:09:42 2022
After that, compile it via
cl -o midi.dll midi.c -IPATH/TO/YOUR/TCL/INCLUDES /link -dll tcl86.lib Winmm.lib
I can load the resulting DLL just fine, but since I have no midi
interface attached, I can't test it.
HTH
R'
On 12/19/2022 7:14 AM, Ralf Fassel wrote:.. snip..
Also, what C compiler are you using. I don't have one on my windows test system other than the 32 bit ms vis c++ 6.0. at present.
I do have a 64 bit magicsplat distro installed however, and I see where it has the include files.
On 12/19/2022 2:32 PM, et4 wrote:
I have just installed the visual studio c++ community version on my test machine. I see it has a /link option when typing just cl to get a
synopsis, so I'm guessing this is the right compiler.
I'll try to hand apply the patch if I can't figure out how to use patch.
Also, I do have a midi device (got it for my daughter who's the music
person here) so I can test it out if I can get it built. And if I do get
it working, I will put the .dll in a zip file on dropbox and post a link
in the wiki page. Or is there a way to post binary files to the wiki?
Am 20.12.22 um 04:31 schrieb et4:...
Shouldn't be too difficult, Ralf basically changed only the returning of a result back into Tcl, which uses an outdated mechanism, and removed the include of tclerrno.h. ....
The wiki is not a good place for binary data, better only provide links. Nowadays one would typically upload software to github (sources and binaries on the corresponding "release" page)
But be prepared that there are some refactoring changes necessary. The code is not 64bit-safe. I've quickly looked into the warnings that Ralf got during the compilation. The code passes pointers around as DWORDs between the windows API and callbacks,which is 32 bit only. YOu may be lucky that replacing some DWORD with DWORD_PTR is enough to get it working, but there is no guarantee. In the worst case you need to adjust the parameter passing.
Christian
The last linker warning seems to suggest I'm not building a 64 bit
version
C:\Users\ET\AppData\Local\Apps\Tcl86\lib\tcl86t.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
* et4 <tclnews@rocketship1.me>
| On 12/19/2022 11:10 PM, Christian Gollwitzer wrote:
| > Am 20.12.22 um 04:31 schrieb et4:
| ...
| > Shouldn't be too difficult, Ralf basically changed only the
| > returning of a result back into Tcl, which uses an outdated
| > mechanism, and removed the include of tclerrno.h. ....
| Ok, think I got it figured out, -u includes 3 lines of context by
| default, and that was confusing me.
Ah, I see. I figured that the 'diff' output might be easier to read
than trying to explain manually what needs to be changed, even if
someone applied the changes manually.
'cl' is the command line compiler provided by any Visual Studio release
I have worked with so far (starting approx in 2003). You should get it
if you open one of the "Visual Studio Command Prompt" entries from the VisualStudio submenu in 'Programs'.
| > But be prepared that there are some refactoring changes
| > necessary. The code is not 64bit-safe. I've quickly looked into the
| > warnings that Ralf got during the compilation. The code passes
| > pointers around as DWORDs between the windows API and callbacks,
| > which is 32 bit only. YOu may be lucky that replacing some DWORD
| > with DWORD_PTR is enough to get it working, but there is no
| > guarantee. In the worst case you need to adjust the parameter
| > passing.
It might be possible to just remove the DWORD casts, but I haven't
looked at the MIDI function signatures whether this would be enough.
| Hmmm, I guess I'll have to look at each error message and try to
| figure out what's wrong. If I'm lucky, the C compiler will complain
| until I fix them all.
| But with the first error at line 666, this could be a sign :)
:-) Good luck!
R'
cl -o midi.dll midi.c -IC:\Users\ET\AppData\Local\Apps\Tcl86\include /link -dll C:\Users\ET\AppData\Local\Apps\Tcl86\lib\tcl86t.lib Winmm.lib
Am 20.12.22 um 22:33 schrieb et4:prompt x64" or similar, maybe also "cross compile x64 bit" (can't check it now, I'm not on Windows at the moment). You might also look for the path where the start menu entry points to, this thing is a batch file and in the same dir you should find
The last linker warning seems to suggest I'm not building a 64 bit version
C:\Users\ET\AppData\Local\Apps\Tcl86\lib\tcl86t.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
Yes, that's correct. You run cl for 32 bit and the Tcl you link it with is 64 bit. For Visual C++, the bitness depends on how you run the command line. You should have different entries in the start menu, labelled "Command prompt x86" and "Command
There are two things to consider
a) 32 bit builds do not make much sense these days anymore
b) Your Tcl is 64 bit
c) your midi.c file needs to be updated for 64 bit
So: The easiest way to get it going would be to get a 32 bit Tcl, then you don't need to do more changes to midi.c. However, for long-term use it is much better to adapt midi.c for 64 bit and switch to the 64 bit compiler....
Christian
On 12/20/2022 3:09 PM, et4 wrote:
I've noticed that there is a struct Tcl_ChannelType that has changed since 8.3 but the docs say it's ok to use the old struct: "It is still possible to create channel with the above structure. The internal channel code will determine the version."
instancePtr->tcl_ChannelType.outputProc = Rpmidi_OutOutput;...
instancePtr->tcl_ChannelType.seekProc = NULL;
instancePtr->tcl_ChannelType.setOptionProc = NULL;
Can you show the changes you've made (diffs)? Maybe I can spare some
time today or tomrrow to have a glance at it.
R'
| Even w/o any midi hardware, you should still see 1 output device:
| load midi.dll
| set i -1
| foreach device [midi::getoutdevs] {
| puts "out [incr i]= $device"
| }
Well, I don't :-/ [midi::getoutdevs] has empty return on my Windows 10.
But I have a real USB MIDI interface at home, connected to a keyboard which
I didn't turn on for 6 years now... so maybe, just maybe... but don't
hold your breath :-)
HTH
R'
* et4 <tclnews@rocketship1.me>
| Here's the code setting up the structure, the midiin is the essentialy
| the same, and wideSeekProc is NOT defined in either case.
| instancePtr->tcl_ChannelType.typeName = "midiout";
| instancePtr->tcl_ChannelType.blockModeProc = NULL;
| instancePtr->tcl_ChannelType.closeProc = Rpmidi_OutClose;
| instancePtr->tcl_ChannelType.inputProc = Rpmidi_OutInput;
| instancePtr->tcl_ChannelType.outputProc = Rpmidi_OutOutput;
| instancePtr->tcl_ChannelType.seekProc = NULL;
| instancePtr->tcl_ChannelType.setOptionProc = NULL;
| instancePtr->tcl_ChannelType.getOptionProc = NULL;
| instancePtr->tcl_ChannelType.watchProc = Rpmidi_OutWatchChannel;
| instancePtr->tcl_ChannelType.getHandleProc = Rpmidi_OutGetHandleProc;
In addition to clearing the memory after alloc, it might be necessary to
set the .version member of the struct so TCL knows it's not an 'old'
binary version (8.3 or earlier). However, the docs are not clear about
what to set it to, I would just use the highest number available (TCL_CHANNEL_VERSION_5) if everything is zeroed properly.
R'
* et4 <tclnews@rocketship1.me>
| Looks like it's not safe to call
| Tcl_SetVar(interp_global, "midi_data_input", data, TCL_GLOBAL_ONLY);
| in the middle of a midi callback, I got an error that says,
| alloc: invalid block: 000001A244E22800: 58 44
| which comes from the panic below given the message and number of
| args. It's in tclThreadAlloc.c
I haven't verified it by looking at the thread-ids, but the only way
what I see (and what you describe here) makes sense is that the
TCL-program and the windows-MIDI-callbacks run in separate threads.
tclsh does not enter the event-loop, yet I see the windows callbacks arriving.
The midi.c code does not handle this situation at all, it simply
modifies the data buffers in both the callback and the TCL-read
function. This cannot work reliably without proper locking mechanisms.
Looking at the poor quality of rest of the midi.c code (error checks
missing, 32/64bit issues, logic errors in some places), I myself would discard that project and start from scratch (maybe using some code
blocks from midi.c).
It's not too complicated:
- you just need interfacing to a few midi-functions (open, close, and
the callbacks, probably the info functions, too)
- get rid of the channel idea, and just specify a TCL callback in the
'open' call for incoming data. Outgoing data is straight forward
anyway.
- in the input-callbacks, store the data in some data structure and
notify TCL by some inter-thread-calls
https://www.tcl.tk/man/tcl8.6/TclLib/Notifier.html
(eg Tcl_ThreadQueueEvent or the like)
Take care of proper locking as required.
- then in the TCL main thread, call the callback function (event loop
required for this) and handle the data at script level.
With my Roland UM-ONE connected to a Pioneer keyboard, there are data
coming in at a very moderate rate (100/s max), so this should be no
problem to handle at script level.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 493 |
Nodes: | 16 (2 / 14) |
Uptime: | 31:32:07 |
Calls: | 9,740 |
Files: | 13,741 |
Messages: | 6,183,148 |