Home | History | Annotate | Download | only in audioquality
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
      5  * use this file except in compliance with the License. You may obtain a copy of
      6  * the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     13  * License for the specific language governing permissions and limitations under
     14  * the License.
     15  */
     16 
     17 #ifndef MEASURE_RMS_H
     18 #define MEASURE_RMS_H
     19 
     20 /* Measure the rms of the non-silence segment of the signal in pcm, which
     21    is of numSamples length, and sampled at sampleRate.  pcm is assumed to
     22    consist of silence - signal - silence, as might be logged during a
     23    speech recognition attempt.  The stimulus signal in this case should
     24    be approximately a 3-second burst of pink noise presented at a level
     25    comparable to normal speaking level.  The RMS is measured using 25ms
     26    duration non-overlapping windows.  These are averaged over the whole
     27    non-silence part of pcm, and the result is returned in rms.  The
     28    standard deviation of this measurement over all frames is returned in
     29    stdRms, and the estimated duration of the non-silence region, in
     30    seconds, is returned in duration.  The target signal is taken to be
     31    that segment that is onsetThresh dB above the background, and is
     32    expected to be continuous, once the onset has been found.  If
     33    onsetThresh < 0.0, simply make the measurememt over the entire pcm
     34    signal.  In both cases, the mean of the entire signal is returned in
     35    mean. */
     36 void measureRms(short* pcm, int numSamples, float sampleRate,
     37                 float onsetThresh, float* rms, float* stdRms,
     38                 float* mean, float* duration);
     39 
     40 
     41 #endif /* MEASURE_RMS_H */
     42