rsenthilk
rsenthilk

Reputation: 95

Audio waveform in java finished coding but readings are different for waveform

I have captured audio from mic and drawn a waveform of the recording, my doubt is will the waveform readings will be between -1+1 or +5-5 ?? my readings are between like 1000's.. could some one help??

Using code from internet (eg:SamplingGraph.java, CapturePlayback.java) i completed this.,

After recording i scaled and drawn waveform and scale readings in Jpanel., but the highest and lowest values of the waveform are like 3000 and -1890 some thing like tat.,

Upvotes: 0

Views: 411

Answers (1)

mwengler
mwengler

Reputation: 2778

Samples from microphone are almost always short type which are integers that range from -32768..+32767. This seems consistent with the values you are seeing. If you want them as doubles ranging from -1 to 1 fix them in a loop

double[] dSamples = new double[iSamples.length];

for (int i=0:i<iSamples.length:i++) {
    dSamples[i] = iSamples[i] / 32768.0d;
}

Upvotes: 1

Related Questions