svb@bksmel.oz.au (Stuart Begg) (09/04/90)
I have recently turned my computing interests to MIDI programming and, having a Macintosh, have invested in some sequencing software and a MIDI interface. And while this system works just fine, it has piqued my interest in developing my own software in this environment. My programming experience is quite extensive, however, my hardware and communications experience leaves something to be desired. With this in mind, and given that I have read what I think are the appropriate sections of "Inside Macintosh" (V1-V5), I can't work out how to configure and access the serial port for MIDI transmission and receipt on my Macintosh Plus! The interface I have clocks the HSK pin on the Macintosh at 1MHz, and I don't understand what, given that the MIDI protocol is asynchronous (31.25kbps, 8 data bits, 1 stop bit), this signal is doing. What vital piece of communications/hardware/interrupt information am I missing here? Also, what about this crazy speed? 31.25kbps, what sort of speed is that for a self respecting piece of equipment to run at? :-) I know there are some MIDI libraries around but I would prefer to understand the process a little more fully by implementing my own. If anyone can help with tips, pointers, source code, references, technical notes, or any other relevant information, I would greatly appreciate the assistance. I can be emailed at the address in the signature, of course. Oh, when you do send something, I would appreciate a reference too, if that's possible. Thanks, in advance. Stuart. ------------------------------------------------------------------ Stuart Begg : usenet = svb@bksmel.oz.au ------------------------------------------------------------------
heksterb@Apple.COM (Ben Hekster) (09/05/90)
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]
fswrr@acad3.fai.alaska.edu (rector walter r) (09/05/90)
In article <302@bksmel.oz.au>, svb@bksmel.oz.au (Stuart Begg) writes... > >My programming experience is quite extensive, however, my hardware and >communications experience leaves something to be desired. With this >in mind, and given that I have read what I think are the appropriate >sections of "Inside Macintosh" (V1-V5), I can't work out how to >configure and access the serial port for MIDI transmission and >receipt on my Macintosh Plus! > >------------------------------------------------------------------ >Stuart Begg : usenet = svb@bksmel.oz.au >------------------------------------------------------------------ You should probably try to find Apple's MIDI Manager. I know that it's supposed to be included with System 7, but I have seen it being used with 6.0.4. On a related note: Does anyone know where I could find some info on how to use the thing? The machine I saw it running on got the system patch and some sample applications, but no real docs at all. I would really like to get ahold of the programming documentation...... help...... -Reed
alves@alcor.usc.edu (William Alves) (09/05/90)
In article <302@bksmel.oz.au> svb@bksmel.UUCP (Stuart Begg) writes: >I have recently turned my computing interests to MIDI programming and, >having a Macintosh, have invested in some sequencing software and a >MIDI interface. And while this system works just fine, it has piqued >my interest in developing my own software in this environment. >My programming experience is quite extensive, however, my hardware and >communications experience leaves something to be desired. With this >in mind, and given that I have read what I think are the appropriate >sections of "Inside Macintosh" (V1-V5), I can't work out how to >configure and access the serial port for MIDI transmission and >receipt on my Macintosh Plus! > What you need is the MIDI Manager software from Apple. This is a package which includes an init and a software library for developing MIDI appli- cations that will be compatible with MultiFinder. They go to great lengths in the documentation to emphasize that you should IGNORE all the MIDI implementation in the Sound Manager in Inside Mac Volume 5. It is full of errors and inconsistencies and was meant as a stopgap anyway until the MIDI Management Tools were developed. This package is available from APDA I believe, at 1-800-282-2732. I got it off of their developer CD-ROM vol 3 (I think), but you may need to be a member of APDA. Bill Alves
nick@cs.ed.ac.uk (Nick Rothwell) (09/06/90)
In article <302@bksmel.oz.au> svb@bksmel.UUCP (Stuart Begg) writes: >I have recently turned my computing interests to MIDI programming and, >having a Macintosh, have invested in some sequencing software and a >MIDI interface. And while this system works just fine, it has piqued >my interest in developing my own software in this environment. > >My programming experience is quite extensive, however, my hardware and >communications experience leaves something to be desired. With this >in mind, and given that I have read what I think are the appropriate >sections of "Inside Macintosh" (V1-V5), I can't work out how to >configure and access the serial port for MIDI transmission and >receipt on my Macintosh Plus! I seem to be posting a message of this kind once a week now. About time Apple pulled the finger out and told folks about the MIDI Manager. Don't use the serial port driving stuff for MIDI. Don't roll your own. It isn't portable. It isn't future-proof. It isn't asynchronous. It isn't user-configurable. It isn't nice. And parsing MIDI is pretty tricky. (if you don't believe me, I bet I can come up with a nasty example.) Use Apple's MIDI Manager. >Also, what about this crazy speed? 31.25kbps, what sort of speed is >that for a self respecting piece of equipment to run at? :-) Some power of 2 dividing 1MHz. Makes sense when you're building the MIDI interface hardware, I can tell you. You call the RS232 speeds sensible? >I know there are some MIDI libraries around but I would prefer to >understand the process a little more fully by implementing my own. You'll be wasting your time and implementing a dinosaur. Nick. -- -- Nick Rothwell, Laboratory for Foundations of Computer Science, Edinburgh. nick@lfcs.ed.ac.uk <Atlantic Ocean>!mcsun!ukc!lfcs!nick ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ "Now remember - and this is most important - you must think in Russian."