本文整理汇总了Java中org.jaudiotagger.audio.generic.Utils.readFourBytesAsChars方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.readFourBytesAsChars方法的具体用法?Java Utils.readFourBytesAsChars怎么用?Java Utils.readFourBytesAsChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jaudiotagger.audio.generic.Utils
的用法示例。
在下文中一共展示了Utils.readFourBytesAsChars方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFileType
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Reads the file type ({@link AiffType}).
*
* @throws CannotReadException if the file type is not supported
*/
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);
}
}
示例2: readChunk
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* 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>
*/
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;
}
示例3: readChunk
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
*
* @return true if successfully read chunks
*
* @throws IOException
*/
public boolean readChunk() throws IOException
{
boolean result = false;
String subIdentifier = Utils.readFourBytesAsChars(chunkData);
if(subIdentifier.equals(WavChunkType.INFO.getCode()))
{
WavInfoChunk chunk = new WavInfoChunk(tag, loggingName);
result = chunk.readChunks(chunkData);
//This is the start of the enclosing LIST element
tag.getInfoTag().setStartLocationInFile(chunkHeader.getStartLocationInFile());
tag.getInfoTag().setEndLocationInFile(chunkHeader.getStartLocationInFile() + ChunkHeader.CHUNK_HEADER_SIZE + chunkHeader.getSize());
tag.setExistingInfoTag(true);
}
return result;
}
示例4: update
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Create header using headerdata, expected to find header at headerdata current position
*
* Note after processing adjusts position to immediately after header
*
* @param headerData
*/
public void update(ByteBuffer headerData)
{
//Read header data into byte array
byte[] b = new byte[HEADER_LENGTH];
headerData.get(b);
//Keep reference to copy of RawData
dataBuffer = ByteBuffer.wrap(b);
dataBuffer.order(ByteOrder.BIG_ENDIAN);
//Calculate box size and id
this.length = dataBuffer.getInt();
this.id = Utils.readFourBytesAsChars(dataBuffer);
logger.finest("Mp4BoxHeader id:"+id+":length:"+length);
if (id.equals("\0\0\0\0"))
{
throw new NullBoxIdException(ErrorMessage.MP4_UNABLE_TO_FIND_NEXT_ATOM_BECAUSE_IDENTIFIER_IS_INVALID.getMsg(id));
}
if(length<HEADER_LENGTH)
{
throw new InvalidBoxHeaderException(ErrorMessage.MP4_UNABLE_TO_FIND_NEXT_ATOM_BECAUSE_IDENTIFIER_IS_INVALID.getMsg(id,length));
}
}
示例5: readHeader
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* 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
*/
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);
}
}
示例6: readChunkHeader
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
public static FmtChunk readChunkHeader(ByteBuffer dataBuffer)
{
String type = Utils.readFourBytesAsChars(dataBuffer);
if (DsfChunkType.FORMAT.getCode().equals(type))
{
return new FmtChunk(dataBuffer);
}
return null;
}
示例7: readChunk
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
public static DsdChunk readChunk(ByteBuffer dataBuffer)
{
String type = Utils.readFourBytesAsChars(dataBuffer);
if (DsfChunkType.DSD.getCode().equals(type))
{
return new DsdChunk(dataBuffer);
}
return null;
}
示例8: readHeader
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Reads the header of a chunk.
*
* @return {@code true}, if we were able to read a chunk header and believe we found a valid chunk id.
*/
public boolean readHeader(final FileChannel fc) throws IOException
{
ByteBuffer header = ByteBuffer.allocate(CHUNK_HEADER_SIZE);
startLocationInFile = fc.position();
fc.read(header);
header.order(byteOrder);
header.position(0);
this.chunkId = Utils.readFourBytesAsChars(header);
this.size = header.getInt();
return true;
}
示例9: readChunk
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
@Override
public boolean readChunk() throws IOException
{
int numChannels = Utils.u(chunkData.getShort());
long numSamples = chunkData.getInt();
int bitsPerSample = Utils.u(chunkData.getShort());
double sampleRate = AiffUtil.read80BitDouble(chunkData);
//Compression format, but not necessarily compressed
String compressionType;
String compressionName;
if (aiffHeader.getFileType() == AiffType.AIFC)
{
// This is a rather special case, but testing did turn up
// a file that misbehaved in this way.
if (chunkData.remaining()==0)
{
return false;
}
compressionType = Utils.readFourBytesAsChars(chunkData);
if (compressionType.equals(AiffCompressionType.SOWT.getCode()))
{
aiffHeader.setEndian(AiffAudioHeader.Endian.LITTLE_ENDIAN);
}
compressionName = Utils.readPascalString(chunkData);
// Proper handling of compression type should depend
// on whether raw output is set
if (compressionType != null)
{
//Is it a known compression type
AiffCompressionType act = AiffCompressionType.getByCode(compressionType);
if (act != null)
{
compressionName = act.getCompression();
aiffHeader.setLossless(act.isLossless());
// we assume that the bitrate is not variable, if there is no compression
if (act == AiffCompressionType.NONE) {
aiffHeader.setVariableBitRate(false);
}
}
else
{
// We don't know compression type, so we have to assume lossy compression as we know we are using AIFC format
aiffHeader.setLossless(false);
}
if (compressionName.isEmpty())
{
aiffHeader.setEncodingType(compressionType);
}
else
{
aiffHeader.setEncodingType(compressionName);
}
}
}
//Must be lossless
else
{
aiffHeader.setLossless(true);
aiffHeader.setEncodingType(AiffCompressionType.NONE.getCompression());
// regular AIFF has no variable bit rate AFAIK
aiffHeader.setVariableBitRate(false);
}
aiffHeader.setBitsPerSample(bitsPerSample);
aiffHeader.setSamplingRate((int) sampleRate);
aiffHeader.setChannelNumber(numChannels);
aiffHeader.setPreciseLength((numSamples / sampleRate));
aiffHeader.setNoOfSamples(numSamples);
return true;
}
示例10: readChunks
import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
* Read Info chunk
* @param chunkData
*/
public boolean readChunks(ByteBuffer chunkData)
{
while(chunkData.remaining()>= IffHeaderChunk.TYPE_LENGTH)
{
String id = Utils.readFourBytesAsChars(chunkData);
//Padding
if(id.trim().isEmpty())
{
return true;
}
int size = chunkData.getInt();
if(
(!Character.isAlphabetic(id.charAt(0)))||
(!Character.isAlphabetic(id.charAt(1)))||
(!Character.isAlphabetic(id.charAt(2)))||
(!Character.isAlphabetic(id.charAt(3)))
)
{
logger.severe(loggingName + "LISTINFO appears corrupt, ignoring:"+id+":"+size);
return false;
}
String value =null;
try
{
value = Utils.getString(chunkData, 0, size, StandardCharsets.UTF_8);
}
catch(BufferUnderflowException bue)
{
logger.log(Level.SEVERE, loggingName + "LISTINFO appears corrupt, ignoring:"+bue.getMessage(), bue);
return false;
}
logger.config(loggingName + "Result:" + id + ":" + size + ":" + value + ":");
WavInfoIdentifier wii = WavInfoIdentifier.getByCode(id);
if(wii!=null && wii.getFieldKey()!=null)
{
try
{
wavInfoTag.setField(wii.getFieldKey(), value);
}
catch(FieldDataInvalidException fdie)
{
logger.log(Level.SEVERE, loggingName + fdie.getMessage(), fdie);
}
}
//Add unless just padding
else if(id!=null && !id.trim().isEmpty())
{
wavInfoTag.addUnRecognizedField(id, value);
}
//Each tuple aligned on even byte boundary
if (Utils.isOddLength(size) && chunkData.hasRemaining())
{
chunkData.get();
}
}
return true;
}