def filter_analog1():
    streamhandler = StreamHandler()
    
    # Configure and start
    dev = FakeMultiSignals(streamhandler = streamhandler)
    dev.configure(     nb_channel = 2,
                                sampling_rate =10000.,
                                buffer_length = 30.,
                                packet_size = 100,
                                last_channel_is_trig = True,
                                )
    dev.initialize()
    dev.start()

    dev2 = FakeDigital(streamhandler = streamhandler)
    dev2.configure( 
                                nb_channel = 30,
                                sampling_rate =10000.,
                                buffer_length = 30.,
                                packet_size = 100,
                                )
    dev2.initialize()
    dev2.start()

    
    
    
    filter = BandPassFilter(stream = dev.streams[0],
                                                streamhandler= streamhandler,
                                                autostart = False,
                                                f_start =0.,
                                                f_stop = dev.streams[0].sampling_rate/10./2.,
                                                )
    decimator = SimpleDecimator( filter.out_stream,
                                                streamhandler= streamhandler,
                                                downsampling_factor = 10,
                                                autostart = False,
                                                )

    decimator2 = SimpleDecimator( dev2.streams[0],
                                                streamhandler= streamhandler,
                                                downsampling_factor = 10,
                                                autostart = False,
                                                )
    print decimator2.out_stream._params
    
                                                
    app = QtGui.QApplication([])
    
    filter.start()
    decimator.start()
    decimator2.start()

    visibles = np.ones(dev.nb_channel, dtype = bool)
    visibles[1:] = False
    
    w1=Oscilloscope(stream = dev.streams[0])
    w2=Oscilloscope(stream = filter.out_stream)
    w3=Oscilloscope(stream = decimator.out_stream)
    
    w4 = OscilloscopeDigital(stream = dev2.streams[0])
    w5 = OscilloscopeDigital(stream = decimator2.out_stream)

    time.sleep(.5)
    
    
    for w in [w1, w2, w3]:
        w.auto_gain_and_offset(mode = 0)
        w.set_params(xsize = 1.,
                                        mode = 'scan',
                                        visibles = visibles,
                                        ylims = [-5,5]
                                        )
        w.show()
    
    for w in [w4, w5]:
        w.set_params(xsize = 1.,
                                        mode = 'scan',
                                        )
        w.show()
    
    
    
    
    app.exec_()
    w1.stop()
    w2.stop()
    
    
    dev.stop()

    dev.close()
def filter_analog1():
    streamhandler = StreamHandler()
    
    # Configure and start
    dev = FakeMultiSignals(streamhandler = streamhandler)
    dev.configure(     nb_channel = 64,
                                sampling_rate =10000.,
                                buffer_length = 30.,
                                packet_size = 100,
                                last_channel_is_trig = True,
                                )
    dev.initialize()
    dev.start()
    
    
    filter = BandPassFilter(stream = dev.streams[0],
                                                streamhandler= streamhandler,
                                                autostart = False)
    
    app = QtGui.QApplication([])
    
    filter.start()

    time.sleep(.2)
    filter.set_params(f_start = 300., f_stop =np.inf)
    time.sleep(.2)
    filter.set_params(f_start = 0., f_stop =40.3)
    time.sleep(.2)
    filter.set_params(f_start = 30., f_stop =70.)


    visibles = np.ones(dev.nb_channel, dtype = bool)
    visibles[1:] = False
    
    w1=Oscilloscope(stream = dev.streams[0])
    w2=Oscilloscope(stream = filter.out_stream)

    time.sleep(.5)
    
    
    for w in [w1, w2]:
        w.auto_gain_and_offset(mode = 0)
        w.set_params(xsize = 1.,
                                        mode = 'scan',
                                        visibles = visibles,
                                        ylims = [-5,5]
                                        )
        w.show()
    
    #~ w3=TimeFreq(stream = dev.streams[0])
    #~ w4=TimeFreq(stream = filter.out_stream)
    #~ for w in [w3, w4]:
        #~ w.set_params(colormap = 'hot', visibles = visibles, 
                                            #~ xsize=30, 
                                            #~ nb_column = 1)
        #~ w.show()
    
    
    
    app.exec_()
    w1.stop()
    w2.stop()
    
    
    dev.stop()

    dev.close()