当前位置: 首页>>代码示例>>Python>>正文


Python ConfigurationAPI.set_audio_input_options方法代码示例

本文整理汇总了Python中api.configuration_api.ConfigurationAPI.set_audio_input_options方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationAPI.set_audio_input_options方法的具体用法?Python ConfigurationAPI.set_audio_input_options怎么用?Python ConfigurationAPI.set_audio_input_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在api.configuration_api.ConfigurationAPI的用法示例。


在下文中一共展示了ConfigurationAPI.set_audio_input_options方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_audio_input_options_should_update_when_48000

# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_audio_input_options [as 别名]
    def test_set_audio_input_options_should_update_when_48000(self, mock_save, mock_load):
        config =  self.default_config
        mock_load.return_value = config
        capi = ConfigurationAPI(ConfigurationManager())
        expected = self.default_config
        expected.audio.input.bit_depth = '32 bit Floating Point'
        expected.audio.input.sample_rate =  48000

        capi.load_printer('Printer')
        
        actual = capi.set_audio_input_options(AudioSetting(48000,'32 bit Floating Point'))

        self.assertConfigurationEqual(expected, mock_save.mock_calls[0][1][0])
开发者ID:superblobmonster,项目名称:peachyprintertools,代码行数:15,代码来源:configuration_api_test.py

示例2: test_set_audio_input_options_should_update_when_48000

# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_audio_input_options [as 别名]
    def test_set_audio_input_options_should_update_when_48000(self, mock_save, mock_load):
        config =  self.DEFAULT_CONFIG.copy()
        mock_load.return_value = config
        capi = ConfigurationAPI(ConfigurationManager())
        expected = config.copy()
        expected['input_bit_depth'] = '32 bit Floating Point'
        expected['input_sample_frequency'] =  48000

        capi.load_printer('Printer')
        
        actual = capi.set_audio_input_options(AudioSetting(48000,'32 bit Floating Point'))

        mock_save.assert_called_with(expected)
开发者ID:colehard,项目名称:peachyprintertools,代码行数:15,代码来源:configuration_api_test.py

示例3: SetupAudioUI

# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_audio_input_options [as 别名]
class SetupAudioUI(PeachyFrame):

    def initialize(self):
        self.grid()
        self._current_printer = self.kwargs['printer']
        self._configuration_api = ConfigurationAPI(self._configuration_manager)
        self._configuration_api.load_printer(self._current_printer)

        audio_options = self._configuration_api.get_available_audio_options()

        self._input_options = dict([ (str(option), option) for option in audio_options['inputs']])
        self._output_options = dict([ (str(option), option) for option in audio_options['outputs']])

        if (len(self._input_options) < 1 or len(self._output_options) < 1):
            logging.error("No inputs available")
            tkMessageBox.showwarning('Error','Audio card appears to not be setup correctly, Have you plugged in your dripper and printer?')
            self._back()
            return
            
        self._input_audio_selection_current = StringVar()
        self._input_audio_selection_current.set(self._currently_selected(self._input_options))

        self._output_options = dict([ (str(option), option) for option in audio_options['outputs']])

        self._output_audio_selection_current = StringVar()
        self._output_audio_selection_current.set(self._currently_selected(self._output_options))
        
        Label(self, text = 'Printer: ').grid(column=0,row=10)
        Label(self, text = self._configuration_api.current_printer()).grid(column=1,row=10)
        Button(self, text='?', command=self._help).grid(column=2, row=10,stick=N+E)

        Label(self).grid(column=0,row=20)
        Label(self, text = 'Selecting a format not supported by your system may result in odd behaviour').grid(column=0,row=25,columnspan=3)
        Label(self).grid(column=0,row=26)

        Label(self, text = "Audio Input Settings" ).grid(column=0,row=30)
        OptionMenu( self, self._input_audio_selection_current, *self._input_options.keys()).grid(column=1,row=30,sticky=NSEW)

        Label(self, text = "Audio Output Settings" ).grid(column=0,row=40)
        OptionMenu(self, self._output_audio_selection_current, *self._output_options.keys()).grid(column=1,row=40,sticky=NSEW)

        Label(self).grid(column=0,row=50)

        Button(self, text ="Back", command = self._back).grid(column=0,row=60,sticky=N+S+W)
        Button(self, text ="Save", command = self._save).grid(column=1,row=60,sticky=N+S+E)

        self.update()

    def _currently_selected(self, audio_options):
        current_option = [ k for k, v in audio_options.iteritems() if v.current ]
        if (len(current_option) == 0):
            return audio_options[0]
        else:
            return current_option[0]

    def _get_recommend_audio_index(self, options):
        for i in range(0,len(options)):
            if options[i].endswith('(Recommended)'):
                return i
        return 0

    def _back(self):
        self.navigate(SetupUI)

    def _help(self):
        PopUp(self,'Help', help_text.setup_audio_help)

    def _save(self):
        input_option = self._input_options[self._input_audio_selection_current.get()]
        output_option = self._output_options[self._output_audio_selection_current.get()]
        
        self._configuration_api.set_audio_input_options(input_option)
        self._configuration_api.set_audio_output_options(output_option)

        self.navigate(SetupUI)

    def close(self):
        pass
开发者ID:superblobmonster,项目名称:peachyprintertools,代码行数:80,代码来源:configuration_ui.py


注:本文中的api.configuration_api.ConfigurationAPI.set_audio_input_options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。