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

47
LINES

< > BotCompany Repo | #1016680 // EndianInputStream

JavaX fragment (include)

1  
// from com.badlogic.audio.io
2  
3  
sclass EndianDataInputStream extends DataInputStream
4  
{	
5  
	*(InputStream in) { super(in); }
6  
7  
	public String read4ByteString( ) ctex
8  
	{
9  
		byte[] bytes = new byte[4];
10  
		readFully(bytes);
11  
		return new String( bytes, "US-ASCII" );
12  
	}
13  
	
14  
	public short readShortLittleEndian( ) ctex
15  
	{
16  
		int result = readUnsignedByte();
17  
		result |= readUnsignedByte() << 8;		
18  
		return (short)result;		
19  
	}
20  
	
21  
	public int readIntLittleEndian( ) ctex
22  
	{
23  
		int result = readUnsignedByte();
24  
		result |= readUnsignedByte() << 8;
25  
		result |= readUnsignedByte() << 16;
26  
		result |= readUnsignedByte() << 24;
27  
		return result;		
28  
	}
29  
	
30  
	public int readInt24BitLittleEndian( ) ctex
31  
	{
32  
		int result = readUnsignedByte();
33  
		result |= readUnsignedByte() << 8;
34  
		result |= readUnsignedByte() << 16;
35  
		if( (result & ( 1 << 23 )) == 8388608 )
36  
			result |= 0xff000000;
37  
		return result;		
38  
	}
39  
	
40  
	public int readInt24Bit( ) ctex
41  
	{
42  
		int result = readUnsignedByte() << 16;
43  
		result |= readUnsignedByte() << 8;
44  
		result |= readUnsignedByte();		
45  
		return result;		
46  
	}
47  
}

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: 416 / 1047
Referenced in: [show references]