home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 10 / amigaformatcd10.iso / -readerstuff- / martin_cameron / bonus / adpcmpack.amos / adpcmpack.amosSourceCode
AMOS Source Code  |  1996-04-02  |  2KB  |  81 lines

  1. Screen Open 0,640,200,2,Hires : Palette $777,$FF9
  2. '
  3. Print "FlowerPower's ADPCM Packer  --  Amos interface by Martin Cameron."
  4. Print 
  5. Print "This program is a replacement for the XtoADPCM utility an the"
  6. Print "FP-ADPCM archive (Aminet/util/pack). It will only pack 8bit RAW, but"
  7. Print "it uses virtual memory to pack samples of any size, unlike XtoADPCM"
  8. Print "which can only handle files of around 1meg no matter how much mem you have."
  9. Print 
  10. Print "Included with this program is the cli program PlayDPCM, which plays"
  11. Print "back these ADPCM files using virtual memory."
  12. Print 
  13. Print "See how good quality a 2 or 3 bit sample can be with ADPCM!"
  14. Print 
  15. Print "Buffer size should be a reasonable amount, upto 500000 if you have the memory!"
  16. Print 
  17. Print 
  18. Input "Enter buffer size (bytes) >";BUFFER
  19. '
  20. Reserve As Work 1,BUFFER
  21. Reserve As Work 2,BUFFER/2
  22. '
  23. IN$=Fsel$("","","Load Raw..") : Open In 1,IN$
  24. OUT$=Fsel$("","","Save ADPCM") : Open Out 2,OUT$
  25. '
  26. Input "Type number of bits (2/3) >";BITS
  27. Input "Type playback samplerate in hertz >";SAMPLRATE
  28. '
  29. Proc HEADER[BITS,SAMPLRATE]
  30. JOINCODE=0
  31. '
  32. Repeat 
  33.    Print "Loading bytes.";Lof(1)-Pof(1);" To go..."
  34.    Proc LODE[BUFFER] : AMOUNT=Param
  35.    Print "Packing";AMOUNT;" bytes to";(AMOUNT/8)*BITS;" bytes."
  36.    Proc ADPACK[Start(1),AMOUNT,Start(2),BITS,JOINCODE] : JOINCODE=Param
  37.    Print "Saving data..."
  38.    Ssave 2,Start(2) To Start(2)+(AMOUNT/8)*BITS
  39. Until AMOUNT<BUFFER
  40. Close 1 : Close 2
  41. '
  42. Procedure ADPACK[STRT,SIZE,DEST,BITS,JOIN]
  43.    Areg(0)=STRT : Dreg(0)=SIZE
  44.    Areg(1)=DEST : Dreg(1)=JOIN
  45.    '
  46.    If BITS=2
  47.       Proc ADCOMP2 : JC=Dreg(0)
  48.    Else If BITS=3
  49.       Proc ADCOMP3 : JC=Dreg(0)
  50.    End If 
  51. End Proc[JC]
  52. '
  53. Procedure LODE[AMOUNT]
  54.    POS=Lof(1)-Pof(1)
  55.    If POS>=AMOUNT
  56.       Sload 1 To Start(1),AMOUNT
  57.    Else 
  58.       Sload 1 To Start(1),POS
  59.       AMOUNT=POS
  60.    End If 
  61. End Proc[AMOUNT]
  62. Procedure HEADER[BITS,SAMPLRATE]
  63. If BITS=2
  64. Poke$ Start(2),"ADPCM2"
  65. Else If BITS=3
  66. Poke$ Start(2),"ADPCM3"
  67. Else 
  68. Print "2 or 3 bits only...bye!" : End 
  69. End If 
  70. '
  71. Loke Start(2)+6,SAMPLRATE
  72. '
  73. Ssave 2,Start(2) To Start(2)+10
  74. End Proc
  75. '
  76. Procedure ADCOMP2
  77.    ' COMPILED PROCEDURE -- can't convert this to AMOS code
  78. End Proc
  79. Procedure ADCOMP3
  80.    ' COMPILED PROCEDURE -- can't convert this to AMOS code
  81. End Proc