Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

47
LINES

< > BotCompany Repo | #1016680 // EndianInputStream

JavaX fragment (include)

// from com.badlogic.audio.io

sclass EndianDataInputStream extends DataInputStream
{	
	*(InputStream in) { super(in); }

	public String read4ByteString( ) ctex
	{
		byte[] bytes = new byte[4];
		readFully(bytes);
		return new String( bytes, "US-ASCII" );
	}
	
	public short readShortLittleEndian( ) ctex
	{
		int result = readUnsignedByte();
		result |= readUnsignedByte() << 8;		
		return (short)result;		
	}
	
	public int readIntLittleEndian( ) ctex
	{
		int result = readUnsignedByte();
		result |= readUnsignedByte() << 8;
		result |= readUnsignedByte() << 16;
		result |= readUnsignedByte() << 24;
		return result;		
	}
	
	public int readInt24BitLittleEndian( ) ctex
	{
		int result = readUnsignedByte();
		result |= readUnsignedByte() << 8;
		result |= readUnsignedByte() << 16;
		if( (result & ( 1 << 23 )) == 8388608 )
			result |= 0xff000000;
		return result;		
	}
	
	public int readInt24Bit( ) ctex
	{
		int result = readUnsignedByte() << 16;
		result |= readUnsignedByte() << 8;
		result |= readUnsignedByte();		
		return result;		
	}
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016680
Snippet name: EndianInputStream
Eternal ID of this version: #1016680/1
Text MD5: b1de3d49ec80fc23ac385d8cd9c0b730
Author: stefan
Category: javax / sound
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-28 00:08:43
Source code size: 1096 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 341 / 971
Referenced in: [show references]