$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
CONST CDR_ATAPI1 AS BYTE = &h01
CONST CDR_ATAPI2 AS BYTE = &h02
CONST CDR_READ6 AS BYTE = &h03
CONST CDR_READ10 AS BYTE = &h04
CONST CDR_READ_D8 AS BYTE = &h05
CONST CDR_READ_D4 AS BYTE = &h06
CONST CDR_READ_D4_1 AS BYTE = &h07
CONST CDR_READ10_2 AS BYTE = &h08
CONST CDP_READCDR = &H0001
CONST CDP_READCDE = &H0002
CONST CDP_METHOD2 = &H0003
CONST CDP_WRITECDR = &H0004
CONST CDP_WRITECDE = &H0005
CONST CDP_AUDIOPLAY = &H0006
CONST CDP_COMPOSITE = &H0007
CONST CDP_DIGITAL1 = &H0008
CONST CDP_DIGITAL2 = &H0009
CONST CDP_M2FORM1 = &H000A
CONST CDP_M2FORM2 = &H000B
CONST CDP_MULTISES = &H000C
CONST CDP_CDDA = &H000D
CONST CDP_STREAMACC = &H000E
CONST CDP_RW = &H000F
CONST CDP_RWCORR = &H0010
CONST CDP_C2SUPP = &H0011
CONST CDP_ISRC = &H0012
CONST CDP_UPC = &H0013
CONST CDP_CANLOCK = &H0014
CONST CDP_LOCKED = &H0015
CONST CDP_PREVJUMP = &H0016
CONST CDP_CANEJECT = &H0017
CONST CDP_MECHTYPE = &H0018
CONST CDP_SEPVOL = &H0019
CONST CDP_SEPMUTE = &H001A
CONST CDP_SDP = &H001B
CONST CDP_SSS = &H001C
CONST CDP_MAXSPEED = &H001D
CONST CDP_NUMVOL = &H001E
CONST CDP_BUFSIZE = &H001F
CONST CDP_CURRSPEED = &H0020
CONST CDP_SPM = &H0021
CONST CDP_FPS = &H0022
CONST CDP_INACTMULT = &H0023
CONST CDP_MSF = &H0024
CONST CDP_OVERLAP = &H0025
CONST CDP_JITTER = &H0026
CONST CDP_READMODE = &H0027
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
DIM AKRIPQ_CDListMS AS QMEMORYSTREAM
DIM AKRIPQ_TOC_Ms AS QMEMORYSTREAM
DIM AKRIPQ_TrackBuf_MS AS QMEMORYSTREAM
DIM AKRIPQ_PercentageDone AS SINGLE
DIM AKRIPQ_FramesTotal AS INTEGER
DIM AKRIPQ_FramesDone AS INTEGER
DIM AKRIPQ_FramesLeft AS INTEGER
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
FUNCTION AKRIPQ_GetCdInfo (id AS INTEGER, rec AS AKRIPQ_CDREC) AS LONG
AKRIPQ_CDListMS.position = 2 + (id * 121)
AKRIPQ_CDListMS.readUDT(rec)
END FUNCTION
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
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
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
|