home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
sound
/
midi
/
midilb20.lha
/
ht
< prev
next >
Wrap
Text File
|
1988-04-07
|
1KB
|
67 lines
'Program HT - Hex Transmit
' Adapted from Pregnant Badger MIDI Library demo
'Assumes exec.bmap and midi.bmap in the current directory
LIBRARY "exec.library"
LIBRARY "midi.library"
DECLARE FUNCTION AllocMem&() LIBRARY
memf.public& = 1&
memf.clear& = 65536&
DECLARE FUNCTION CreateMSource&() LIBRARY
DECLARE FUNCTION MRouteSource&() LIBRARY
DestName$="MidiOut"+CHR$(0)
Buffer&=AllocMem&(256&,memf.public&+memf.clear&)
RouteInfo&=AllocMem&(14&,memf.public&+memf.clear&)
POKEW RouteInfo& ,-1
POKEW RouteInfo&+2,-1
HTMain:
CLS : PRINT"MIDI Hex transmit demo"
Source&=CreateMSource&(0&,0&)
IF Source&=0 THEN PRINT"Can't create Source":GOTO CloseDown
Route&=MRouteSource&(Source&,SADD(DestName$),RouteInfo&)
IF Route&=0 THEN PRINT"Can't create Route":GOTO CloseDown
CALL GetHex(Buffer&,buf.len&)
CALL PutMidiStream(Source&,0&,Buffer&,buf.len&,buf.len&)
CloseDown:
IF Route&<>0 THEN CALL DeleteMRoute(Route&)
IF Source&<>0 THEN CALL DeleteMSource(Source&)
CALL FreeMem(RouteInfo&,14&)
CALL FreeMem(Buffer&,14&)
LIBRARY CLOSE
END
SUB GetHex (BufPtr&,nbytes&) STATIC
INPUT "Transmit:";l$
l%=LEN(l$) : i%=1 : nbytes&=0
WHILE i%<=l%
x%=0
WHILE i%<=l% AND MID$(l$,i%,1)<>" "
m%=ASC(MID$(l$,i%,1))
IF m%>=48 AND m%<=57 THEN
x%=16*x%+m%-48
ELSEIF m%>=97 AND m%<=102 THEN
x%=16*x%+m%-87
ELSEIF m%>=65 AND m%<=70 THEN
x%=16*x%+m%-55
END IF
i%=i%+1
WEND
PRINT x%; : POKE BufPtr&+nbytes&,x% AND 255
nbytes&=nbytes&+1 : i%=i%+1
WEND
PRINT
END SUB