# HG changeset patch # User Amine Sehili # Date 1550693841 -3600 # Node ID 2a1054f9d9f36591f83a4f1dfe02445830c689b1 # Parent 90dd15daf373aa89625bbc5ea2896e789421eeaf Add tests for _extract_selected_channel with channel mixing diff -r 90dd15daf373 -r 2a1054f9d9f3 tests/test_io.py --- 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",