Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- from http://wiki.multimedia.cx/index.php?title=CRI_ADX_file
- ADX format
- --------------------------------------
- BYTE - usigned 1 byte
- SHORT- unsigned 2 bytes
- DWORD- unsigned 4 bytes
- format is Big Endian
- --------------------------------------
- SHORT - 0x000, header
- SHORT - data offset // In between the header and the audio data there is useless padding. Immediately before the audio data, the last 6 bytes of padding is the signature "(c)CRI" in ASCII.
- BYTE - format, must be 3 for ADX
- BYTE - block size (typically 18)
- BYTE - bits per sample? (4)
- BYTE - channel count, usually 1 or 2
- DWORD - sampling rate (Hz)
- DWORD - sample count
- SHORT - high-pass cutoff
- BYTE - loop data type (03, 04, or 05)
- BYTE - encryption flag (other flags?)
- if "loop data" = 03:
- DWORD - unknown
- DWORD - loop flag
- DWORD - loop start sample
- DWORD - loop start byte
- DWORD - loop end sample
- DWORD - loop end byte
- if "loop data" = 04:
- BYTE[16] - unknown // It is possible that the extra 16 bytes for type 04 are involved in setting the initial decoder history; they are nonzero in the second segments of some AIXs (which may need some way to match up the history from one segment to another).
- DWORD - loop flag
- DWORD - loop start sample
- DWORD - loop start byte
- DWORD - loop end sample
- DWORD - loop end byte
- # other loop types are unknown
- '''
- import struct
- import sys
- try:
- filename = sys.argv[1]
- except:
- filename = 'ay_getready.adx'
- file = open(filename, 'rb')
- header = hex(struct.unpack('>H', file.read(2))[0])
- print 'header:', header
- dataoffset = struct.unpack('>H', file.read(2))[0]
- print 'data offset:', dataoffset
- format = struct.unpack('>B', file.read(1))[0]
- print 'format:', format
- blocksize = struct.unpack('>B', file.read(1))[0]
- print 'block size:', blocksize
- bitspersample = struct.unpack('>B', file.read(1))[0]
- print 'bits per sample:', bitspersample
- channelcount = struct.unpack('>B', file.read(1))[0]
- print 'channel count:', channelcount
- samplingrate = struct.unpack('>I', file.read(4))[0]
- print 'sampling rate:', samplingrate, 'Hz'
- samplecount = struct.unpack('>I', file.read(4))[0]
- print 'sample count:', samplecount
- highpasscutoff = struct.unpack('>H', file.read(2))[0]
- print 'high pass cutoff:', highpasscutoff
- loopdatatype = struct.unpack('>B', file.read(1))[0]
- print 'loop data type:', loopdatatype
- if loopdatatype == 3:
- unknown = file.read(4)
- elif loopdatatype == 4:
- unknown = file.read(16)
- else:
- print 'unknown loop data type'
- loopflag = struct.unpack('>I', file.read(4))[0]
- print 'loop flag:', loopflag
- loopstartsample = struct.unpack('>I', file.read(4))[0]
- print 'loop start sample:', loopstartsample
- loopstartbyte = struct.unpack('>I', file.read(4))[0]
- print 'loop start byte:', loopstartbyte
- loopendsample = struct.unpack('>I', file.read(4))[0]
- print 'loop end sample:', loopendsample
- loopendbyte = struct.unpack('>I', file.read(4))[0]
- print 'loop end byte:', loopendbyte
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement