Exemple #1
0
 def method_load_file(self):
     import os
     wildcard = 'music sounds (MO3, IT, XM, S3M, MTM, MOD, UMX)|*.mo3;*.it;*.xm;*.s3m;*.mtm;*.mod;*.umx'
     wildcard += '|stream sounds (MP3, MP2, MP1, OGG, WAV, AIFF)|*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aiff'
     for plugin in self.plugins.itervalues():
         if plugin[0] > 0:
             wildcard += plugin[1]
     wildcard += '|All files (*.*)|*.*'
     dlg = wx.FileDialog(self,
                         message=_('Choose a file'),
                         defaultDir=os.getcwd(),
                         defaultFile='',
                         wildcard=wildcard,
                         style=wx.OPEN | wx.CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         self.name_stream = file_name = dlg.GetPath()
         if os.path.isfile(file_name):
             flags = 0
             if isinstance(file_name, unicode):
                 flags |= pybass.BASS_UNICODE
                 try:
                     pybass.BASS_CHANNELINFO._fields_.remove(
                         ('filename', pybass.ctypes.c_char_p))
                 except Exception:
                     pass
                 else:
                     pybass.BASS_CHANNELINFO._fields_.append(
                         ('filename', pybass.ctypes.c_wchar_p))
             error_msg = 'BASS_StreamCreateFile error'
             new_bass_handle = 0
             if dlg.GetFilterIndex() == 0:  # BASS_CTYPE_MUSIC_MOD
                 flags |= pybass.BASS_MUSIC_PRESCAN
                 new_bass_handle = pybass.BASS_MusicLoad(
                     False, file_name, 0, 0, flags, 0)
                 error_msg = 'BASS_MusicLoad error'
             else:  # other sound types
                 new_bass_handle = pybass.BASS_StreamCreateFile(
                     False, file_name, 0, 0, flags)
             if new_bass_handle == 0:
                 print(
                     error_msg,
                     pybass.get_error_description(
                         pybass.BASS_ErrorGetCode()))
             else:
                 self.method_stop_audio()
                 self.bass_handle = new_bass_handle
                 self.stream = None
                 self.method_slider_set_range()
                 self.method_check_controls()
Exemple #2
0
 def __init__(self, *args, **kwargs):
     self.config_file_name = kwargs.pop('config_file_name', 'randomiz.ini')
     self.config = config(file_name=self.config_file_name)
     self.time_delay = self.config.get_int('time_delay', 2)
     self.play_sound = self.config.get_bool('play_sound', True)
     self.texture_from_file = self.config.get_bool('texture_from_file',
                                                   False)
     self.sound_volume = self.config.get_float('sound_volume', 1.0)
     self.sound_file = self.config.get('sound_file', 'media//sound.mod')
     self.bass_handle = None
     self.sound_playing = False
     self.menu_options = None
     if pybass:
         if pybass.BASS_Init(-1, 44100, 0, 0, 0):
             pybass.BASS_SetVolume(self.sound_volume)
             if os.path.isfile(self.sound_file):
                 self.bass_handle = pybass.BASS_MusicLoad(
                     False, self.sound_file, 0, 0,
                     pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
                 if self.play_sound:
                     self.sound_play()
     self.device_type = self.config.get_int('device_type', EDT_OPENGL)
     self.window_size = dimension2du(
         self.config.get_int('window_width', 640),
         self.config.get_int('window_height', 480))
     self.device = createDevice(self.device_type, self.window_size)
     self.menu_device_types = {}
     self.help_dialog = None
     self.fog_enable = self.config.get_bool('fog_enable', True)
     self.fog_color = SColor(
         *self.config.get('fog_color', (0, 255, 255, 255)))
     self.fog_type = self.config.get_int('fog_type', EFT_FOG_LINEAR)
     self.fog_start = self.config.get_float('fog_start', 500.0)
     self.fog_end = self.config.get_float('fog_end', 1000.0)
     self.fog_density = self.config.get_float('fog_density', 0.01)
     self.fog_pixel = self.config.get_bool('fog_pixel', False)
     self.fog_range = self.config.get_bool('fog_range', False)
     # random volume variable
     self.tile_count = randint(10, 50)
     # len tile
     self.tile_len = 100
     self.results = 0
Exemple #3
0
 def __init__(self, *args, **kwargs):
     global pybass, pyespeak
     self.config_file_name = kwargs.pop('config_file_name', 'entrain.ini')
     self.config = config(file_name=self.config_file_name)
     self.time_delay = self.config.get_int('time_delay', 5)
     self.play_sound = self.config.get_bool('play_sound', True)
     self.sound_volume = self.config.get_float('sound_volume', 0.5)
     self.music_file = self.config.get('music_file',
                                       'music//Ranger_Song.s3m')
     self.svg_directory = self.config.get('svg_dir', 'svg_data')
     if not os.path.isdir(self.svg_directory):
         self.svg_directory = ''
     self.bass_handle = None
     self.sound_playing = False
     self.menu_options = None
     if pybass:
         if pybass.BASS_Init(-1, 44100, 0, 0, 0):
             pybass.BASS_SetVolume(self.sound_volume)
             if os.path.isfile(self.music_file):
                 self.bass_handle = pybass.BASS_MusicLoad(
                     False, self.music_file, 0, 0,
                     pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
                 if self.play_sound:
                     self.sound_play()
         else:
             pybass = None
     self.voice_rate = self.config.get_int('voice_rate', 150)
     self.voice_pitch = self.config.get_int('voice_pitch', 50)
     if pyespeak:
         if pyespeak.espeak_Initialize(pyespeak.AUDIO_OUTPUT_SYNCH_PLAYBACK,
                                       0, '.',
                                       0) == pyespeak.EE_INTERNAL_ERROR:
             pyespeak = None
         else:
             pyespeak.espeak_SetVoiceByName('default')
             pyespeak.espeak_SetParameter(pyespeak.espeakRATE,
                                          self.voice_rate, 0)
             pyespeak.espeak_SetParameter(pyespeak.espeakPITCH,
                                          self.voice_pitch, 0)
     default_driver_type = EDT_SOFTWARE
     if 'win' in sys.platform:
         default_driver_type = EDT_DIRECT3D9
     elif 'linux' in sys.platform:
         default_driver_type = EDT_OPENGL
     self.device_parameters = SIrrlichtCreationParameters()
     self.device_parameters.DriverType = self.config.get_int(
         'driver_type', default_driver_type)
     self.device_parameters.WindowSize = dimension2du(
         self.config.get_int('window_width', 640),
         self.config.get_int('window_height', 480))
     self.device_parameters.AntiAlias = self.config.get_int('anti_alias', 2)
     self.device_parameters.WithAlphaChannel = self.config.get_bool(
         'with_alpha_channel', True)
     self.device = createDeviceEx(self.device_parameters)
     self.menu_driver_types = {}
     self.help_dialog = None
     self.good_results = 0
     self.bad_results = 0
     #~ self.button_repeat_voice = None
     self.voice_on = self.config.get_bool('voice_on', True)
     self.font_size = self.config.get_int('font_size', 32)
     self.font_file = self.replace_env_vars(
         self.config.get('font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
     self.gui_font_size = self.config.get_int('gui_font_size', 24)
     self.gui_font_file = self.replace_env_vars(
         self.config.get('gui_font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
     self.svg_image = None
Exemple #4
0
def loadmusic(mem, file, offset=0, length=0, flags=0):
    """
Load a MOD music file
    """
    return dll.BASS_MusicLoad(mem, file, offset, length, flags, 0)
Exemple #5
0
        font_file = font_path + 'arial' + font_ext
        gui_font = CGUITTFont(guienv, font_file, 12)
        if not gui_font:
            gui_font = guienv.getBuiltInFont()

        skin = guienv.getSkin()
        skin.setFont(gui_font)
        gui_font.drop()
        menu_height = skin.getSize(EGDS_MENU_HEIGHT)

        if pybass:
            if pybass.BASS_Init(-1, 44100, 0, 0, 0):
                pybass.BASS_SetVolume(sound_volume)
                if os.path.isfile(sound_file):
                    bass_handle = pybass.BASS_MusicLoad(
                        False, sound_file, 0, 0,
                        pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
                    if play_sound:
                        sound_play()

        menu_options = None

        menu = guienv.addMenu()
        menu.addItem(_('File'), -1, True, True)
        menu.addItem(_('Options'), -1, True, True)
        menu.addItem(_('Help'), -1, True, True)

        submenu = menu.getSubMenu(0)
        submenu.addItem(_('Load game'), GUI_ID_LOAD)
        submenu.addItem(_('Save game'), GUI_ID_SAVE)
        submenu.addSeparator()