android - getMaxAmplitude() alternative for Visualizer -


In my app I let the user record audio using the phone's camera while recording is in progress. The generalized form of getMaxAmplitude () for the time and value of y as value.

  float amp = Math.min (mRecorder.getMaxAmplitude (), mmx amplitude) / (float) mxaxupltid;  

It works well.

My problem occurs when I go back to audio (after transportation on the network). I want to recreate the generated waveform during the recording, but the same is not the same as getMaxAmplitude () method in the Media Player category.

The framework I'm trying to use the visualizer class, but having a hard time getting a useful result for the y value. Back-byte array contains values ​​between -128 and 127 but when I look at the actual values, they do not represent the wave, because I hope this should be.

How do I use values ​​returned from the visualizer to get the value associated with sound louds?

Your byte array is probably an array of 16, 24 or 32 bit signed values. Assuming that they have signed 16 bits, the bytes will change the Hi-byte and interview bit and lo-byte with MSB. Or, depending on the endurance, it can be low-byte after high bite. In addition, if you have two channels of data, then each sample is probably interlaced. Again, to handle 16-bit, you can decode the samples in a manner similar to this:

 For  (int i = 0; i & lt; numbytes / 2; + + I) {sample [i] = (bytes [i * 2]  

getMaxAmplitude , this gives the maximum absolute dimension which was the sample after the last call. I think it means the peak dimension, but it is not quite clear from the documentation. To calculate the peak dimension, simply calculate the maximum of the stomach of all samples.

  int maxPeak = 0.0; For (int i = 0; i & lt; numSamples; ++ i) {maxPeak = maximum (max pak, stomach (i []]); }  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -