Using apache's FFT to convert a .wav file to freq array

357
June 20, 2017, at 06:00 AM

Here's what i have so far:

InputStream is = AudioSystem.getAudioInputStream(new File("C:/users/barnao/desktop/uotm.wav"));
byte[] bytes = IOUtils.toByteArray(is);
short[] shorts = new short[bytes.length/2];
ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(shorts);
double[] vals = new double[shorts.length];
for (int i = 0; i < shorts.length; i++)
    vals[i] = (double) shorts[i];
FastFourierTransformer fft = new FastFourierTransformer(DftNormalization.STANDARD);
Complex[] freqs = fft.transform(vals, TransformType.FORWARD);

However i'm getting an error message that the input isn't a power of 2...

Exception in thread "main" org.apache.commons.math3.exception.MathIllegalArgumentException: 31,590,166 is not a power of 2, consider padding for fix

How do i fix this?

Rent Charter Buses Company
READ ALSO
How to avoid a NullPointerException from FaceContext in Junit tests?

How to avoid a NullPointerException from FaceContext in Junit tests?

My team and me made a Webapp in Spring as a project and we have to test most of our codeThe problem is that we use FaceContext messages in quite a lot of methods and always when we try to test those methods we get NullPointerException s at the FaceContext-Messages

720
Middleware with one ServerSocket or two ServerSockets

Middleware with one ServerSocket or two ServerSockets

I have implemeted app and server sideThe App has a Socket and the server side has a ServerSocket as well as socket to talk with the Android app

307
Firebase create account [on hold]

Firebase create account [on hold]

How can I create a program to create a Firebase account in my app? Now I can write my data into firebase but I dont know how to check if the account has been created or not

405
read/write to Windows Registry using Java

read/write to Windows Registry using Java

How is it possible to read/write to the Windows Registry using java?

1178