Guidance
指路人
g.yi.org
software / rapidq / Examples / Audio & Video / akrip32 / akrip32.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
     $TYPECHECK ON

     $DEFINE BOOL INTEGER
     CONST TRUE = 1
     CONST FALSE = 0

     DECLARE FUNCTION AKRIP_GetCDList LIB "akrip32.dll" ALIAS "GetCDList" _
      (cdlist AS LONG) AS INTEGER

     DECLARE FUNCTION AKRIP_GetCdHandle LIB "akrip32.dll" ALIAS "GetCDHandle" _
      (cdh AS LONG) AS LONG

     DECLARE FUNCTION AKRIP_ModifyCDParms LIB "akrip32.dll" ALIAS "ModifyCDParms" _
      (hCD AS LONG, which AS INTEGER, value AS DWORD) AS LONG

     DECLARE FUNCTION AKRIP_ReadTOC LIB "akrip32.dll" ALIAS "ReadTOC" _
      (hCD AS LONG, lpTOC AS LONG) AS DWORD

     DECLARE FUNCTION AKRIP_ReadCDAudioLBA LIB "akrip32.dll" ALIAS "ReadCDAudioLBA"_
      (hCD AS LONG, trackbuf AS LONG) AS LONG


     DECLARE FUNCTION AKRIPQ_Callback AS LONG
     DIM AKRIPQ_Fptr AS LONG
     BIND AKRIPQ_Fptr TO AKRIPQ_Callback


     CONST  MAXIDLEN =  64
     CONST  AKRIP_MAXCDLIST = 8

     CONST CDR_ANY        AS BYTE =   &h00       ' unknown
     CONST CDR_ATAPI1     AS BYTE =   &h01       ' ATAPI per spec
     CONST CDR_ATAPI2     AS BYTE =   &h02       ' alternate ATAPI
     CONST CDR_READ6      AS BYTE =   &h03       ' using SCSI READ(6)
     CONST CDR_READ10     AS BYTE =   &h04       ' using SCSI READ(10)
     CONST CDR_READ_D8    AS BYTE =   &h05       ' using command &hD8 (Plextor?)
     CONST CDR_READ_D4    AS BYTE =   &h06       ' using command &hD4 (NEC?)
     CONST CDR_READ_D4_1  AS BYTE =   &h07       ' &hD4 with a mode select
     CONST CDR_READ10_2   AS BYTE =   &h08       ' different mode select w/ READ(10)

     CONST CDP_READCDR      = &H0001     ' can read CD-R
     CONST CDP_READCDE      = &H0002     ' can read CD-E
     CONST CDP_METHOD2      = &H0003     ' can read CD-R wriiten via method 2
     CONST CDP_WRITECDR     = &H0004     ' can write CD-R
     CONST CDP_WRITECDE     = &H0005     ' can write CD-E
     CONST CDP_AUDIOPLAY    = &H0006     ' can play audio
     CONST CDP_COMPOSITE    = &H0007     ' composite audio/video stream
     CONST CDP_DIGITAL1     = &H0008     ' digital output (IEC958) on port 1
     CONST CDP_DIGITAL2     = &H0009     ' digital output (IEC958) on port 2
     CONST CDP_M2FORM1      = &H000A     ' reads Mode 2 Form 1 (XA) format
     CONST CDP_M2FORM2      = &H000B     ' reads Mode 2 Form 2 format
     CONST CDP_MULTISES     = &H000C     ' reads multi-session or Photo-CD
     CONST CDP_CDDA         = &H000D     ' supports cd-da
     CONST CDP_STREAMACC    = &H000E     ' supports "stream is accurate"
     CONST CDP_RW           = &H000F     ' can return R-W info
     CONST CDP_RWCORR       = &H0010     ' returns R-W de-interleaved and err.
                                    ' corrected
     CONST CDP_C2SUPP       = &H0011     ' C2 error pointers
     CONST CDP_ISRC         = &H0012     ' can return the ISRC info
     CONST CDP_UPC          = &H0013     ' can return the Media Catalog Number
     CONST CDP_CANLOCK      = &H0014     ' prevent/allow cmd. can lock the media
     CONST CDP_LOCKED       = &H0015     ' current lock state (TRUE = LOCKED)
     CONST CDP_PREVJUMP     = &H0016     ' prevent/allow jumper state
     CONST CDP_CANEJECT     = &H0017     ' drive can eject disk
     CONST CDP_MECHTYPE     = &H0018     ' type of disk loading supported
     CONST CDP_SEPVOL       = &H0019     ' independent audio level for channels
     CONST CDP_SEPMUTE      = &H001A     ' independent mute for channels
     CONST CDP_SDP          = &H001B     ' supports disk present (SDP)
     CONST CDP_SSS          = &H001C     ' Software Slot Selection
     CONST CDP_MAXSPEED     = &H001D     ' maximum supported speed of drive
     CONST CDP_NUMVOL       = &H001E     ' number of volume levels
     CONST CDP_BUFSIZE      = &H001F     ' size of output buffer
     CONST CDP_CURRSPEED    = &H0020     ' current speed of drive
     CONST CDP_SPM          = &H0021     ' "S" units per "M" (MSF format)
     CONST CDP_FPS          = &H0022     ' "F" units per "S" (MSF format)
     CONST CDP_INACTMULT    = &H0023     ' inactivity multiplier ( x 125 ms)
     CONST CDP_MSF          = &H0024     ' use MSF format for READ TOC cmd
     CONST CDP_OVERLAP      = &H0025     ' number of overlap frames for jitter
     CONST CDP_JITTER       = &H0026     ' number of frames to check for jitter
     CONST CDP_READMODE     = &H0027     ' mode to attempt jitter corr.


     TYPE AKRIPQ_CDREC
      ha AS BYTE
      tgt AS BYTE
      lun AS BYTE
      pad AS BYTE
      id AS STRING*65
      vendor AS STRING*9
      prodID AS STRING*17
      rev AS STRING*5
      vendspec AS STRING*21
     END TYPE


     TYPE AKRIP_GETCDHAND
      size AS BYTE
      ver AS BYTE
      ha AS BYTE
      tgt AS BYTE
      lun AS BYTE
      readtype AS BYTE
      jitterCorr AS BOOL
      numJitter AS BYTE
      numOverlap AS BYTE
     END TYPE

     TYPE AKRIPQ_TOCINFO
      TocLen AS WORD
      FirstTrack AS BYTE
      LastTrack AS BYTE
     END TYPE

     TYPE AKRIPQ_TrackInfo
      rsvd AS BYTE
      ADR AS BYTE
      tracknumber AS BYTE
      rsvd2 AS BYTE
      addr0 AS BYTE
      addr1 AS BYTE
      addr2 AS BYTE
      addr3 AS BYTE
     END TYPE


     TYPE AKRIP_TrackBuf
      startframe AS INTEGER
      numframes AS INTEGER
      maxlen AS INTEGER
      length AS INTEGER
      status AS INTEGER
      startoffset AS INTEGER
     END TYPE


' These are "global" Qmemorystreams.

     DIM AKRIPQ_CDListMS AS QMEMORYSTREAM
     DIM AKRIPQ_TOC_Ms AS QMEMORYSTREAM
     DIM AKRIPQ_TrackBuf_MS AS QMEMORYSTREAM


' These one can be used inside the AKRIPQ_CALLBACK Function

     DIM AKRIPQ_PercentageDone AS SINGLE
     DIM AKRIPQ_FramesTotal AS INTEGER
     DIM AKRIPQ_FramesDone AS INTEGER
     DIM AKRIPQ_FramesLeft AS INTEGER

'______________________________________________________________________________

' The following function reads looks for CD drives (max 8 drives) and stores
' info about the drives in the AKRIPQ_CDListMS Qmemorystream. If everything
' is OK, the function will return the number of drives found.
' You can change the number of maximum drives changing the AKRIP_MAXCDLIST
' constant


     FUNCTION AKRIPQ_GetCdList AS LONG
      DIM bufsize AS INTEGER
      DIM temp AS BYTE
      bufsize = 2 + (121 * AKRIP_MAXCDLIST)
      AKRIPQ_CDListMS.position = 0
      AKRIPQ_CDListMS.writestr(SPACE$(bufsize), bufsize)
      AKRIPQ_CDListMS.position = 0
      AKRIPQ_CDListMS.writenum (AKRIP_MAXCDLIST, 1)
      AKRIPQ_CDListMS.position = 0
      AKRIP_GetCDList(AKRIPQ_CDListMS.pointer)
      AKRIPQ_CDListMS.position = 1
      temp = AKRIPQ_CDListMS.readnum(1)
      AKRIPQ_CDListMS.position = 0
      result = temp
     END FUNCTION


'______________________________________________________________________________

' This one reads CD-DRIVE data and stores in a AKRIPQ_CDREC structure. The
' CD-drive is identified by a zero-based ID (i.e. the first drive will have
' ID=0, the second ID=1  etc...)

     FUNCTION AKRIPQ_GetCdInfo (id AS INTEGER, rec AS AKRIPQ_CDREC) AS LONG
      AKRIPQ_CDListMS.position = 2 + (id * 121)
      AKRIPQ_CDListMS.readUDT(rec)
     END FUNCTION




'______________________________________________________________________________

' You can't do almost anything if you don't have a CD-Handle. Function success
' will return 1.

     FUNCTION AKRIPQ_GetCdHandle (DriveID AS INTEGER) AS LONG
      DIM cdh AS AKRIP_GETCDHAND
      DIM cd AS AKRIPQ_CDREC
      AKRIPQ_GetCdInfo (DriveID, cd)

      cdh.ver = 1
      cdh.ha = cd.ha
      cdh.tgt = cd.tgt
      cdh.lun = cd.lun
      cdh.readtype = CDR_ANY
      cdh.size = SIZEOF(cdh)

      DIM cdhMS AS QMEMORYSTREAM
      cdhMS.writestr(STRING$(cdh.size, 0), cdh.size)
      cdhMS.position = 0
      cdhMS.writeUDT(cdh)

      result = AKRIP_GetCdHandle(cdhMS.pointer)
     END FUNCTION

' ______________________________________________________________________________

     FUNCTION AKRIPQ_ReadToc (hCd AS LONG, TocInfo AS AKRIPQ_TOCINFO ) AS LONG
      AKRIPQ_TOC_Ms.position = 0
      AKRIPQ_TOC_Ms.writestr(STRING$(806, 0), 806)
      AKRIPQ_TOC_Ms.position = 0
      AKRIP_ReadTOC(hCd, AKRIPQ_TOC_Ms.pointer)
      AKRIPQ_TOC_Ms.position = 0
      AKRIPQ_TOC_Ms.ReadUDT(TocInfo)

     END FUNCTION

'______________________________________________________________________________

' Stores track information in the AKRIPQ_TrackInfo structure

     FUNCTION AKRIPQ_GetTrackInfo _
       (trNumber AS INTEGER, trackinfo AS AKRIPQ_TrackInfo) AS LONG

      AKRIPQ_TOC_Ms.position = 4 + ((trNumber - 1) * 8)
      AKRIPQ_TOC_Ms.ReadUDT(trackinfo)
     END FUNCTION

'______________________________________________________________________________

     FUNCTION AKRIPQ_GetLBA (trNumber AS INTEGER) AS LONG

      DIM temp AS LONG
      DIM ti AS AKRIPQ_TrackInfo
      AKRIPQ_GetTrackinfo(trNumber, ti)
      temp =  (ti.addr3) + (ti.addr2 * 256) + _
       (ti.addr1 * 65536) + (ti.addr0 * 16777216)

      result = temp
     END FUNCTION

'______________________________________________________________________________

     SUB WriteWavHeader (Stream AS QFILESTREAM, length AS INTEGER)
      Stream.WriteStr("RIFF", 4)
      Stream.WriteNum((length + 44 - 8), 4)
      Stream.WriteStr("WAVEfmt ", 8)
      Stream.WriteNum(16, 4)
      Stream.WriteNum(1, 2)
      Stream.WriteNum(2, 2)
      Stream.WriteNum(44100, 4)
      Stream.WriteNum(176400, 4)
      Stream.WriteNum(4,2)
      Stream.WriteNum(16,2)
      Stream.WriteStr("data", 4)
      Stream.WriteNum(length, 4)
     END SUB

' ______________________________________________________________________________

' This function saves track n° <trNumber> of the selected CD to the <filename>
' file. For each reading cycle, the function will execute the AKRIPQ_Callback
' function, which you can write in your code.

     FUNCTION AKRIPQ_Savetrack ( hCD AS LONG, _
       trNumber AS INTEGER, _
       filename AS STRING) AS LONG



      AKRIPQ_FramesTotal = AKRIPQ_GETLBA(trNumber + 1) - AKRIPQ_GETLBA(trNumber)


      DIM tbd AS AKRIP_Trackbuf
      tbd.startframe = AKRIPQ_GetLBA(trNumber)
      tbd.numframes = 26
      tbd.maxlen= tbd.numframes * 2352
      tbd.length = 0
      tbd.status = 0
      tbd.startoffset = 0

      DIM TBSize AS INTEGER
      TBSize =  tbd.maxlen + 24



      AKRIPQ_FramesLeft = AKRIPQ_GETLBA(trNumber + 1) - tbd.startframe

      DIM temp AS QFILESTREAM
      IF temp.OPEN (filename, 65535) = 0  THEN EXIT FUNCTION
      WriteWavHeader(temp, (AKRIPQ_FramesTotal * 2352))

      DO
       IF tbd.numframes > AKRIPQ_FramesLeft THEN
        tbd.numframes = AKRIPQ_FramesLeft
        tbd.maxlen= tbd.numframes * 2352
        TBSize =  tbd.maxlen + 24
       END IF



       tbd.status = 0
       tbd.startoffset =  0
       tbd.length = 0

       AKRIPQ_TrackBuf_MS.position = 0
       AKRIPQ_TrackBuf_MS.writestr(SPACE$(TBSize), TBSize)
       AKRIPQ_TrackBuf_MS.position = 0
       AKRIPQ_TrackBuf_MS.WriteUDT(tbd)
       AKRIPQ_TrackBuf_MS.position = 0
       AKRIP_ReadCDAudioLBA(hCd, AKRIPQ_TrackBuf_MS.pointer)
       AKRIPQ_TrackBuf_MS.position = 24
       temp.copyfrom (AKRIPQ_TrackBuf_MS, TBSize - 24)

       tbd.startframe = tbd.startframe + tbd.numframes
       AKRIPQ_FramesLeft = AKRIPQ_FramesLeft - tbd.numframes
       AKRIPQ_FramesDone = AKRIPQ_FramesDone + tbd.numframes

       AKRIPQ_PercentageDone = (AKRIPQ_FramesDone / AKRIPQ_FramesTotal) * 100
       CALLFUNC AKRIPQ_Fptr
      LOOP UNTIL AKRIPQ_FramesLeft <= 0

      temp.CLOSE
      AKRIPQ_TrackBuf_MS.CLOSE
     END FUNCTION
掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:42:31