I'm at a dead end right now . I searched and experimented with audio comparison. I found a lot of material and a ton of links to different libraries and methods for this.
At the moment, I took Audacity and exported a 3-minute wav file called "long.wav", and then split the first 30 seconds of this into a file called "short.wav". I decided that somewhere along the line I could visually log (log.txt) the data through java for each and should be able to see at least some visual similarity between the values .... here is some code
The main method:
int totalFramesRead = 0;
File fileIn = new File(filePath);
BufferedWriter writer = new BufferedWriter(new FileWriter(outPath));
writer.flush();
writer.write("");
try {
AudioInputStream audioInputStream =
AudioSystem.getAudioInputStream(fileIn);
int bytesPerFrame =
audioInputStream.getFormat().getFrameSize();
if (bytesPerFrame == AudioSystem.NOT_SPECIFIED) {
bytesPerFrame = 1;
}
int numBytes = 1024 * bytesPerFrame;
byte[] audioBytes = new byte[numBytes];
try {
int numBytesRead = 0;
int numFramesRead = 0;
while ((numBytesRead =
audioInputStream.read(audioBytes)) != -1) {
numFramesRead = numBytesRead / bytesPerFrame;
totalFramesRead += numFramesRead;
if(totalFramesRead <= 4096 * 100)
{
Complex[][] results = PerformFFT(audioBytes);
int[][] lines = GetKeyPoints(results);
DumpToFile(lines, writer);
}
}
} catch (Exception ex) {
}
audioInputStream.close();
} catch (Exception e) {
}
writer.close();
Then PerformFFT :
public static Complex[][] PerformFFT(byte[] data) throws IOException
{
final int totalSize = data.length;
int amountPossible = totalSize/Harvester.CHUNK_SIZE;
Complex[][] results = new Complex[amountPossible][];
for(int times = 0;times < amountPossible; times++) {
Complex[] complex = new Complex[Harvester.CHUNK_SIZE];
for(int i = 0;i < Harvester.CHUNK_SIZE;i++) {
complex[i] = new Complex(data[(times*Harvester.CHUNK_SIZE)+i], 0);
}
results[times] = FFT.fft(complex);
}
return results;
}
: audioBytes , FFT.
: , , log.txt wav . . , small.wav large.wav( ), wav byte [], Complex [] [] fft... - ..
, .
, , ! , , !