changeset 148:2a1054f9d9f3

Add tests for _extract_selected_channel with channel mixing
author Amine Sehili <amine.sehili@gmail.com>
date Wed, 20 Feb 2019 21:17:21 +0100
parents 90dd15daf373
children 81413c14c5bb
files tests/test_io.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_io.py	Wed Feb 20 20:52:44 2019 +0100
+++ b/tests/test_io.py	Wed Feb 20 21:17:21 2019 +0100
@@ -263,6 +263,22 @@
         )
         self.assertEqual(selected_channel, expected)
 
+    @genty_dataset(mono=([400],), three_channel=([600, 1150, 2400],))
+    def test_extract_selected_channel_mix(self, frequencies):
+
+        mono_channels = [PURE_TONE_DICT[freq] for freq in frequencies]
+        channels = len(frequencies)
+        fmt = DATA_FORMAT[2]
+        expected = _array_to_bytes(
+            array(
+                fmt,
+                (sum(samples) // channels for samples in zip(*mono_channels)),
+            )
+        )
+        data = _array_to_bytes(array(fmt, _sample_generator(*mono_channels)))
+        selected_channel = _extract_selected_channel(data, channels, 2, "mix")
+        self.assertEqual(selected_channel, expected)
+
     @genty_dataset(
         raw_with_audio_format=(
             "audio",