Package davaguine.jmac.tools

Examples of davaguine.jmac.tools.ByteArrayReader


    public final static int APE_DESCRIPTOR_BYTES = 52;

    public static APEDescriptor read(final File file) throws IOException {
        try {
            APEDescriptor header = new APEDescriptor();
            final ByteArrayReader reader = new ByteArrayReader(file, APE_DESCRIPTOR_BYTES - 16);
            header.cID = reader.readString(4, "US-ASCII");
            header.nVersion = reader.readUnsignedShort();
            reader.skipBytes(2);
            header.nDescriptorBytes = reader.readUnsignedInt();
            header.nHeaderBytes = reader.readUnsignedInt();
            header.nSeekTableBytes = reader.readUnsignedInt();
            header.nHeaderDataBytes = reader.readUnsignedInt();
            header.nAPEFrameDataBytes = reader.readUnsignedInt();
            header.nAPEFrameDataBytesHigh = reader.readUnsignedInt();
            header.nTerminatingDataBytes = reader.readUnsignedInt();
            file.readFully(header.cFileMD5);
            return header;
        } catch (EOFException e) {
            throw new JMACException("Unsupported Format");
        }
View Full Code Here


        if (pInfo.nJunkHeaderBytes < 0)
            throw new JMACException("Unsupported Format");

        // read the first 8 bytes of the descriptor (ID and version)
        m_pIO.mark(10);
        final ByteArrayReader reader = new ByteArrayReader(m_pIO, 8);
        if (!reader.readString(4, "US-ASCII").equals("MAC "))
            throw new JMACException("Unsupported Format");

        int version = reader.readUnsignedShort();

        m_pIO.reset();

        if (version >= 3980) {
            // current header format
View Full Code Here

            // figure the extra header bytes
            m_pIO.mark(1000);

            // skip an ID3v2 tag (which we really don't support anyway...)
            ByteArrayReader reader = new ByteArrayReader(10);
            reader.reset(m_pIO, 10);
            final String tag = reader.readString(3, "US-ASCII");
            if (tag.equals("ID3")) {
                // why is it so hard to figure the lenght of an ID3v2 tag ?!?
                reader.readByte();
                reader.readByte();
                int byte5 = reader.readUnsignedByte();

                int nSyncSafeLength;
                nSyncSafeLength = (reader.readUnsignedByte() & 127) << 21;
                nSyncSafeLength += (reader.readUnsignedByte() & 127) << 14;
                nSyncSafeLength += (reader.readUnsignedByte() & 127) << 7;
                nSyncSafeLength += (reader.readUnsignedByte() & 127);

                boolean bHasTagFooter = false;

                if ((byte5 & 16) > 0) {
                    bHasTagFooter = true;
View Full Code Here

    public final static int APE_HEADER_BYTES = 24;

    public static APEHeaderNew read(final File file) throws IOException {
        try {
            APEHeaderNew header = new APEHeaderNew();
            final ByteArrayReader reader = new ByteArrayReader(file, APE_HEADER_BYTES);
            header.nCompressionLevel = reader.readUnsignedShort();
            header.nFormatFlags = reader.readUnsignedShort();
            header.nBlocksPerFrame = reader.readUnsignedInt();
            header.nFinalFrameBlocks = reader.readUnsignedInt();
            header.nTotalFrames = reader.readUnsignedInt();
            header.nBitsPerSample = reader.readUnsignedShort();
            header.nChannels = reader.readUnsignedShort();
            header.nSampleRate = reader.readUnsignedInt();
            return header;
        } catch (EOFException e) {
            throw new JMACException("Unsupported Format");
        }
    }
View Full Code Here

        if (pos < 0)
            return null;
        file.seek(pos);
        APETagFooter tag = new APETagFooter();
        try {
            final ByteArrayReader reader = new ByteArrayReader(file, APE_TAG_FOOTER_BYTES);
            tag.m_cID = reader.readString(8, "US-ASCII");
            tag.m_nVersion = reader.readInt();
            tag.m_nSize = reader.readInt();
            tag.m_nFields = reader.readInt();
            tag.m_nFlags = reader.readInt();
            return tag;
        } catch (EOFException e) {
            throw new JMACException("Unsupported Format");
        }
    }
View Full Code Here

        pWaveFormatEx.nBlockAlign = (short) ((pWaveFormatEx.wBitsPerSample / 8) * pWaveFormatEx.nChannels);
        pWaveFormatEx.nAvgBytesPerSec = pWaveFormatEx.nBlockAlign * pWaveFormatEx.nSamplesPerSec;
    }

    public void readHeader(File io) throws IOException {
        ByteArrayReader reader = new ByteArrayReader(io, WAV_HEADER_SIZE);
        wFormatTag = reader.readShort();
        nChannels = reader.readShort();
        nSamplesPerSec = reader.readInt();
        nAvgBytesPerSec = reader.readInt();
        nBlockAlign = reader.readShort();
        wBitsPerSample = reader.readShort();
    }
View Full Code Here

    public long nChunkBytes;        // the bytes of the chunk

    private final static int RIFF_CHUNK_HEADER_SIZE = 8;

    public void read(File io) throws IOException {
        ByteArrayReader reader = new ByteArrayReader(io, RIFF_CHUNK_HEADER_SIZE);
        cChunkLabel = reader.readInt();
        nChunkBytes = reader.readUnsignedInt();
    }
View Full Code Here

        pWAVHeader.nDataBytes = nAudioBytes;
    }

    public final static WaveHeader read(final File file) throws IOException {
        try {
            final ByteArrayReader reader = new ByteArrayReader(file, WAVE_HEADER_BYTES);
            return read(reader);
        } catch (EOFException e) {
            return null;
        }
    }
View Full Code Here

            return null;
        }
    }

    public final static WaveHeader read(final byte[] data) {
        final ByteArrayReader reader = new ByteArrayReader(data);
        return read(reader);
    }
View Full Code Here

        //move the remaining data to the front
        System.arraycopy(al = m_pBitArray, j = (int) nBitArrayIndex, al, 0, (int) (al.length - nBitArrayIndex));

        //read the new data
        ByteArrayReader reader = m_pReader;
        reader.reset(m_pIO, j << 2);
        long l1;
        int i = (int) ((l1 = m_nElements) - nBitArrayIndex);
        if ((long) i < l1)
            do {
                al[i] = reader.readUnsignedInt();
                i++;
            } while ((long) i < l1);

        //adjust the m_Bit pointer
        m_nCurrentBitIndex &= 31;
View Full Code Here

TOP

Related Classes of davaguine.jmac.tools.ByteArrayReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.