예제 #1
0
class SpectrographWidget(pg.PlotWidget):
    def __init__(self):
        super(SpectrographWidget, self).__init__()
        self.setLabel('bottom', 'Index', units='B')
        nPlots = 18
        nSamples = 500
        self.curves = []

        for i in range(nPlots):
            c = pg.PlotCurveItem(pen=(i, nPlots * 1.3))
            self.addItem(c)
            c.setPos(0, i * 6)
            self.curves.append(c)
            c.setData(np.zeros(nSamples))

        self.setYRange(0, nPlots * 6)
        self.setXRange(0, nSamples)

        self.buffer = np.zeros(nSamples)
        self.nPlots = nPlots

        self.filter = IIRFilter()


    def updateValue(self, newValue):
        self.buffer[:-1] = self.buffer[1:]
        self.buffer[-1] = newValue

        self.filter.update(newValue)

    def updateGUI(self):
        for i in range(self.nPlots):
            lo = float(i+0) / self.nPlots * 125.
            hi = float(i+1) / self.nPlots * 125.
            
            # Ugly workaround: Skip the bands containing 50 Hz and DC/Ultra Low Frequencies
            if i == 0 or (lo < 50 and hi > 50):
                print "pass", lo, hi
                continue

            foo = self.curves[i].getData()[1]
            foo[:-1] = foo[1:]
            foo[-1] = (self.filter.band(lo, hi) / 50)

            self.curves[i].setData(foo)
예제 #2
0
class SpectrographWidget(pg.PlotWidget):
    def __init__(self):
        super(SpectrographWidget, self).__init__()
        self.setLabel('bottom', 'Index', units='B')
        nPlots = 18
        nSamples = 500
        self.curves = []

        for i in range(nPlots):
            c = pg.PlotCurveItem(pen=(i, nPlots * 1.3))
            self.addItem(c)
            c.setPos(0, i * 6)
            self.curves.append(c)
            c.setData(np.zeros(nSamples))

        self.setYRange(0, nPlots * 6)
        self.setXRange(0, nSamples)

        self.buffer = np.zeros(nSamples)
        self.nPlots = nPlots

        self.filter = IIRFilter()

    def updateValue(self, newValue):
        self.buffer[:-1] = self.buffer[1:]
        self.buffer[-1] = newValue

        self.filter.update(newValue)

    def updateGUI(self):
        for i in range(self.nPlots):
            lo = float(i + 0) / self.nPlots * 125.
            hi = float(i + 1) / self.nPlots * 125.

            # Ugly workaround: Skip the bands containing 50 Hz and DC/Ultra Low Frequencies
            if i == 0 or (lo < 50 and hi > 50):
                print "pass", lo, hi
                continue

            foo = self.curves[i].getData()[1]
            foo[:-1] = foo[1:]
            foo[-1] = (self.filter.band(lo, hi) / 50)

            self.curves[i].setData(foo)
예제 #3
0
    def __init__(self):
        super(SpectrographWidget, self).__init__()
        self.setLabel('bottom', 'Index', units='B')
        nPlots = 18
        nSamples = 500
        self.curves = []

        for i in range(nPlots):
            c = pg.PlotCurveItem(pen=(i, nPlots * 1.3))
            self.addItem(c)
            c.setPos(0, i * 6)
            self.curves.append(c)
            c.setData(np.zeros(nSamples))

        self.setYRange(0, nPlots * 6)
        self.setXRange(0, nSamples)

        self.buffer = np.zeros(nSamples)
        self.nPlots = nPlots

        self.filter = IIRFilter()
예제 #4
0
    def __init__(self):
        super(SpectrographWidget, self).__init__()
        self.setLabel('bottom', 'Index', units='B')
        nPlots = 18
        nSamples = 500
        self.curves = []

        for i in range(nPlots):
            c = pg.PlotCurveItem(pen=(i, nPlots * 1.3))
            self.addItem(c)
            c.setPos(0, i * 6)
            self.curves.append(c)
            c.setData(np.zeros(nSamples))

        self.setYRange(0, nPlots * 6)
        self.setXRange(0, nSamples)

        self.buffer = np.zeros(nSamples)
        self.nPlots = nPlots

        self.filter = IIRFilter()
예제 #5
0
    pass


try:
    from mpd import MPDClient
    client = MPDClient()
    client.connect("localhost", 6600)

    def setMPDVolume(val):
        val = 100 - val
        val = np.min((np.max((val, 10)), 100))
        client.setvol(int(val))
except Exception, e:
    print "MPD error: ", e

iir0 = IIRFilter()
iir = IIRFilter()
iir2 = IIRFilter()
iir3 = IIRFilter()
iir4 = IIRFilter()


def update(channels):

    gridFilter.update(channels[0])

    iir0.update(channels[0])

    spectrogram.updateValue(gridFilter.ac)

    delta = iir0.band(0.5, 4)