Home » Personal collection » Acorn ADFS disks » Electron » Music_2.ADF » MUSIC/T\MIDIon

MUSIC/T\MIDIon

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn ADFS disks » Electron » Music_2.ADF
Filename: MUSIC/T\MIDIon
Read OK:
File size: 0861 bytes
Load address: FFFFFF43
Exec address: 14017F73
File contents
*MIDIon (<addr>|OFF)
Sets up an intercept on the SOUND command (OSWORD 7) to direct it via a
MIDI port.  The command assumes the port is a simple 6850 ACIA in page
&FC.  If no address is given, then &FCF0 is used (status register at &FCF0
and data register at &FCF1).  If a two byte address is given, then that is
used as the address in page &FC instead, eg *MIDIon 80 would set up the
intercept using an ACIA at &FC80.  Using 'OFF' will deselect the MIDI
intercept.
A small buffer is kept to remember what notes have previously been sent. 
The SOUND commands are intercepted in the following way:
	SOUND chan,vol,dur,pitch  -->  Turns off previous note, 
					sends current note.
	SOUND chan,0,dur,pitch	  -->  Turns off previous note, then
					doesn't send anything (ie silence).
	SOUND 0,vol,dur,pitch	  -->  Ignored at the moment.
	SOUND &1xxx,vol,dur,pitch -->  Ignored.
There are also some extra extensions:
	SOUND -2,x,x,x		  -->  All Notes Off.  Sends a note off for
					all possible notes.
	SOUND -3,x,0,MIDIchannel  -->  Sets MIDI channel.
	SOUND -3,x,1,ignoreflag   -->  Sets the ignore flag.  If b7 set
					then all calls go to the internal
					SOUND system as well as to the MIDI
					port.
	SOUND &FFxx,x,b2,b1	  -->  Sends a specific MIDI command:
		Where xx is &8x to &Bx, sends to the MIDI channel followed
		by b1 then b2.
		Where xx is &Cx to &Ex, sends to the MIDI channel, followed
		by b1.
		Where xx is &Fx, just sends that command.
The actual duration is ignored.  The length of the note is defined by
sending another note (or a silence) after it to turn it off.  This means
that this is only suitable for direct use with programs that use a timing
mechanism to time the notes, rather than using the sound queue to time
them.  For example, programs that use a structure similar to:
	T%=TIME+delay%
	SOUND etc, etc, etc,
	REPEAT UNTIL TIME>T%
Many demo music programs use this method, and the music programs supplied
by J.G.Harston PD use it.
Another point to bear in mind is that this will only work with programs
that use SOUND (or OSWORD 7).  It will not work with programs that
directly access the sound hardware.
00000000  2a 4d 49 44 49 6f 6e 20  28 3c 61 64 64 72 3e 7c  |*MIDIon (<addr>||
00000010  4f 46 46 29 0d 53 65 74  73 20 75 70 20 61 6e 20  |OFF).Sets up an |
00000020  69 6e 74 65 72 63 65 70  74 20 6f 6e 20 74 68 65  |intercept on the|
00000030  20 53 4f 55 4e 44 20 63  6f 6d 6d 61 6e 64 20 28  | SOUND command (|
00000040  4f 53 57 4f 52 44 20 37  29 20 74 6f 20 64 69 72  |OSWORD 7) to dir|
00000050  65 63 74 20 69 74 20 76  69 61 20 61 0d 4d 49 44  |ect it via a.MID|
00000060  49 20 70 6f 72 74 2e 20  20 54 68 65 20 63 6f 6d  |I port.  The com|
00000070  6d 61 6e 64 20 61 73 73  75 6d 65 73 20 74 68 65  |mand assumes the|
00000080  20 70 6f 72 74 20 69 73  20 61 20 73 69 6d 70 6c  | port is a simpl|
00000090  65 20 36 38 35 30 20 41  43 49 41 20 69 6e 20 70  |e 6850 ACIA in p|
000000a0  61 67 65 0d 26 46 43 2e  20 20 49 66 20 6e 6f 20  |age.&FC.  If no |
000000b0  61 64 64 72 65 73 73 20  69 73 20 67 69 76 65 6e  |address is given|
000000c0  2c 20 74 68 65 6e 20 26  46 43 46 30 20 69 73 20  |, then &FCF0 is |
000000d0  75 73 65 64 20 28 73 74  61 74 75 73 20 72 65 67  |used (status reg|
000000e0  69 73 74 65 72 20 61 74  20 26 46 43 46 30 0d 61  |ister at &FCF0.a|
000000f0  6e 64 20 64 61 74 61 20  72 65 67 69 73 74 65 72  |nd data register|
00000100  20 61 74 20 26 46 43 46  31 29 2e 20 20 49 66 20  | at &FCF1).  If |
00000110  61 20 74 77 6f 20 62 79  74 65 20 61 64 64 72 65  |a two byte addre|
00000120  73 73 20 69 73 20 67 69  76 65 6e 2c 20 74 68 65  |ss is given, the|
00000130  6e 20 74 68 61 74 20 69  73 0d 75 73 65 64 20 61  |n that is.used a|
00000140  73 20 74 68 65 20 61 64  64 72 65 73 73 20 69 6e  |s the address in|
00000150  20 70 61 67 65 20 26 46  43 20 69 6e 73 74 65 61  | page &FC instea|
00000160  64 2c 20 65 67 20 2a 4d  49 44 49 6f 6e 20 38 30  |d, eg *MIDIon 80|
00000170  20 77 6f 75 6c 64 20 73  65 74 20 75 70 20 74 68  | would set up th|
00000180  65 0d 69 6e 74 65 72 63  65 70 74 20 75 73 69 6e  |e.intercept usin|
00000190  67 20 61 6e 20 41 43 49  41 20 61 74 20 26 46 43  |g an ACIA at &FC|
000001a0  38 30 2e 20 20 55 73 69  6e 67 20 27 4f 46 46 27  |80.  Using 'OFF'|
000001b0  20 77 69 6c 6c 20 64 65  73 65 6c 65 63 74 20 74  | will deselect t|
000001c0  68 65 20 4d 49 44 49 0d  69 6e 74 65 72 63 65 70  |he MIDI.intercep|
000001d0  74 2e 0d 41 20 73 6d 61  6c 6c 20 62 75 66 66 65  |t..A small buffe|
000001e0  72 20 69 73 20 6b 65 70  74 20 74 6f 20 72 65 6d  |r is kept to rem|
000001f0  65 6d 62 65 72 20 77 68  61 74 20 6e 6f 74 65 73  |ember what notes|
00000200  20 68 61 76 65 20 70 72  65 76 69 6f 75 73 6c 79  | have previously|
00000210  20 62 65 65 6e 20 73 65  6e 74 2e 20 0d 54 68 65  | been sent. .The|
00000220  20 53 4f 55 4e 44 20 63  6f 6d 6d 61 6e 64 73 20  | SOUND commands |
00000230  61 72 65 20 69 6e 74 65  72 63 65 70 74 65 64 20  |are intercepted |
00000240  69 6e 20 74 68 65 20 66  6f 6c 6c 6f 77 69 6e 67  |in the following|
00000250  20 77 61 79 3a 0d 09 53  4f 55 4e 44 20 63 68 61  | way:..SOUND cha|
00000260  6e 2c 76 6f 6c 2c 64 75  72 2c 70 69 74 63 68 20  |n,vol,dur,pitch |
00000270  20 2d 2d 3e 20 20 54 75  72 6e 73 20 6f 66 66 20  | -->  Turns off |
00000280  70 72 65 76 69 6f 75 73  20 6e 6f 74 65 2c 20 0d  |previous note, .|
00000290  09 09 09 09 09 73 65 6e  64 73 20 63 75 72 72 65  |.....sends curre|
000002a0  6e 74 20 6e 6f 74 65 2e  0d 09 53 4f 55 4e 44 20  |nt note...SOUND |
000002b0  63 68 61 6e 2c 30 2c 64  75 72 2c 70 69 74 63 68  |chan,0,dur,pitch|
000002c0  09 20 20 2d 2d 3e 20 20  54 75 72 6e 73 20 6f 66  |.  -->  Turns of|
000002d0  66 20 70 72 65 76 69 6f  75 73 20 6e 6f 74 65 2c  |f previous note,|
000002e0  20 74 68 65 6e 0d 09 09  09 09 09 64 6f 65 73 6e  | then......doesn|
000002f0  27 74 20 73 65 6e 64 20  61 6e 79 74 68 69 6e 67  |'t send anything|
00000300  20 28 69 65 20 73 69 6c  65 6e 63 65 29 2e 0d 09  | (ie silence)...|
00000310  53 4f 55 4e 44 20 30 2c  76 6f 6c 2c 64 75 72 2c  |SOUND 0,vol,dur,|
00000320  70 69 74 63 68 09 20 20  2d 2d 3e 20 20 49 67 6e  |pitch.  -->  Ign|
00000330  6f 72 65 64 20 61 74 20  74 68 65 20 6d 6f 6d 65  |ored at the mome|
00000340  6e 74 2e 0d 09 53 4f 55  4e 44 20 26 31 78 78 78  |nt...SOUND &1xxx|
00000350  2c 76 6f 6c 2c 64 75 72  2c 70 69 74 63 68 20 2d  |,vol,dur,pitch -|
00000360  2d 3e 20 20 49 67 6e 6f  72 65 64 2e 0d 54 68 65  |->  Ignored..The|
00000370  72 65 20 61 72 65 20 61  6c 73 6f 20 73 6f 6d 65  |re are also some|
00000380  20 65 78 74 72 61 20 65  78 74 65 6e 73 69 6f 6e  | extra extension|
00000390  73 3a 0d 09 53 4f 55 4e  44 20 2d 32 2c 78 2c 78  |s:..SOUND -2,x,x|
000003a0  2c 78 09 09 20 20 2d 2d  3e 20 20 41 6c 6c 20 4e  |,x..  -->  All N|
000003b0  6f 74 65 73 20 4f 66 66  2e 20 20 53 65 6e 64 73  |otes Off.  Sends|
000003c0  20 61 20 6e 6f 74 65 20  6f 66 66 20 66 6f 72 0d  | a note off for.|
000003d0  09 09 09 09 09 61 6c 6c  20 70 6f 73 73 69 62 6c  |.....all possibl|
000003e0  65 20 6e 6f 74 65 73 2e  0d 09 53 4f 55 4e 44 20  |e notes...SOUND |
000003f0  2d 33 2c 78 2c 30 2c 4d  49 44 49 63 68 61 6e 6e  |-3,x,0,MIDIchann|
00000400  65 6c 20 20 2d 2d 3e 20  20 53 65 74 73 20 4d 49  |el  -->  Sets MI|
00000410  44 49 20 63 68 61 6e 6e  65 6c 2e 0d 09 53 4f 55  |DI channel...SOU|
00000420  4e 44 20 2d 33 2c 78 2c  31 2c 69 67 6e 6f 72 65  |ND -3,x,1,ignore|
00000430  66 6c 61 67 20 20 20 2d  2d 3e 20 20 53 65 74 73  |flag   -->  Sets|
00000440  20 74 68 65 20 69 67 6e  6f 72 65 20 66 6c 61 67  | the ignore flag|
00000450  2e 20 20 49 66 20 62 37  20 73 65 74 0d 09 09 09  |.  If b7 set....|
00000460  09 09 74 68 65 6e 20 61  6c 6c 20 63 61 6c 6c 73  |..then all calls|
00000470  20 67 6f 20 74 6f 20 74  68 65 20 69 6e 74 65 72  | go to the inter|
00000480  6e 61 6c 0d 09 09 09 09  09 53 4f 55 4e 44 20 73  |nal......SOUND s|
00000490  79 73 74 65 6d 20 61 73  20 77 65 6c 6c 20 61 73  |ystem as well as|
000004a0  20 74 6f 20 74 68 65 20  4d 49 44 49 0d 09 09 09  | to the MIDI....|
000004b0  09 09 70 6f 72 74 2e 0d  09 53 4f 55 4e 44 20 26  |..port...SOUND &|
000004c0  46 46 78 78 2c 78 2c 62  32 2c 62 31 09 20 20 2d  |FFxx,x,b2,b1.  -|
000004d0  2d 3e 20 20 53 65 6e 64  73 20 61 20 73 70 65 63  |->  Sends a spec|
000004e0  69 66 69 63 20 4d 49 44  49 20 63 6f 6d 6d 61 6e  |ific MIDI comman|
000004f0  64 3a 0d 09 09 57 68 65  72 65 20 78 78 20 69 73  |d:...Where xx is|
00000500  20 26 38 78 20 74 6f 20  26 42 78 2c 20 73 65 6e  | &8x to &Bx, sen|
00000510  64 73 20 74 6f 20 74 68  65 20 4d 49 44 49 20 63  |ds to the MIDI c|
00000520  68 61 6e 6e 65 6c 20 66  6f 6c 6c 6f 77 65 64 0d  |hannel followed.|
00000530  09 09 62 79 20 62 31 20  74 68 65 6e 20 62 32 2e  |..by b1 then b2.|
00000540  0d 09 09 57 68 65 72 65  20 78 78 20 69 73 20 26  |...Where xx is &|
00000550  43 78 20 74 6f 20 26 45  78 2c 20 73 65 6e 64 73  |Cx to &Ex, sends|
00000560  20 74 6f 20 74 68 65 20  4d 49 44 49 20 63 68 61  | to the MIDI cha|
00000570  6e 6e 65 6c 2c 20 66 6f  6c 6c 6f 77 65 64 0d 09  |nnel, followed..|
00000580  09 62 79 20 62 31 2e 0d  09 09 57 68 65 72 65 20  |.by b1....Where |
00000590  78 78 20 69 73 20 26 46  78 2c 20 6a 75 73 74 20  |xx is &Fx, just |
000005a0  73 65 6e 64 73 20 74 68  61 74 20 63 6f 6d 6d 61  |sends that comma|
000005b0  6e 64 2e 0d 54 68 65 20  61 63 74 75 61 6c 20 64  |nd..The actual d|
000005c0  75 72 61 74 69 6f 6e 20  69 73 20 69 67 6e 6f 72  |uration is ignor|
000005d0  65 64 2e 20 20 54 68 65  20 6c 65 6e 67 74 68 20  |ed.  The length |
000005e0  6f 66 20 74 68 65 20 6e  6f 74 65 20 69 73 20 64  |of the note is d|
000005f0  65 66 69 6e 65 64 20 62  79 0d 73 65 6e 64 69 6e  |efined by.sendin|
00000600  67 20 61 6e 6f 74 68 65  72 20 6e 6f 74 65 20 28  |g another note (|
00000610  6f 72 20 61 20 73 69 6c  65 6e 63 65 29 20 61 66  |or a silence) af|
00000620  74 65 72 20 69 74 20 74  6f 20 74 75 72 6e 20 69  |ter it to turn i|
00000630  74 20 6f 66 66 2e 20 20  54 68 69 73 20 6d 65 61  |t off.  This mea|
00000640  6e 73 0d 74 68 61 74 20  74 68 69 73 20 69 73 20  |ns.that this is |
00000650  6f 6e 6c 79 20 73 75 69  74 61 62 6c 65 20 66 6f  |only suitable fo|
00000660  72 20 64 69 72 65 63 74  20 75 73 65 20 77 69 74  |r direct use wit|
00000670  68 20 70 72 6f 67 72 61  6d 73 20 74 68 61 74 20  |h programs that |
00000680  75 73 65 20 61 20 74 69  6d 69 6e 67 0d 6d 65 63  |use a timing.mec|
00000690  68 61 6e 69 73 6d 20 74  6f 20 74 69 6d 65 20 74  |hanism to time t|
000006a0  68 65 20 6e 6f 74 65 73  2c 20 72 61 74 68 65 72  |he notes, rather|
000006b0  20 74 68 61 6e 20 75 73  69 6e 67 20 74 68 65 20  | than using the |
000006c0  73 6f 75 6e 64 20 71 75  65 75 65 20 74 6f 20 74  |sound queue to t|
000006d0  69 6d 65 0d 74 68 65 6d  2e 20 20 46 6f 72 20 65  |ime.them.  For e|
000006e0  78 61 6d 70 6c 65 2c 20  70 72 6f 67 72 61 6d 73  |xample, programs|
000006f0  20 74 68 61 74 20 75 73  65 20 61 20 73 74 72 75  | that use a stru|
00000700  63 74 75 72 65 20 73 69  6d 69 6c 61 72 20 74 6f  |cture similar to|
00000710  3a 0d 09 54 25 3d 54 49  4d 45 2b 64 65 6c 61 79  |:..T%=TIME+delay|
00000720  25 0d 09 53 4f 55 4e 44  20 65 74 63 2c 20 65 74  |%..SOUND etc, et|
00000730  63 2c 20 65 74 63 2c 0d  09 52 45 50 45 41 54 20  |c, etc,..REPEAT |
00000740  55 4e 54 49 4c 20 54 49  4d 45 3e 54 25 0d 4d 61  |UNTIL TIME>T%.Ma|
00000750  6e 79 20 64 65 6d 6f 20  6d 75 73 69 63 20 70 72  |ny demo music pr|
00000760  6f 67 72 61 6d 73 20 75  73 65 20 74 68 69 73 20  |ograms use this |
00000770  6d 65 74 68 6f 64 2c 20  61 6e 64 20 74 68 65 20  |method, and the |
00000780  6d 75 73 69 63 20 70 72  6f 67 72 61 6d 73 20 73  |music programs s|
00000790  75 70 70 6c 69 65 64 0d  62 79 20 4a 2e 47 2e 48  |upplied.by J.G.H|
000007a0  61 72 73 74 6f 6e 20 50  44 20 75 73 65 20 69 74  |arston PD use it|
000007b0  2e 0d 41 6e 6f 74 68 65  72 20 70 6f 69 6e 74 20  |..Another point |
000007c0  74 6f 20 62 65 61 72 20  69 6e 20 6d 69 6e 64 20  |to bear in mind |
000007d0  69 73 20 74 68 61 74 20  74 68 69 73 20 77 69 6c  |is that this wil|
000007e0  6c 20 6f 6e 6c 79 20 77  6f 72 6b 20 77 69 74 68  |l only work with|
000007f0  20 70 72 6f 67 72 61 6d  73 0d 74 68 61 74 20 75  | programs.that u|
00000800  73 65 20 53 4f 55 4e 44  20 28 6f 72 20 4f 53 57  |se SOUND (or OSW|
00000810  4f 52 44 20 37 29 2e 20  20 49 74 20 77 69 6c 6c  |ORD 7).  It will|
00000820  20 6e 6f 74 20 77 6f 72  6b 20 77 69 74 68 20 70  | not work with p|
00000830  72 6f 67 72 61 6d 73 20  74 68 61 74 0d 64 69 72  |rograms that.dir|
00000840  65 63 74 6c 79 20 61 63  63 65 73 73 20 74 68 65  |ectly access the|
00000850  20 73 6f 75 6e 64 20 68  61 72 64 77 61 72 65 2e  | sound hardware.|
00000860  0d                                                |.|
00000861
MUSIC/T\MIDIon.m0
MUSIC/T\MIDIon.m1
MUSIC/T\MIDIon.m2
MUSIC/T\MIDIon.m4
MUSIC/T\MIDIon.m5