Class PcmUtil
java.lang.Object
de.pottgames.tuningfork.misc.PcmUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floataverageSample(byte[] input, PcmFormat format, int startSample, int endSample, int channel) Calculates the average amplitude of a slice of samples.static byte[]reverseAudio(byte[] pcmData, int sampleSizeInBytes) Reverses the audio data.
-
Constructor Details
-
PcmUtil
public PcmUtil()
-
-
Method Details
-
reverseAudio
public static byte[] reverseAudio(byte[] pcmData, int sampleSizeInBytes) Reverses the audio data.- Parameters:
pcmData- the source array of pcm datasampleSizeInBytes- the bytes per sample- Returns:
- the reversed audio data
-
averageSample
public static float averageSample(byte[] input, PcmFormat format, int startSample, int endSample, int channel) Calculates the average amplitude of a slice of samples. The result is always in the range 0 - 1. With 0 equals silence and 1 equals full amplitude.- Parameters:
input- the input byte array containing the samplesformat- the data format of the input byte arraystartSample- the start index of the desired sliceendSample- the end index of the desired slicechannel- the channel number samples will be read from- Returns:
- the average amplitude of all samples in the slice in the range 0 - 1
-