Package htw.ai.dln.utils
Class WavUtils
- java.lang.Object
-
- htw.ai.dln.utils.WavUtils
-
public class WavUtils extends java.lang.Object- Since:
- : 22.02.21
- Version:
- : 1.0
- Author:
- : Enrico Gamil Toros Project name : apt-decoder
-
-
Constructor Summary
Constructors Constructor Description WavUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int[]convertByteArray(byte[] audioData, int frameSize, boolean isBigEndian)Converts the byte array into an array of integers where each integer corresponds to an audio sample.static voidsaveAudio(byte[] audio, java.io.File outputFile, javax.sound.sampled.AudioFormat audioFormat)Save Wav Audio to given outputstatic byte[]stereoToMono(byte[] stereoAudio, int sampleSizeInBits)Convert stereo to mono (ignores second channel)
-
-
-
Method Detail
-
convertByteArray
public static int[] convertByteArray(byte[] audioData, int frameSize, boolean isBigEndian) throws UnsupportedFrameSizeExceptionConverts the byte array into an array of integers where each integer corresponds to an audio sample.- Parameters:
audioData- the audio data as bytesframeSize- size of framesisBigEndian- is big endian- Returns:
- the corresponding array of integers as samples
- Throws:
UnsupportedFrameSizeException- If the frame size is > 2
-
stereoToMono
public static byte[] stereoToMono(byte[] stereoAudio, int sampleSizeInBits)Convert stereo to mono (ignores second channel)- Parameters:
stereoAudio- audio bytes of stereo audiosampleSizeInBits- the size of a sample in bits- Returns:
- byte[] with one channel
-
saveAudio
public static void saveAudio(byte[] audio, java.io.File outputFile, javax.sound.sampled.AudioFormat audioFormat) throws java.io.IOExceptionSave Wav Audio to given output- Parameters:
audio- audio to saveoutputFile- output fileaudioFormat- audio format- Throws:
java.io.IOException- if any I/O errors
-
-