unable to load resource 'sfd.ser'
Hey :) I know you don't do any more updates on this repo, but I try to ask anyway... I'm trying to use your lib to detect beats on an mp3 file i have already loaded on an android app i'm developing.
Here's how I use your lib :
int resId = getResources().getIdentifier("centquarante", "raw", getPackageName()); // The only way I found to access a file i stored in res/raw folder if this one; then I write it in the internal storage of the app to be able to use it. If there's another way, I'd love to know ! I've been struggling with this already...
File audioFile = new File(getFilesDir(), "centquarance.mp3");
try (InputStream inputStream = getResources().openRawResource(resId);
OutputStream outputStream = new FileOutputStream(audioFile)) {
byte[] buffer = new byte[4 * 1024];
int read;
while ((read = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, read);
}
Beat[] beats = BeatDetector.detectBeats(audioFile, BeatDetector.AudioType.MP3);
Arrays.stream(beats).forEach(beat -> logAction("Beat : "+beat.energy+" at "+beat.timeMs));
} catch (IOException e) {
throw new RuntimeException(e);
}
When I run the code, I get an exception in your lib :
java.lang.ExceptionInInitializerError
at v4lk.lwbd.decoders.processing.jlayer.SynthesisFilter.load_d(SynthesisFilter.java:1626)
at v4lk.lwbd.decoders.processing.jlayer.SynthesisFilter.<init>(SynthesisFilter.java:75)
at v4lk.lwbd.decoders.processing.jlayer.Decoder.initialize(Decoder.java:283)
at v4lk.lwbd.decoders.processing.jlayer.Decoder.decodeFrame(Decoder.java:138)
at v4lk.lwbd.decoders.JLayerMp3Decoder.fillBuffer(JLayerMp3Decoder.java:69)
at v4lk.lwbd.decoders.JLayerMp3Decoder.nextMonoFrame(JLayerMp3Decoder.java:44)
at v4lk.lwbd.BeatDetector$AudioFunctions.calculateSpectralFluxes(BeatDetector.java:41)
at v4lk.lwbd.BeatDetector.detectBeats(BeatDetector.java:202)
at v4lk.lwbd.BeatDetector.detectBeats(BeatDetector.java:293)
at v4lk.lwbd.BeatDetector.detectBeats(BeatDetector.java:262)
...
Caused by: java.io.IOException: unable to load resource 'sfd.ser'
at v4lk.lwbd.decoders.processing.jlayer.JavaLayerUtils.deserializeArrayResource(JavaLayerUtils.java:140)
at v4lk.lwbd.decoders.processing.jlayer.SynthesisFilter.load_d(SynthesisFilter.java:1621)
I don't really understand why this doesn't work. Do you have any idea what could be done to fix this ? Many thanks in advance, if you end-up seeing this :)
The library the issue occurs in, jlayer, is vendored into this project's source and is therefore 8 years out of date. Most likely something in Android that jlayer had an implicit dependency on has changed that is causing this obscure error.
But you're right, I don't update this repo at all, sorry for that. Wish you luck with your issue, and please comment if you solved it.