home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / LEDGERS / LEDG_07B.MSA / SOURCE / MR_MUSIC.V2 / QUARCON2.GFA (.txt) < prev    next >
GFA-BASIC Atari  |  1985-11-20  |  5KB  |  146 lines

  1. ' -----------------------------------------------------------------------------'
  2. '              Quartet to MR Music Convertor By Martin Griffiths               '
  3. ' -----------------------------------------------------------------------------'
  4. ' Version 0.9 - Almost complete version which handles everything except slides.
  5. ' Version 1.0 - All functions converted.
  6. CLS
  7. PRINT AT(24,2);"---------------------------------------"
  8. PRINT AT(24,3);"Quartet 4V to Mr Music File Convertor!!"
  9. PRINT AT(24,4);"    Full convertor (in theory!!!)"
  10. PRINT AT(24,6);"     Written in GFA Basic V3.02!"
  11. PRINT AT(24,7);"         By Martin Griffiths"
  12. PRINT AT(24,8);"---------------------------------------"
  13. PRINT AT(27,22);"Please Press any key to Continue"
  14. a&=INP(2)
  15. DIM match_freq%(64)
  16. DIM loop_ptrs%(100)                           !store for upto 100 depth loop
  17. DIM input_buf%(12000)                         !50k input buffer
  18. DIM output_buf%(12000)                        !50k output buffer
  19. DIM voiceset_buf%(30000),loop_flag&(19)
  20. RESTORE
  21. FOR i&=0 TO 59
  22.   READ match_freq%(i&)
  23. NEXT i&
  24. input_ptr%=V:input_buf%(0)                    !ptr to input buffer
  25. output_ptr%=V:output_buf%(0)                  !ptr to output buffer
  26. CLS
  27. PRINT "                     Please select a Quartet 4V to Convert!"
  28. PRINT "                     --------------------------------------"
  29. REPEAT
  30.   FILESELECT "\*.4V",f$,f$
  31. UNTIL RIGHT$(f$,3)=".4V" OR f$=""
  32. IF f$=""
  33.   END
  34. ENDIF
  35. BLOAD f$,input_ptr%
  36. CLS
  37. PRINT AT(19,1);"Please Select accompanying Quartet .SET file"
  38. PRINT AT(19,2);"--------------------------------------------"
  39. FILESELECT "\*.SET",voiceset_name$,voiceset_name$
  40. IF voiceset_name$=""
  41.   END
  42. ENDIF
  43. BLOAD voiceset_name$,V:voiceset_buf%(0)
  44. FOR i&=0 TO 19
  45.   i%=V:voiceset_buf%(0)+LPEEK(V:voiceset_buf%(0)+&H8E+SHL(i&,2))
  46.   IF DPEEK(i%)=65535
  47.     loop_flag&(i&)=FALSE
  48.   ELSE
  49.     loop_flag&(i&)=TRUE
  50.   ENDIF
  51. NEXT i&
  52. CLS
  53. ADD input_ptr%,16
  54. CLR curr_note&,curr_instrument&,curr_sustain&,loopsize&,loop_depth&
  55. ' Conversion loop
  56. FOR ch&=1 TO 4                                !loop for 4 channels
  57.   PRINT AT(1,3);"Working on channel:";ch&
  58.   DO
  59.     command_read&=DPEEK(input_ptr%)
  60.     EXIT IF command_read&=70                  !exit if 'F' - end of chan
  61.     SELECT command_read&
  62.     CASE 108                                  !'l' - beginning of a loop
  63.       loop_ptrs%(loop_depth&)=output_ptr%
  64.       INC loop_depth&
  65.     CASE 76                                   !'L' - end of a loop
  66.       loop&=DPEEK(input_ptr%+8)               !no of loops -1
  67.       DEC loop_depth&
  68.       DPOKE output_ptr%,-128                  !signify loop
  69.       POKE output_ptr%+2,loop&
  70.       POKE output_ptr%+3,loop&
  71.       loopsize&=(output_ptr%+4)-loop_ptrs%(loop_depth&)   !loopsize
  72.       DPOKE output_ptr%+4,loopsize&
  73.       ADD output_ptr%,6
  74.     CASE 83                                   !'S' - Slide!
  75.       DPOKE output_ptr%,4+curr_sustain&       !bit 2 set(4!!)
  76.       note%=LPEEK(input_ptr%+4)
  77.       FOR i&=0 TO 59
  78.         EXIT IF note%=match_freq%(i&)
  79.       NEXT i&
  80.       d&=DPEEK(input_ptr%+2)/4                !slide duration
  81.       diff&=ABS(i&-curr_note&)
  82.       DPOKE output_ptr%+2,i&                  !Destination note
  83.       IF diff&=0
  84.         DPOKE output_ptr%+4,1
  85.       ELSE IF d&/diff&<2
  86.         DPOKE output_ptr%+4,1
  87.       ELSE
  88.         DPOKE output_ptr%+4,2
  89.       ENDIF
  90.       DPOKE output_ptr%+6,d&                  ! vbl count(slide duration)
  91.       ADD output_ptr%,8
  92.       curr_note&=i&
  93.     CASE 86                                   !'V' - New instrument
  94.       curr_instrument&=DPEEK(input_ptr%+10)/4
  95.       IF loop_flag&(curr_instrument&)=TRUE
  96.         curr_sustain&=16384
  97.       ELSE
  98.         CLR curr_sustain&
  99.       ENDIF
  100.     CASE 80                                   !'P' - New note
  101.       DPOKE output_ptr%,3+curr_sustain&       !bits 0 and 1 set=3
  102.       DPOKE output_ptr%+2,curr_instrument&
  103.       note%=LPEEK(input_ptr%+4)
  104.       FOR i&=0 TO 59
  105.         EXIT IF note%=match_freq%(i&)
  106.       NEXT i&
  107.       DPOKE output_ptr%+4,i&
  108.       curr_note&=i&
  109.       DPOKE output_ptr%+6,DPEEK(input_ptr%+2)/4  ! duration/4
  110.       ADD output_ptr%,8
  111.     CASE 82                                   !'R' - Rest
  112.       DPOKE output_ptr%,8
  113.       DPOKE output_ptr%+2,DPEEK(input_ptr%+2)/4    !store vbl count(200hz cnt/4)
  114.       ADD output_ptr%,4
  115.     DEFAULT
  116.     ENDSELECT
  117.     ADD input_ptr%,12                         !advance to quartet's next command
  118.   LOOP
  119.   DPOKE output_ptr%,-9999
  120.   ADD output_ptr%,2
  121.   ADD input_ptr%,12                           !advance to quartet's next command
  122. NEXT ch&
  123. new_length%=output_ptr%-V:output_buf%(0)
  124. PRINT "Original Length:";input_ptr%-V:input_buf%(0)
  125. PRINT "New Length:";new_length%
  126. FILESELECT "\*.SNG",f$,f$
  127. BSAVE f$,V:output_buf%(0),new_length%
  128. ' Quartet to Mr music frequency match table
  129. table:
  130. DATA &000000,&000000,&000000,&000000
  131. DATA &000000,&000000,&000000,&000000
  132. DATA &000000,&000000,&004C1B,&0050A2
  133. DATA &00556E,&005A82,&005FE4,&006597
  134. DATA &006BA2,&007208,&0078D0,&008000
  135. DATA &00879C,&008FAC,&009837,&00A145
  136. DATA &00AADC,&00B504,&00BFC8
  137. DATA &00CB2F,&00D744,&00E411,&00F1A1
  138. DATA &010000,&010F38,&011F59,&01306F
  139. DATA &01428A,&0155B8,&016A09,&017F91
  140. DATA &01965E,&01AE89,&01C823,&01E343
  141. DATA &020000,&021E71,&023EB3,&0260DE
  142. DATA &028514,&02AB70,&02D412,&02FF22
  143. DATA &032CBC,&035D12,&039046,&03C686
  144. DATA &040000,&043CE2,&047D66,&04C1BC
  145. DATA &050A28
  146.