I have released
my code for extracting chord sequences from Band-in-a-Box format files today. Partly I do this as advertisement for TOE. And to be honest, partly because Im a little tired of being asked for it (if only I get a penny everytime ... :-). As you can see,
the code is very simple and most of it was worked out in a day. Due to its origin (it is part of
MyJazzBand), Im only allowing non-commercial use of the code. Additional restrictions on it are the same as the original BSD license (attribution, advertising clause, etc.).
This is part of the software licensing model for my business. The next version of MyJazzBand will support user-defined styles, which will be specified in scripting languages such as Python and Scheme. I will open the source code that implements this, which will include new versions of the
jazz theory classes and
MIDI note generators that I have written about. Id like people to learn from it, use it for personal purposes, use it to teach classes, and conduct research with it. But I cant complete with commercial applications based on my own library: Ill have to both maintain it
and develop and sell the applications!
So heres the model. Low-level TOE code (such as the current
Sysex and
Destination classes) will be released under the original BSD license. High-level TOE code (for supporting user-defined styles, for example) will be released under a non-commerical use software license (such as
the one for BiaBReader). The applications I will sell will of course still be close source.
A while ago I wrote some code to display
a panel for browsing banks and programs on MIDI devices. That code used Cocoa bindings which made most of it quite clean. A big portion of that code, however, was for accessing CoreMIDI and parsing XML to construct the bank and program lists. Now that I have written TOE, I can just call it to get the banks and programs. The program will also get the additional functionality of sending bank selects and program changes to the MIDI devices by using the class methods
BankSelect,
ProgramChange, and
Send. So
this new sample project will be a good test of the support provided by TOEs
Destination class.
The archive containing the sample project also contains a new version of TOE that allows it to be built as a framework. The latter is referenced by relative path in the sample project. So if both its project folder and that of TOE are in the same folder, Xcode will correctly locate the framework. If things need to be moved, read Apples documentation
Creating a Framework.
Heres a screenshot of the sample project in action:
When one of the programs in the last column is selected and the
Select button is clicked, the corresponding bank select and program change MIDI messages are sent to that MIDI device. So this panel serves as a control center of all the devices in the MIDI setup. Of course the user interface will need to be improved for this to be put to practical use. Right now, its a neat little sample program that would need a lot more effort to write if one must do so without TOE.
[DISCUSS THIS ENTRY]
I wrote two versions of a sample program today using TOE. The program requests sysex bulk dumps containing patch names from a E-mu Morpheus, extracts them, then generates a MIDI name document that contains these patch names. The MIDI name document can then be used as the master name document or one of the overriding name documents and can be associated with the Morpheus using my
NameConfigSetup utility.
Ive written a similar program called
MidnamUtility a while ago. The one today tests the use of TOE. It also shows how the use of SWIG in building TOE allows the sample program to be written in either Python or Scheme. The code has been structured for reuse, which I hope will encourage people to build their own MIDI name document utility for their MIDI device models. Its really very simple once youve figured out the sysex requests to send and where the names are in the sysex replies.
Heres the main line of
the Python version:
TOE.Initialize()
d = TOE.Sysex('Morpheus')
ramRomSysex = GetSysexBulkDump(d, '\xf0\x18\x0c\x00x12\xf7', 3336)
ramPresets = ExtractNameList(ramRomSysex, 128, 7, 13, 12)
romPresets = ExtractNameList(ramRomSysex, 128, 7 + 13 * 128, 13, 12)
hyperSysex = GetSysexBulkDump(d, '\xf0\x18\x0c\x00\x50\xf7', 1672)
hyperPresets = ExtractNameList(hyperSysex, 128, 7, 13, 12)
print template % (PatchNameList("RAM Presets", ramPresets) + \
PatchNameList("ROM Presets", romPresets) + \
PatchNameList("HyperPresets", hyperPresets))
TOE.Terminate()
The function
GetSysexBulkDump(d, requestSysex, lengthExpected) sends sysex data
requestSysex to device
d and receives and returns
lengthExpected bytes of bulk dump data.
The function
ExtractNameList(sysexData, numNames, startOffset, interval, nameLen) extracts and returns a list of
numNames patch names from the bulk dump data
sysexData. Each name is of length
nameLen. The first name starts at byte offest
startOffset. The next names start at
startOffset + interval,
startOffset + 2 * interval, and so on.
The function
PatchNameList(nameListName, nameList) converts a list of patch names into the
<PatchNameList> XML element to be inserted into the MIDI name document.
The variable
template contains the string representation of the MIDI name document, except for the patch name lists. The latter are inserted using the Python string formatting operator.
Heres the
Scheme (Chicken) version of the same program.
[DISCUSS THIS ENTRY]