def on_ok(a_self=None): f_buffer_size = int(str(f_buffer_size_combobox.currentText())) f_samplerate = int(str(f_samplerate_combobox.currentText())) f_worker_threads = f_worker_threads_combobox.currentIndex() f_midi_in_device = str(f_midi_in_device_combobox.currentText()) f_audio_engine = f_audio_engine_combobox.currentIndex() if f_thread_affinity_checkbox.isChecked(): f_thread_affinity = 1 else: f_thread_affinity = 0 if f_governor_checkbox.isChecked(): f_performance = 1 else: f_performance = 0 try: #This doesn't work if the device is open already, #so skip the test, and if it fails the #user will be prompted again next time PyDAW starts if f_audio_engine != 7 or \ not self.is_running or \ "name" not in pydaw_util.global_device_val_dict or \ pydaw_util.global_device_val_dict["name"] != self.device_name: f_output = portaudio.PaStreamParameters( f_name_to_index[self.device_name], 2, portaudio.paInt16, float(f_buffer_size)/float(f_samplerate), None) f_supported = self.pyaudio.Pa_IsFormatSupported( 0, ctypes.byref(f_output), f_samplerate) if not f_supported: raise Exception() f_file = open(pydaw_util.global_pydaw_device_config, "w") f_file.write("name|{}\n".format(self.device_name)) f_file.write("bufferSize|{}\n".format(f_buffer_size)) f_file.write("sampleRate|{}\n".format(f_samplerate)) f_file.write("audioEngine|{}\n".format(f_audio_engine)) f_file.write("threads|{}\n".format(f_worker_threads)) f_file.write("threadAffinity|{}\n".format(f_thread_affinity)) f_file.write("performance|{}\n".format(f_performance)) f_file.write("midiInDevice|{}\n".format(f_midi_in_device)) f_file.write("\\") f_file.close() self.close_devices() if a_notify: QtGui.QMessageBox.warning(f_window, _("Settings changed"), _("Hardware settings have been changed, and will be " "applied next time you start PyDAW.")) time.sleep(1.0) pydaw_util.pydaw_read_device_config() self.dialog_result = True f_window.close() except Exception as ex: QtGui.QMessageBox.warning(f_window, _("Error"), _("Couldn't open audio device\n\n{}\n\n" "This may (or may not) be because the " "device already open by " "another application such as a DAW, or Jack.").format(ex))
def on_ok(a_self=None): if self.device_name == "default": f_warn_result = QMessageBox.question( f_window, _("Warning"), _("You have selected the 'default' audio device, " "which may not be a valid device. It is recommended " "that you explicitly pick the audio device you " "intend to use. Use the 'default' device anyway?"), QMessageBox.Yes | QMessageBox.Cancel, QMessageBox.Cancel) if f_warn_result == QMessageBox.Cancel: return f_buffer_size = int(str(f_buffer_size_combobox.currentText())) f_samplerate = int(str(f_samplerate_combobox.currentText())) f_midi_in_devices = sorted(str(k) for k, v in self.midi_in_checkboxes.items() if v.isChecked()) if len(f_midi_in_devices) >= 8: QMessageBox.warning( f_window, _("Error"), _("Using more than 8 MIDI devices is not supported, " "please de-select some devices")) return f_worker_threads = f_worker_threads_combobox.currentIndex() if pydaw_util.IS_WINDOWS or pydaw_util.IS_MAC_OSX: f_audio_engine = 8 elif pydaw_util.IS_LINUX: f_audio_engine = f_audio_engine_combobox.currentIndex() f_thread_affinity = \ 1 if f_thread_affinity_checkbox.isChecked() else 0 f_hugepages = 1 if f_hugepages_checkbox.isChecked() else 0 f_audio_inputs = f_audio_in_spinbox.value() f_out_tuple = (f_audio_out_spinbox,) + OUT_SPINBOXES f_audio_outputs = "|".join(str(x.value()) for x in f_out_tuple) try: #This doesn't work if the device is open already, #so skip the test, and if it fails the #user will be prompted again next time MusiKernel starts if f_audio_engine != 7 or \ not self.is_running or \ "name" not in pydaw_util.global_device_val_dict or \ pydaw_util.global_device_val_dict["name"] != self.device_name: if (pydaw_util.IS_WINDOWS or pydaw_util.IS_MAC_OSX) \ and f_audio_inputs: f_input = portaudio.PaStreamParameters( f_name_to_index[self.subsystem][self.device_name], f_audio_inputs, portaudio.paInt16, float(f_buffer_size) / float(f_samplerate), None) f_input_ref = ctypes.byref(f_input) else: f_input_ref = 0 f_output = portaudio.PaStreamParameters( f_name_to_index[self.subsystem][self.device_name], 2, portaudio.paInt16, float(f_buffer_size) / float(f_samplerate), None) f_supported = self.pyaudio.Pa_IsFormatSupported( f_input_ref, ctypes.byref(f_output), f_samplerate) if not f_supported: raise Exception() f_file = open( pydaw_util.global_pydaw_device_config, "w", newline="\n") f_file.write("hostApi|{}\n".format(self.subsystem)) f_file.write("name|{}\n".format(self.device_name)) if (pydaw_util.IS_WINDOWS or pydaw_util.IS_MAC_OSX) \ and self.input_name: f_file.write("inputName|{}\n".format(self.input_name)) f_file.write("bufferSize|{}\n".format(f_buffer_size)) f_file.write("sampleRate|{}\n".format(f_samplerate)) f_file.write("threads|{}\n".format(f_worker_threads)) if pydaw_util.IS_LINUX: f_file.write("audioEngine|{}\n".format(f_audio_engine)) f_file.write("threadAffinity|{}\n".format( f_thread_affinity)) f_file.write("hugePages|{}\n".format(f_hugepages)) f_file.write("audioInputs|{}\n".format(f_audio_inputs)) f_file.write("audioOutputs|{}\n".format(f_audio_outputs)) for f_midi_in_device in f_midi_in_devices: f_file.write("midiInDevice|{}\n".format( f_midi_in_device)) f_file.write("\\") f_file.close() self.close_devices() self.dialog_result = True time.sleep(1.0) pydaw_util.pydaw_read_device_config() f_window.close() except Exception as ex: QMessageBox.warning(f_window, _("Error"), _("Couldn't open audio device\n\n{}\n\n" "This may (or may not) be because the " "device is already open by another application or " "a sound daemon such as JACK.").format(ex))
def on_ok(a_self=None): if self.device_name == "default": f_warn_result = QMessageBox.question( f_window, _("Warning"), _("You have selected the 'default' audio device, " "which may not be a valid device. It is recommended " "that you explicitly pick the audio device you " "intend to use. Use the 'default' device anyway?"), QMessageBox.Yes | QMessageBox.Cancel, QMessageBox.Cancel) if f_warn_result == QMessageBox.Cancel: return f_buffer_size = int(str(f_buffer_size_combobox.currentText())) f_samplerate = int(str(f_samplerate_combobox.currentText())) f_midi_in_devices = sorted( str(k) for k, v in self.midi_in_checkboxes.items() if v.isChecked()) if len(f_midi_in_devices) >= 8: QMessageBox.warning( f_window, _("Error"), _("Using more than 8 MIDI devices is not supported, " "please de-select some devices")) return f_worker_threads = f_worker_threads_combobox.currentIndex() if pydaw_util.IS_WINDOWS or pydaw_util.IS_MAC_OSX: f_audio_engine = 8 elif pydaw_util.IS_LINUX: f_audio_engine = f_audio_engine_combobox.currentIndex() f_thread_affinity = \ 1 if f_thread_affinity_checkbox.isChecked() else 0 f_hugepages = 1 if f_hugepages_checkbox.isChecked() else 0 f_audio_inputs = f_audio_in_spinbox.value() f_out_tuple = (f_audio_out_spinbox, ) + OUT_SPINBOXES f_audio_outputs = "|".join(str(x.value()) for x in f_out_tuple) try: #This doesn't work if the device is open already, #so skip the test, and if it fails the #user will be prompted again next time MusiKernel starts if f_audio_engine != 7 or \ not self.is_running or \ "name" not in pydaw_util.global_device_val_dict or \ pydaw_util.global_device_val_dict["name"] != self.device_name: if (pydaw_util.IS_WINDOWS or pydaw_util.IS_MAC_OSX) \ and f_audio_inputs: f_input = portaudio.PaStreamParameters( f_name_to_index[self.subsystem][self.device_name], f_audio_inputs, portaudio.paInt16, float(f_buffer_size) / float(f_samplerate), None) f_input_ref = ctypes.byref(f_input) else: f_input_ref = 0 f_output = portaudio.PaStreamParameters( f_name_to_index[self.subsystem][self.device_name], 2, portaudio.paInt16, float(f_buffer_size) / float(f_samplerate), None) f_supported = self.pyaudio.Pa_IsFormatSupported( f_input_ref, ctypes.byref(f_output), f_samplerate) if not f_supported: raise Exception() f_file = open(pydaw_util.global_pydaw_device_config, "w", newline="\n") f_file.write("hostApi|{}\n".format(self.subsystem)) f_file.write("name|{}\n".format(self.device_name)) if (pydaw_util.IS_WINDOWS or pydaw_util.IS_MAC_OSX) \ and self.input_name: f_file.write("inputName|{}\n".format(self.input_name)) f_file.write("bufferSize|{}\n".format(f_buffer_size)) f_file.write("sampleRate|{}\n".format(f_samplerate)) f_file.write("threads|{}\n".format(f_worker_threads)) if pydaw_util.IS_LINUX: f_file.write("audioEngine|{}\n".format(f_audio_engine)) f_file.write( "threadAffinity|{}\n".format(f_thread_affinity)) f_file.write("hugePages|{}\n".format(f_hugepages)) f_file.write("audioInputs|{}\n".format(f_audio_inputs)) f_file.write("audioOutputs|{}\n".format(f_audio_outputs)) for f_midi_in_device in f_midi_in_devices: f_file.write("midiInDevice|{}\n".format(f_midi_in_device)) f_file.write("\\") f_file.close() self.close_devices() self.dialog_result = True time.sleep(1.0) pydaw_util.pydaw_read_device_config() f_window.close() except Exception as ex: QMessageBox.warning( f_window, _("Error"), _("Couldn't open audio device\n\n{}\n\n" "This may (or may not) be because the " "device is already open by another application or " "a sound daemon such as JACK.").format(ex))