[autotest] audio_data: Add method to query maximum value from format

The maximum value a sample can hold is needed to normalize the audio
data to [-1, 1] so we can better analyze the RMS value to be meaningful
or not.

BUG=chromium:550395
TEST=not used yet.

Change-Id: Icb216546f78318fb35a95be3d2c38ffaea3cc85f
Reviewed-on: https://chromium-review.googlesource.com/313074
Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Rohit Makasana <rohitbm@chromium.org>
diff --git a/client/cros/audio/audio_data.py b/client/cros/audio/audio_data.py
index b0f67d4..3cc150d 100644
--- a/client/cros/audio/audio_data.py
+++ b/client/cros/audio/audio_data.py
@@ -30,6 +30,18 @@
                 size_bytes=2))
 
 
+def get_maximum_value_from_sample_format(sample_format):
+    """Gets the maximum value from sample format.
+
+    @param sample_format: A key in SAMPLE_FORMAT.
+
+    @returns: The maximum value the sample can hold + 1.
+
+    """
+    size_bits = SAMPLE_FORMATS[sample_format]['size_bytes'] * 8
+    return 1 << (size_bits - 1)
+
+
 class AudioRawDataError(Exception):
     """Error in AudioRawData."""
     pass