Exemplo n.º 1
0
 def play(self):
     if not self._but_lp:
         inp = pyo.Input(self._input_channels)
         mix = pyo.Mix(inp)
         self._but_lp = pyo.ButLP(mix, self._lpf)
     if not self._follower:
         self._follower = pyo.Follower2(self._but_lp,
                                        risetime=self._attack,
                                        falltime=self._release)
     if not self._peak_amp:
         self._peak_amp = pyo.PeakAmp(self._follower,
                                      self._peak_amp_callback)
Exemplo n.º 2
0
    def StartAudioInputMeter(self):
        input_meter = wx.FindWindowById(ID_INPUT_METER)
        if not input_meter:
            self.StopAudioInputMeter()
            return

        input_meter_ref = weakref.ref(input_meter)

        def peak_amp_func(*args):
            meter_data = [min(120, max(0, int(-120.0 if arg < 0.000001 else 20.0 * math.log10(arg)) + 90)) for arg in args]
            # meter_data = [min(120, max(0, int(pyo.rescale(arg, 0, 1, 0, 120)))) for arg in args]
            input_meter = input_meter_ref()
            if input_meter:
                input_meter.SetData(meter_data, 0, len(meter_data))

        aic = self.GetAudioInputChannels()
        chans = [n for n in range(8) if (aic & (2 ** n))]
        inp = pyo.Input(chans)
        mix = pyo.Mix(inp, 2)
        self._input_peak_amp = pyo.PeakAmp(mix, peak_amp_func)
Exemplo n.º 3
0
    def __init__(self, elem_list: List[Tuple[str, Callable, Optional[Any]]], server: pyo.Server, main_out_obj: pyo.PyoObject):
        wx.Frame.__init__(self, None, pos=(200, 200), title="The Grid",
                          style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))

        self._status_bar = wx.StatusBar(self)
        self.SetStatusBar(self._status_bar)
        self._status_bar.SetFieldsCount(3)
        self._status_bar.SetStatusText("Stopped", 0)

        self._server = server
        self._IS_RECORDING = False
        self._button_size = (100, 100)
        self._button_list = []
        self._callback_mapping = {}
        self._args_mapping = {}
        self._max_columns = 8
        self._slave_windows = []

        # BUTTONS
        self._gbs = wx.GridBagSizer(vgap=5, hgap=5)
        self._start_server_btn = wx.Button(self, label="Start Server")
        self._start_server_btn.Bind(wx.EVT_LEFT_UP, self.ToggleServerState)
        self._gbs.Add(self._start_server_btn, pos=(0, 0), span=wx.GBSpan(1, 3), flag=wx.EXPAND)
        self._rec_btn = wx.Button(self, label="Start Recording")
        self._rec_btn.Bind(wx.EVT_LEFT_UP, self.ToggleRecording)
        self._rec_btn.Disable()
        self._gbs.Add(self._rec_btn, pos=(0, 3), span=wx.GBSpan(1, 3), flag=wx.EXPAND)
        self._mute_btn = wx.Button(self, label="Mute Server")
        self._mute_btn.Bind(wx.EVT_LEFT_UP, self.ToggleMuting)
        self._mute_btn.Disable()
        self._gbs.Add(self._mute_btn, pos=(0, 6), span=wx.GBSpan(1,2), flag=wx.ALIGN_LEFT)

        # METERS
        self._last_peak_value = -120
        self._last_rms_value = -120

        self._peak_meter = pyo.PyoGuiVuMeter(self, nchnls=2, size=(300, 1))
        self._gbs.Add(self._peak_meter, pos=(1,0), span=wx.GBSpan(1, 7))
        self._peak_text = wx.StaticText(self, -1, "")
        self._setPeakText(-120)
        self._peak_text.Bind(wx.EVT_LEFT_DOWN, self.OnPeakValMouseDown)
        self._gbs.Add(self._peak_text, pos=(1, 7), flag=wx.EXPAND)

        self._rms_meter = pyo.PyoGuiVuMeter(self, nchnls=2, size=(300, 1))
        self._gbs.Add(self._rms_meter, pos=(2, 0), span=wx.GBSpan(1, 7))
        self._rms_text = wx.StaticText(self, -1, "")
        self._setRMSText(-120)
        self._rms_text.Bind(wx.EVT_LEFT_DOWN, self.OnRMSValMouseDown)
        self._gbs.Add(self._rms_text, pos=(2, 7), flag=wx.EXPAND)

        self._peak_obj = pyo.PeakAmp(main_out_obj, self._metersCallback)
        self._rms_obj = pyo.RMS(main_out_obj, None)
        self._rms_obj.polltime(0.5)
        self._rms_port = pyo.Port(self._rms_obj, 0.5, 0.1)


        row = 2 # current rox number, which is 1 after adding the sta/stop buttons and the VuMeter
        for elem in elem_list:
            self._button_list.append(wx.Button(self, label=self._formatText(elem[0]), size=self._button_size))

            self._callback_mapping[self._button_list[-1].GetId()] = elem[1]
            if len(elem) > 2:
                self._args_mapping[self._button_list[-1].GetId()] = elem[2:]
            else:
                self._args_mapping[self._button_list[-1].GetId()] = None

            self._button_list[-1].Bind(wx.EVT_LEFT_UP, self.OnMouseUp)

            col = (len(self._button_list) - 1) % self._max_columns
            if col == 0:
                row += 1

            self._gbs.Add(self._button_list[-1], (row, col))

        box = wx.BoxSizer()
        box.Add(self._gbs, 1, wx.EXPAND | wx.ALL, 5)
        self.SetSizerAndFit(box)
        self._gbs.RecalcSizes()