def set_channels(self, channels):
        ''' Add buffer per channel '''
        self.channels = channels
        for i in range(min(self.channels, self.MAX_GRAPHS)):
            self.graph_show_state[i] = True
            self.Xstart[i] = 0
            self.Ystart[i] = 0
            self.Xend[i] = 1150
            self.Yend[i] = 750
            self.type[i] = 0
            if i == 0:
                self.color[i] = self.activity.stroke_color
            elif i == 1:
                self.color[i] = self.activity.fill_color
            else:
                self.color[i] = '#FFFFFF'
            self.source[i] = 0

        for i in range(self.channels):
            self.ringbuffer.append(
                RingBuffer1d(self.max_samples, dtype='int16'))
            self.y_mag.append(3.0)
            self.gain.append(1.0)
            self.bias.append(0)
            self.invert.append(False)
 def set_max_samples(self, num):
     """ Maximum no. of samples in ringbuffer """
     if self.max_samples == num:
         return
     for i in range(self.channels):
         new_buffer = RingBuffer1d(num, dtype='int16')
         new_buffer.append(self.ringbuffer[i].read())
         self.ringbuffer[i] = new_buffer
     self.max_samples = num
     return
示例#3
0
 def limpiar_canales(self):
     for i in range(self.audiograb.channels):
         self.wave.ringbuffer[i] = RingBuffer1d(self.wave.max_samples,
                                                dtype='int16')
         self.wave.new_buffer([0], i)
    def __init__(self, msr, playsound, input_frequency=48000):
        """ Initialize drawing area and scope parameter """
        gtk.DrawingArea.__init__(self)

        self.add_events(gtk.gdk.BUTTON_PRESS_MASK | \
                        gtk.gdk.PROPERTY_CHANGE_MASK)

        self.activity = msr
        self.soundplayer = playsound
        self.vrg = 0
        self.topCount = 0
        self.inTop = -6
        self.playingTop = 0
        self.bottomCount = 0
        self.inBottom = -6
        self.playingBottom = 0

        self._input_freq = input_frequency
        self.triggering = self.TRIGGER_NONE
        self.trigger_xpos = 0.0
        self.trigger_ypos = 0.5

        self.active = False
        self._redraw_atom = gtk.gdk.atom_intern('MeasureRedraw')

        self.buffers = array([])
        self.main_buffers = array([])
        self.str_buffer = ''
        self.peaks = []
        self.fftx = []

        self._tick_size = 50

        self.rms = ''
        self.avg = ''
        self.pp = ''
        self.count = 0
        self.invert = False
        self.startbuffer = True

        self.y_mag = 3.0  # additional scale factor for display
        self.gain = 1.0
        self.bias = 0  # vertical position fine-tuning from slider
        self._freq_range = 4
        self.draw_interval = 10
        self.num_of_points = 115
        self.details_iter = 50
        self.c = 1180
        self.m = 0.0238
        self.k = 0.0238
        self.c2 = 139240  # c squared
        self.rms = 0
        self.avg = 0
        self.Rv = 0
        # constant to multiply with self.param2 while scaling values
        self.log_param1 = ""
        self.log_param2 = ""
        self.log_param3 = ""
        self.log_param4 = ""
        self.log_param5 = ""

        self._BACKGROUND_LINE_THICKNESS = 0.8
        self._TRIGGER_LINE_THICKNESS = 3
        self._FOREGROUND_LINE_THICKNESS = 6

        self.stop = False
        self.fft_show = False
        self.side_toolbar_copy = None

        self.scaleX = str(1.04167 / self.draw_interval) + ' ms'
        self.scaleY = ""

        self._back_surf = None
        self.expose_event_id = self.connect('expose_event', self._expose)

        self.pr_time = 0
        self.MAX_GRAPHS = MAX_GRAPHS     # Maximum simultaneous graphs

        self.graph_show_state = []
        self.Xstart = []
        self.Ystart = []
        self.Xend = []
        self.Yend = []
        self.type = []
        self.color = []
        self.source = []
        self.graph_id = []

        for x in range(0, self.MAX_GRAPHS):
            self.graph_show_state.append(False)
            self.Xstart.append(0)
            self.Ystart.append(50)
            self.Xend.append(1000)
            self.Yend.append(500)
            self.type .append(0)
            self.color.append('#FF0000')
            self.source.append(0)
            self.graph_id.append(x)

        self.graph_show_state[0] = True
        self.Xstart[0] = 0
        self.Ystart[0] = 0
        self.Xend[0] = 1150
        self.Yend[0] = 750
        self.type[0] = 0
        self.color[0] = self.activity.stroke_color
        self.source[0] = 0

        """
        self.graph_show_state[1]=True
        self.Xstart[0] = 0
        self.Ystart[1] = 0
        self.Xend[0] = 800
        self.Yend[1] = 600
        self.type[1]  = 0
        self.color[1]  = [0,65535,65535]
        self.source[1] = 0

        self.graph_show_state[2]=True
        self.Xstart[2] = 30
        self.Ystart[2] = 0
        self.Xend[2] = 300
        self.Yend[2] = 300
        self.type[2]  = 0
        self.color[2]  = [0,65535,0]
        self.source[2] = 0

        self.graph_show_state[3]=True
        self.Xstart[3] = 0
        self.Ystart[3] = 300
        self.Xend[3] = 1000
        self.Yend[3] = 700
        self.type[3]  = 0
        self.color[3]  = [65535,65535,0]
        self.source[3] = 0
        """

        self.max_samples = 115
        self.max_samples_fact = 3

        self.time_div = 1.0
        self.freq_div = 1.0
        self.input_step = 1

        self.ringbuffer = RingBuffer1d(self.max_samples, dtype='int16')

        self.debug_str = 'start'

        self.context = True