2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 #include <proto/exec.h>
10 #include <proto/dos.h>
12 #include "camd_intern.h"
15 /* Sysex receiving is a bit of a mess... (and not very much tested either) -ksvalast- */
17 int GetSysXLen(UBYTE
*buffer
){
20 while(buffer
[lokke
]<0x80){ // "!=0xf7" should allso be correct, but this one is perhaps safer.
27 BOOL
PutSysEx2Link(struct MidiLink
*midilink
,UBYTE data
){
29 struct MyMidiMessage2 msg2
;
31 struct MyMidiNode
*mymidinode
=(struct MyMidiNode
*)midilink
->ml_MidiNode
;
33 if(mymidinode
->sysex_laststart
==NULL
&& data
!=0xf0){
34 return TRUE
; // This midinode was created in the middle of receiving a sysex-string.
37 if(mymidinode
->sysex_start
!=NULL
&& (!(mymidinode
->error
&CMEF_SysExFull
))){
38 if(data
==0xff){ // Error in sysex-string. Sysex is cancelled.
39 mymidinode
->sysex_write
=mymidinode
->sysex_laststart
;
40 ReleaseSemaphore(&mymidinode
->sysexsemaphore
);
44 ObtainSemaphore(&mymidinode
->sysexsemaphore
);
45 ObtainSemaphore(&mymidinode
->sysexsemaphore2
);
46 mymidinode
->sysex_laststart
=mymidinode
->sysex_write
;
48 ObtainSemaphore(&mymidinode
->sysexsemaphore2
);
50 *mymidinode
->sysex_write
=data
;
51 mymidinode
->sysex_write
++;
52 if(mymidinode
->sysex_write
==mymidinode
->sysex_end
){
53 mymidinode
->sysex_write
=mymidinode
->sysex_start
;
55 if(mymidinode
->sysex_write
==mymidinode
->sysex_read
){
56 mymidinode
->error
|= CMEF_SysExFull
;
57 mymidinode
->sysex_write
=mymidinode
->sysex_laststart
;
58 ReleaseSemaphore(&mymidinode
->sysexsemaphore2
);
59 ReleaseSemaphore(&mymidinode
->sysexsemaphore
);
62 ReleaseSemaphore(&mymidinode
->sysexsemaphore2
);
64 sysex
=mymidinode
->sysex_laststart
;
69 PutMidi2Link(midilink
,&msg2
,*mymidinode
->midinode
.mi_TimeStamp
);
70 ReleaseSemaphore(&mymidinode
->sysexsemaphore
);