예제 #1
0
    def start(self, args):
        """Start Function"""
        scene = bge.logic.getCurrentScene()
        cam = scene.active_camera

        # Loading the device...
        self.device = aud.Device()
        self.device.distance_model = aud.DISTANCE_MODEL_LINEAR

        # Loading the sound...
        sName = bge.logic.expandPath("//")+args["Sound File"]
        self.sound = aud.Sound(sName)

        # Playing the sound...
        self.handle = self.device.play(self.sound)

        # 3D Sound configuration...
        self.__3dSound = args["3D Sound"]
        self.handle.relative = (self.__3dSound == False)
        self.handle.distance_maximum = abs(args["Max Distance"])
        self.handle.distance_reference = abs(args["Min Distance"])
        self.handle.pitch = args["Pitch"]

        self.handle.volume = args["Volume"]

        if args["Loop Sound"]:
            self.handle.loop_count = -1
        else:
            self.handle.loop_count = 0

        self.__deleteObj = args["Delete Object After End"]
예제 #2
0
    def execute(self, context):

        if self.clear:
            context.scene.rp_playlist.clear()
            context.window_manager.radiola_clear = True
            self.clear = False
            return {'FINISHED'}
        if self.make:
            self.dolist(urls, names)
            context.window_manager.radiola_clear = False
            self.make = False
            return {'FINISHED'}

        if not len(context.scene.rp_playlist):
            self.dolist(urls, names)
        url = context.scene.rp_playlist[self.item_play].url

        if self.play:
            context.window_manager.radiola_dev.stopAll()
            #music = sp.Popen(['/usr/bin/mplayer', url])
            context.window_manager.radiola_dev.play(aud.Sound(url))
            context.window_manager.radiola_ind = self.item_play
            #context.window_manager.radiola = music.pid
        else:
            #os.kill(context.window_manager.radiola, signal.SIGTERM)
            #music.terminate()
            context.window_manager.radiola_dev.stopAll()
        return {'FINISHED'}
예제 #3
0
def play_sound(*args):
    import pathlib
    import aud

    ping_path = pathlib.Path(__file__).with_name('ping.ogg')

    aud_dev = aud.Device()
    aud_sound = aud.Sound(str(ping_path))
    aud_dev.play(aud_sound)
    def execute(self, context):
        try:

            st_t = time.time()
            return_data = GlobalData.importer.ImportCreation(
                vanilla_skins=context.scene.bsgimp_use_vanilla_blocks,
                create_parent=context.scene.bsgimp_create_parent,
                join_line_components=context.scene.
                bsgimp_line_type_join_components,
                generate_material=context.scene.bsgimp_generate_materials,
                bracethreshold=context.scene.
                bsgimp_line_type_brace_delete_threshold,
                line_type_cleanup=context.scene.
                bsgimp_line_type_cleanup_options,
                node_grouping_mode=context.scene.
                bsgimp_make_unique_node_groups,
                use_node_groups=context.scene.bsgimp_use_node_group,
                node_group_setup=context.scene.bsgimp_node_set,
                merge_decor_blocks=context.scene.bsgimp_merge_decor_components,
                surface_block_resolution=context.scene.
                bsgimp_surface_type_resolution,
                surface_block_thickness_mult=context.scene.
                bsgimp_surface_type_thickness_multiplier,
                skip_surfaces=context.scene.bsgimp_surface_type_skip_surfaces)

            et_t = time.time()
            if (et_t - st_t) > 5 and context.scene.bsgimp_notify_on_complete:
                device = aud.Device()
                path_to_sound = os.path.join(
                    os.path.dirname(
                        os.path.realpath(__file__)), 'import-complete.mp3'
                ) if not dev_mode else 'import-complete.mp3'
                sound = aud.Sound(path_to_sound)
                device.play(sound)
            for material in return_data['imported_materials']:
                newmat = bpy.context.scene.bsgimp_purgeable_materials.add()
                newmat.obj_pointer = material

            for object_imp in return_data['imported_objects']:
                try:
                    newobj = bpy.context.scene.bsgimp_selectable_imports.add()
                    # newobj.name = object_imp.name
                    newobj.obj_pointer = object_imp
                    # print(object_imp)
                    # object_imp.select_set(True)
                except:
                    pass

            self.report({'INFO'}, 'Import complete in {:.2f} seconds'.format(
                (et_t - st_t)))
        except:
            self.report(
                {'ERROR'},
                'Error encountered in the import process. Check console')
            traceback.print_exc()
        return ({'FINISHED'})
예제 #5
0
    def play_chaching_sound(self):
        # TODO: make pitch higher as costs rise
        try:
            import aud

            device = aud.Device()
            # chaching.mp3 is by Lucish_ CC-BY-3.0 https://freesound.org/people/Lucish_/sounds/554841/
            sound = aud.Sound(
                os.path.join(context.scene.BIMProperties.data_dir,
                             "chaching.mp3"))
            handle = device.play(sound)
            sound_buffered = aud.Sound.buffer(sound)
            handle_buffered = device.play(sound_buffered)
            handle.stop()
            handle_buffered.stop()
        except:
            pass  # ah well
예제 #6
0
def init(cont):
    own = cont.owner

    #toggle menghilang
    own.visible = True

    var.w = wave.open(soundFile)
    w = var.w
    var.frameRate = w.getframerate()
    var.totalFrames = w.getnframes()
    var.totalTime = w.getnframes() / w.getframerate()

    own['totalTime'] = var.totalTime

    var.startYPos = own.worldPosition.y

    cont.activate(cont.actuators['s1'])

    device = aud.Device()
    factory = aud.Sound(soundFile)
    handle = device.play(factory)
    var.isStart = True
    var.handle = handle
예제 #7
0
    def execute(self, context):
        check = eval(self.item_play)
        if check[0]:
            bpy.context.window_manager.mp_index = check[1]
            check[0] = False
        bpy.types.WindowManager.mp_f = aud.Sound(context.scene.mp_playlist[
            context.window_manager.mp_index].playlist)
        bpy.types.WindowManager.mp_playsound = context.window_manager.mp_d.play(
            context.window_manager.mp_f.fadein(0, 3))
        context.window_manager.mp_pause = False
        context.window_manager.mp_playsound.volume = context.scene.mp_volume
        threading.Thread(target=soundIsOn, args=(context, )).start()
        self.report({'INFO'}, 'Lets rock...')
        context.window_manager.mp_playing = True

        if bpy.context.scene.mp_playlist_names.__len__():
            pl = [a.playlist for a in bpy.context.scene.mp_playlist_names]
        else:
            pl = [a.playlist for a in bpy.context.scene.mp_playlist]
        print("||| %s of %s ||| %s" %
              (str(context.window_manager.mp_index + 1),
               str(len(context.scene.mp_playlist)),
               str(pl[context.window_manager.mp_index])))
        return {'FINISHED'}
예제 #8
0
파일: aud.py 프로젝트: clayne/Bforartists
"""
Basic Sound Playback
++++++++++++++++++++

This script shows how to use the classes: :class:`Device`, :class:`Sound` and
:class:`Handle`.
"""
import aud

device = aud.Device()
# load sound file (it can be a video file with audio)
sound = aud.Sound('music.ogg')

# play the audio, this return a handle to control play/pause
handle = device.play(sound)
# if the audio is not too big and will be used often you can buffer it
sound_buffered = aud.Sound.cache(sound)
handle_buffered = device.play(sound_buffered)

# stop the sounds (otherwise they play until their ends)
handle.stop()
handle_buffered.stop()
예제 #9
0
def play_sound(scene):
    ping_path = pathlib.Path(__file__).with_name('ping.ogg')

    aud_dev = aud.Device()
    aud_sound = aud.Sound(str(ping_path))
    aud_dev.play(aud_sound)
from bpy.app.handlers import persistent
from bpy.props import *
from bpy.types import Operator, AddonPreferences
import requests
import re
import os
import aud

bl_info = {
    "name": "Render Audio",
    "blender": (2, 83, 0),
    "category": "Object",
}

path = "D:\Blender\Render.mp3"
snd = aud.Sound(path)
dev = aud.Device()


@persistent
def finish_render(scene):
    dev.play(snd)


class RenderAudio(bpy.types.Operator):
    """Stop Audio"""
    bl_idname = "object.render_audio"
    bl_label = "Stop Audio"
    bl_options = {'REGISTER', 'UNDO'}
    total: bpy.props.IntProperty(name="Steps", default=2, min=1, max=100)