private void readFromFilePath_ReadChunks_Data(DataInputStreamLittleEndian reader) throws IOException { byte[] data = new byte[4]; reader.read(data); int subchunk2Size = reader.readInt(); byte[] samplesForChannelsMixedAsBytes = new byte[subchunk2Size]; reader.read(samplesForChannelsMixedAsBytes); Sample[][] samplesForChannels = Sample.buildManyFromBytes(samplingInfo, samplesForChannelsMixedAsBytes); this.samplesForChannels = samplesForChannels; }
private void readFromFilePath_ReadChunks(DataInputStreamLittleEndian reader) throws IOException { byte[] riff = new byte[4]; reader.read(riff); int numberOfBytesInFile = reader.readInt(); byte[] wave = new byte[4]; reader.read(wave); this.readFromFilePath_ReadChunks_Format(reader); this.readFromFilePath_ReadChunks_Data(reader); }
public static WavFile readFromFilePath( String filePathToReadFrom, boolean[] key1, boolean[] key2) { WavFile returnValue = new WavFile(filePathToReadFrom, null, null); key = key1; IV = key2; try { DataInputStream dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(filePathToReadFrom))); DataInputStreamLittleEndian reader; reader = new DataInputStreamLittleEndian(dataInputStream); returnValue.readFromFilePath_ReadChunks(reader); reader.close(); } catch (IOException ex) { ex.printStackTrace(); } return returnValue; }
private void readFromFilePath_ReadChunks_Format(DataInputStreamLittleEndian reader) throws IOException { byte[] fmt = new byte[4]; reader.read(fmt); int chunkSizeInBytes = reader.readInt(); Short formatCode = reader.readShort(); Short numberOfChannels = reader.readShort(); int samplesPerSecond = reader.readInt(); int bytesPerSecond = reader.readInt(); Short bytesPerSampleMaybe = reader.readShort(); Short bitsPerSample = reader.readShort(); SamplingInfo samplingInfo = new SamplingInfo( "[from file]", chunkSizeInBytes, formatCode, numberOfChannels, samplesPerSecond, bitsPerSample); this.samplingInfo = samplingInfo; }