def test_CreateSilence(self):
     self._sample_1.extract_channel(0)
     self._sample_2.extract_channel(0)
     
     channel = self._sample_1.get_channel(0)
     extracter = ChannelFragmentExtracter(channel)
     newchannel = extracter.extract_fragment(1*channel.get_framerate(),2*channel.get_framerate())
     self.assertEqual(newchannel.get_nframes()/newchannel.get_framerate(), 1)
Пример #2
0
def fragment_channels( settings, begin, end, p=None ):
    """
    Fragment channels of the settings.
    @param settings: a list of dictionaries with extracted information from a settings file.
    @param p is a progress dialog

    """

    for channel in settings:
        extracter = ChannelFragmentExtracter(channel['channel'])
        channel['channel'] = extracter.extract_fragment(begin*channel['channel'].get_framerate(), end*channel['channel'].get_framerate())
        del extracter
Пример #3
0
audio = signals.open(args.w)

if args.bf and args.bs:
    print "bf option and bs option can't be used at the same time !"
    sys.exit(1)

if args.ef and args.es:
    print "ef option and es option can't be used at the same time !"
    sys.exit(1)

if args.bf:
    begin = args.bf
elif args.bs:
    begin = args.bs*audio.get_framerate()
else:
    begin = 0
if args.ef:
    end = args.ef
elif args.es:
    end = args.es*audio.get_framerate()
else:
    end = 0

for i in xrange(audio.get_nchannels()):
    idx = audio.extract_channel(i)
    audio.rewind()
    channel = audio.get_channel(idx)
    extracter = ChannelFragmentExtracter(channel)
    audio_out.append_channel(extracter.extract_fragment(begin, end))
    
signals.save(args.o, audio_out)