2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <proto/utility.h>
14 #include "camd_intern.h"
18 struct MidiLink
*midilink
,
19 struct MyMidiMessage2
*msg2
,
25 struct MyMidiNode
*mymidinode
=(struct MyMidiNode
*)midilink
->ml_MidiNode
;
27 if(mymidinode
->error
&CMEF_BufferFull
){
31 if(msg2
->status
<0x80){
34 type
=MidiMsgType_status_data1(msg2
->status
,msg2
->data1
);
37 if(! ( (1L<<type
) & midilink
->ml_EventTypeMask
) ){
41 if( (midilink
->ml_ChannelMask
!=(UWORD
)~0) && ((1L<<type
)&CMF_Channel
) ){
43 ( 1L<< (msg2
->status
&0xf) )
45 midilink
->ml_ChannelMask
52 if(midilink
->ml_SysExFilter
.sxf_Mode
!=0){
53 if(midilink
->ml_SysExFilter
.sxf_Mode
&SXFM_3Byte
){
55 midilink
->ml_SysExFilter
.sxf_ID1
!=msg2
->status
||
56 midilink
->ml_SysExFilter
.sxf_ID1
!=msg2
->status
||
57 midilink
->ml_SysExFilter
.sxf_ID1
!=msg2
->status
59 mymidinode
->sysex_write
=mymidinode
->sysex_laststart
;
63 if(midilink
->ml_SysExFilter
.sxf_ID1
==msg2
->status
) goto outofhere
;
64 if(midilink
->ml_SysExFilter
.sxf_ID2
==msg2
->status
) goto outofhere
;
65 if(midilink
->ml_SysExFilter
.sxf_ID3
==msg2
->status
) goto outofhere
;
66 mymidinode
->sysex_write
=mymidinode
->sysex_laststart
;
71 msg2
->data2
=msg2
->data1
;
72 msg2
->data1
=msg2
->status
;
77 if(mymidinode
->midinode
.mi_ReceiveHook
!=NULL
){
79 /* I haven`t found any documentation about what the hooks carry. But the
80 camd in tool hook for Barsnpipes has the following proto:
82 static ULONG __asm __saveds midiinhook(register __a0 struct Hook *hook,
83 register __a2 struct MidiLink *link,
84 register __a1 MidiMsg *msg,
85 register __d0 long sysexlen,
86 register __a3 void *sysexdata);
87 ... So I do that. -K.Matheussen.
90 CallHookPkt(mymidinode
->midinode
.mi_ReceiveHook
,NULL
,NULL
);
93 hmsg
.mm_Time
=timestamp
;
95 hmsg
.mm_Status
=msg2
->status
;
97 hmsg
.mm_Data1
=msg2
->data1
;
102 hmsg
.mm_Data2
=msg2
->data2
;
106 hmsg
.mm_Port
=midilink
->ml_PortID
;
112 REG(a0
, struct Hook
*),
113 REG(a2
, struct MidiLink
*),
120 REG(a0
) struct Hook
*,
121 REG(a2
) struct MidiLink
*,
128 (mymidinode
->midinode
.mi_ReceiveHook
->h_Entry
)
131 mymidinode
->midinode
.mi_ReceiveHook
,
134 hmsg
.mm_Status
==0xf0?GetSysXLen(mymidinode
->sysex_laststart
):0L,
135 hmsg
.mm_Status
==0xf0?mymidinode
->sysex_laststart
:NULL
141 msg
=mymidinode
->in_curr
;
142 if(msg
==NULL
){ //If no buffer.
146 if(mymidinode
->unpicked
+1==mymidinode
->midinode
.mi_MsgQueueSize
-1){
147 mymidinode
->error
|= CMEF_BufferFull
;
151 msg
->mm_Time
=timestamp
;
153 msg
->mm_Status
=msg2
->status
;
155 msg
->mm_Data1
=msg2
->data1
;
160 msg
->mm_Data2
=msg2
->data2
;
164 msg
->mm_Port
=midilink
->ml_PortID
;
166 mymidinode
->unpicked
++;
168 mymidinode
->in_curr
++;
169 if(mymidinode
->in_curr
==mymidinode
->in_end
){
170 mymidinode
->in_curr
=mymidinode
->in_start
;
173 if(mymidinode
->midinode
.mi_ReceiveSigBit
!=-1){
174 Signal(mymidinode
->midinode
.mi_SigTask
,1L<<mymidinode
->midinode
.mi_ReceiveSigBit
);