public final class AudioUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static double |
audioLevelToDoubleRange(double audioLevel)
Converts the audio level to double in range [0, 1]
|
static short |
bytesToShort(byte b1,
byte b2)
Converts two bytes to one short
|
static short[] |
bytesToShorts(byte[] bytes)
Converts bytes to shorts
|
static double |
calculateAudioLevel(byte[] samples,
int offset,
int length)
Calculates the audio level
|
static double |
calculateAudioLevel(short[] samples,
int offset,
int length)
Calculates the audio level
|
static double |
calculateAudioLevelFromRMS(double rms,
int sampleCount)
Calculates the audio level from RMS and samples count
|
static double |
calculateHighestAudioLevel(short[] samples)
Gets the highest audio level in the samples
|
static boolean |
containsMinAudioLevel(byte[] samples,
double minAudioLevel)
Checks if any sample audio level greater than the min audio level
|
static boolean |
containsMinAudioLevel(short[] samples,
double minAudioLevel)
Checks if any sample audio level greater than the min audio level
|
static byte[] |
convertToMonoBytes(short[] samples)
Converts stereo samples to mono bytes
|
static short[] |
convertToMonoShorts(short[] samples)
Converts stereo samples to mono shorts
|
static float |
dbToMul(float db) |
static double |
doubleRangeToAudioLevel(double value)
Converts the double in range [0, 1] to audio level
|
static short[] |
floatsToShorts(float[] floats)
Converts floats to shorts
|
static float |
gainCoefficient(int sampleRate,
float time) |
static short |
getHighestAbsoluteSample(short[] samples)
Gets the highest absolute sample
|
static float |
mulToDB(float mul) |
static byte[] |
shortsToBytes(short[] shorts)
Converts shorts to bytes
|
static float[] |
shortsToFloats(short[] input)
Converts shorts to float
|
static byte[] |
shortToBytes(short s)
Converts one short to two byte
|
public static short[] bytesToShorts(byte[] bytes)
public static byte[] shortsToBytes(short[] shorts)
public static short bytesToShort(byte b1,
byte b2)
public static byte[] shortToBytes(short s)
public static short[] floatsToShorts(float[] floats)
public static float[] shortsToFloats(short[] input)
public static boolean containsMinAudioLevel(byte[] samples,
double minAudioLevel)
public static boolean containsMinAudioLevel(short[] samples,
double minAudioLevel)
public static double calculateAudioLevel(byte[] samples,
int offset,
int length)
samples - the samplesoffset - offset from the start of the samples arraylength - count of samples to process the calculationpublic static double calculateAudioLevel(short[] samples,
int offset,
int length)
samples - the samplesoffset - offset from the start of the samples arraylength - count of samples to process the calculationpublic static double calculateAudioLevelFromRMS(double rms,
int sampleCount)
rms - root mean squaresampleCount - count of samplespublic static double calculateHighestAudioLevel(short[] samples)
samples - the samplespublic static double audioLevelToDoubleRange(double audioLevel)
public static double doubleRangeToAudioLevel(double value)
public static byte[] convertToMonoBytes(short[] samples)
public static short[] convertToMonoShorts(short[] samples)
public static short getHighestAbsoluteSample(short[] samples)
public static float mulToDB(float mul)
public static float dbToMul(float db)
public static float gainCoefficient(int sampleRate,
float time)