Closed plinioseniore closed 9 years ago
This is somehow feasible, but the frequencies will be limited to 3: bass, med and high
The goal is get control over frequencies, we need one entry for frequency in the array
From Mobile.
The magnitude algorithm we wrote together is written to treat three frequencies, I don't know how to edit that method to be fully dynamic on the FFT array:
that code is part of "it works but I don't know how" :)
I don't know how a checkbox looks like into Android, assuming that's an array of 0 and 1 for each available selection, we should have one checkbox array for each color R, G and B.
The code will then result as
for (int i = 0; i < data.lenght / 2; i++) {// half part is imaginary
if(red_checkbox(i)) {
byte rfk = data[2 * i];
byte ifk = data[2 * (i + 1)];
float magnitude_low = (rfk * rfk + ifk * ifk);
dbValue_low += magnitude_low;
}
if(green_checkbox(i)) {
// MEDI
rfk = data[2 * i];
ifk = data[ 2 * (i + 1)];
float magnitude_med = (rfk * rfk + ifk * ifk);
dbValue_medium += magnitude_med;
}
if(blue_checkbox(i)) {
// ALTI
rfk = data[ 2 * i];
ifk = data[2 * (i + 1)];
float magnitude_high = (rfk * rfk + ifk * ifk);
dbValue_high += magnitude_high;
}
}
We should then get the frequencies value to be displayed in the selection list.
Yes it's an array. But how long? I have to draw it, I have to know before
Are we using this? If so:
The capture is an 8-bit magnitude FFT, the frequency range covered being 0 (DC) to half of the sampling rate returned by getSamplingRate(). The capture returns the real and imaginary parts of a number of frequency points equal to half of the capture size plus one.
The capture size is getCaptureSize () and is set with setCaptureSize (int size), with the following note: Sets the capture size, i.e. the number of bytes returned by getWaveForm(byte[]) and getFft(byte[]) methods. The capture size must be a power of 2 in the range returned by getCaptureSizeRange(). This method must not be called when the Visualizer is enabled.
So we should set a capture size at startup of the application, we may try with 2^4 captures. In that case the frequency of each sample will be (k*Fs)/(n/2) where Fs is getSamplingRate ().
I had a talk with a friends that knows a bit in music synch and similars and he suggested to have the ability to configure the frequency that we would match with the relevant primary color.
In SoulissApp, we need an additional configuration pane like this with checkboxes:
In this way we can select which frequency for each color, and so:
n_red = sum of frequency selected for R red = R_equalizer * R_costant * (Frequency 1 / MAX_Frequency + Frequency2 / MAX Frequency + ... ) / n_red.
In this way we can get a more customizable synch and better result.