[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

1553.0. "MIDI from Amiga BASIC " by ANT::JANZEN (Tom 296-5421 LMO2/O23) Thu Jul 21 1988 10:24

Last night I built the last adapter from MIDI socket to MIDI socket and
hooked it all up.  My oscilloscope was there to verify activity and baud rate.
Deluxe Music Construction Set does indeed play out the serial port all
by itself at what looks like the right rate (by measuring the duration of
the shortest visible mark, and taking that as a single bit).
My BASIC program, however can't do it at the right baud rate.  
I opened COM1:.  In BASIC, only baud rate <=19200 are allowed.
Omitting the baud rate only gets a syntax error (in violation of the
BASIC manual format of the com1: file name, so the manual is wrong).
Omitting everything following "COM1:" seems to default to about 300 baud.
recappng:
	1. OPEN "COM1:19200,1,N,8" AS #5 or something works but is the wrong
			buad rate
	2. OPEN "COM1:,1,N,8" AS #5 is not accepted by BASIc. If this had
		worked, then setting the baud from preferences would have
		been sufficient.
	3. OPEN "COM1:" seems to default to 300 baud.

So the upshot is that I could not send a program change to the spx90.
In addition, what worries me is that although Deluxe Music could
send data, the spx90 did not do a program change.  DMCS allows setting
a preset on a channel.  I had it omni or on channel 2 and addressed channel
2, and nothing.  The SPX also requires setting up the correspondance
between program numbers and memory places, but I left them 1 to 1, 2 to 2,
etc.  I also turned MIDI ON on the SPX90.  So that failed.  

Does anybody know a trick for getting the COM1: device to go at 31250 baud
from Amiga BASIC?
Tom Janzen Digital Equipment Corp 111 Locke Dr marlboro ma 01752
T.RTitleUserPersonal
Name
DateLines
1553.1Limitations of an InterpreterULTRA::KINDELBill Kindel @ BXB1Thu Jul 21 1988 11:265
    It may be that BASIC is restricted to baud rates <= 19.2k because it
    can't keep up at higher speeds.  BASIC interpreters execute a whole lot
    (think HUNDREDS) of machine instructions for each BASIC statement.
    Compiled BASIC (or any other language) would reduce this by at least an
    order of magnitude.
1553.2 what!no DE RE AMIGA ?MERIDN::ROSCETTIA horse that knows arithmeticFri Jul 22 1988 10:2348
		Swag...

 RE .0

 A couple of possibilities...

	1. instead of using COM1: use SER:  - according to the sparse
	   documentation SER: doesn't allow you to specify Baud rate
	   so I assume it uses whatever is in preferences. Since SER:
	   is technically a Printer device you may have to set up for
	   a serial printer.

	2. I don't have the documentation but is it possible to
	   Poke the baud rate into the Uart after the Open?
	   Uart is internal to the Paula chip.



 Re .1 

 I wouldn't think that Basic's Speed would be a direct limiting factor
on Baud rate. - the par/ser conversion is strictly a function of the uart

 Basic's speed will more likely affect throughput... ex can't send a stream
 of 32nd notes at temp >120. On the recieve side you might expect something
 on the order of data overruns. Does anyone know if the I/O is buffered
 in memory?    

 Perhaps COM1: only supports up 19.2 because that is the upper limit
 for "standard" term/modem type interfaces.



 I'm just beginning to realize how little documention I have. The two
books that came with the 500 don't begin to tell me what I need to know.


brien      
    
    PS. .0
    
>        Last night I built the last adapter from MIDI socket to MIDI socket and
> hooked it all up.
    
    does this mean you built your own MIDI interface ?
    
    
1553.3I've basicall given upANT::JANZENTom 296-5421 LMO2/O23Fri Jul 22 1988 10:348
    I just had to build the null modem cable and a midi plug to plug
    cable in order to hook it all up.
    This project was only for sysex dumps, which have not been well
    supported in commercial software.
    SER: was a disaster.  I could try it again.
    It's also possible to try to call library routines or use assembler,
    in terms of my resources, but could be difficult.
    TOm
1553.4what a messANT::JANZENTom 296-5421 LMO2/O23Sat Aug 13 1988 23:1511
    Hi
    I've been studying again.  I've been reading serial.i c include
    file about the serial.device, serial.device 
    and other things.  I think I could
    call the right system library routines to deal with midi from
    BASIC, but it's getting too complicated.
    I don't know c either, so it's hard to read sometimes.
    Please let me know if you have used any libraries from Amiga BASIC.
    Although I'm giving up again.  is DRAW routine faster for drawing
    lines than the BASIC linedrawing routine?
Tom
1553.5better late than never - sometimesMERIDN::ROSCETTISome things u never get used toMon Nov 14 1988 23:3920
    
    Tom,
    
    
     It's probably too late for what you wanted .. BUT...
    
     FF disk 101 ( available on TAPE::user1:[amiga]) has a set of
    Midi Library calls, useable from Basic, C, etc. The December
    Issue of Electronic musician describes it and give a sample 
    program in BASIC , of a CZ101 patch librarian, xfer of SYSEX data
    etc.
    
    
     Now you can hack up anything you want...
    
    
    brien
    
    Ps - they also get around to reviewing SYNTHIA in this issue
        
1553.6How to set Midi Baud rate from AmigaBASICFORTY2::TATHAMNick Tatham @REOTue Feb 07 1989 03:2139
A magazine published in the UK has just shown how to drive Midi from
AmigaBASIC. The Baud rate can be set up with a POKE. I've typed in the
explanation below - hope this helps.

Nick

From ST-Amiga Format Magazine, Issue 5 Nov-88

The Midi Baud Rate

     The Amiga controls its Baud rate by having a divide-by-'N' circuit
between a clock generator and the device which provies the serial
encoding/decoding (which is done by the Amiga's 'Paula' custom chip). N is a
number written to a hardware register, enabling any Baud rate within reason
to be obtained with a fair degree of accuracy.

     The Amiga's divide-by-N register is called 'SERPER', and is at address
$DFF032. Not all computer languages, including AmigaBASIC, will accept
six-digit hexadecimal numbers, so you need to use the decimal equivalent,
14676018.

     Bits 0 to 14 of SERPER supply the number for the divide-by-N operation.
To be precise, the divisor is one more than the number written to this
register. Bit 15 of SERPER controls the byte length, which is either 8 or 9
bits. It would normally be 0, for eight bit operation.

     With the aid of a calculator it is not too difficult to work out the
correct value to write to SERPER. Each clock cycle lasts 0.2794�s, and the
duration of each MIDI bit is 32�s. Dividing 32 by 0.2794 and deducting one
gives the correct divisor, which is 113.53. Values of 113 or 114 give a Baud
rate accurate to 0.5%, which is perfectly acceptable.

     In the AmigaBASIC listings given elsewhere in the article the following
code is used to initialise the serial port for MIDI:

	OPEN "com1:300,n,8,1" AS #1
	POKEW 14676018&, 114