Ejemplo n.º 1
0
    def plot(self):
        ''' function to plot the level over time '''
        data = self.audiobuffer.newdata()

        r_m_s = dB(rms(data))

        self.stream_data[0:-1] = self.stream_data[1:]
        self.stream_data[-1] = r_m_s

        self.PlotSpek.read_array(self.stream_data)
Ejemplo n.º 2
0
    def plot(self, blocklength, plotflag=1):
        ''' function to plot the estimated power spectral densitiy '''

        # blocklength may be changed by user
        self.plotflag = plotflag
        self.blocklength = blocklength
        data = self.audiobuffer.newdata()

        # limitation of the blocklength to the next lower 2^n in case of
        # drainage of buffer
        if self.blocklength > len(data[0]):
            self.blocklength = 2 ** (self.nextpow2(len(data[0])))
            self.data = np.zeros(self.blocklength / 2)

        data = data[0][:self.blocklength]

        self.data_new = (abs(scipy.fft(data)))
        self.data_new = dB(self.data_new[:self.blocklength / 2])

        if self.blocklength != self.blocklength_old:
            self.data = np.zeros(self.blocklength / 2)
            self.must_plot = True


        # recursive power spectral density estimation
        self.data = (self.recursive_weight * self.data_new
                    + (1 - self.recursive_weight) * self.data)
        self.blocklength_old = self.blocklength

        if self.must_plot:

            # plotflag 0 sets the frequency axis to linear stepping
            if self.plotflag == 0:
                self.lines, = self.PlotSpek.axes.plot(np.linspace(0,
                                                     self.fs / 2,
                                                     len(self.data)),
                                                     self.data)

                self.PlotSpek.axes.set_xlim(0, self.fs / 2)
            # plotflag 1 sets the frequency axis to logarithmic stepping
            else:
                self.lines, = self.PlotSpek.axes.semilogx(np.linspace(0,
                                    self.fs / 4, len(self.data)), self.data)
                self.PlotSpek.axes.set_xlim(0, self.fs / 2)

            self.PlotSpek.axes.set_ylim(-100, 30)
            self.PlotSpek.axes.grid(True, which='both')
            self.must_plot = False
        else:
            self.lines.set_ydata(self.data - 20)

        self.PlotSpek.draw()
Ejemplo n.º 3
0
    def plot(self):
        ''' function for Plotting each channel gain as a bar plot'''

        data = self.audiobuffer.newdata()
        nchannel, _ = data.shape

        channel_dB = np.zeros((nchannel), float)
        #index = np.arange(nchannel)
        for i in range(nchannel):
            channel_dB[i] = dB(rms(data[i, :]))

        nchannel = np.arange(nchannel)

        self.PlotChannel.readArray(channel_dB, nchannel)
Ejemplo n.º 4
0
    def plot(self, blocklength, plotflag=1):
        ''' function to plot the estimated power spectral densitiy '''

        # blocklength may be changed by user
        self.plotflag = plotflag
        self.blocklength = blocklength
        data = self.audiobuffer.newdata()

        # limitation of the blocklength to the next lower 2^n in case of
        # drainage of buffer
        if self.blocklength > len(data[0]):
            self.blocklength = 2**(self.nextpow2(len(data[0])))
            self.data = np.zeros(self.blocklength / 2)

        data = data[0][:self.blocklength]

        self.data_new = (abs(scipy.fft(data)))
        self.data_new = dB(self.data_new[:self.blocklength / 2])

        if self.blocklength != self.blocklength_old:
            self.data = np.zeros(self.blocklength / 2)
            self.must_plot = True

        # recursive power spectral density estimation
        self.data = (self.recursive_weight * self.data_new +
                     (1 - self.recursive_weight) * self.data)
        self.blocklength_old = self.blocklength

        if self.must_plot:

            # plotflag 0 sets the frequency axis to linear stepping
            if self.plotflag == 0:
                self.lines, = self.PlotSpek.axes.plot(
                    np.linspace(0, self.fs / 2, len(self.data)), self.data)

                self.PlotSpek.axes.set_xlim(0, self.fs / 2)
            # plotflag 1 sets the frequency axis to logarithmic stepping
            else:
                self.lines, = self.PlotSpek.axes.semilogx(
                    np.linspace(0, self.fs / 4, len(self.data)), self.data)
                self.PlotSpek.axes.set_xlim(0, self.fs / 2)

            self.PlotSpek.axes.set_ylim(-100, 30)
            self.PlotSpek.axes.grid(True, which='both')
            self.must_plot = False
        else:
            self.lines.set_ydata(self.data - 20)

        self.PlotSpek.draw()
    def plot(self, weight):
        data = self.audiobuffer.newdata()
        ''' function to obtain and plot the third octave level '''
        self.weight = weight
        self.block = array(data, dtype=float64)
        self.thirdpow = []

        if self.weight == 1:
            self.frequenzbewertung = self.frequenzbewertung_a
        elif self.weight == 2:
            self.frequenzbewertung = self.frequenzbewertung_c
        else:
            self.frequenzbewertung = [0.0] * len(self.fc)

        # obtainment of the third octave levels
        for freq in range(len(self.fc)):
            freqpow = (dB(rms(lfilter(self.b[freq], self.a[freq],
                                     self.block[:])[0])) +
                                     self.frequenzbewertung[freq])
            self.thirdpow.append(freqpow)

        self.PlotSpektro.readArray(self.thirdpow)
    def plot(self, weight):
        data = self.audiobuffer.newdata()
        ''' function to obtain and plot the third octave level '''
        self.weight = weight
        self.block = array(data, dtype=float64)
        self.thirdpow = []

        if self.weight == 1:
            self.frequenzbewertung = self.frequenzbewertung_a
        elif self.weight == 2:
            self.frequenzbewertung = self.frequenzbewertung_c
        else:
            self.frequenzbewertung = [0.0] * len(self.fc)

        # obtainment of the third octave levels
        for freq in range(len(self.fc)):
            freqpow = (dB(
                rms(lfilter(self.b[freq], self.a[freq], self.block[:])[0])) +
                       self.frequenzbewertung[freq])
            self.thirdpow.append(freqpow)

        self.PlotSpektro.readArray(self.thirdpow)