Package davaguine.jmac.tools

Examples of davaguine.jmac.tools.RandomAccessFile


     * @throws UnsupportedAudioFileException - if the File does not point to valid MAC audio file
     * @throws IOException                   - if an I/O exception occurs
     */
    public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
        IAPEDecompress decoder = null;
        davaguine.jmac.tools.File io = new RandomAccessFile(file, "r");
        try {
            decoder = IAPEDecompress.CreateIAPEDecompress(io);
        } catch (JMACException e) {
            throw new UnsupportedAudioFileException("Unsupported audio file");
        } catch (EOFException e) {
            throw new UnsupportedAudioFileException("Unsupported audio file");
        } finally {
            io.close();
        }

        Map fileProperties = new HashMap();
        Map formatProperties = new HashMap();
        APEPropertiesHelper.readProperties(decoder, fileProperties, formatProperties);
View Full Code Here


    public APEInfo(java.io.File file) throws IOException {
        this(file, null);
    }

    public APEInfo(java.io.File file, APETag pTag) throws IOException {
        this(new RandomAccessFile(file, "r"), pTag);
    }
View Full Code Here

        m_nStartBlock = 0;
        m_nFinishBlock = 0;
        m_cImageFilename = "";

        // open the file
        File ioLinkFile = new RandomAccessFile(new java.io.File(pFilename), "r");
        // create a buffer
        byte[] spBuffer = new byte[1024];

        // fill the buffer from the file and null terminate it
        int numRead = ioLinkFile.read(spBuffer);

        byte[] buffer = new byte[numRead];
        System.arraycopy(spBuffer, 0, buffer, 0, numRead);

        // call the other constructor (uses a buffer instead of opening the file)
View Full Code Here

        ID3Tag.setDefaultEncoding("windows-1251");
    }

    public boolean readAPEv2Tag(Track track) throws IOException {
      TrackData trackData = track.getTrackData();
        RandomAccessFile ras = null;
        try {
            ras = new RandomAccessFile(trackData.getFile(), "r");
            APETag tag = new APETag(ras, true);
            if (tag.GetHasAPETag() || tag.GetHasID3Tag()) {
              setMusiqueTagFieldValue(tag, trackData, FieldKey.ARTIST, APETag.APE_TAG_FIELD_ARTIST);
              setMusiqueTagFieldValue(tag, trackData, FieldKey.ALBUM, APETag.APE_TAG_FIELD_ALBUM);
              setMusiqueTagFieldValue(tag, trackData, FieldKey.TITLE, APETag.APE_TAG_FIELD_TITLE);
              setMusiqueTagFieldValue(tag, trackData, FieldKey.YEAR, APETag.APE_TAG_FIELD_YEAR);
              setMusiqueTagFieldValue(tag, trackData, FieldKey.GENRE, APETag.APE_TAG_FIELD_GENRE);
              setMusiqueTagFieldValue(tag, trackData, FieldKey.COMMENT, APETag.APE_TAG_FIELD_COMMENT);
              setMusiqueTagFieldValue(tag, trackData, FieldKey.ALBUM_ARTIST, "album artist");
              handleTrackDiscFields(tag, trackData);

              setCustomMusiqueTagFieldValue(tag, trackData, FieldKey.RECORD_LABEL);
              setCustomMusiqueTagFieldValue(tag, trackData, FieldKey.CATALOG_NO);
              setCustomMusiqueTagFieldValue(tag, trackData, FieldKey.RATING);

              trackData.setCueSheet(tag.GetFieldString("CUESHEET"));
                if (tag.GetHasAPETag())
                    return tag.GetHasAPETag();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (ras != null)
                ras.close();
        }
        return false;
    }
View Full Code Here

        return false;
    }

    public void writeAPEv2Tag(Track track) throws IOException {
      TrackData trackData = track.getTrackData();
        RandomAccessFile ras = null;
        try {
            ras = new RandomAccessFile(trackData.getFile(), "rw");
            APETag tag = new APETag(ras, true);

            setApeTagFieldValue(tag, trackData, FieldKey.ARTIST, APETag.APE_TAG_FIELD_ARTIST);
            setApeTagFieldValue(tag, trackData, FieldKey.ALBUM, APETag.APE_TAG_FIELD_ALBUM);
            setApeTagFieldValue(tag, trackData, FieldKey.TITLE, APETag.APE_TAG_FIELD_TITLE);
            setApeTagFieldValue(tag, trackData, FieldKey.YEAR, APETag.APE_TAG_FIELD_YEAR);
            setApeTagFieldValue(tag, trackData, FieldKey.GENRE, APETag.APE_TAG_FIELD_GENRE);
            setApeTagFieldValue(tag, trackData, FieldKey.COMMENT, APETag.APE_TAG_FIELD_COMMENT);
            setApeTagFieldValue(tag, trackData, FieldKey.TRACK, APETag.APE_TAG_FIELD_TRACK);
            setApeTagFieldValue(tag, trackData, FieldKey.ALBUM_ARTIST, "Album Artist");

            setCustomApeTagFieldValue(tag, trackData, FieldKey.DISC_NO);
            setCustomApeTagFieldValue(tag, trackData, FieldKey.TRACK_TOTAL);
            setCustomApeTagFieldValue(tag, trackData, FieldKey.DISC_TOTAL);
            setCustomApeTagFieldValue(tag, trackData, FieldKey.RECORD_LABEL);
            setCustomApeTagFieldValue(tag, trackData, FieldKey.CATALOG_NO);
            setCustomApeTagFieldValue(tag, trackData, FieldKey.RATING);

            // TODO review this hardcoded const
            tag.SetFieldString("CUESHEET", trackData.getCueSheet());

            tag.Save();
       
        track.getTrackData().removeEmptyTagFields();
        } finally {
            if (ras != null)
                ras.close();
        }
    }
View Full Code Here

            fillWaveFormat(format, fmt);
            int level = CompressionLevel.COMPRESSION_LEVEL_NORMAL;
            if (options != null) {
                level = options.getInt("encoder.ape.level", level);
            }
            encoder.StartEx(new RandomAccessFile(outputFile, "rw"),
                    format, IAPECompress.MAX_AUDIO_BYTES_UNKNOWN,
                    level);
            available = 0;
            return true;
        } catch (IOException e) {
View Full Code Here

    private APETagProcessor tagProcessor = new APETagProcessor();

    public Track readSingle(Track track) {
        try {
            ID3Tag.setDefaultEncoding(defaultCharset.name());
            RandomAccessFile ras = new RandomAccessFile(track.getTrackData().getFile(), "r");
            APEHeader header = new APEHeader(ras);
            APEFileInfo fileInfo = new APEFileInfo();
            header.Analyze(fileInfo);
            parseInfo(track, fileInfo);

            tagProcessor.readAPEv2Tag(track);
            ras.close();
            return track;
        } catch (Exception e) {
            System.out.println("Couldn't read file: " + track.getTrackData().getFile());
        }
        return null;
View Full Code Here

TOP

Related Classes of davaguine.jmac.tools.RandomAccessFile

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.