Summary of wavelets
https://en.wikipedia.org/wiki/Wavelet_transform
https://en.wikipedia.org/wiki/Discrete_wavelet_transform
Read the 2nd URL link... "One level of the transform" (i.e. a single level of the filterbank)
"Due to the decomposition process the input signal must be a multiple of 2^n where n is the number of levels."
Then read the Haar Wavelet java source...
```
public static int[] discreteHaarWaveletTransform(int[] input) {
// This function assumes that input.length=2^n, n>1
int[] output = new int[input.length];
for (int length = input.length / 2; ; length = length / 2) {
// length is the current length of the working area of the output array.
// length starts at half of the array size and every iteration is halved until it is 1.
for (int i = 0; i < length; ++i) {
int sum = input[i * 2] + input[i * 2 + 1];
int difference = input[i * 2] - input[i * 2 + 1];
output[i] = sum;
output[length + i] = difference;
}
if (length == 1) {
return output;
}
//Swap arrays to do next iteration
System.arraycopy(output, 0, input, 0, length);
}
}
```
You'll realise, that the DWT requires "N" levels (filterbanks) ... where the input (number of samples) is 2^N...
NB: The inner loop that calculates the sum and difference is particular for the "Haar Wavelet".
Depending on the mother wavelet chosen, this may be different equation/formula/algorithm.
That's all!