Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

How Detect Correct Raw Data? #10

Open
saeedmozaffari opened this issue Oct 3, 2017 · 1 comment
Open

How Detect Correct Raw Data? #10

saeedmozaffari opened this issue Oct 3, 2017 · 1 comment
Labels

Comments

@saeedmozaffari
Copy link

saeedmozaffari commented Oct 3, 2017

Hi
i record voice in telegram and final wave form is like following image

b

but when i used from this audio for test app the result was like this!

a

my code is

byte[] soundBytes = null;
try {
    InputStream inputStream = getApplicationContext().getResources().openRawResource(R.raw.f);
    soundBytes = new byte[inputStream.available()];
    soundBytes = toByteArray(inputStream);
} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
waveView.setWaveColor(Color.parseColor("#007fff"));
waveView.setScaledData(soundBytes);
waveView.setRawData(soundBytes, new OnSamplingListener() {
    @Override
    public void onComplete() {
    }
});

How Detect Correct Raw Data?

@svenoaks
Copy link

svenoaks commented Dec 13, 2017

If "f" is an mp3 file or anything besides wav it won't be accurate, I don't know why author uses mp3 in demo app. Even with wav you should discard the first 44 bytes as it is the header.

Come to think of it, I'm not sure if anything but 8-bit pcm data would be accurate, for some reason library used byte[], I think it should be short[] for the typical 16-bit data. I guess you could divide short /2.

But I know if your array accurately represents the amplitudes of the song it will work.

Also why you call setScaledData, then setRawData, that is pointless I think.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants