C
C   OUTPUT TO MOOG
C
      SUBROUTINE BACK(NOTE,OUTP)
      LOGICAL IOFF,LTPEN
      INTEGER OUTP(200,3)
      INTEGER*2 LIST(2),LIST2(2)
      INTEGER*2 I1,I2,I3,I4
      INTEGER IMIN,ISEC,ISEC10,ICYCLE
      REAL DME(110),DUR(10)
      COMMON DME,DUR
      COMMON/CCC/ITAG,LTPEN,IX,IY
      EQUIVALENCE (LIST2(1),I1),(LIST2(2),I4)
      LTPEN=.FALSE.
C   USE OUTPUT CHANNELS 1 AND 2
      N=2
C   PITCH
      LIST(1)=1
C   TRIGGER
      LIST(2)=2
C   SET TIME COUNTER TO 0
      NTM=0
      CALL TIME60(IMIN,ISEC,ISEC10,ICYCLE,IOFF)
C   NOTE = # OF NOTES TO BE PLAYED
      DO 60 I=1,NOTE
C   I1 = PITCH
      I1=DME(OUTP(I,1))
C   I2 = DURATION
      I2=DUR(OUTP(I,2))
C   I3 = SPECIAL INFO
C   IF I3=1...SLUR TO NEXT NOTE,=2...STACCATO
      I3=OUTP(I,3)
C   I4 = 10V. FOR TRIGGER
      I4=0
      IF(OUTP(I,1).EQ.1)I4=2047
      NTM=NTM+I2
C   IS = DURATION THAT THE 'KEY' IS DEPRESSED
      IS=I2-I2/7
      IF(I3.EQ.2)IS=I2/2
C   NTS = REPRESENTS TIME WHEN KEY IS RELEASED
      NTS=NTM+IS-I2
      II=1
      IF(I3.EQ.1)II=0
   61 IF(FLOAT(ICYCLE).GE.NTM)GO TO 59
      IF(FLOAT(ICYCLE).GE.NTS)I4=II*2047
      CALL OUTPUT(N,LIST,LIST2)
      GO TO 61
   59 IF(LTPEN)GO TO 70
   60 CONTINUE
      IOFF=.TRUE.
      ICYCLE=0
      RETURN
C   TURN MOOG OFF IF STOPPED WITH LIGHTPEN
   70 I1=1800
      I4=2047
      CALL OUTPUT(N,LIST,LIST2)
      IOFF=.TRUE.
      ICYCLE=0
      RETURN
      END
