Пример #1
0
    def __init__(self,address,ordinal):
        agent.Agent.__init__(self, signature=version,names='audio',container=9,ordinal=ordinal)
        self.domain = piw.clockdomain_ctl()

        self.__timestamp = 0

        self.output = bundles.Splitter(self.domain)
        self[2] = AudioOutputList(self,'outputs')

        self.clone = piw.clone(True)
        self.audio = AudioDelegate(self,self.domain)
        self.recorder = piw.wavrecorder(self.domain)
        self.clone.set_output(1,self.audio.cookie())
        self.clone.set_output(2,self.recorder.cookie())
        self.input = bundles.ScalarInput(self.clone.cookie(),self.domain,signals=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64),threshold=0)
        self.__loading = False

        self[1] = AudioInputList(self)
        self[1].create_channel(1)
        self[1].create_channel(2)

        self[3] = atom.Atom(domain=domain.EnumOrNull(44100,48000,96000), names='sample rate', protocols='bind set', policy=atom.default_policy(self.__change_sample_rate),container=(None,'sample rate',self.verb_container()))
        self[3].add_verb2(1,'set([],~a,role(None,[instance(~self)]),role(to,[numeric]))',callback=self.__set_sample_rate)
        self[3].add_verb2(2,'set([un],~a,role(None,[instance(~self)]))',callback=self.__unset_sample_rate)

        self[4] = atom.Atom(domain=domain.BoundedIntOrNull(0,64), names='input channels', protocols='output', policy=policy.ReadOnlyPolicy())
        self[5] = atom.Atom(domain=domain.BoundedIntOrNull(0,64), names='output channels', protocols='output', policy=policy.ReadOnlyPolicy())

        self[7] = Port(self)

        self[8] = atom.Atom(domain=domain.BoundedIntOrNull(0,3072,0), names='buffer size', protocols='bind set', policy=atom.default_policy(self.__change_buffer_size),container=(None,'buffer size',self.verb_container()))
        self[8].add_verb2(1,'set([],~a,role(None,[instance(~self)]),role(to,[numeric]))',callback=self.__set_buffer_size)
        self[8].add_verb2(2,'set([un],~a,role(None,[instance(~self)]))',callback=self.__unset_buffer_size)

        self.add_verb2(1,'mute([],None)', self.__mute)
        self.add_verb2(2,'mute([un],None)', self.__unmute)
        self.add_verb2(3,'choose([],None,role(None,[ideal([~server,port]),singular]))',self.__choose)
        self.add_verb2(4,'create([],None,role(None,[mass([input])]))', self.__create_input)
        self.add_verb2(5,'create([un],None,role(None,[mass([input])]))', self.__uncreate_input)
        self.add_verb2(6,'create([],None,role(None,[mass([output])]))', self.__create_output)
        self.add_verb2(7,'create([un],None,role(None,[mass([output])]))', self.__uncreate_output)

        self.enum()

        self.__filename = resource.new_resource_file('Audio','audio.wav')
        self.recorder.setfile(self.__filename)

        self[10] = atom.Atom(domain=domain.Bool(),init=False,transient=True,policy=policy.FastPolicy(self.recorder.record(),policy.TriggerStreamPolicy()),protocols='nostage',names='recorder running input')

        self[2].channels_changed()
Пример #2
0
    def __init__(self, container):
        self.__func = piw.indirectchange()
        Bool.__init__(self,
                      False,
                      transient=True,
                      protocols='deferred',
                      policy=policy.FastPolicy(self.__func,
                                               policy.TriggerStreamPolicy(),
                                               clock=False))

        self.__private = node.Server(value=piw.makestring('', 0),
                                     change=self.__change)
        self.set_private(self.__private)
        self.container = container
        self.index = 0
        self.label = None
        self.ctx = None
        self.args = None
        self.status = None
Пример #3
0
    def __init__(self, address, ordinal):
        agent.Agent.__init__(self,
                             signature=version,
                             names='audio',
                             icon='plg_macosx/audio.png',
                             container=9,
                             ordinal=ordinal)

        self.domain = piw.clockdomain_ctl()
        self.clone = piw.clone(True)
        self.audio = AudioDelegate(self, self.domain)
        self.recorder = piw.wavrecorder(self.domain)
        self.clone.set_output(1, self.audio.cookie())
        self.clone.set_output(2, self.recorder.cookie())
        self.input = bundles.ScalarInput(self.clone.cookie(),
                                         self.domain,
                                         signals=(1, 2),
                                         threshold=0)
        self.__loading = False

        self[1] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                            names='left input',
                            policy=self.input.nodefault_policy(1, True))
        self[2] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                            names='right input',
                            policy=self.input.nodefault_policy(2, True))
        self[3] = atom.Atom(
            domain=domain.EnumOrNull(44100, 48000, 96000),
            names='sample rate',
            protocols='bind set',
            policy=atom.default_policy(self.__change_sample_rate),
            container=(None, 'sample rate', self.verb_container()))
        self[3].add_verb2(
            1,
            'set([],~a,role(None,[instance(~self)]),role(to,[numeric]))',
            callback=self.__set_sample_rate)
        self[3].add_verb2(2,
                          'set([un],~a,role(None,[instance(~self)]))',
                          callback=self.__unset_sample_rate)
        self[7] = Port(self)
        self[8] = atom.Atom(
            domain=domain.BoundedIntOrNull(0, 3072, 0),
            names='buffer size',
            protocols='bind set',
            policy=atom.default_policy(self.__change_buffer_size),
            container=(None, 'buffer size', self.verb_container()))
        self[8].add_verb2(
            1,
            'set([],~a,role(None,[instance(~self)]),role(to,[numeric]))',
            callback=self.__set_buffer_size)
        self[8].add_verb2(2,
                          'set([un],~a,role(None,[instance(~self)]))',
                          callback=self.__unset_buffer_size)

        self.add_verb2(1, 'mute([],None)', self.__mute)
        self.add_verb2(2, 'mute([un],None)', self.__unmute)
        self.add_verb2(
            3, 'choose([],None,role(None,[ideal([~server,port]),singular]))',
            self.__choose)

        self.enum()

        self.__filename = resource.new_resource_file('audio', 'audio.wav')
        self.recorder.setfile(self.__filename)

        self[10] = atom.Atom(domain=domain.Bool(),
                             init=False,
                             transient=True,
                             policy=policy.FastPolicy(
                                 self.recorder.record(),
                                 policy.TriggerStreamPolicy()),
                             names='recorder running input')