code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
private void setOriginal() { isOriginal = (mpegBytes[BYTE_4] & MASK_MP3_HOME) != 0; }
Sets the original attribute of the MPEGFrame object
MPEGFrameHeader::setOriginal
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setProtected() { isProtected = (mpegBytes[BYTE_2] & MASK_MP3_PROTECTION) == 0x00; }
Sets the protected attribute of the MPEGFrame object
MPEGFrameHeader::setProtected
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setPrivate() { isPrivate = (mpegBytes[BYTE_3] & MASK_MP3_PRIVACY) != 0; }
Sets the private attribute of the MPEGFrame object
MPEGFrameHeader::setPrivate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setBitrate() throws InvalidAudioFrameException { /* BitRate, get by checking header setBitrate bits and MPEG Version and Layer */ int bitRateIndex = mpegBytes[BYTE_3] & MASK_MP3_BITRATE | mpegBytes[BYTE_2] & MASK_MP3_ID | mpegBytes[BYTE_2] & MASK_MP3_LAYER; bitRate = bitrateMap.get(bitRateIndex); if (bitRate == null) { throw new InvalidAudioFrameException("Invalid bitrate"); } }
Get the setBitrate of this frame @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MPEGFrameHeader::setBitrate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setChannelMode() throws InvalidAudioFrameException { channelMode = (mpegBytes[BYTE_4] & MASK_MP3_MODE) >>> 6; channelModeAsString = modeMap.get(channelMode); if (channelModeAsString == null) { throw new InvalidAudioFrameException("Invalid channel mode"); } }
Set the Mpeg channel mode of this frame as a constant (see constants) @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MPEGFrameHeader::setChannelMode
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setEmphasis() throws InvalidAudioFrameException { emphasis = mpegBytes[BYTE_4] & MASK_MP3_EMPHASIS; emphasisAsString = emphasisMap.get(emphasis); if (getEmphasisAsString() == null) { throw new InvalidAudioFrameException("Invalid emphasis"); } }
Get the setEmphasis mode of this frame in a string representation @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MPEGFrameHeader::setEmphasis
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setPadding() { isPadding = (mpegBytes[BYTE_3] & MASK_MP3_PADDING) != 0; }
Set whether this frame uses padding bytes
MPEGFrameHeader::setPadding
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setLayer() throws InvalidAudioFrameException { layer = (mpegBytes[BYTE_2] & MASK_MP3_LAYER) >>> 1; layerAsString = mpegLayerMap.get(layer); if (layerAsString == null) { throw new InvalidAudioFrameException("Invalid Layer"); } }
Get the layer version of this frame as a constant int value (see constants) @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MPEGFrameHeader::setLayer
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setModeExtension() throws InvalidAudioFrameException { int index = (mpegBytes[BYTE_4] & MASK_MP3_MODE_EXTENSION) >> 4; if (layer == LAYER_III) { modeExtension = modeExtensionLayerIIIMap.get(index); if (getModeExtension() == null) { throw new InvalidAudioFrameException("Invalid Mode Extension"); } } else { modeExtension = modeExtensionMap.get(index); if (getModeExtension() == null) { throw new InvalidAudioFrameException("Invalid Mode Extension"); } } }
Sets the string representation of the mode extension of this frame @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MPEGFrameHeader::setModeExtension
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private void setSamplingRate() throws InvalidAudioFrameException { //Frequency int index = (mpegBytes[BYTE_3] & MASK_MP3_FREQUENCY) >>> 2; Map<Integer, Integer> samplingRateMapForVersion = samplingRateMap.get(version); if (samplingRateMapForVersion == null) { throw new InvalidAudioFrameException("Invalid version"); } samplingRate = samplingRateMapForVersion.get(index); if (samplingRate == null) { throw new InvalidAudioFrameException("Invalid sampling rate"); } }
set the sampling rate in Hz of this frame @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MPEGFrameHeader::setSamplingRate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public int getNumberOfChannels() { switch (channelMode) { case MODE_DUAL_CHANNEL: return 2; case MODE_JOINT_STEREO: return 2; case MODE_MONO: return 1; case MODE_STEREO: return 2; default: return 0; } }
Gets the number of channels @return The setChannelMode value
MPEGFrameHeader::getNumberOfChannels
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public int getVersion() { return version; }
Gets the mPEGVersion attribute of the MPEGFrame object @return The mPEGVersion value
MPEGFrameHeader::getVersion
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public int getPaddingLength() { if (isPadding()) { return 1; } else { return 0; } }
Gets the paddingLength attribute of the MPEGFrame object @return The paddingLength value
MPEGFrameHeader::getPaddingLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public int getFrameLength() { switch (version) { case VERSION_2: case VERSION_2_5: switch (layer) { case LAYER_I: return (LAYER_I_FRAME_SIZE_COEFFICIENT * (getBitRate() * SCALE_BY_THOUSAND) / getSamplingRate() + getPaddingLength()) * LAYER_I_SLOT_SIZE; case LAYER_II: return (LAYER_II_FRAME_SIZE_COEFFICIENT ) * (getBitRate() * SCALE_BY_THOUSAND) / getSamplingRate() + getPaddingLength() * LAYER_II_SLOT_SIZE; case LAYER_III: if (this.getChannelMode() == MODE_MONO) { return (LAYER_III_FRAME_SIZE_COEFFICIENT / 2 ) * (getBitRate() * SCALE_BY_THOUSAND) / getSamplingRate() + getPaddingLength() * LAYER_III_SLOT_SIZE; } else { return (LAYER_III_FRAME_SIZE_COEFFICIENT) * (getBitRate() * SCALE_BY_THOUSAND) / getSamplingRate() + getPaddingLength() * LAYER_III_SLOT_SIZE; } default: throw new RuntimeException("Mp3 Unknown Layer:" + layer); } case VERSION_1: switch (layer) { case LAYER_I: return (LAYER_I_FRAME_SIZE_COEFFICIENT * (getBitRate() * SCALE_BY_THOUSAND) / getSamplingRate() + getPaddingLength()) * LAYER_I_SLOT_SIZE; case LAYER_II: return LAYER_II_FRAME_SIZE_COEFFICIENT * (getBitRate() * SCALE_BY_THOUSAND) / getSamplingRate() + getPaddingLength() * LAYER_II_SLOT_SIZE; case LAYER_III: return LAYER_III_FRAME_SIZE_COEFFICIENT * (getBitRate() * SCALE_BY_THOUSAND) / getSamplingRate() + getPaddingLength() * LAYER_III_SLOT_SIZE; default: throw new RuntimeException("Mp3 Unknown Layer:" + layer); } default: throw new RuntimeException("Mp3 Unknown Version:" + version); } }
Gets the paddingLength attribute of the MPEGFrame object @return The paddingLength value public int getPaddingLength() { if (isPadding()) { return 1; } else { return 0; } } public Integer getBitRate() { return bitRate; } public Integer getSamplingRate() { return samplingRate; } /* Gets this frame length in bytes, value should always be rounded down to the nearest byte (not rounded up) Calculation is Bitrate (scaled to bps) divided by sampling frequency (in Hz), The larger the bitrate the larger the frame but the more samples per second the smaller the value, also have to take into account frame padding Have to multiple by a coefficient constant depending upon the layer it is encoded in,
MPEGFrameHeader::getFrameLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public int getNoOfSamples() { Integer noOfSamples = samplesPerFrameMap.get(version).get(layer); return noOfSamples; }
Get the number of samples in a frame, all frames in a file have a set number of samples as defined by their MPEG Versiona and Layer @return
MPEGFrameHeader::getNoOfSamples
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private MPEGFrameHeader() throws InvalidAudioFrameException { }
Hide Constructor @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MPEGFrameHeader::MPEGFrameHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private MPEGFrameHeader(byte[] b) throws InvalidAudioFrameException { mpegBytes = b; setBitrate(); setVersion(); setLayer(); setProtected(); setSamplingRate(); setPadding(); setPrivate(); setChannelMode(); setModeExtension(); setCopyrighted(); setOriginal(); setEmphasis(); }
Try and create a new MPEG frame with the given byte array and decodes its contents If decoding header causes a problem it is not a valid header @param b the array of bytes representing this mpeg frame @throws InvalidAudioFrameException if does not match expected format
MPEGFrameHeader::MPEGFrameHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public static MPEGFrameHeader parseMPEGHeader(ByteBuffer bb) throws InvalidAudioFrameException { int position = bb.position(); bb.get(header, 0, HEADER_SIZE); bb.position(position); MPEGFrameHeader frameHeader = new MPEGFrameHeader(header); return frameHeader; }
Parse the MPEGFrameHeader of an MP3File, file pointer returns at end of the frame header @param bb the byte buffer containing the header @return @throws InvalidAudioFrameException if there is no header at this point
MPEGFrameHeader::parseMPEGHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public static boolean isMPEGFrame(ByteBuffer bb) { int position = bb.position(); return (((bb.get(position) & SYNC_BYTE1) == SYNC_BYTE1) && ((bb.get(position + 1) & SYNC_BYTE2) == SYNC_BYTE2) && ((bb.get(position + 2) & SYNC_BIT_ANDSAMPING_BYTE3) != SYNC_BIT_ANDSAMPING_BYTE3)); }
Gets the MPEGFrame attribute of the MPEGFrame object @param bb @return The mPEGFrame value
MPEGFrameHeader::isMPEGFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
public String toString() { return " mpeg frameheader:" + " frame length:" + getFrameLength() + " version:" + versionAsString + " layer:" + layerAsString + " channelMode:" + channelModeAsString + " noOfSamples:" + getNoOfSamples() + " samplingRate:" + samplingRate + " isPadding:" + isPadding + " isProtected:" + isProtected + " isPrivate:" + isPrivate + " isCopyrighted:" + isCopyrighted + " isOriginal:" + isCopyrighted + " isVariableBitRate" + this.isVariableBitRate() + " header as binary:" + AbstractTagDisplayFormatter.displayAsBinary(mpegBytes[BYTE_1]) + " " + AbstractTagDisplayFormatter.displayAsBinary(mpegBytes[BYTE_2]) + " " + AbstractTagDisplayFormatter.displayAsBinary(mpegBytes[BYTE_3]) + " " + AbstractTagDisplayFormatter.displayAsBinary(mpegBytes[BYTE_4]); }
@return a string represntation
MPEGFrameHeader::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MPEGFrameHeader.java
Apache-2.0
private XingFrame(ByteBuffer header) { this.header=header; //Go to start of Buffer header.rewind(); //Set Vbr setVbr(); //Read Flags, only the fourth byte of interest to us byte[] flagBuffer = new byte[XING_FLAG_BUFFER_SIZE]; header.get(flagBuffer); //Read FrameCount if flag set if ((flagBuffer[BYTE_4] & (byte) (1)) != 0) { setFrameCount(); } //Read Size if flag set if ((flagBuffer[BYTE_4] & (byte) (1 << 1)) != 0) { setAudioSize(); } //TODO TOC //TODO VBR Quality //Look for LAME Header as long as we have enough bytes to do it properly if (header.limit() >= XING_HEADER_BUFFER_SIZE + LameFrame.LAME_HEADER_BUFFER_SIZE) { header.position(XING_HEADER_BUFFER_SIZE); lameFrame = LameFrame.parseLameFrame(header); } }
Read the Xing Properties from the buffer
XingFrame::XingFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
private void setVbr() { //Is it VBR or CBR byte[] identifier = new byte[XING_IDENTIFIER_BUFFER_SIZE]; header.get(identifier); if (Arrays.equals(identifier, XING_VBR_ID)) { MP3File.logger.finest("Is Vbr"); vbr = true; } }
Set whether or not VBR, (Xing can also be used for CBR though this is less useful)
XingFrame::setVbr
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
private void setFrameCount() { byte[] frameCountBuffer = new byte[XING_FRAMECOUNT_BUFFER_SIZE]; header.get(frameCountBuffer); isFrameCountEnabled = true; frameCount = (frameCountBuffer[BYTE_1] << 24) & 0xFF000000 | (frameCountBuffer[BYTE_2] << 16) & 0x00FF0000 | (frameCountBuffer[BYTE_3] << 8) & 0x0000FF00 | frameCountBuffer[BYTE_4] & 0x000000FF; }
Set count of frames
XingFrame::setFrameCount
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public final boolean isFrameCountEnabled() { return isFrameCountEnabled; }
@return true if frameCount has been specified in header
XingFrame::isFrameCountEnabled
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public final int getFrameCount() { return frameCount; }
@return count of frames
XingFrame::getFrameCount
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
private void setAudioSize() { byte[] frameSizeBuffer = new byte[XING_AUDIOSIZE_BUFFER_SIZE]; header.get(frameSizeBuffer); isAudioSizeEnabled = true; audioSize = (frameSizeBuffer[BYTE_1] << 24) & 0xFF000000 | (frameSizeBuffer[BYTE_2] << 16) & 0x00FF0000 | (frameSizeBuffer[BYTE_3] << 8) & 0x0000FF00 | frameSizeBuffer[BYTE_4] & 0x000000FF; }
Set size of AudioData
XingFrame::setAudioSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public final boolean isAudioSizeEnabled() { return isAudioSizeEnabled; }
@return true if audioSize has been specified in header
XingFrame::isAudioSizeEnabled
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public final int getAudioSize() { return audioSize; }
@return size of audio data in bytes
XingFrame::getAudioSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public static XingFrame parseXingFrame(ByteBuffer header) throws InvalidAudioFrameException { XingFrame xingFrame = new XingFrame(header); return xingFrame; }
Parse the XingFrame of an MP3File, cannot be called until we have validated that this is a XingFrame @return @throws InvalidAudioFrameException
XingFrame::parseXingFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public static ByteBuffer isXingFrame(ByteBuffer bb, MPEGFrameHeader mpegFrameHeader) { //We store this so can return here after scanning through buffer int startPosition = bb.position(); //Get to Start of where Xing Frame Should be ( we dont know if it is one at this point) if (mpegFrameHeader.getVersion() == MPEGFrameHeader.VERSION_1) { if (mpegFrameHeader.getChannelMode() == MPEGFrameHeader.MODE_MONO) { bb.position(startPosition + MPEG_VERSION_1_MODE_MONO_OFFSET); } else { bb.position(startPosition + MPEG_VERSION_1_MODE_STEREO_OFFSET); } } //MPEGVersion 2 and 2.5 else { if (mpegFrameHeader.getChannelMode() == MPEGFrameHeader.MODE_MONO) { bb.position(startPosition + MPEG_VERSION_2_MODE_MONO_OFFSET); } else { bb.position(startPosition + MPEG_VERSION_2_MODE_STEREO_OFFSET); } } //Create header from here ByteBuffer header = bb.slice(); // Return Buffer to start Point bb.position(startPosition); //Check Identifier byte[] identifier = new byte[XING_IDENTIFIER_BUFFER_SIZE]; header.get(identifier); if ((!Arrays.equals(identifier, XING_VBR_ID)) && (!Arrays.equals(identifier, XING_CBR_ID))) { return null; } MP3File.logger.finest("Found Xing Frame"); return header; }
IS this a Xing frame @param bb @param mpegFrameHeader @return true if this is a Xing frame
XingFrame::isXingFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public final boolean isVbr() { return vbr; }
Is this XingFrame detailing a variable bit rate MPEG @return
XingFrame::isVbr
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public String toString() { return "xingheader" + " vbr:" + vbr + " frameCountEnabled:" + isFrameCountEnabled + " frameCount:" + frameCount + " audioSizeEnabled:" + isAudioSizeEnabled + " audioFileSize:" + audioSize; }
@return a string representation
XingFrame::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/XingFrame.java
Apache-2.0
public MP3File() { }
Creates a new empty MP3File datatype that is not associated with a specific file.
MP3File::MP3File
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public MP3File(String filename) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException { this(new File(filename)); }
Creates a new MP3File datatype and parse the tag from the given filename. @param filename MP3 file @throws IOException on any I/O error @throws TagException on any exception generated by this library. @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MP3File::MP3File
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public MP3File(File file, int loadOptions) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException { this(file, loadOptions, false); }
Creates a new MP3File dataType and parse the tag from the given file Object, files must be writable to use this constructor. @param file MP3 file @param loadOptions decide what tags to load @throws IOException on any I/O error @throws TagException on any exception generated by this library. @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MP3File::MP3File
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
private void readV1Tag(File file, RandomAccessFile newFile, int loadOptions) throws IOException { if ((loadOptions & LOAD_IDV1TAG) != 0) { logger.finer("Attempting to read id3v1tags"); try { id3v1tag = new ID3v11Tag(newFile, file.getName()); } catch (TagNotFoundException ex) { logger.config("No ids3v11 tag found"); } try { if (id3v1tag == null) { id3v1tag = new ID3v1Tag(newFile, file.getName()); } } catch (TagNotFoundException ex) { logger.config("No id3v1 tag found"); } } }
Read v1 tag @param file @param newFile @param loadOptions @throws IOException
MP3File::readV1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
private void readV2Tag(File file, int loadOptions, int startByte) throws IOException, TagException { //We know where the actual Audio starts so load all the file from start to that point into //a buffer then we can read the IDv2 information without needing any more File I/O if (startByte >= AbstractID3v2Tag.TAG_HEADER_LENGTH) { logger.finer("Attempting to read id3v2tags"); try (final FileInputStream fis = new FileInputStream(file)) { final ByteBuffer bb = ByteBuffer.allocateDirect(startByte); fis.getChannel().read(bb,0); bb.rewind(); if ((loadOptions & LOAD_IDV2TAG) != 0) { logger.config("Attempting to read id3v2tags"); try { this.setID3v2Tag(new ID3v24Tag(bb, file.getName())); } catch (TagNotFoundException ex) { logger.config("No id3v24 tag found"); } try { if (id3v2tag == null) { this.setID3v2Tag(new ID3v23Tag(bb, file.getName())); } } catch (TagNotFoundException ex) { logger.config("No id3v23 tag found"); } try { if (id3v2tag == null) { this.setID3v2Tag(new ID3v22Tag(bb, file.getName())); } } catch (TagNotFoundException ex) { logger.config("No id3v22 tag found"); } } } } else { logger.config("Not enough room for valid id3v2 tag:" + startByte); } }
Read V2tag, if exists. TODO:shouldn't we be handing TagExceptions:when will they be thrown @param file the file to read tags from @param loadOptions load options @throws IOException IO issues @throws TagException tag issues
MP3File::readV2Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
private void readLyrics3Tag(File file, RandomAccessFile newFile, int loadOptions) throws IOException { /*if ((loadOptions & LOAD_LYRICS3) != 0) { try { lyrics3tag = new Lyrics3v2(newFile); } catch (TagNotFoundException ex) { } try { if (lyrics3tag == null) { lyrics3tag = new Lyrics3v1(newFile); } } catch (TagNotFoundException ex) { } } */ }
Read lyrics3 Tag TODO:not working @param file @param newFile @param loadOptions @throws IOException
MP3File::readLyrics3Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
private boolean isFilePortionNull(int startByte, int endByte) throws IOException { logger.config("Checking file portion:" + Hex.asHex(startByte) + ":" + Hex.asHex(endByte)); FileInputStream fis=null; FileChannel fc=null; try { fis = new FileInputStream(file); fc = fis.getChannel(); fc.position(startByte); ByteBuffer bb = ByteBuffer.allocateDirect(endByte - startByte); fc.read(bb); while(bb.hasRemaining()) { if(bb.get()!=0) { return false; } } } finally { if (fc != null) { fc.close(); } if (fis != null) { fis.close(); } } return true; }
@param startByte @param endByte @return @throws Exception @return true if all the bytes between in the file between startByte and endByte are null, false otherwise
MP3File::isFilePortionNull
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
private MP3AudioHeader checkAudioStart(long startByte, MP3AudioHeader firstHeaderAfterTag) throws IOException, InvalidAudioFrameException { MP3AudioHeader headerOne; MP3AudioHeader headerTwo; logger.warning(ErrorMessage.MP3_ID3TAG_LENGTH_INCORRECT.getMsg(file.getPath(), Hex.asHex(startByte), Hex.asHex(firstHeaderAfterTag.getMp3StartByte()))); //because we cant agree on start location we reread the audioheader from the start of the file, at least //this way we cant overwrite the audio although we might overwrite part of the tag if we write this file //back later headerOne = new MP3AudioHeader(file, 0); logger.config("Checking from start:" + headerOne); //Although the id3 tag size appears to be incorrect at least we have found the same location for the start //of audio whether we start searching from start of file or at the end of the alleged of file so no real //problem if (firstHeaderAfterTag.getMp3StartByte() == headerOne.getMp3StartByte()) { logger.config(ErrorMessage.MP3_START_OF_AUDIO_CONFIRMED.getMsg(file.getPath(), Hex.asHex(headerOne.getMp3StartByte()))); return firstHeaderAfterTag; } else { //We get a different value if read from start, can't guarantee 100% correct lets do some more checks logger.config((ErrorMessage.MP3_RECALCULATED_POSSIBLE_START_OF_MP3_AUDIO.getMsg(file.getPath(), Hex.asHex(headerOne.getMp3StartByte())))); //Same frame count so probably both audio headers with newAudioHeader being the first one if (firstHeaderAfterTag.getNumberOfFrames() == headerOne.getNumberOfFrames()) { logger.warning((ErrorMessage.MP3_RECALCULATED_START_OF_MP3_AUDIO.getMsg(file.getPath(), Hex.asHex(headerOne.getMp3StartByte())))); return headerOne; } //If the size reported by the tag header is a little short and there is only nulls between the recorded value //and the start of the first audio found then we stick with the original header as more likely that currentHeader //DataInputStream not really a header if(isFilePortionNull((int) startByte,(int) firstHeaderAfterTag.getMp3StartByte())) { return firstHeaderAfterTag; } //Skip to the next header (header 2, counting from start of file) headerTwo = new MP3AudioHeader(file, headerOne.getMp3StartByte() + headerOne.mp3FrameHeader.getFrameLength()); //It matches the header we found when doing the original search from after the ID3Tag therefore it //seems that newAudioHeader was a false match and the original header was correct if (headerTwo.getMp3StartByte() == firstHeaderAfterTag.getMp3StartByte()) { logger.warning((ErrorMessage.MP3_START_OF_AUDIO_CONFIRMED.getMsg(file.getPath(), Hex.asHex(firstHeaderAfterTag.getMp3StartByte())))); return firstHeaderAfterTag; } //It matches the frameCount the header we just found so lends weight to the fact that the audio does indeed start at new header //however it maybe that neither are really headers and just contain the same data being misrepresented as headers. if (headerTwo.getNumberOfFrames() == headerOne.getNumberOfFrames()) { logger.warning((ErrorMessage.MP3_RECALCULATED_START_OF_MP3_AUDIO.getMsg(file.getPath(), Hex.asHex(headerOne.getMp3StartByte())))); return headerOne; } ///Doesnt match the frameCount lets go back to the original header else { logger.warning((ErrorMessage.MP3_RECALCULATED_START_OF_MP3_AUDIO.getMsg(file.getPath(), Hex.asHex(firstHeaderAfterTag.getMp3StartByte())))); return firstHeaderAfterTag; } } }
Regets the audio header starting from start of file, and write appropriate logging to indicate potential problem to user. @param startByte @param firstHeaderAfterTag @return @throws IOException @throws InvalidAudioFrameException
MP3File::checkAudioStart
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public MP3File(File file, int loadOptions, boolean readOnly) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException { RandomAccessFile newFile = null; try { this.file = file; //Check File accessibility newFile = checkFilePermissions(file, readOnly); //Read ID3v2 tag size (if tag exists) to allow audioHeader parsing to skip over tag long tagSizeReportedByHeader = AbstractID3v2Tag.getV2TagSizeIfExists(file); logger.config("TagHeaderSize:" + Hex.asHex(tagSizeReportedByHeader)); audioHeader = new MP3AudioHeader(file, tagSizeReportedByHeader); //If the audio header is not straight after the end of the tag then search from start of file if (tagSizeReportedByHeader != ((MP3AudioHeader) audioHeader).getMp3StartByte()) { logger.config("First header found after tag:" + audioHeader); audioHeader = checkAudioStart(tagSizeReportedByHeader, (MP3AudioHeader) audioHeader); } //Read v1 tags (if any) readV1Tag(file, newFile, loadOptions); //Read v2 tags (if any) readV2Tag(file, loadOptions, (int)((MP3AudioHeader) audioHeader).getMp3StartByte()); //If we have a v2 tag use that, if we do not but have v1 tag use that //otherwise use nothing //TODO:if have both should we merge //rather than just returning specific ID3v22 tag, would it be better to return v24 version ? if (this.getID3v2Tag() != null) { tag = this.getID3v2Tag(); } else if (id3v1tag != null) { tag = id3v1tag; } } finally { if (newFile != null) { newFile.close(); } } }
Creates a new MP3File dataType and parse the tag from the given file Object, files can be opened read only if required. @param file MP3 file @param loadOptions decide what tags to load @param readOnly causes the files to be opened readonly @throws IOException on any I/O error @throws TagException on any exception generated by this library. @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MP3File::MP3File
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public long getMP3StartByte(File file) throws InvalidAudioFrameException, IOException { try { //Read ID3v2 tag size (if tag exists) to allow audio header parsing to skip over tag long startByte = AbstractID3v2Tag.getV2TagSizeIfExists(file); MP3AudioHeader audioHeader = new MP3AudioHeader(file, startByte); if (startByte != audioHeader.getMp3StartByte()) { logger.config("First header found after tag:" + audioHeader); audioHeader = checkAudioStart(startByte, audioHeader); } return audioHeader.getMp3StartByte(); } catch (InvalidAudioFrameException iafe) { throw iafe; } catch (IOException ioe) { throw ioe; } }
Used by tags when writing to calculate the location of the music file @param file @return the location within the file that the audio starts @throws java.io.IOException @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MP3File::getMP3StartByte
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public File extractID3v2TagDataIntoFile(File outputFile) throws TagNotFoundException, IOException { int startByte = (int) ((MP3AudioHeader) audioHeader).getMp3StartByte(); if (startByte >= 0) { //Read byte into buffer FileInputStream fis = new FileInputStream(file); FileChannel fc = fis.getChannel(); ByteBuffer bb = ByteBuffer.allocate(startByte); fc.read(bb); //Write bytes to outputFile FileOutputStream out = new FileOutputStream(outputFile); out.write(bb.array()); out.close(); fc.close(); fis.close(); return outputFile; } throw new TagNotFoundException("There is no ID3v2Tag data in this file"); }
Extracts the raw ID3v2 tag data into a file. This provides access to the raw data before manipulation, the data is written from the start of the file to the start of the Audio Data. This is primarily useful for manipulating corrupted tags that are not (fully) loaded using the standard methods. @param outputFile to write the data to @return @throws TagNotFoundException @throws IOException
MP3File::extractID3v2TagDataIntoFile
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public MP3AudioHeader getMP3AudioHeader() { return (MP3AudioHeader) getAudioHeader(); }
Return audio header @return
MP3File::getMP3AudioHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public boolean hasID3v1Tag() { return (id3v1tag != null); }
Returns true if this datatype contains an <code>Id3v1</code> tag @return true if this datatype contains an <code>Id3v1</code> tag
MP3File::hasID3v1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public boolean hasID3v2Tag() { return (id3v2tag != null); }
Returns true if this datatype contains an <code>Id3v2</code> tag @return true if this datatype contains an <code>Id3v2</code> tag
MP3File::hasID3v2Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public MP3File(File file) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException { this(file, LOAD_ALL); }
Creates a new MP3File datatype and parse the tag from the given file Object. @param file MP3 file @throws IOException on any I/O error @throws TagException on any exception generated by this library. @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MP3File::MP3File
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void setID3v1Tag(ID3v1Tag id3v1tag) { logger.config("setting tagv1:v1 tag"); this.id3v1tag = id3v1tag; }
Sets the ID3v1(_1)tag to the tag provided as an argument. @param id3v1tag
MP3File::setID3v1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void setID3v1Tag(AbstractTag mp3tag) { logger.config("setting tagv1:abstract"); id3v1tag = new ID3v11Tag(mp3tag); }
Sets the <code>ID3v1</code> tag for this dataType. A new <code>ID3v1_1</code> dataType is created from the argument and then used here. @param mp3tag Any MP3Tag dataType can be used and will be converted into a new ID3v1_1 dataType.
MP3File::setID3v1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public ID3v1Tag getID3v1Tag() { return id3v1tag; }
Returns the <code>ID3v1</code> tag for this dataType. @return the <code>ID3v1</code> tag for this dataType
MP3File::getID3v1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void setID3v2Tag(AbstractTag mp3tag) { id3v2tag = new ID3v24Tag(mp3tag); }
Sets the <code>ID3v2</code> tag for this dataType. A new <code>ID3v2_4</code> dataType is created from the argument and then used here. @param mp3tag Any MP3Tag dataType can be used and will be converted into a new ID3v2_4 dataType.
MP3File::setID3v2Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void setID3v2Tag(AbstractID3v2Tag id3v2tag) { this.id3v2tag = id3v2tag; if (id3v2tag instanceof ID3v24Tag) { this.id3v2Asv24tag = (ID3v24Tag) this.id3v2tag; } else { this.id3v2Asv24tag = new ID3v24Tag(id3v2tag); } }
Sets the v2 tag to the v2 tag provided as an argument. Also store a v24 version of tag as v24 is the interface to be used when talking with client applications. @param id3v2tag
MP3File::setID3v2Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public AbstractID3v2Tag getID3v2Tag() { return id3v2tag; }
Returns the <code>ID3v2</code> tag for this datatype. @return the <code>ID3v2</code> tag for this datatype
MP3File::getID3v2Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public ID3v24Tag getID3v2TagAsv24() { return id3v2Asv24tag; }
@return a representation of tag as v24
MP3File::getID3v2TagAsv24
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void delete(AbstractTag mp3tag) throws FileNotFoundException, IOException { RandomAccessFile raf = new RandomAccessFile(this.file, "rw"); mp3tag.delete(raf); raf.close(); if(mp3tag instanceof ID3v1Tag) { id3v1tag=null; } if(mp3tag instanceof AbstractID3v2Tag) { id3v2tag=null; } }
Remove tag from file @param mp3tag @throws FileNotFoundException @throws IOException
MP3File::delete
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void save() throws IOException, TagException { save(this.file); }
Saves the tags in this dataType to the file referred to by this dataType. @throws IOException on any I/O error @throws TagException on any exception generated by this library.
MP3File::save
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void commit() throws CannotWriteException { try { save(); } catch (UnableToModifyFileException umfe) { throw new NoWritePermissionsException(umfe); } catch (IOException ioe) { throw new CannotWriteException(ioe); } catch (TagException te) { throw new CannotWriteException(te); } }
Overridden for compatibility with merged code @throws NoWritePermissionsException if the file could not be written to due to file permissions @throws CannotWriteException
MP3File::commit
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void precheck(File file) throws IOException { Path path = file.toPath(); if (!Files.exists(path)) { logger.severe(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_NOT_FOUND.getMsg(file.getName())); throw new IOException(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_NOT_FOUND.getMsg(file.getName())); } if (TagOptionSingleton.getInstance().isCheckIsWritable() && !Files.isWritable(path)) { logger.severe(Permissions.displayPermissions(path)); logger.severe(ErrorMessage.GENERAL_WRITE_FAILED.getMsg(file.getName())); throw new IOException(ErrorMessage.GENERAL_WRITE_FAILED.getMsg(file.getName())); } if (file.length() <= MINIMUM_FILESIZE) { logger.severe(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_IS_TOO_SMALL.getMsg(file.getName())); throw new IOException(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_IS_TOO_SMALL.getMsg(file.getName())); } }
Check can write to file @param file @throws IOException
MP3File::precheck
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void save(File fileToSave) throws IOException { //Ensure we are dealing with absolute filepaths not relative ones File file = fileToSave.getAbsoluteFile(); logger.config("Saving : " + file.getPath()); //Checks before starting write precheck(file); RandomAccessFile rfile = null; try { //ID3v2 Tag if (TagOptionSingleton.getInstance().isId3v2Save()) { if (id3v2tag == null) { rfile = new RandomAccessFile(file, "rw"); (new ID3v24Tag()).delete(rfile); (new ID3v23Tag()).delete(rfile); (new ID3v22Tag()).delete(rfile); logger.config("Deleting ID3v2 tag:"+file.getName()); rfile.close(); } else { logger.config("Writing ID3v2 tag:"+file.getName()); final MP3AudioHeader mp3AudioHeader = (MP3AudioHeader) this.getAudioHeader(); final long mp3StartByte = mp3AudioHeader.getMp3StartByte(); final long newMp3StartByte = id3v2tag.write(file, mp3StartByte); if (mp3StartByte != newMp3StartByte) { logger.config("New mp3 start byte: " + newMp3StartByte); mp3AudioHeader.setMp3StartByte(newMp3StartByte); } } } rfile = new RandomAccessFile(file, "rw"); //Lyrics 3 Tag if (TagOptionSingleton.getInstance().isLyrics3Save()) { if (lyrics3tag != null) { lyrics3tag.write(rfile); } } //ID3v1 tag if (TagOptionSingleton.getInstance().isId3v1Save()) { logger.config("Processing ID3v1"); if (id3v1tag == null) { logger.config("Deleting ID3v1"); (new ID3v1Tag()).delete(rfile); } else { logger.config("Saving ID3v1"); id3v1tag.write(rfile); } } } catch (FileNotFoundException ex) { logger.log(Level.SEVERE, ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_NOT_FOUND.getMsg(file.getName()), ex); throw ex; } catch (IOException iex) { logger.log(Level.SEVERE, ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE.getMsg(file.getName(), iex.getMessage()), iex); throw iex; } catch (RuntimeException re) { logger.log(Level.SEVERE, ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE.getMsg(file.getName(), re.getMessage()), re); throw re; } finally { if (rfile != null) { rfile.close(); } } }
Saves the tags in this dataType to the file argument. It will be saved as TagConstants.MP3_FILE_SAVE_WRITE @param fileToSave file to save the this dataTypes tags to @throws FileNotFoundException if unable to find file @throws IOException on any I/O error
MP3File::save
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public String displayStructureAsXML() { createXMLStructureFormatter(); tagFormatter.openHeadingElement("file", this.getFile().getAbsolutePath()); if (this.getID3v1Tag() != null) { this.getID3v1Tag().createStructure(); } if (this.getID3v2Tag() != null) { this.getID3v2Tag().createStructure(); } tagFormatter.closeHeadingElement("file"); return tagFormatter.toString(); }
Displays MP3File Structure
MP3File::displayStructureAsXML
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public String displayStructureAsPlainText() { createPlainTextStructureFormatter(); tagFormatter.openHeadingElement("file", this.getFile().getAbsolutePath()); if (this.getID3v1Tag() != null) { this.getID3v1Tag().createStructure(); } if (this.getID3v2Tag() != null) { this.getID3v2Tag().createStructure(); } tagFormatter.closeHeadingElement("file"); return tagFormatter.toString(); }
Displays MP3File Structure
MP3File::displayStructureAsPlainText
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public void setTag(Tag tag) { this.tag = tag; if (tag instanceof ID3v1Tag) { setID3v1Tag((ID3v1Tag) tag); } else { setID3v2Tag((AbstractID3v2Tag) tag); } }
Set the Tag If the parameter tag is a v1tag then the v1 tag is set if v2tag then the v2tag. @param tag
MP3File::setTag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3File.java
Apache-2.0
public MP3AudioHeader(final File seekFile) throws IOException, InvalidAudioFrameException { if (!seek(seekFile, 0)) { throw new InvalidAudioFrameException("No audio header found within" + seekFile.getName()); } }
Search for the first MP3Header in the file The search starts from the start of the file, it is usually safer to use the alternative constructor that allows you to provide the length of the tag header as a parameter so the tag can be skipped over. @param seekFile @throws IOException @throws InvalidAudioFrameException
MP3AudioHeader::MP3AudioHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public MP3AudioHeader(final File seekFile, long startByte) throws IOException, InvalidAudioFrameException { if (!seek(seekFile, startByte)) { throw new InvalidAudioFrameException(ErrorMessage.NO_AUDIO_HEADER_FOUND.getMsg(seekFile.getName())); } }
Search for the first MP3Header in the file Starts searching from location startByte, this is because there is likely to be an ID3TagHeader before the start of the audio. If this tagHeader contains unsynchronized information there is a possibility that it might be inaccurately identified as the start of the Audio data. Various checks are done in this code to prevent this happening but it cannot be guaranteed. Of course if the startByte provided overstates the length of the tag header, this could mean the start of the MP3AudioHeader is missed, further checks are done within the MP3 class to recognize if this has occurred and take appropriate action. @param seekFile @param startByte @throws IOException @throws InvalidAudioFrameException
MP3AudioHeader::MP3AudioHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public boolean seek(final File seekFile, long startByte) throws IOException { //References to Xing/VRbi Header ByteBuffer header; //This is substantially faster than updating the filechannels position long filePointerCount; final FileInputStream fis = new FileInputStream(seekFile); final FileChannel fc = fis.getChannel(); //Read into Byte Buffer in Chunks ByteBuffer bb = ByteBuffer.allocateDirect(FILE_BUFFER_SIZE); //Move FileChannel to the starting position (skipping over tag if any) fc.position(startByte); //Update filePointerCount filePointerCount = startByte; //Read from here into the byte buffer , doesn't move location of filepointer fc.read(bb, startByte); bb.flip(); boolean syncFound = false; try { do { //TODO remaining() is quite an expensive operation, isn't there a way we can work this out without //interrogating the bytebuffer. Also this is rarely going to be true, and could be made less true //by increasing FILE_BUFFER_SIZE if (bb.remaining() <= MIN_BUFFER_REMAINING_REQUIRED) { bb.clear(); fc.position(filePointerCount); fc.read(bb, fc.position()); bb.flip(); if (bb.limit() <= MIN_BUFFER_REMAINING_REQUIRED) { //No mp3 exists return false; } } //MP3File.logger.finest("fc:"+fc.position() + "bb"+bb.position()); if (MPEGFrameHeader.isMPEGFrame(bb)) { try { if (MP3AudioHeader.logger.isLoggable(Level.FINEST)) { MP3AudioHeader.logger.finest("Found Possible header at:" + filePointerCount); } mp3FrameHeader = MPEGFrameHeader.parseMPEGHeader(bb); syncFound = true; //if(2==1) use this line when you want to test getting the next frame without using xing if ((header = XingFrame.isXingFrame(bb, mp3FrameHeader))!=null) { if (MP3AudioHeader.logger.isLoggable(Level.FINEST)) { MP3AudioHeader.logger.finest("Found Possible XingHeader"); } try { //Parses Xing frame without modifying position of main buffer mp3XingFrame = XingFrame.parseXingFrame(header); } catch (InvalidAudioFrameException ex) { // We Ignore because even if Xing Header is corrupted //doesn't mean file is corrupted } break; } else if ((header = VbriFrame.isVbriFrame(bb, mp3FrameHeader))!=null) { if (MP3AudioHeader.logger.isLoggable(Level.FINEST)) { MP3AudioHeader.logger.finest("Found Possible VbriHeader"); } try { //Parses Vbri frame without modifying position of main buffer mp3VbriFrame = VbriFrame.parseVBRIFrame(header); } catch (InvalidAudioFrameException ex) { // We Ignore because even if Vbri Header is corrupted //doesn't mean file is corrupted } break; } // There is a small but real chance that an unsynchronised ID3 Frame could fool the MPEG // Parser into thinking it was an MPEG Header. If this happens the chances of the next bytes // forming a Xing frame header are very remote. On the basis that most files these days have // Xing headers we do an additional check for when an apparent frame header has been found // but is not followed by a Xing Header:We check the next header this wont impose a large // overhead because wont apply to most Mpegs anyway ( Most likely to occur if audio // has an APIC frame which should have been unsynchronised but has not been) , or if the frame // has been encoded with as Unicode LE because these have a BOM of 0xFF 0xFE else { syncFound = isNextFrameValid(seekFile, filePointerCount, bb, fc); if (syncFound) { break; } } } catch (InvalidAudioFrameException ex) { // We Ignore because likely to be incorrect sync bits , // will just continue in loop } } //TODO position() is quite an expensive operation, isn't there a way we can work this out without //interrogating the bytebuffer bb.position(bb.position() + 1); filePointerCount++; } while (!syncFound); } catch (EOFException ex) { MP3AudioHeader.logger.log(Level.WARNING, "Reached end of file without finding sync match", ex); syncFound = false; } catch (IOException iox) { MP3AudioHeader.logger.log(Level.SEVERE, "IOException occurred whilst trying to find sync", iox); syncFound = false; throw iox; } finally { if (fc != null) { fc.close(); } if (fis != null) { fis.close(); } } //Return to start of audio header if (MP3AudioHeader.logger.isLoggable(Level.FINEST)) { MP3AudioHeader.logger.finer("Return found matching mp3 header starting at" + filePointerCount); } setFileSize(seekFile.length()); setMp3StartByte(filePointerCount); setTimePerFrame(); setNumberOfFrames(); setTrackLength(); setBitRate(); setEncoder(); /*if((filePointerCount - startByte )>0) { logger.severe(seekFile.getName()+"length:"+startByte+"Difference:"+(filePointerCount - startByte)); } */ return syncFound; }
Returns true if the first MP3 frame can be found for the MP3 file This is the first byte of music data and not the ID3 Tag Frame. * @param seekFile MP3 file to seek @param startByte if there is an ID3v2tag we dont want to start reading from the start of the tag @return true if the first MP3 frame can be found @throws IOException on any I/O error
MP3AudioHeader::seek
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
private boolean isNextFrameValid(File seekFile, long filePointerCount, ByteBuffer bb, FileChannel fc) throws IOException { if (MP3AudioHeader.logger.isLoggable(Level.FINEST)) { MP3AudioHeader.logger.finer("Checking next frame" + seekFile.getName() + ":fpc:" + filePointerCount + "skipping to:" + (filePointerCount + mp3FrameHeader.getFrameLength())); } boolean result = false; int currentPosition = bb.position(); //Our buffer is not large enough to fit in the whole of this frame, something must //have gone wrong because frames are not this large, so just return false //bad frame header if (mp3FrameHeader.getFrameLength() > (FILE_BUFFER_SIZE - MIN_BUFFER_REMAINING_REQUIRED)) { MP3AudioHeader.logger.finer("Frame size is too large to be a frame:" + mp3FrameHeader.getFrameLength()); return false; } //Check for end of buffer if not enough room get some more if (bb.remaining() <= MIN_BUFFER_REMAINING_REQUIRED + mp3FrameHeader.getFrameLength()) { MP3AudioHeader.logger.finer("Buffer too small, need to reload, buffer size:" + bb.remaining()); bb.clear(); fc.position(filePointerCount); fc.read(bb, fc.position()); bb.flip(); //So now original buffer has been replaced, so set current position to start of buffer currentPosition = 0; //Not enough left if (bb.limit() <= MIN_BUFFER_REMAINING_REQUIRED) { //No mp3 exists MP3AudioHeader.logger.finer("Nearly at end of file, no header found:"); return false; } //Still Not enough left for next alleged frame size so giving up if (bb.limit() <= MIN_BUFFER_REMAINING_REQUIRED + mp3FrameHeader.getFrameLength()) { //No mp3 exists MP3AudioHeader.logger.finer("Nearly at end of file, no room for next frame, no header found:"); return false; } } //Position bb to the start of the alleged next frame bb.position(bb.position() + mp3FrameHeader.getFrameLength()); if (MPEGFrameHeader.isMPEGFrame(bb)) { try { MPEGFrameHeader.parseMPEGHeader(bb); MP3AudioHeader.logger.finer("Check next frame confirms is an audio header "); result = true; } catch (InvalidAudioFrameException ex) { MP3AudioHeader.logger.finer("Check next frame has identified this is not an audio header"); result = false; } } else { MP3AudioHeader.logger.finer("isMPEGFrame has identified this is not an audio header"); } //Set back to the start of the previous frame bb.position(currentPosition); return result; }
Called in some circumstances to check the next frame to ensure we have the correct audio header @param seekFile @param filePointerCount @param bb @param fc @return true if frame is valid @throws java.io.IOException
MP3AudioHeader::isNextFrameValid
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
protected void setMp3StartByte(final long startByte) { this.startByte = startByte; }
Set the location of where the Audio file begins in the file @param startByte
MP3AudioHeader::setMp3StartByte
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public long getMp3StartByte() { return startByte; }
Returns the byte position of the first MP3 Frame that the <code>file</code> arguement refers to. This is the first byte of music data and not the ID3 Tag Frame. @return the byte position of the first MP3 Frame
MP3AudioHeader::getMp3StartByte
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
protected void setNumberOfFrames() { numberOfFramesEstimate = (fileSize - startByte) / mp3FrameHeader.getFrameLength(); if (mp3XingFrame != null && mp3XingFrame.isFrameCountEnabled()) { numberOfFrames = mp3XingFrame.getFrameCount(); } else if (mp3VbriFrame != null) { numberOfFrames = mp3VbriFrame.getFrameCount(); } else { numberOfFrames = numberOfFramesEstimate; } }
Set number of frames in this file, use Xing if exists otherwise ((File Size - Non Audio Part)/Frame Size)
MP3AudioHeader::setNumberOfFrames
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public long getNumberOfFrames() { return numberOfFrames; }
@return The number of frames within the Audio File, calculated as accurately as possible
MP3AudioHeader::getNumberOfFrames
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public long getNumberOfFramesEstimate() { return numberOfFramesEstimate; }
@return The number of frames within the Audio File, calculated by dividing the filesize by the number of frames, this may not be the most accurate method available.
MP3AudioHeader::getNumberOfFramesEstimate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
protected void setTimePerFrame() { timePerFrame = mp3FrameHeader.getNoOfSamples() / mp3FrameHeader.getSamplingRate().doubleValue(); //Because when calculating framelength we may have altered the calculation slightly for MPEGVersion2 //to account for mono/stereo we seem to have to make a corresponding modification to get the correct time if ((mp3FrameHeader.getVersion() == MPEGFrameHeader.VERSION_2) || (mp3FrameHeader.getVersion() == MPEGFrameHeader.VERSION_2_5)) { if ((mp3FrameHeader.getLayer() == MPEGFrameHeader.LAYER_II) || (mp3FrameHeader.getLayer() == MPEGFrameHeader.LAYER_III)) { if (mp3FrameHeader.getNumberOfChannels() == 1) { timePerFrame = timePerFrame / 2; } } } }
Set the time each frame contributes to the audio in fractions of seconds, the higher the sampling rate the shorter the audio segment provided by the frame, the number of samples is fixed by the MPEG Version and Layer
MP3AudioHeader::setTimePerFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
private double getTimePerFrame() { return timePerFrame; }
@return the the time each frame contributes to the audio in fractions of seconds
MP3AudioHeader::getTimePerFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
protected void setTrackLength() { trackLength = numberOfFrames * getTimePerFrame(); }
Estimate the length of the audio track in seconds Calculation is Number of frames multiplied by the Time Per Frame using the first frame as a prototype Time Per Frame is the number of samples in the frame (which is defined by the MPEGVersion/Layer combination) divided by the sampling rate, i.e the higher the sampling rate the shorter the audio represented by the frame is going to be.
MP3AudioHeader::setTrackLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public double getPreciseTrackLength() { return trackLength; }
@return Track Length in seconds
MP3AudioHeader::getPreciseTrackLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getTrackLengthAsString() { final Date timeIn; try { final long lengthInSecs = getTrackLength(); synchronized(timeInFormat) { timeIn = timeInFormat.parse(String.valueOf(lengthInSecs)); } if (lengthInSecs < NO_SECONDS_IN_HOUR) { synchronized(timeOutFormat) { return timeOutFormat.format(timeIn); } } else { synchronized(timeOutOverAnHourFormat) { return timeOutOverAnHourFormat.format(timeIn); } } } catch (ParseException pe) { logger.warning("Unable to parse:"+getPreciseTrackLength() +" failed with ParseException:"+pe.getMessage()); return ""; } }
Return the length in user friendly format @return
MP3AudioHeader::getTrackLengthAsString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getEncodingType() { return TYPE_MP3; }
@return the audio file type
MP3AudioHeader::getEncodingType
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
protected void setBitRate() { if (mp3XingFrame != null && mp3XingFrame.isVbr()) { if (mp3XingFrame.isAudioSizeEnabled() && mp3XingFrame.getAudioSize() > 0) { bitrate = (long) (((long) mp3XingFrame.getAudioSize() * CONVERTS_BYTE_TO_BITS) / (timePerFrame * getNumberOfFrames() * CONVERT_TO_KILOBITS)); } else { bitrate = (long) (((fileSize - startByte) * CONVERTS_BYTE_TO_BITS) / (timePerFrame * getNumberOfFrames() * CONVERT_TO_KILOBITS)); } } else if (mp3VbriFrame != null) { if (mp3VbriFrame.getAudioSize() > 0) { bitrate = (long) (((long) mp3VbriFrame.getAudioSize() * CONVERTS_BYTE_TO_BITS) / (timePerFrame * getNumberOfFrames() * CONVERT_TO_KILOBITS)); } else { bitrate = (long) (((fileSize - startByte) * CONVERTS_BYTE_TO_BITS) / (timePerFrame * getNumberOfFrames() * CONVERT_TO_KILOBITS)); } } else { bitrate = mp3FrameHeader.getBitRate(); } }
Set bitrate in kbps, if Vbr use Xingheader if possible
MP3AudioHeader::setBitRate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public long getBitRateAsNumber() { return bitrate; }
@return bitrate in kbps, no indicator is provided as to whether or not it is vbr
MP3AudioHeader::getBitRateAsNumber
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getBitRate() { if (mp3XingFrame != null && mp3XingFrame.isVbr()) { return isVbrIdentifier + String.valueOf(bitrate); } else if (mp3VbriFrame != null) { return isVbrIdentifier + String.valueOf(bitrate); } else { return String.valueOf(bitrate); } }
@return the BitRate of the Audio, to distinguish cbr from vbr we add a '~' for vbr.
MP3AudioHeader::getBitRate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public int getSampleRateAsNumber() { return mp3FrameHeader.getSamplingRate(); }
@return the sampling rate in Hz
MP3AudioHeader::getSampleRateAsNumber
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public int getBitsPerSample() { //TODO: can it really be different in such an MP3 ? I think not. return 16; }
@return the number of bits per sample
MP3AudioHeader::getBitsPerSample
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getSampleRate() { return String.valueOf(mp3FrameHeader.getSamplingRate()); }
@return the sampling rate as string
MP3AudioHeader::getSampleRate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getMpegVersion() { return mp3FrameHeader.getVersionAsString(); }
@return MPEG Version (1-3)
MP3AudioHeader::getMpegVersion
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getMpegLayer() { return mp3FrameHeader.getLayerAsString(); }
@return MPEG Layer (1-3)
MP3AudioHeader::getMpegLayer
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getFormat() { return mp3FrameHeader.getVersionAsString() + " " + mp3FrameHeader.getLayerAsString(); }
@return the format of the audio (i.e. MPEG-1 Layer3)
MP3AudioHeader::getFormat
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getChannels() { return mp3FrameHeader.getChannelModeAsString(); }
@return the Channel Mode such as Stero or Mono
MP3AudioHeader::getChannels
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getEmphasis() { return mp3FrameHeader.getEmphasisAsString(); }
@return Emphasis
MP3AudioHeader::getEmphasis
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public boolean isVariableBitRate() { if (mp3XingFrame != null) { return mp3XingFrame.isVbr(); } else if (mp3VbriFrame != null) { return mp3VbriFrame.isVbr(); } else { return mp3FrameHeader.isVariableBitRate(); } }
@return if the bitrate is variable, Xing header takes precedence if we have one
MP3AudioHeader::isVariableBitRate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String getEncoder() { return encoder; }
@return encoder
MP3AudioHeader::getEncoder
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
protected void setFileSize(long fileSize) { this.fileSize = fileSize; }
Set the size of the file, required in some calculations @param fileSize
MP3AudioHeader::setFileSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public String toString() { String s = "fileSize:" + fileSize + " encoder:" + encoder + " startByte:" + Hex.asHex(startByte) + " numberOfFrames:" + numberOfFrames + " numberOfFramesEst:" + numberOfFramesEstimate + " timePerFrame:" + timePerFrame + " bitrate:" + bitrate + " trackLength:" + getTrackLengthAsString(); if (this.mp3FrameHeader != null) { s += mp3FrameHeader.toString(); } else { s +=" mpegframeheader:false"; } if (this.mp3XingFrame != null) { s += mp3XingFrame.toString(); } else { s +=" mp3XingFrame:false"; } if (this.mp3VbriFrame != null) { s +=mp3VbriFrame.toString(); } else { s +=" mp3VbriFrame:false"; } return s; }
@return a string representation
MP3AudioHeader::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public Integer getByteRate() { return null; }
TODO (Was originally added for Wavs) @return
MP3AudioHeader::getByteRate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
public Long getAudioDataLength() { return Long.valueOf(0); }
TODO (Was origjnally added for Wavs) @return
MP3AudioHeader::getAudioDataLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3AudioHeader.java
Apache-2.0
private LameFrame(ByteBuffer lameHeader) { encoder = Utils.getString(lameHeader, 0, ENCODER_SIZE, StandardCharsets.ISO_8859_1); }
Initilise a Lame Mpeg Frame @param lameHeader
LameFrame::LameFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/LameFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/LameFrame.java
Apache-2.0
public static LameFrame parseLameFrame(ByteBuffer bb) { ByteBuffer lameHeader = bb.slice(); String id = Utils.getString(lameHeader, 0, LAME_ID_SIZE, StandardCharsets.ISO_8859_1); lameHeader.rewind(); if (id.equals(LAME_ID)) { LameFrame lameFrame = new LameFrame(lameHeader); return lameFrame; } return null; }
Parse frame @param bb @return frame or null if not exists
LameFrame::parseLameFrame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/LameFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/LameFrame.java
Apache-2.0
public String getEncoder() { return encoder; }
@return encoder
LameFrame::getEncoder
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/LameFrame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/LameFrame.java
Apache-2.0
public AudioFile readMustBeWritable(File f) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException { MP3File mp3File = new MP3File(f, MP3File.LOAD_IDV1TAG | MP3File.LOAD_IDV2TAG, false); return mp3File; }
Read @param f @return @throws ReadOnlyFileException thrown if the file is not writable @throws org.jaudiotagger.tag.TagException @throws java.io.IOException @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
MP3FileReader::readMustBeWritable
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/mp3/MP3FileReader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/MP3FileReader.java
Apache-2.0
public WavTag read(Path path) throws CannotReadException, IOException { logger.config(loggingName + " Read Tag:start"); WavTag tag = new WavTag(TagOptionSingleton.getInstance().getWavOptions()); try(FileChannel fc = FileChannel.open(path)) { if (WavRIFFHeader.isValidHeader(fc)) { while (fc.position() < fc.size()) { if (!readChunk(fc, tag)) { break; } } } else { throw new CannotReadException(loggingName+ " Wav RIFF Header not valid"); } } createDefaultMetadataTagsIfMissing(tag); logger.config(loggingName + " Read Tag:end"); return tag; }
Read file and return tag metadata @param path @return @throws CannotReadException @throws IOException
WavTagReader::read
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/wav/WavTagReader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/wav/WavTagReader.java
Apache-2.0
private void createDefaultMetadataTagsIfMissing(WavTag tag) { if(!tag.isExistingId3Tag()) { tag.setID3Tag(WavTag.createDefaultID3Tag()); } if(!tag.isExistingInfoTag()) { tag.setInfoTag(new WavInfoTag()); } }
So if the file doesn't contain (both) types of metadata we construct them so data can be added and written back to file on save @param tag
WavTagReader::createDefaultMetadataTagsIfMissing
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/audio/wav/WavTagReader.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/wav/WavTagReader.java
Apache-2.0