2017-04-08 00:34:45 +02:00
|
|
|
import bpy
|
|
|
|
from bpy.props import *
|
|
|
|
from bpy.types import Node, NodeSocket
|
|
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
|
|
|
|
class PlaySoundNode(Node, ArmLogicTreeNode):
|
2020-05-15 23:22:41 +02:00
|
|
|
"""Play sound node"""
|
2018-02-21 23:23:23 +01:00
|
|
|
bl_idname = 'LNPlaySoundRawNode'
|
2017-04-08 00:34:45 +02:00
|
|
|
bl_label = 'Play Sound'
|
2018-12-18 23:48:38 +01:00
|
|
|
bl_icon = 'QUESTION'
|
2017-04-08 00:34:45 +02:00
|
|
|
|
2019-01-21 16:48:11 +01:00
|
|
|
property0: PointerProperty(name='', type=bpy.types.Sound)
|
2020-05-15 23:22:41 +02:00
|
|
|
property1: BoolProperty(
|
|
|
|
name='Use Custom Sample Rate',
|
|
|
|
description='If enabled, override the default sample rate',
|
|
|
|
default=False)
|
|
|
|
property2: IntProperty(
|
|
|
|
name='Sample Rate',
|
|
|
|
description='Set the sample rate used to play this sound',
|
|
|
|
default=44100,
|
|
|
|
min=0)
|
2018-02-21 23:23:23 +01:00
|
|
|
|
2017-04-08 00:34:45 +02:00
|
|
|
def init(self, context):
|
2017-04-08 20:05:35 +02:00
|
|
|
self.inputs.new('ArmNodeSocketAction', 'In')
|
|
|
|
self.outputs.new('ArmNodeSocketAction', 'Out')
|
2017-04-08 00:34:45 +02:00
|
|
|
|
2018-02-21 23:23:23 +01:00
|
|
|
def draw_buttons(self, context, layout):
|
|
|
|
layout.prop_search(self, 'property0', bpy.data, 'sounds', icon='NONE', text='')
|
|
|
|
|
2020-05-15 23:22:41 +02:00
|
|
|
layout.label(text="Overrides:")
|
|
|
|
# Sample rate
|
|
|
|
split = layout.split(factor=0.15, align=False)
|
|
|
|
split.prop(self, 'property1', text="")
|
|
|
|
row = split.row()
|
|
|
|
if not self.property1:
|
|
|
|
row.enabled = False
|
|
|
|
row.prop(self, 'property2')
|
|
|
|
|
2017-04-08 00:34:45 +02:00
|
|
|
add_node(PlaySoundNode, category='Sound')
|