Classic Computer Magazine Archive START VOL. 4 NO. 10 / MAY 1990

Review

DR. T'S T-BASIC

BASIC Programming With A MIDI Twist

BY STEVE JOHNS

The current crop of sequencing programs for the ST are solid, complex and powerful second-generation products that provide MIDI recording/editing environments of great utility and, in some cases, even elegance. Each is like a personal work of art, illuminating the creative intelligence of its particular designer - but therein also lies a limitation. However bold its conception or comprehensive its features, you could never get more out of the program than the package itself (or its latest upgrade) delivered.

Until now.

Dr. T's T-BASIC
T-BASIC is the first programming language for the ST designed specifically to interface with a high-end MIDI sequencer. It's a superset of ST BASIC and runs either as a standalone program or under Dr. T's MultiProgramming Environment (MPE). In addition to the standard repetoire of BASIC statements and functions, including calls to the GEM AES and VDI, it provides command and data-structure access to Dr. T's popular Keyboard Controlled Sequencer (KCS) and sequence data files created by it. The manual shows you how to adapt standard BASIC programs to run under T-BASIC.


The T-BASIC Edit Window here shows the source code.


Here is an example of output of the ENVIRON.BAS program.

The Good
T-BASIC provides key words and library routines that let you interact directly with the ST MIDI ports and memory-resident KCS sequences. This is a first - no other ST sequencer developer provides a programming interface to its sequencer's internal data. (Jim Miller provides LISP for his Personal Composer program, but that program is only for IBM computers.)

A KCS sequence is a list of "events." Each event consists of several parameters designated as: time, type, note, velocity and duration. The actual function of note, velocity and duration depends upon the type of event. Each one of these parameters in every sequence can be set or read by a T-BASIC call. You may also add events to a sequence and play a sequence from within T-BASIC. Note that setting or reading the time is a library function rather than a key word. The difference is that to use library functions you must first use the editor to include their text in your program source code. This is not necessary for key words, which T-BASIC recognized automatically. One other obviously missing key-word function is event copy. You'll have to code this yourself and include it when you need it.

To illustrate one of the many uses of T-BASIC, I've written a short program for KCS users (see sidebar). It displays all of the documented KCS environment variables on a single screen. The T-BASIC manual documents the way to read these variables. This program will save you from having to code your own environment display.
 
The KCS Environment Display

CLS

print "KCS Environment Report - For Binary Variables 0=Off,False 1=On,True"
print "Midi Merge: ";:print peekb(envptr+0)
print "Start is First Clock. ";:print peekb(envptr+1)
print "No MIDI Start: ";:print peekb(envptr+2)
print "Song Pointer Send: ";:print peekb(envptr+3)
print "MIDI Clock Out: ";: print peekb(envptr+4)
print "Running Status: ";:print peekb(envptr+5)
print "Audible Metronome: ";: print peekb(envptr+7)
print "Visual Metronome: ";:print peekb(envptr+8)
print "Play Metronome: ";:print peekb(envptr+9)
print "Record Controllers: ",:print peekb(envptr+10)
print "Record Aftertouch: ";:print peekb(envptr+11)
print "Record Note Off Vek: ";:print peekb(envptr+12)
print "Align on/off: ";:print peekb(envptr+13)
print "Auto record on/off: ";:print peekb(envptr+14)
print "Steps/metronome: ";:print peekblenvptr+15)
print "Steps/measure: ";:print peek(envptr+16)
print "Count in: ";:print peek(envpti+18)
print "Echo on/off: ",:print peekb(envplr+20)
print "Echo Channel: ";:print peekb(envptr+21)
print "Clock source: ";:print peekb(envptr+22)
gotoxy 40,1 : print "Steps/beat: ";:print peek(envptr+28);
gotoxy 40,2 : print "Cue Move Amount: ";:print peek(envptr+30);
gotoxy 40,3 : print "MIDI Slow: ";:print peek(envptr+32);
gotoxy 40,4 pnnt "Sieps/MIDI clock: ",:print peekb(envptr+34);
gotoxy 40,5: print "Tempo Change by Ratio: ";:print peekb(envptr+35)
gotoxy 40,6 print "Silent punch: ";:print pee&b(envptr+36)
gotoxy 40,7 : print "Activity display: ";:print peekb(envptr+37)
gotoxy 40,8 print "Step display: ";:print peekb(envptr+38)
gotoxy 40,9 : print "Re-record stop: ";:print peekb(envptr+39)
gotoxy 40,10: print "Velocity pedal channe: ";:print peekb(envplr+40)
gotoxy 40,11: print "Drum channel: ";:print peekb(envptr+41)
gotoxy 40,12: print "Debounce: ";:print peek(envptr+42)
gotoxy 40,14 : print "Note: Valid MlDl Channels list as 0-15"  
gotoxy 40,15 print "    instead of 1-16."  
gotoxy 0,25  
   

The Bad
The T-BASIC package includes the manual, program disks, several libraries of BASIC subroutines for MIDI and example programs for both MIDI and non-MIDI applications. The language disk uses key disk copy protection and runs on all ST/Mega models and monitors. The manual covers all of T-BASIC's keywords and library functions, including the special ones for MIDI. Manual entries are ordered by command functional group, with an overall alphabetical list provided for reference (personally, I think the opposite arrangement is easier to work with). The manual includes a table of contents and an index, but lacks a tutorial and ASCII and MIDI specification charts.

T-BASIC is an interpreted BASIC. You type in your program as a text file. When you go to run the program, T-BASIC executes it line by line. There are two operating modes: edit and command line. Most of what a MIDI user will probably want to do with T-BASIC will not involve a sophisticated graphical interface. This is fortunate, since the most useful GEM function for simple user interaction and messages is the dialog function, which crashed my programs every time I tried to use it. Until this problem is fixed, I'd ignore the GEM features of T-BASIC and stick to traditional BASIC statements like PRINT, INPUT and so forth. By doing so you'll get satisfactory, if less than artful, results. There is no compiler to create stand-alone versions of your programs.

A few of the provided sample programs contained syntax errors and did not run. There is no on-line help available in T-BASIC - the Help key does nothing.

The T-BASIC text editor lacks several essential features. When you go from the command-line mode to the edit mode the editor does not come up in a full-screen configuration. Instead, you must use the arrow keys to manually scroll up and down to fill the screen with your program text. There are no search and replace functions nor does the tab key work.

When T-BASIC detects a syntax error it places an asterisk next to the line number. This requires you to not only fix the syntax error but also manually delete the asterisk flag. Text blocks may be defined by command keys but not through the more intuitive means of dragging the mouse. You cannot open more than one window, preventing easy cut/ copy/paste from one program file into another, though you can append an entire file to another. Attempting to insert a new line between two already sequentially numbered lines causes T-BASIC to drop back to command-line mode without displaying the command-mode prompt to let you know where you are.

I honestly have to say that T-BASIC's "basic" editor hampered me at every turn. Doubtless several kilobytes of memory were saved by not implementing many editor features. The program would be much nicer if the features were provided and the choice of disabling them to save memory were left to the user.

Recommendations
I hope I've given you a good idea of some of the things you can do - and not do - with T-BASIC. If you know standard BASIC and are looking for a way to do some MIDI programming without having to write a lot of low-level code, T-BASIC may meet your needs, especially if you own KCS. If you're already a programmer and are used to a sophisticated editor you may feel a bit cramped in the T-BASIC environment. In any case, T-BASIC is the only game in town when it comes to letting a user program an ST in conjunction with an existing commercial sequencer.

PRODUCTS MENTIONED

T-BASIC, $149. Dr. T's Music Software, 220 Boyleston Street, Suite 306, Chestnut Hill, MA 02167, (617) 244-6954.