Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!apple!heksterb From: heksterb@Apple.COM (Ben Hekster) Newsgroups: comp.sys.mac.hardware Subject: Re: MIDI, the Mac and the Serial Port (Help!) Message-ID: <44536@apple.Apple.COM> Date: 5 Sep 90 02:00:06 GMT References: <302@bksmel.oz.au> Organization: Apple Computer Inc., Cupertino, CA Lines: 67 I built my own MIDI interface a while ago and started writing a very small sequencer to test it, so I somewhat understand what you're going through. Unfortunately I don't have it or my notes over here. If you really wanted to do it yourself, you should get a data sheet for the Zilog Z8530 Serial Communications Controller, which is the part that converts the serial signals on the modem and printer ports to the raw data (i.e., MIDI commands) that you require. Although extremely interesting to Electronics Engineering students such as myself, from a purely software- oriented viewpoint this document will give you much, much more information than you really need. The 31250 bit/s speed standard was set some time ago and may perhaps seem a little archaic to us now. Keep in mind, however, that it corresponds to roughly 3 kb/s, which is probably more bandwidth than you or I could generate playing MIDI instruments. I don't really know if it's a limitation or not. One of the reasons that this particular baud rate was chosen is because it's a convenient multiple (2^5, bit-time wise) of 1 MHz. Unfortunately for us Mac programmers, the Macintosh SCC is not clocked at 1, 2, 4 MHz or somesuch speed but at 3.672 Mhz (cf. Inside Macintosh, p III-25). This may not seem very logical, but it was chosen to provide a near match with existing protocol speeds (300, 2400, 9600, 19200 baud and the like). Now look at the table on (IM pp. II-250). You can interpolate that the 31250 baud rate requires an SCC counter value (the low 10 bits, see figure, of the serConfig parameter to the SerReset routine) somewhere between 0 and 4. The closest integer value (probably 3) does not correspond to an SCC speed which is actually near enough (I think the MIDI standard dictates +/- 10%) to be acceptable to MIDI equipment. (I know--I tried it) Fortunately, though, the Mac/Z8530 allow you to provide an external clock to override the 3.672 MHz clock. Because of the nature of asynchronous serial data, it is actually necessary to supply a clock signal with a much higher frequency than the signal you are looking for, i.e., 16, 32 or 64 times as high. Hence the 1 Mhz external clock. So finally, (sorry if I'm boring you with stuff you already know) what you need to do is initialize the SCC to recognize the external clock and tell it exactly how much faster the clock is than the MIDI signal. There are a series of bytes that you need to write to either port's SCC control register (either *SCCWr + aCtl for the modem port or *SCCWr + bCtl for the printer port, cf. pp. III-44, 45). This, of course, makes your application hardware- dependent and is the reason why so many MIDI applications `break' on newer Macs. As I say, I don't have my notes here so I can't tell you what those command bytes are from memory. Reading the Z8530 data sheet will definitely provide you with the requisite information, but, depending on your background, it may be pretty difficult to understand. If you can't get the information you need from a more informed source than myself, let me know and I'll see what I can do. Good luck! ________________________________________________________________________________ Ben Hekster Installer Dude | "Give me all Macintosh System Software | the storybook told me AppleLink: heksterb | The faith and the glory Internet: heksterb@apple.com | 'till my kingdom comes" BITNET: heksterb@henut5 | --Hymn, Ultravox -- ________________________________________________________________________________ Ben Hekster | "Sitting targets Installer dude | sitting praying AppleLink: heksterb | And God is saying Internet: heksterb@apple.com | nothing" BITNET: heksterb@henut5 | --Depeche Mode, Nothing [101]