Esempio n. 1
0
    def test_Mix(self):
        self._sample_1.extract_channel(0)
        self._sample_2.extract_channel(0)

        formatter1 = ChannelFormatter(self._sample_1.get_channel(0))
        formatter1.set_framerate(16000)
        formatter1.set_sampwidth(2)
        formatter1.convert()

        formatter2 = ChannelFormatter(self._sample_2.get_channel(0))
        formatter2.set_framerate(16000)
        formatter2.set_sampwidth(2)
        formatter2.convert()

        mixer = ChannelsMixer()
        mixer.append_channel(formatter1.get_channel())
        mixer.append_channel(formatter2.get_channel())
        mixer.norm_length()

        self.assertEqual(mixer.get_channel(0).get_nframes(), mixer.get_channel(1).get_nframes())

        newchannel = mixer.mix()

        self.assertEqual(newchannel.get_nframes(), mixer.get_channel(0).get_nframes())
        self.assertEqual(newchannel.get_nframes(), mixer.get_channel(1).get_nframes())
Esempio n. 2
0
def normalize_channels( settings, p=None ):
    """
    Normalize the length of channels of the settings.

    @param settings: a list of dictionaries with extracted information from a settings file.
    @param p is a progress dialog

    """
    norm = ChannelsMixer()

    if p: p.update(0.25, "Load channels to normalize. ")
    for channel in settings:
        norm.append_channel( channel['channel'] )

    if p: p.update(0.50, "Normalize length of each channel... ")
    norm.norm_length()

    if p: p.update(0.90, "Save normalized channels. ")
    for i,channel in enumerate(settings):
        channel['channel'] = norm.get_channel(i)