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 |
---|---|---|---|---|---|---|---|
public Date getTimestamp()
{
return timestamp;
} |
Return the timestamp of the file.
| Endian::getTimestamp | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void setTimestamp(Date d)
{
timestamp = d;
} |
Set the timestamp.
| Endian::setTimestamp | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public AiffType getFileType()
{
return fileType;
} |
Return the file type (AIFF or AIFC)
| Endian::getFileType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void setFileType(AiffType typ)
{
fileType = typ;
} |
Set the file type (AIFF or AIFC)
| Endian::setFileType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public String getAuthor()
{
return author;
} |
Return the author
| Endian::getAuthor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void setAuthor(String a)
{
author = a;
} |
Set the author
| Endian::setAuthor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public String getName()
{
return name;
} |
Return the name. May be null.
| Endian::getName | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void setName(String n)
{
name = n;
} |
Set the name
| Endian::setName | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public String getCopyright()
{
return copyright;
} |
Return the copyright. May be null.
| Endian::getCopyright | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void setCopyright(String c)
{
copyright = c;
} |
Set the copyright
| Endian::setCopyright | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public Endian getEndian()
{
return endian;
} |
Return endian status (big or little)
| Endian::getEndian | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void setEndian(Endian e)
{
endian = e;
} |
Set endian status (big or little)
| Endian::setEndian | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public List<String> getApplicationIdentifiers()
{
return applicationIdentifiers;
} |
Return list of all application identifiers
| Endian::getApplicationIdentifiers | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void addApplicationIdentifier(String id)
{
applicationIdentifiers.add(id);
} |
Add an application identifier. There can be any number of these.
| Endian::addApplicationIdentifier | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public List<String> getAnnotations()
{
return annotations;
} |
Return list of all annotations
| Endian::getAnnotations | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void addAnnotation(String a)
{
annotations.add(a);
} |
Add an annotation. There can be any number of these.
| Endian::addAnnotation | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public List<String> getComments()
{
return comments;
} |
Return list of all comments
| Endian::getComments | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public void addComment(String c)
{
comments.add(c);
} |
Add a comment. There can be any number of these.
| Endian::addComment | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffAudioHeader.java | Apache-2.0 |
public long readHeader(FileChannel fc, final AiffAudioHeader aiffAudioHeader, String fileName) throws IOException, CannotReadException
{
final ByteBuffer headerData = ByteBuffer.allocateDirect(HEADER_LENGTH);
headerData.order(BIG_ENDIAN);
final int bytesRead = fc.read(headerData);
headerData.position(0);
if (bytesRead < HEADER_LENGTH)
{
throw new IOException(fileName + " AIFF:Unable to read required number of databytes read:" + bytesRead + ":required:" + HEADER_LENGTH);
}
final String signature = Utils.readFourBytesAsChars(headerData);
if(FORM.equals(signature))
{
// read chunk size
final long chunkSize = headerData.getInt();
logger.severe(fileName + " Reading AIFF header size:" + Hex.asDecAndHex(chunkSize));
readFileType(headerData, aiffAudioHeader);
// subtract the file type length from the chunk size to get remaining number of bytes
return chunkSize - TYPE_LENGTH;
}
else
{
throw new CannotReadException(fileName + "Not an AIFF file: incorrect signature " + signature);
}
} |
Reads the file header and registers the data (file type) with the given header.
@param fc random access file
@param aiffAudioHeader the {@link org.jaudiotagger.audio.AudioHeader} we set the read data to
@param fileName
@return the number of bytes in the FORM chunk, i.e. the size of the payload
@throws IOException
@throws CannotReadException if the file is not a valid AIFF file
| AiffFileHeader::readHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffFileHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffFileHeader.java | Apache-2.0 |
private void readFileType(final ByteBuffer bytes, final AiffAudioHeader aiffAudioHeader) throws IOException, CannotReadException {
final String type = Utils.readFourBytesAsChars(bytes);
if (AIFF.getCode().equals(type))
{
aiffAudioHeader.setFileType(AIFF);
}
else if (AIFC.getCode().equals(type))
{
aiffAudioHeader.setFileType(AIFC);
}
else
{
throw new CannotReadException("Invalid AIFF file: Incorrect file type info " + type);
}
} |
Reads the file type ({@link AiffType}).
@throws CannotReadException if the file type is not supported
| AiffFileHeader::readFileType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffFileHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffFileHeader.java | Apache-2.0 |
public static Date timestampToDate(long timestamp)
{
Calendar cal = Calendar.getInstance();
cal.set(1904, 0, 1, 0, 0, 0);
// If we add the seconds directly, we'll truncate the long
// value when converting to int. So convert to hours plus
// residual seconds.
int hours = (int) (timestamp / 3600);
int seconds = (int) (timestamp - (long) hours * 3600L);
cal.add(Calendar.HOUR_OF_DAY, hours);
cal.add(Calendar.SECOND, seconds);
Date dat = cal.getTime();
return dat;
} |
Converts a Macintosh-style timestamp (seconds since
January 1, 1904) into a Java date. The timestamp is
treated as a time in the default localization.
Depending on that localization,
there may be some variation in the exact hour of the date
returned, e.g., due to daylight savings time.
| AiffUtil::timestampToDate | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffUtil.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffUtil.java | Apache-2.0 |
public static String formatDate(Date dat)
{
return dateFmt.format(dat);
} |
Format a date as text
| AiffUtil::formatDate | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffUtil.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffUtil.java | Apache-2.0 |
private void calculateBitRate(GenericAudioHeader info) throws CannotReadException
{
if(info.getAudioDataLength()!=null)
{
info.setBitRate((int)(Math.round(info.getAudioDataLength()
* Utils.BITS_IN_BYTE_MULTIPLIER / (info.getPreciseTrackLength() * Utils.KILOBYTE_MULTIPLIER))));
}
} |
Calculate bitrate, done it here because requires data from multiple chunks
@param info
@throws CannotReadException
| AiffInfoReader::calculateBitRate | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffInfoReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffInfoReader.java | Apache-2.0 |
private boolean readChunk(FileChannel fc, AiffAudioHeader aiffAudioHeader, String fileName) throws IOException, CannotReadException
{
logger.config(fileName + " Reading Info Chunk");
final Chunk chunk;
final ChunkHeader chunkHeader = new ChunkHeader(ByteOrder.BIG_ENDIAN);
if (!chunkHeader.readHeader(fc))
{
return false;
}
logger.config(fileName + "Reading Next Chunk:" + chunkHeader.getID() + ":starting at:" + chunkHeader.getStartLocationInFile() + ":sizeIncHeader:" + (chunkHeader.getSize() + ChunkHeader.CHUNK_HEADER_SIZE));
chunk = createChunk(fc, chunkHeader, aiffAudioHeader);
if (chunk != null)
{
if (!chunk.readChunk())
{
logger.severe(fileName + "ChunkReadFail:" + chunkHeader.getID());
return false;
}
}
else
{
if(chunkHeader.getSize() < 0)
{
String msg = fileName + " Not a valid header, unable to read a sensible size:Header"
+ chunkHeader.getID()+"Size:"+chunkHeader.getSize();
logger.severe(msg);
throw new CannotReadException(msg);
}
fc.position(fc.position() + chunkHeader.getSize());
}
IffHeaderChunk.ensureOnEqualBoundary(fc, chunkHeader);
return true;
} |
Reads an AIFF Chunk.
@return {@code false}, if we were not able to read a valid chunk id
| AiffInfoReader::readChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffInfoReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffInfoReader.java | Apache-2.0 |
private Chunk createChunk(FileChannel fc, final ChunkHeader chunkHeader, AiffAudioHeader aiffAudioHeader)
throws IOException {
final AiffChunkType chunkType = AiffChunkType.get(chunkHeader.getID());
Chunk chunk;
if (chunkType != null)
{
switch (chunkType)
{
case FORMAT_VERSION:
chunk = new FormatVersionChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case APPLICATION:
chunk = new ApplicationChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case COMMON:
chunk = new CommonChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case COMMENTS:
chunk = new CommentsChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case NAME:
chunk = new NameChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case AUTHOR:
chunk = new AuthorChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case COPYRIGHT:
chunk = new CopyrightChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case ANNOTATION:
chunk = new AnnotationChunk(chunkHeader, readChunkDataIntoBuffer(fc,chunkHeader), aiffAudioHeader);
break;
case SOUND:
//Dont need to read chunk itself just need size
aiffAudioHeader.setAudioDataLength(chunkHeader.getSize());
aiffAudioHeader.setAudioDataStartPosition(fc.position());
aiffAudioHeader.setAudioDataEndPosition(fc.position() + chunkHeader.getSize());
chunk = null;
break;
default:
chunk = null;
}
}
else
{
chunk = null;
}
return chunk;
} |
Create a chunk. May return {@code null}, if the chunk is not of a valid type.
@param fc
@param chunkHeader
@param aiffAudioHeader
@return
@throws IOException
| AiffInfoReader::createChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/AiffInfoReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/AiffInfoReader.java | Apache-2.0 |
public static boolean isOnlyMetadataTagsAfterStartingMetadataTag(AiffTag tag)
{
boolean firstId3Tag = false;
for(ChunkSummary cs:tag.getChunkSummaryList())
{
if(firstId3Tag)
{
if(!cs.getChunkId().equals(AiffChunkType.TAG.getCode()))
{
return false;
}
}
else
{
if (cs.getFileStartLocation() == tag.getStartLocationInFileOfId3Chunk())
{
//Found starting point
firstId3Tag = true;
}
}
}
//Should always be true but this is to protect against something gone wrong
return firstId3Tag;
} |
Checks that there are only id3 tags after the currently selected id3tag because this means its safe to truncate
the remainder of the file.
@param tag
@return
| AiffChunkSummary::isOnlyMetadataTagsAfterStartingMetadataTag | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkSummary.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkSummary.java | Apache-2.0 |
public static ChunkSummary getChunkBeforeStartingMetadataTag(AiffTag tag)
{
for(int i=0;i < tag.getChunkSummaryList().size(); i++)
{
ChunkSummary cs = tag.getChunkSummaryList().get(i);
if (cs.getFileStartLocation() == tag.getStartLocationInFileOfId3Chunk())
{
return tag.getChunkSummaryList().get(i - 1);
}
}
return null;
} |
Get chunk before starting metadata tag
@param tag
@return
| AiffChunkSummary::getChunkBeforeStartingMetadataTag | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkSummary.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkSummary.java | Apache-2.0 |
protected ByteBuffer readChunkDataIntoBuffer(FileChannel fc, final ChunkHeader chunkHeader) throws IOException
{
final ByteBuffer chunkData = ByteBuffer.allocateDirect((int)chunkHeader.getSize());
chunkData.order(ByteOrder.BIG_ENDIAN);
fc.read(chunkData);
chunkData.position(0);
return chunkData;
} |
Read the next chunk into ByteBuffer as specified by ChunkHeader and moves raf file pointer
to start of next chunk/end of file.
@param fc
@param chunkHeader
@return
@throws java.io.IOException
| AiffChunkReader::readChunkDataIntoBuffer | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkReader.java | Apache-2.0 |
AiffChunkType(final String code)
{
this.code=code;
} |
@param code 4 char string
| AiffChunkType::AiffChunkType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkType.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkType.java | Apache-2.0 |
public synchronized static AiffChunkType get(final String code) {
if (CODE_TYPE_MAP.isEmpty()) {
for (final AiffChunkType type : values()) {
CODE_TYPE_MAP.put(type.getCode(), type);
}
}
return CODE_TYPE_MAP.get(code);
} |
Get {@link AiffChunkType} for code (e.g. "SSND").
@param code chunk id
@return chunk type or {@code null} if not registered
| AiffChunkType::get | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkType.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkType.java | Apache-2.0 |
public String getCode()
{
return code;
} |
4 char type code.
@return 4 char type code, e.g. "SSND" for the sound chunk.
| AiffChunkType::getCode | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkType.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AiffChunkType.java | Apache-2.0 |
public FormatVersionChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkData, chunkHeader);
this.aiffHeader = aiffAudioHeader;
} |
@param chunkHeader The header for this chunk
@param chunkData The buffer from which the AIFF data are being read
@param aiffAudioHeader The AiffTag into which information is stored
| FormatVersionChunk::FormatVersionChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/FormatVersionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/FormatVersionChunk.java | Apache-2.0 |
public boolean readChunk() throws IOException
{
final long rawTimestamp = chunkData.getInt();
// The timestamp is in seconds since January 1, 1904.
// We must convert to Java time.
final Date timestamp = AiffUtil.timestampToDate(rawTimestamp);
aiffHeader.setTimestamp(timestamp);
return true;
} |
Reads a chunk and extracts information.
@return <code>false</code> if the chunk is structurally
invalid, otherwise <code>true</code>
| FormatVersionChunk::readChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/FormatVersionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/FormatVersionChunk.java | Apache-2.0 |
public CopyrightChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkHeader, chunkData, aiffAudioHeader);
} |
@param chunkHeader The header for this chunk
@param chunkData The buffer from which the AIFF data are being read
@param aiffAudioHeader The AiffAudioHeader into which information is stored
| CopyrightChunk::CopyrightChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CopyrightChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CopyrightChunk.java | Apache-2.0 |
public TextChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkData, chunkHeader);
this.aiffAudioHeader = aiffAudioHeader;
} |
Constructor.
@param chunkHeader The header for this chunk
@param chunkData The buffer from which the AIFF data are being read
@param aiffAudioHeader aiff header
| TextChunk::TextChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/TextChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/TextChunk.java | Apache-2.0 |
protected String readChunkText() throws IOException {
// the spec actually only defines ASCII, not ISO_8859_1, but it probably does not hurt to be lenient
return Utils.getString(chunkData, 0, chunkData.remaining(), StandardCharsets.ISO_8859_1);
} |
Reads the chunk and transforms it to a {@link String}.
@return text string
@throws IOException if the read fails
| TextChunk::readChunkText | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/TextChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/TextChunk.java | Apache-2.0 |
public ApplicationChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkData, chunkHeader);
this.aiffHeader = aiffAudioHeader;
} |
Constructor.
@param chunkHeader The header for this chunk
@param chunkData The file from which the AIFF data are being read
@param aiffAudioHeader audio header
| ApplicationChunk::ApplicationChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ApplicationChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ApplicationChunk.java | Apache-2.0 |
public boolean readChunk() throws IOException
{
final String applicationSignature = Utils.readFourBytesAsChars(chunkData);
String applicationName = null;
/* If the application signature is 'pdos' or 'stoc',
* then the beginning of the data area is a Pascal
* string naming the application. Otherwise, we
* ignore the data. ('pdos' is for Apple II
* applications, 'stoc' for the entire non-Apple world.)
*/
if (SIGNATURE_STOC.equals(applicationSignature) || SIGNATURE_PDOS.equals(applicationSignature))
{
applicationName = Utils.readPascalString(chunkData);
}
aiffHeader.addApplicationIdentifier(applicationSignature + ": " + applicationName);
return true;
} |
Reads a chunk and puts an Application property into
the RepInfo object.
@return <code>false</code> if the chunk is structurally
invalid, otherwise <code>true</code>
| ApplicationChunk::readChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ApplicationChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ApplicationChunk.java | Apache-2.0 |
public ID3Chunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffTag tag)
{
super(chunkData, chunkHeader);
aiffTag = tag;
} |
Constructor.
@param chunkHeader The header for this chunk
@param chunkData The content of this chunk
@param tag The AiffTag into which information is stored
| ID3Chunk::ID3Chunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ID3Chunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ID3Chunk.java | Apache-2.0 |
private boolean isId3v2Tag(final ByteBuffer headerData) throws IOException
{
for (int i = 0; i < AbstractID3v2Tag.FIELD_TAGID_LENGTH; i++)
{
if (headerData.get() != AbstractID3v2Tag.TAG_ID[i])
{
return false;
}
}
return true;
} |
Reads 3 bytes to determine if the tag really looks like ID3 data.
| ID3Chunk::isId3v2Tag | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ID3Chunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/ID3Chunk.java | Apache-2.0 |
public CommonChunk(ChunkHeader hdr, ByteBuffer chunkData, AiffAudioHeader aiffAudioHeader)
{
super(chunkData, hdr);
aiffHeader = aiffAudioHeader;
} |
@param hdr
@param chunkData
@param aiffAudioHeader
| CommonChunk::CommonChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CommonChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CommonChunk.java | Apache-2.0 |
public NameChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkHeader, chunkData, aiffAudioHeader);
} |
@param chunkHeader The header for this chunk
@param chunkData The buffer from which the AIFF data are being read
@param aiffAudioHeader The AiffAudioHeader into which information is stored
| NameChunk::NameChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/NameChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/NameChunk.java | Apache-2.0 |
public SoundChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData)
{
super(chunkData, chunkHeader);
} |
@param chunkHeader The header for this chunk
@param chunkData The file from which the AIFF data are being read
| SoundChunk::SoundChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/SoundChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/SoundChunk.java | Apache-2.0 |
public boolean readChunk() throws IOException
{
return true;
} |
Reads a chunk and extracts information.
@return <code>false</code> if the chunk is structurally
invalid, otherwise <code>true</code>
| SoundChunk::readChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/SoundChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/SoundChunk.java | Apache-2.0 |
public CommentsChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkData, chunkHeader);
this.aiffHeader = aiffAudioHeader;
} |
@param chunkHeader The header for this chunk
@param chunkData The buffer from which the AIFF data are being read
@param aiffAudioHeader audio header
| CommentsChunk::CommentsChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CommentsChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CommentsChunk.java | Apache-2.0 |
public boolean readChunk() throws IOException
{
final int numComments = Utils.u(chunkData.getShort());
//For each comment
for (int i = 0; i < numComments; i++)
{
final long timestamp = Utils.u(chunkData.getInt());
final Date jTimestamp = AiffUtil.timestampToDate(timestamp);
final int marker = Utils.u(chunkData.getShort());
final int count = Utils.u(chunkData.getShort());
// Append a timestamp to the comment
final String text = Utils.getString(chunkData, 0, count, StandardCharsets.ISO_8859_1) + " " + AiffUtil.formatDate(jTimestamp);
if (count % 2 != 0) {
// if count is odd, text is padded with an extra byte that we need to consume
chunkData.get();
}
aiffHeader.addComment(text);
}
return true;
} |
Reads a chunk and extracts information.
@return <code>false</code> if the chunk is structurally
invalid, otherwise <code>true</code>
| CommentsChunk::readChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CommentsChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/CommentsChunk.java | Apache-2.0 |
public AuthorChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkHeader, chunkData, aiffAudioHeader);
} |
@param chunkHeader The header for this chunk
@param chunkData The buffer from which the AIFF data are being read
@param aiffAudioHeader The AiffAudioHeader into which information is stored
| AuthorChunk::AuthorChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AuthorChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AuthorChunk.java | Apache-2.0 |
public AnnotationChunk(final ChunkHeader chunkHeader, final ByteBuffer chunkData, final AiffAudioHeader aiffAudioHeader)
{
super(chunkHeader, chunkData, aiffAudioHeader);
} |
@param chunkHeader The header for this chunk
@param chunkData The buffer from which the AIFF data are being read
@param aiffAudioHeader The AiffAudioHeader into which information is stored
| AnnotationChunk::AnnotationChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AnnotationChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/aiff/chunk/AnnotationChunk.java | Apache-2.0 |
public ByteBuffer write()
{
ByteBuffer buffer = ByteBuffer.allocateDirect(DSD_HEADER_LENGTH);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.put(DsfChunkType.DSD.getCode().getBytes(StandardCharsets.US_ASCII));
buffer.putLong(chunkSizeLength);
buffer.putLong(fileLength);
buffer.putLong(metadataOffset);
buffer.flip();
return buffer;
} |
Write new DSDchunk to buffer
@return
| DsdChunk::write | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/dsf/DsdChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/dsf/DsdChunk.java | Apache-2.0 |
private Tag readTag(FileChannel fc, DsdChunk dsd, String fileName) throws CannotReadException,IOException
{
if(dsd.getMetadataOffset() > 0)
{
fc.position(dsd.getMetadataOffset());
ID3Chunk id3Chunk = ID3Chunk.readChunk(Utils.readFileDataIntoBufferLE(fc, (int) (fc.size() - fc.position())));
if(id3Chunk!=null)
{
int version = id3Chunk.getDataBuffer().get(AbstractID3v2Tag.FIELD_TAG_MAJOR_VERSION_POS);
try
{
switch (version)
{
case ID3v22Tag.MAJOR_VERSION:
return new ID3v22Tag(id3Chunk.getDataBuffer(), "");
case ID3v23Tag.MAJOR_VERSION:
return new ID3v23Tag(id3Chunk.getDataBuffer(), "");
case ID3v24Tag.MAJOR_VERSION:
return new ID3v24Tag(id3Chunk.getDataBuffer(), "");
default:
logger.log(Level.WARNING, fileName + " Unknown ID3v2 version " + version + ". Returning an empty ID3v2 Tag.");
return null;
}
}
catch (TagException e)
{
throw new CannotReadException(fileName + " Could not read ID3v2 tag:corruption");
}
}
else
{
logger.log(Level.WARNING, fileName + " No existing ID3 tag(1)");
return null;
}
}
else
{
logger.log(Level.WARNING, fileName + " No existing ID3 tag(2)");
return null;
}
} |
Reads the ID3v2 tag starting at the {@code tagOffset} position in the
supplied file.
@param fc the filechannel from which to read
@param dsd the dsd chunk
@param fileName
@return the read tag or an empty tag if something went wrong. Never
<code>null</code>.
@throws IOException if cannot read file.
| DsfFileReader::readTag | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/dsf/DsfFileReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/dsf/DsfFileReader.java | Apache-2.0 |
public ByteBuffer convert(final AbstractID3v2Tag tag) throws UnsupportedEncodingException
{
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
long existingTagSize = tag.getSize();
//If existingTag is uneven size lets make it even
if( existingTagSize > 0)
{
if(Utils.isOddLength(existingTagSize))
{
existingTagSize++;
}
}
//Write Tag to buffer
tag.write(baos, (int) existingTagSize);
//If the tag is now odd because we needed to increase size and the data made it odd sized
//we redo adding a padding byte to make it even
if((baos.toByteArray().length & 1)!=0)
{
int newSize = baos.toByteArray().length + 1;
baos = new ByteArrayOutputStream();
tag.write(baos, newSize);
}
final ByteBuffer buf = ByteBuffer.wrap(baos.toByteArray());
buf.rewind();
return buf;
}
catch (IOException ioe)
{
//Should never happen as not writing to file at this point
throw new RuntimeException(ioe);
}
} |
Convert ID3 tag into a ByteBuffer, also ensures always even to avoid problems
@param tag
@return
@throws UnsupportedEncodingException
| DsfFileWriter::convert | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/dsf/DsfFileWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/dsf/DsfFileWriter.java | Apache-2.0 |
DsfChunkType(final String code)
{
this.code=code;
} |
@param code 4 char string
| DsfChunkType::DsfChunkType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/dsf/DsfChunkType.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/dsf/DsfChunkType.java | Apache-2.0 |
public synchronized static DsfChunkType get(final String code) {
if (CODE_TYPE_MAP.isEmpty()) {
for (final DsfChunkType type : values()) {
CODE_TYPE_MAP.put(type.getCode(), type);
}
}
return CODE_TYPE_MAP.get(code);
} |
Get {@link org.jaudiotagger.audio.dsf.DsfChunkType} for code (e.g. "SSND").
@param code chunk id
@return chunk type or {@code null} if not registered
| DsfChunkType::get | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/dsf/DsfChunkType.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/dsf/DsfChunkType.java | Apache-2.0 |
public String getCode()
{
return code;
} |
4 char type code.
@return 4 char type code, e.g. "SSND" for the sound chunk.
| DsfChunkType::getCode | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/dsf/DsfChunkType.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/dsf/DsfChunkType.java | Apache-2.0 |
public FlacStreamReader(FileChannel fc, String loggingName)
{
this.fc = fc;
this.loggingName =loggingName;
} |
Create instance for holding stream info
@param fc
@param loggingName
| FlacStreamReader::FlacStreamReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacStreamReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacStreamReader.java | Apache-2.0 |
public void findStream() throws IOException, CannotReadException
{
//Begins tag parsing
if (fc.size() == 0)
{
//Empty File
throw new CannotReadException("Error: File empty"+ " " + loggingName);
}
fc.position(0);
//FLAC Stream at start
if (isFlacHeader())
{
startOfFlacInFile = 0;
return;
}
//Ok maybe there is an ID3v24tag first
if (isId3v2Tag())
{
startOfFlacInFile = (int) (fc.position() - FLAC_STREAM_IDENTIFIER_LENGTH);
return;
}
throw new CannotReadException(loggingName + ErrorMessage.FLAC_NO_FLAC_HEADER_FOUND.getMsg());
} |
Reads the stream block to ensure it is a flac file
@throws IOException
@throws CannotReadException
| FlacStreamReader::findStream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacStreamReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacStreamReader.java | Apache-2.0 |
public int getStartOfFlacInFile()
{
return startOfFlacInFile;
} |
Usually flac header is at start of file, but unofficially an ID3 tag is allowed at the start of the file.
@return the start of the Flac within file
| FlacStreamReader::getStartOfFlacInFile | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacStreamReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacStreamReader.java | Apache-2.0 |
public ByteBuffer convert(Tag tag, int paddingSize) throws UnsupportedEncodingException
{
logger.config("Convert flac tag:padding:" + paddingSize);
FlacTag flacTag = (FlacTag) tag;
int tagLength = 0;
ByteBuffer vorbiscomment = null;
if (flacTag.getVorbisCommentTag() != null)
{
vorbiscomment = creator.convert(flacTag.getVorbisCommentTag());
tagLength = vorbiscomment.capacity() + MetadataBlockHeader.HEADER_LENGTH;
}
for (MetadataBlockDataPicture image : flacTag.getImages())
{
tagLength += image.getBytes().limit() + MetadataBlockHeader.HEADER_LENGTH;
}
logger.config("Convert flac tag:taglength:" + tagLength);
ByteBuffer buf = ByteBuffer.allocate(tagLength + paddingSize);
MetadataBlockHeader vorbisHeader;
//If there are other metadata blocks
if (flacTag.getVorbisCommentTag() != null)
{
if ((paddingSize > 0) || (flacTag.getImages().size() > 0))
{
vorbisHeader = new MetadataBlockHeader(false, BlockType.VORBIS_COMMENT, vorbiscomment.capacity());
}
else
{
vorbisHeader = new MetadataBlockHeader(true, BlockType.VORBIS_COMMENT, vorbiscomment.capacity());
}
buf.put(vorbisHeader.getBytes());
buf.put(vorbiscomment);
}
//Images
ListIterator<MetadataBlockDataPicture> li = flacTag.getImages().listIterator();
while (li.hasNext())
{
MetadataBlockDataPicture imageField = li.next();
MetadataBlockHeader imageHeader;
if (paddingSize > 0 || li.hasNext())
{
imageHeader = new MetadataBlockHeader(false, BlockType.PICTURE, imageField.getLength());
}
else
{
imageHeader = new MetadataBlockHeader(true, BlockType.PICTURE, imageField.getLength());
}
buf.put(imageHeader.getBytes());
buf.put(imageField.getBytes());
}
//Padding
logger.config("Convert flac tag at" + buf.position());
if (paddingSize > 0)
{
int paddingDataSize = paddingSize - MetadataBlockHeader.HEADER_LENGTH;
MetadataBlockHeader paddingHeader = new MetadataBlockHeader(true, BlockType.PADDING, paddingDataSize);
MetadataBlockDataPadding padding = new MetadataBlockDataPadding(paddingDataSize);
buf.put(paddingHeader.getBytes());
buf.put(padding.getBytes());
}
buf.rewind();
return buf;
} |
@param tag
@param paddingSize extra padding to be added
@return
@throws UnsupportedEncodingException
| FlacTagCreator::convert | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagCreator.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagCreator.java | Apache-2.0 |
public int countMetaBlocks(File f) throws CannotReadException, IOException
{
try(FileChannel fc = FileChannel.open(f.toPath()))
{
FlacStreamReader flacStream = new FlacStreamReader(fc, f.toPath() + " ");
flacStream.findStream();
boolean isLastBlock = false;
int count = 0;
while (!isLastBlock)
{
MetadataBlockHeader mbh = MetadataBlockHeader.readHeader(fc);
logger.config(f + ":Found block:" + mbh.getBlockType());
fc.position(fc.position() + mbh.getDataLength());
isLastBlock = mbh.isLastBlock();
count++;
}
return count;
}
} |
Count the number of metadatablocks, useful for debugging
@param f
@return
@throws CannotReadException
@throws IOException
| FlacInfoReader::countMetaBlocks | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacInfoReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacInfoReader.java | Apache-2.0 |
public void delete(Tag tag, Path file) throws CannotWriteException
{
//This will save the file without any Comment or PictureData blocks
FlacTag emptyTag = new FlacTag(null, new ArrayList<MetadataBlockDataPicture>());
write(emptyTag, file);
} |
@param tag
@param file
@throws IOException
@throws CannotWriteException
| FlacTagWriter::delete | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
public void write(Tag tag, Path file) throws CannotWriteException
{
logger.config(file + " Writing tag");
try (FileChannel fc = FileChannel.open(file, StandardOpenOption.WRITE, StandardOpenOption.READ))
{
MetadataBlockInfo blockInfo = new MetadataBlockInfo();
//Read existing data
FlacStreamReader flacStream = new FlacStreamReader(fc, file.toString() + " ");
try
{
flacStream.findStream();
}
catch (CannotReadException cre)
{
throw new CannotWriteException(cre.getMessage());
}
boolean isLastBlock = false;
while (!isLastBlock)
{
try
{
MetadataBlockHeader mbh = MetadataBlockHeader.readHeader(fc);
if (mbh.getBlockType() != null)
{
switch (mbh.getBlockType())
{
case STREAMINFO:
{
blockInfo.streamInfoBlock = new MetadataBlock(mbh, new MetadataBlockDataStreamInfo(mbh, fc));
break;
}
case VORBIS_COMMENT:
case PADDING:
case PICTURE:
{
//All these will be replaced by the new metadata so we just treat as padding in order
//to determine how much space is already allocated in the file
fc.position(fc.position() + mbh.getDataLength());
MetadataBlockData mbd = new MetadataBlockDataPadding(mbh.getDataLength());
blockInfo.metadataBlockPadding.add(new MetadataBlock(mbh, mbd));
break;
}
case APPLICATION:
{
MetadataBlockData mbd = new MetadataBlockDataApplication(mbh, fc);
blockInfo.metadataBlockApplication.add(new MetadataBlock(mbh, mbd));
break;
}
case SEEKTABLE:
{
MetadataBlockData mbd = new MetadataBlockDataSeekTable(mbh, fc);
blockInfo.metadataBlockSeekTable.add(new MetadataBlock(mbh, mbd));
break;
}
case CUESHEET:
{
MetadataBlockData mbd = new MetadataBlockDataCueSheet(mbh, fc);
blockInfo.metadataBlockCueSheet.add(new MetadataBlock(mbh, mbd));
break;
}
default:
{
//What are the consequences of doing this
fc.position(fc.position() + mbh.getDataLength());
break;
}
}
}
isLastBlock = mbh.isLastBlock();
}
catch (CannotReadException cre)
{
throw new CannotWriteException(cre.getMessage());
}
}
//Number of bytes in the existing file available before audio data
int availableRoom = computeAvailableRoom(blockInfo);
//Minimum Size of the New tag data without padding
int newTagSize = tc.convert(tag).limit();
//Other blocks required size
int otherBlocksRequiredSize = computeNeededRoom(blockInfo);
//Number of bytes required for new tagdata and other metadata blocks
int neededRoom = newTagSize + otherBlocksRequiredSize;
//Go to start of Flac within file
fc.position(flacStream.getStartOfFlacInFile());
logger.config(file + ":Writing tag available bytes:" + availableRoom + ":needed bytes:" + neededRoom);
//There is enough room to fit the tag without moving the audio just need to
//adjust padding accordingly need to allow space for padding header if padding required
if ((availableRoom == neededRoom) || (availableRoom > neededRoom + MetadataBlockHeader.HEADER_LENGTH))
{
logger.config(file + ":Room to Rewrite");
//Jump over Id3 (if exists) and flac header
fc.position(flacStream.getStartOfFlacInFile() + FlacStreamReader.FLAC_STREAM_IDENTIFIER_LENGTH);
//Write stream info and other non metadata blocks
writeOtherMetadataBlocks(fc, blockInfo);
//Write tag (and padding)
fc.write(tc.convert(tag, availableRoom - neededRoom));
}
//Need to move audio
else
{
logger.config(file + ":Audio must be shifted "+ "NewTagSize:" + newTagSize + ":AvailableRoom:" + availableRoom + ":MinimumAdditionalRoomRequired:"+(neededRoom - availableRoom));
//As we are having to both anyway may as well put in the default padding
insertUsingChunks(file, tag, fc, blockInfo, flacStream, neededRoom + FlacTagCreator.DEFAULT_PADDING, availableRoom);
}
}
catch (AccessDeniedException ade)
{
logger.log(Level.SEVERE, ade.getMessage(), ade);
throw new NoWritePermissionsException(file + ":" + ade.getMessage());
}
catch (IOException ioe)
{
logger.log(Level.SEVERE, ioe.getMessage(), ioe);
throw new CannotWriteException(file + ":" + ioe.getMessage());
}
} |
@param tag
@param file
@throws CannotWriteException
@throws IOException
| MetadataBlockInfo::write | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
private void insertUsingDirectBuffer(Path file, Tag tag, FileChannel fc, MetadataBlockInfo blockInfo, FlacStreamReader flacStream, int availableRoom) throws IOException
{
//Find end of metadata blocks (start of Audio), i.e start of Flac + 4 bytes for 'fLaC', 4 bytes for streaminfo header and
//34 bytes for streaminfo and then size of all the other existing blocks
fc.position(flacStream.getStartOfFlacInFile()
+ FlacStreamReader.FLAC_STREAM_IDENTIFIER_LENGTH
+ MetadataBlockHeader.HEADER_LENGTH
+ MetadataBlockDataStreamInfo.STREAM_INFO_DATA_LENGTH
+ availableRoom);
//And copy into Buffer, because direct buffer doesnt use heap
ByteBuffer audioData = ByteBuffer.allocateDirect((int)(fc.size() - fc.position()));
fc.read(audioData);
audioData.flip();
//Jump over Id3 (if exists) Flac Header
fc.position(flacStream.getStartOfFlacInFile() + FlacStreamReader.FLAC_STREAM_IDENTIFIER_LENGTH);
writeOtherMetadataBlocks(fc, blockInfo);
//Write tag (and add some default padding)
fc.write(tc.convert(tag, FlacTagCreator.DEFAULT_PADDING));
//Write Audio
fc.write(audioData);
} |
Insert metadata into space that is not large enough, so have to shift existing audio data by copying into buffer
and the reinserting after adding the metadata
However this method requires a contiguous amount of memory equal to the size of the audio to be available and this
can cause a failure on low memory systems, so no longer used.
@param tag
@param fc
@param blockInfo
@param flacStream
@param availableRoom
@throws IOException
@throws UnsupportedEncodingException
| MetadataBlockInfo::insertUsingDirectBuffer | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
private void insertUsingChunks(Path file, Tag tag, FileChannel fc, MetadataBlockInfo blockInfo, FlacStreamReader flacStream, int neededRoom, int availableRoom) throws IOException, UnsupportedEncodingException
{
long originalFileSize = fc.size();
//Find end of metadata blocks (start of Audio), i.e start of Flac + 4 bytes for 'fLaC', 4 bytes for streaminfo header and
//34 bytes for streaminfo and then size of all the other existing blocks
long audioStart =flacStream.getStartOfFlacInFile()
+ FlacStreamReader.FLAC_STREAM_IDENTIFIER_LENGTH
+ MetadataBlockHeader.HEADER_LENGTH
+ MetadataBlockDataStreamInfo.STREAM_INFO_DATA_LENGTH
+ availableRoom;
//Extra Space Required for larger metadata block
int extraSpaceRequired = neededRoom - availableRoom;
logger.config(file + " Audio needs shifting:"+extraSpaceRequired);
//ChunkSize must be at least as large as the extra space required to write the metadata
int chunkSize = (int)TagOptionSingleton.getInstance().getWriteChunkSize();
if(chunkSize < extraSpaceRequired)
{
chunkSize = extraSpaceRequired;
}
Queue<ByteBuffer> queue = new LinkedBlockingQueue<>();
//Read first chunk of audio
fc.position(audioStart);
{
ByteBuffer audioBuffer = ByteBuffer.allocateDirect(chunkSize);
fc.read(audioBuffer);
audioBuffer.flip();
queue.add(audioBuffer);
}
long readPosition = fc.position();
//Jump over Id3 (if exists) and Flac Header
fc.position(flacStream.getStartOfFlacInFile() + FlacStreamReader.FLAC_STREAM_IDENTIFIER_LENGTH);
writeOtherMetadataBlocks(fc, blockInfo);
fc.write(tc.convert(tag, FlacTagCreator.DEFAULT_PADDING));
long writePosition = fc.position();
fc.position(readPosition);
while (fc.position() < originalFileSize)
{
//Read next chunk
ByteBuffer audioBuffer = ByteBuffer.allocateDirect(chunkSize);
fc.read(audioBuffer);
readPosition=fc.position();
audioBuffer.flip();
queue.add(audioBuffer);
//Write previous chunk
fc.position(writePosition);
fc.write(queue.remove());
writePosition=fc.position();
fc.position(readPosition);
}
fc.position(writePosition);
fc.write(queue.remove());
} |
Insert metadata into space that is not large enough
We do this by reading/writing chunks of data allowing it to work on low memory systems
Chunk size defined by TagOptionSingleton.getInstance().getWriteChunkSize()
@param tag
@param fc
@param blockInfo
@param flacStream
@param neededRoom
@param availableRoom
@throws IOException
@throws UnsupportedEncodingException
| MetadataBlockInfo::insertUsingChunks | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
private void insertTagAndShift(Path file, Tag tag, FileChannel fc, MetadataBlockInfo blockInfo, FlacStreamReader flacStream, int neededRoom, int availableRoom) throws IOException, UnsupportedEncodingException
{
int headerLength = flacStream.getStartOfFlacInFile() + FlacStreamReader.FLAC_STREAM_IDENTIFIER_LENGTH + MetadataBlockHeader.HEADER_LENGTH // this should be the length of the block header for the stream info
+ MetadataBlockDataStreamInfo.STREAM_INFO_DATA_LENGTH;
long targetSizeBeforeAudioData = headerLength + neededRoom + FlacTagCreator.DEFAULT_PADDING;
long remainderTargetSize = fc.size() - (headerLength + availableRoom);
long totalTargetSize = targetSizeBeforeAudioData + remainderTargetSize;
MappedByteBuffer mappedFile =null;
try
{
//Use ByteBuffer
mappedFile = fc.map(MapMode.READ_WRITE, 0, totalTargetSize);
insertTagAndShiftViaMappedByteBuffer(tag, mappedFile, fc, targetSizeBeforeAudioData, totalTargetSize, blockInfo, flacStream, neededRoom, availableRoom);
}
catch(IOException ioe)
{
//#175: Flac Map error on write
if(mappedFile==null)
{
insertUsingChunks(file, tag, fc, blockInfo, flacStream, neededRoom + FlacTagCreator.DEFAULT_PADDING, availableRoom);
}
else
{
logger.log(Level.SEVERE, ioe.getMessage(), ioe);
throw ioe;
}
}
} |
Insert new metadata into file by using memory mapped file, and if fails write in chunks
But this is problematic on 32bit systems for large flac files may not be able to map a contiguous address space large enough
for a large audio size , so no longer used since better to go straight to using chunks
@param tag
@param fc
@param blockInfo
@param flacStream
@param neededRoom
@param availableRoom
@throws IOException
@throws UnsupportedEncodingException
| MetadataBlockInfo::insertTagAndShift | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
private void insertTagAndShiftViaMappedByteBuffer(Tag tag, MappedByteBuffer mappedFile, FileChannel fc, long targetSizeBeforeAudioData, long totalTargetSize, MetadataBlockInfo blockInfo, FlacStreamReader flacStream, int neededRoom, int availableRoom) throws IOException, UnsupportedEncodingException
{
//Find end of metadata blacks (start of Audio)
int currentEndOfFilePosition = safeLongToInt(fc.size());
/*
* First shift data to the 'right' of the tag to the end of the file, whose position is currentEndOfTagsPosition
*/
int currentEndOfTagsPosition = safeLongToInt((targetSizeBeforeAudioData - FlacTagCreator.DEFAULT_PADDING) - neededRoom + availableRoom);
int lengthDiff = safeLongToInt(totalTargetSize - currentEndOfFilePosition);
final int BLOCK_SIZE = safeLongToInt(TagOptionSingleton.getInstance().getWriteChunkSize());
int currentPos = currentEndOfFilePosition - BLOCK_SIZE;
byte[] buffer = new byte[BLOCK_SIZE];
for (; currentPos >= currentEndOfTagsPosition; currentPos -= BLOCK_SIZE)
{
mappedFile.position(currentPos);
mappedFile.get(buffer, 0, BLOCK_SIZE);
mappedFile.position(currentPos + lengthDiff);
mappedFile.put(buffer, 0, BLOCK_SIZE);
}
/*
* Final movement of start bytes. This also covers cases where BLOCK_SIZE is larger than the audio data
*/
int remainder = (currentPos + BLOCK_SIZE) - currentEndOfTagsPosition;
if (remainder > 0)
{
mappedFile.position(currentEndOfTagsPosition);
mappedFile.get(buffer, 0, remainder);
mappedFile.position(currentEndOfTagsPosition + lengthDiff);
mappedFile.put(buffer, 0, remainder);
}
DirectByteBufferUtils.release(mappedFile);
/* Now overwrite the tag */
writeTags(tag, fc, blockInfo, flacStream);
} |
Insert new metadata into file by using memory mapped file
But this is problematic on 32bit systems for large flac files may not be able to map a contiguous address space large enough
for a large audio size , so no longer used
@param tag
@param mappedFile
@param fc
@param targetSizeBeforeAudioData
@param totalTargetSize
@param blockInfo
@param flacStream
@param neededRoom
@param availableRoom
@throws IOException
@throws UnsupportedEncodingException
| MetadataBlockInfo::insertTagAndShiftViaMappedByteBuffer | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
private void writeOtherMetadataBlocks(FileChannel fc, MetadataBlockInfo blockInfo) throws IOException
{
//Write StreamInfo, we always write this first even if wasn't first in original spec
fc.write(ByteBuffer.wrap(blockInfo.streamInfoBlock.getHeader().getBytesWithoutIsLastBlockFlag()));
fc.write(blockInfo.streamInfoBlock.getData().getBytes());
//Write Application Blocks
for (MetadataBlock aMetadataBlockApplication : blockInfo.metadataBlockApplication)
{
fc.write(ByteBuffer.wrap(aMetadataBlockApplication.getHeader().getBytesWithoutIsLastBlockFlag()));
fc.write(aMetadataBlockApplication.getData().getBytes());
}
//Write Seek Table Blocks
for (MetadataBlock aMetadataBlockSeekTable : blockInfo.metadataBlockSeekTable)
{
fc.write(ByteBuffer.wrap(aMetadataBlockSeekTable.getHeader().getBytesWithoutIsLastBlockFlag()));
fc.write(aMetadataBlockSeekTable.getData().getBytes());
}
//Write Cue sheet Blocks
for (MetadataBlock aMetadataBlockCueSheet : blockInfo.metadataBlockCueSheet)
{
fc.write(ByteBuffer.wrap(aMetadataBlockCueSheet.getHeader().getBytesWithoutIsLastBlockFlag()));
fc.write(aMetadataBlockCueSheet.getData().getBytes());
}
} |
Write all metadata blocks except for the the actual tag metadata
<p/>
We always write blocks in this order
@param fc
@param blockInfo
@throws IOException
| MetadataBlockInfo::writeOtherMetadataBlocks | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
private int computeAvailableRoom(MetadataBlockInfo blockInfo)
{
int length = 0;
for (MetadataBlock aMetadataBlockApplication : blockInfo.metadataBlockApplication)
{
length += aMetadataBlockApplication.getLength();
}
for (MetadataBlock aMetadataBlockSeekTable : blockInfo.metadataBlockSeekTable)
{
length += aMetadataBlockSeekTable.getLength();
}
for (MetadataBlock aMetadataBlockCueSheet : blockInfo.metadataBlockCueSheet)
{
length += aMetadataBlockCueSheet.getLength();
}
//Note when reading metadata has been put into padding as well for purposes of write
for (MetadataBlock aMetadataBlockPadding : blockInfo.metadataBlockPadding)
{
length += aMetadataBlockPadding.getLength();
}
return length;
} |
@param blockInfo
@return space currently available for writing all Flac metadatablocks except for StreamInfo which is fixed size
| MetadataBlockInfo::computeAvailableRoom | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
private int computeNeededRoom(MetadataBlockInfo blockInfo)
{
int length = 0;
for (MetadataBlock aMetadataBlockApplication : blockInfo.metadataBlockApplication)
{
length += aMetadataBlockApplication.getLength();
}
for (MetadataBlock aMetadataBlockSeekTable : blockInfo.metadataBlockSeekTable)
{
length += aMetadataBlockSeekTable.getLength();
}
for (MetadataBlock aMetadataBlockCueSheet : blockInfo.metadataBlockCueSheet)
{
length += aMetadataBlockCueSheet.getLength();
}
return length;
} |
@param blockInfo
@return space required to write the metadata blocks that are part of Flac but are not part of tagdata
in the normal sense.
| MetadataBlockInfo::computeNeededRoom | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/FlacTagWriter.java | Apache-2.0 |
public ByteBuffer getBytes()
{
return rawdata;
} |
@return the rawdata as it will be written to file
| MetadataBlockDataStreamInfo::getBytes | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | Apache-2.0 |
private int readThreeByteInteger(byte b1, byte b2, byte b3)
{
int rate = (Utils.u(b1) << 16) + (Utils.u(b2) << 8) + (Utils.u(b3));
return rate;
} |
SOme values are stored as 3 byte integrals (instead of the more usual 2 or 4)
@param b1
@param b2
@param b3
@return
| MetadataBlockDataStreamInfo::readThreeByteInteger | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | Apache-2.0 |
private int readSamplingRate()
{
int rate = (Utils.u(rawdata.get(10)) << 12) + (Utils.u(rawdata.get(11)) << 4) + ((Utils.u(rawdata.get(12)) & 0xF0) >>> 4);
return rate;
} |
Sampling rate is stored over 20 bits bytes 10 and 11 and half of bytes 12 so have to mask third one
@return
| MetadataBlockDataStreamInfo::readSamplingRate | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | Apache-2.0 |
private int readNoOfChannels()
{
return ((Utils.u(rawdata.get(12)) & 0x0E) >>> 1) + 1;
} |
Stored in 5th to 7th bits of byte 12
| MetadataBlockDataStreamInfo::readNoOfChannels | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | Apache-2.0 |
private int readBitsPerSample()
{
return ((Utils.u(rawdata.get(12)) & 0x01) << 4) + ((Utils.u(rawdata.get(13)) & 0xF0) >>> 4) + 1;
} |
Stored in 5th to 7th bits of byte 12
private int readNoOfChannels()
{
return ((Utils.u(rawdata.get(12)) & 0x0E) >>> 1) + 1;
}
/** Stored in last bit of byte 12 and first 4 bits of byte 13 | MetadataBlockDataStreamInfo::readBitsPerSample | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | Apache-2.0 |
private int readTotalNumberOfSamples()
{
int nb = Utils.u(rawdata.get(17));
nb += Utils.u(rawdata.get(16)) << 8;
nb += Utils.u(rawdata.get(15)) << 16;
nb += Utils.u(rawdata.get(14)) << 24;
nb += (Utils.u(rawdata.get(13)) & 0x0F) << 32;
return nb;
} | Stored in second half of byte 13 plus bytes 14 - 17
@return
| MetadataBlockDataStreamInfo::readTotalNumberOfSamples | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataStreamInfo.java | Apache-2.0 |
public MetadataBlockDataPicture(ByteBuffer rawdata) throws IOException, InvalidFrameException
{
initFromByteBuffer(rawdata);
} |
Initialize MetaBlockDataPicture from byteBuffer
@param rawdata
@throws IOException
@throws InvalidFrameException
| MetadataBlockDataPicture::MetadataBlockDataPicture | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public MetadataBlockDataPicture(byte[] imageData, int pictureType, String mimeType, String description, int width, int height, int colourDepth, int indexedColouredCount)
{
//Picture Type
this.pictureType = pictureType;
//MimeType
if(mimeType!=null)
{
this.mimeType = mimeType;
}
//Description
this.description = description;
this.width = width;
this.height = height;
this.colourDepth = colourDepth;
this.indexedColouredCount = indexedColouredCount;
//ImageData
this.imageData = imageData;
} |
Construct new MetadataPicture block
@param imageData
@param pictureType
@param mimeType
@param description
@param width
@param height
@param colourDepth
@param indexedColouredCount
| MetadataBlockDataPicture::MetadataBlockDataPicture | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public boolean isImageUrl()
{
return getMimeType().equals(IMAGE_IS_URL);
} |
@return true if imagedata is held as a url rather than actually being imagedata
| MetadataBlockDataPicture::isImageUrl | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public String getImageUrl()
{
if (isImageUrl())
{
return new String(getImageData(), StandardCharsets.ISO_8859_1);
}
else
{
return "";
}
} |
@return the image url if there is otherwise return an empty String
| MetadataBlockDataPicture::getImageUrl | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public void copyContent(TagField field)
{
throw new UnsupportedOperationException();
} |
This method copies the data of the given field to the current data.<br>
@param field The field containing the data to be taken.
| MetadataBlockDataPicture::copyContent | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public String getId()
{
return FieldKey.COVER_ART.name();
} |
Returns the Id of the represented tag field.<br>
This value should uniquely identify a kind of tag data, like title.
{@link org.jaudiotagger.audio.generic.AbstractTag} will use the "id" to summarize multiple
fields.
@return Unique identifier for the fields type. (title, artist...)
| MetadataBlockDataPicture::getId | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public byte[] getRawContent() throws UnsupportedEncodingException
{
return getBytes().array();
} |
This method delivers the binary representation of the fields data in
order to be directly written to the file.<br>
@return Binary data representing the current tag field.<br>
@throws java.io.UnsupportedEncodingException
Most tag data represents text. In some cases the underlying
implementation will need to convert the text data in java to
a specific charset encoding. In these cases an
{@link java.io.UnsupportedEncodingException} may occur.
| MetadataBlockDataPicture::getRawContent | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public boolean isBinary()
{
return true;
} |
Determines whether the represented field contains (is made up of) binary
data, instead of text data.<br>
Software can identify fields to be displayed because they are human
readable if this method returns <code>false</code>.
@return <code>true</code> if field represents binary data (not human
readable).
| MetadataBlockDataPicture::isBinary | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public void isBinary(boolean b)
{
//Do nothing, always true
} |
This method will set the field to represent binary data.<br>
Some implementations may support conversions.<br>
As of now (Octobre 2005) there is no implementation really using this
method to perform useful operations.
@param b <code>true</code>, if the field contains binary data.
@deprecated As for now is of no use. Implementations should use another
way of setting this property.
| MetadataBlockDataPicture::isBinary | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public boolean isCommon()
{
return true;
} |
Identifies a field to be of common use.<br>
Some software may differ between common and not common fields. A common
one is for sure the title field. A web link may not be of common use for
tagging. However some file formats, or future development of users
expectations will make more fields common than now can be known.
@return <code>true</code> if the field is of common use.
| MetadataBlockDataPicture::isCommon | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public boolean isEmpty()
{
return false;
} |
Determines whether the content of the field is empty.<br>
@return <code>true</code> if no data is stored (or empty String).
| MetadataBlockDataPicture::isEmpty | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockDataPicture.java | Apache-2.0 |
public static MetadataBlockHeader readHeader(FileChannel fc) throws CannotReadException, IOException
{
ByteBuffer rawdata = ByteBuffer.allocate(HEADER_LENGTH);
int bytesRead = fc.read(rawdata);
if (bytesRead < HEADER_LENGTH)
{
throw new IOException("Unable to read required number of databytes read:" + bytesRead + ":required:" + HEADER_LENGTH);
}
rawdata.rewind();
return new MetadataBlockHeader(rawdata);
} |
Create header by reading from file
@param fc
@return
@throws IOException
| MetadataBlockHeader::readHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockHeader.java | Apache-2.0 |
public MetadataBlockHeader(ByteBuffer rawdata) throws CannotReadException
{
isLastBlock = ((rawdata.get(0) & 0x80) >>> 7) == 1;
int type = rawdata.get(0) & 0x7F;
if (type < BlockType.values().length)
{
blockType = BlockType.values()[type];
dataLength = (u(rawdata.get(1)) << 16) + (u(rawdata.get(2)) << 8) + (u(rawdata.get(3)));
bytes = new byte[HEADER_LENGTH];
for (int i = 0; i < HEADER_LENGTH; i++)
{
bytes[i] = rawdata.get(i);
}
}
else
{
throw new CannotReadException(ErrorMessage.FLAC_NO_BLOCKTYPE.getMsg(type));
}
} |
Construct header by reading bytes
@param rawdata
| MetadataBlockHeader::MetadataBlockHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockHeader.java | Apache-2.0 |
public MetadataBlockHeader(boolean isLastBlock, BlockType blockType, int dataLength)
{
ByteBuffer rawdata = ByteBuffer.allocate(HEADER_LENGTH);
this.blockType = blockType;
this.isLastBlock = isLastBlock;
this.dataLength = dataLength;
byte type;
if (isLastBlock)
{
type = (byte) (0x80 | blockType.getId());
}
else
{
type = (byte) blockType.getId();
}
rawdata.put(type);
//Size is 3Byte BigEndian int
rawdata.put((byte) ((dataLength & 0xFF0000) >>> 16));
rawdata.put((byte) ((dataLength & 0xFF00) >>> 8));
rawdata.put((byte) (dataLength & 0xFF));
bytes = new byte[HEADER_LENGTH];
for (int i = 0; i < HEADER_LENGTH; i++)
{
bytes[i] = rawdata.get(i);
}
} |
Construct a new header in order to write metadatablock to file
@param isLastBlock
@param blockType
@param dataLength
| MetadataBlockHeader::MetadataBlockHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/flac/metadatablock/MetadataBlockHeader.java | Apache-2.0 |
private VbriFrame(ByteBuffer header)
{
this.header=header;
//Go to start of Buffer
header.rewind();
header.position(10);
setAudioSize();
setFrameCount();
} |
Read the VBRI Properties from the buffer
| VbriFrame::VbriFrame | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
private void setAudioSize()
{
byte[] frameSizeBuffer = new byte[VBRI_AUDIOSIZE_BUFFER_SIZE];
header.get(frameSizeBuffer);
boolean audioSizeEnabled = 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
| VbriFrame::setAudioSize | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
private void setFrameCount()
{
byte[] frameCountBuffer = new byte[VBRI_FRAMECOUNT_BUFFER_SIZE];
header.get(frameCountBuffer);
boolean frameCountEnabled = 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
| VbriFrame::setFrameCount | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
public final int getFrameCount()
{
return frameCount;
} |
@return count of frames
| VbriFrame::getFrameCount | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
public final int getAudioSize()
{
return audioSize;
} |
@return size of audio data in bytes
| VbriFrame::getAudioSize | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
public static VbriFrame parseVBRIFrame(ByteBuffer header) throws InvalidAudioFrameException
{
VbriFrame VBRIFrame = new VbriFrame(header);
return VBRIFrame;
} |
Parse the VBRIFrame of an MP3File, cannot be called until we have validated that
this is a VBRIFrame
@return
@throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
| VbriFrame::parseVBRIFrame | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
public static ByteBuffer isVbriFrame(ByteBuffer bb, MPEGFrameHeader mpegFrameHeader)
{
//We store this so can return here after scanning through buffer
int startPosition = bb.position();
MP3File.logger.finest("Checking VBRI Frame at" + startPosition);
bb.position(startPosition + VBRI_OFFSET);
//Create header from here
ByteBuffer header = bb.slice();
// Return Buffer to start Point
bb.position(startPosition);
//Check Identifier
byte[] identifier = new byte[VBRI_IDENTIFIER_BUFFER_SIZE];
header.get(identifier);
if ((!Arrays.equals(identifier, VBRI_VBR_ID)))
{
return null;
}
MP3File.logger.finest("Found VBRI Frame");
return header;
} |
IS this a VBRI frame
@param bb
@param mpegFrameHeader
@return raw header if this is a VBRI frame
| VbriFrame::isVbriFrame | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
public final boolean isVbr()
{
return true;
} |
Is this VBRIFrame detailing a varaible bit rate MPEG
@return
| VbriFrame::isVbr | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
public String toString()
{
return "VBRIheader" + " vbr:" + vbr + " frameCount:" + frameCount + " audioFileSize:" + audioSize + " encoder:" + getEncoder();
} |
@return a string represntation
| VbriFrame::toString | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/mp3/VbriFrame.java | Apache-2.0 |
public int getLayer()
{
return layer;
} |
Gets the layerVersion attribute of the MPEGFrame object
@return The layerVersion value
| MPEGFrameHeader::getLayer | 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 setCopyrighted()
{
isCopyrighted = (mpegBytes[BYTE_4] & MASK_MP3_COPY) != 0;
} |
Gets the copyrighted attribute of the MPEGFrame object
| MPEGFrameHeader::setCopyrighted | 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 setVersion() throws InvalidAudioFrameException
{
//MPEG Version
version = (byte) ((mpegBytes[BYTE_2] & MASK_MP3_VERSION) >> 3);
versionAsString = mpegVersionMap.get(version);
if (versionAsString == null)
{
throw new InvalidAudioFrameException("Invalid mpeg version");
}
} |
Set the version of this frame as an int value (see constants)
@throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
| MPEGFrameHeader::setVersion | 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 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.