Esempio n. 1
0
    def __init__(self, address, ordinal):
        agent.Agent.__init__(self,
                             signature=version,
                             names='stereo mixer',
                             protocols='inputlist has_subsys',
                             icon='plg_synth/mixer.png',
                             ordinal=ordinal)

        self.clk = piw.clockdomain_ctl()
        self.vol = piw.make_f2f_table(
            0, 120, 1000, picross.make_f2f_functor(volume_function))
        self.pan = piw.make_f2f_table(-1, 1, 1000,
                                      picross.make_f2f_functor(pan_function))

        self[1] = atom.Atom()
        self[1][1] = bundles.Output(1, True, names='left audio output')
        self[1][2] = bundles.Output(2, True, names='right audio output')

        self.output = bundles.Splitter(self.clk, self[1][1], self[1][2])
        self.final_mixer = piw.stereomixer(self.vol, self.pan, self.clk,
                                           self.output.cookie())
        self.aggregator = piw.aggregator(self.final_mixer.cookie(), self.clk)

        self.ctl_input = bundles.ScalarInput(self.aggregator.get_output(1),
                                             self.clk,
                                             signals=(1, 2))

        self[2] = atom.Atom()
        self[2][1] = atom.Atom(
            domain=domain.BoundedFloat(0,
                                       120,
                                       hints=(T('inc', 1), T('biginc', 10),
                                              T('control', 'updown'))),
            init=100,
            names='master volume',
            policy=self.ctl_input.policy(1,
                                         policy.LopassStreamPolicy(1000,
                                                                   0.97)))
        self[2][2] = atom.Atom(
            domain=domain.BoundedFloat(-1,
                                       1,
                                       hints=(T('inc', 0.02), T('biginc', 0.2),
                                              T('control', 'updown'))),
            init=0,
            names='master pan',
            policy=self.ctl_input.policy(2,
                                         policy.LopassStreamPolicy(1000,
                                                                   0.97)))

        for n in range(0, num_inputs):
            ss = Input(n + 1, self.vol, self.pan, self.clk,
                       self.aggregator.get_output(n + 2), self.signature)
            self.add_subsystem(str(n), ss)
Esempio n. 2
0
    def __set_pan(self, v):
        if v not in pan_laws:
            return errors.doesnt_exist(v, 'set')

        pan_function = pan_laws[v]
        self.pan = piw.make_f2f_table(-1, 1, 1000,
                                      picross.make_f2f_functor(pan_function))
        print 'set pan law', v, self.pan(-1), self.pan(0), self.pan(1)
        self.mixer.set_curves(self.vol, self.pan)
Esempio n. 3
0
    def __init__(self, address, ordinal):
        agent.Agent.__init__(self,
                             signature=version,
                             names='panner',
                             ordinal=ordinal)

        self.pan = piw.make_f2f_table(-1, 1, 1000,
                                      picross.make_f2f_functor(pan_function))

        self.domain = piw.clockdomain_ctl()
        self.output = bundles.Splitter(self.domain)
        self.panner = piw.panner(self.pan, self.output.cookie(), self.domain)
        self.input = bundles.VectorInput(self.panner.cookie(),
                                         self.domain,
                                         signals=(1, 2, 3))

        self[1] = audio.AudioOutput(self.output, 1, 2)
        self[2] = audio.AudioInput(self.input, 2, 2)

        self[3] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                            names="pan input",
                            policy=self.input.merge_policy(
                                1, policy.IsoStreamPolicy(1, -1, 0)))
Esempio n. 4
0
    def __init__(self, address, ordinal):
        # the agent event clock
        self.domain = piw.clockdomain_ctl()

        # verb container, used by all taps
        agent.Agent.__init__(self,
                             signature=version,
                             names='convolver',
                             container=3,
                             ordinal=ordinal)

        self.vol = piw.make_f2f_table(
            -24, 24, 1000, picross.make_f2f_functor(volume_function))

        # outputs
        self[1] = bundles.Output(1, True, names="left audio output")
        self[2] = bundles.Output(2, True, names="right audio output")
        self.output = bundles.Splitter(self.domain, self[1], self[2])

        # the convolver class
        self.convolver = convolver_native.convolver(self.vol,
                                                    self.output.cookie(),
                                                    self.domain)

        # input has the correlator and a bundle style output
        self.input = bundles.ScalarInput(self.convolver.cookie(),
                                         self.domain,
                                         signals=(1, 2, 3, 4))

        # self[3] = verb container

        self[4] = ImpulseBrowser(self)

        # audio inputs
        # use vector policy inputs
        self[5] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                            names="left audio input",
                            policy=self.input.nodefault_policy(1, True))
        self[6] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                            names="right audio input",
                            policy=self.input.nodefault_policy(2, True))

        # wet/dry mix
        self[7] = atom.Atom(domain=domain.BoundedFloat(
            -24,
            24,
            hints=(T('stageinc', 0.1), T('inc',
                                         0.1), T('biginc',
                                                 1), T('control', 'updown'))),
                            init=0,
                            names="dry gain",
                            protocols='input',
                            policy=self.input.merge_policy(3, False))
        self[11] = atom.Atom(domain=domain.BoundedFloat(
            -24,
            24,
            hints=(T('stageinc', 0.1), T('inc',
                                         0.1), T('biginc',
                                                 1), T('control', 'updown'))),
                             init=0,
                             names="wet gain",
                             protocols='input',
                             policy=self.input.merge_policy(4, False))
        # effect enable
        self[8] = atom.Atom(domain=domain.Bool(),
                            init=True,
                            names="enable",
                            protocols='input',
                            policy=atom.default_policy(self.__set_enable))
        # mono processing mode
        self[9] = atom.Atom(domain=domain.Bool(),
                            init=False,
                            names="mono",
                            policy=atom.default_policy(
                                self.__set_mono_processing))
        # enable time, time to fade in and out when enabling in ms
        self[10] = atom.Atom(
            names='enable time input',
            domain=domain.BoundedFloat(0,
                                       100000,
                                       hints=(T('stageinc', 1), T('inc', 1),
                                              T('biginc',
                                                10), T('control', 'updown'))),
            init=100,
            policy=atom.default_policy(self.__set_enable_time))

        self.__set_enable(self[8].get_value())
        self.__set_mono_processing(self[9].get_value())
        self.__set_enable_time(self[10].get_value())

        self.add_verb2(
            1,
            'choose([],None,role(None,[ideal([~server,impulse]),singular]))',
            self.__choose)
Esempio n. 5
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EigenD.  If not, see <http://www.gnu.org/licenses/>.
#

from pi import agent, bundles, atom, action, domain, paths, upgrade, const, policy, node
from . import scaler_version as version
import piw
import picross
from pi.logic.shortcuts import T

linear = lambda: piw.make_f2f_identity()
quadratic = lambda: piw.make_f2f_table(
    -1, 1, 1000, picross.make_f2f_functor(lambda x: x * x
                                          if x > 0 else -x * x))
cubic = lambda: piw.make_f2f_table(
    -1, 1, 1000, picross.make_f2f_functor(lambda x: x * x * x))
step = lambda: piw.step_bucket()

curves = (linear, quadratic, cubic, step)


class Agent(agent.Agent):
    def __init__(self, address, ordinal):
        agent.Agent.__init__(self,
                             signature=version,
                             names='scaler',
                             protocols='bind set',
                             container=5,
Esempio n. 6
0
    def __init__(self, address, ordinal):
        # self[3] is the verb container
        agent.Agent.__init__(self,
                             signature=version,
                             names='console mixer',
                             protocols='inputlist has_subsys oldbrowse',
                             ordinal=ordinal)

        self.clk = piw.clockdomain_ctl()

        pan_function = pan_laws[default_pan]

        # make vol and pan tables
        self.vol = piw.make_f2f_table(
            -70, 14, 1000, picross.make_f2f_functor(volume_function))
        self.pan = piw.make_f2f_table(-1, 1, 1000,
                                      picross.make_f2f_functor(pan_function))

        self[1] = atom.Atom(names='outputs')
        self[1][1] = bundles.Output(1, True, names='left audio output')
        self[1][2] = bundles.Output(2, True, names='right audio output')
        self.output = bundles.Splitter(self.clk, self[1][1], self[1][2])

        self.mixer = piw.consolemixer(self.vol, self.pan, self.clk,
                                      self.output.cookie())

        self[10] = atom.Atom(
            names='pan curve',
            domain=domain.StringEnum(*sorted(pan_laws.keys())),
            init=default_pan,
            policy=atom.default_policy(self.__set_pan))

        self.master_controls_input = bundles.ScalarInput(
            self.mixer.master_controls_cookie(), self.clk, signals=(1, 2))

        self[2] = atom.Atom(names='master')
        self[2][1] = atom.Atom(domain=domain.BoundedFloat(
            -70,
            14,
            hints=(T('stageinc', 0.1), T('inc', 1), T('biginc', 10),
                   T('control', 'updown'), T('distribution', 'tapered'))),
                               init=0,
                               names='master volume',
                               policy=self.master_controls_input.notify_policy(
                                   1,
                                   policy.LopassStreamPolicy(100, 0.97),
                                   notify=self.changes_pending))
        self[2][2] = atom.Atom(domain=domain.BoundedFloat(
            -1,
            1,
            hints=(T('stageinc',
                     0.1), T('inc', 0.02), T('biginc',
                                             0.2), T('control', 'updown'))),
                               init=0,
                               names='master pan',
                               policy=self.master_controls_input.policy(
                                   2, policy.LopassStreamPolicy(100, 0.97)))

        self[3] = ChannelList(self)
        self[4] = FxChannelList(self)

        self.channels = self[3]
        self.fxchannels = self[4]

        # add channels numbered 1..24, which means effect channels cannot be called 1..24 ...
        for n in range(0, num_inputs):
            self.channels.create_channel(n + 1)

        # verbs
        # verb to create a named effect channel
        self.add_verb2(
            1,
            'create([],None,role(None,[abstract,matches([effect])]), option(called,[abstract]))',
            self.__create_fx_chan)
        self.add_verb2(
            2,
            'create([un],None,role(None,[concrete,singular,partof(~(a)#4)]))',
            self.__uncreate_fx_chan)

        self.__timestamp = piw.tsd_time()
        self.__selected = None

        self.__pending = True
        self.__thing = piw.thing()
        piw.tsd_thing(self.__thing)
        self.__thing.set_slow_timer_handler(utils.notify(self.update))
        self.__thing.timer_slow(500)
Esempio n. 7
0
    def __init__(self, address, ordinal):
        # self[3] is the verb container
        agent.Agent.__init__(self,
                             signature=version,
                             names='console mixer',
                             protocols='inputlist has_subsys browse',
                             icon='plg_synth/mixer.png',
                             container=3,
                             ordinal=ordinal)

        self.__private = node.Server()
        self.set_private(self.__private)
        self.__private[1] = container.PersistentFactory(
            asserted=self.__inst_asserted, retracted=self.__inst_retracted)

        self.__private[2] = node.server(value=piw.makestring('testing1', 0))

        self.clk = piw.clockdomain_ctl()

        pan_function = pan_laws[default_pan]

        # make vol and pan tables
        self.vol = piw.make_f2f_table(
            0, 120, 1000, picross.make_f2f_functor(volume_function))
        self.pan = piw.make_f2f_table(-1, 1, 1000,
                                      picross.make_f2f_functor(pan_function))

        self[1] = atom.Atom()
        self[1][1] = bundles.Output(1, True, names='left audio output')
        self[1][2] = bundles.Output(2, True, names='right audio output')
        self.output = bundles.Splitter(self.clk, self[1][1], self[1][2])

        self.mixer = piw.consolemixer(self.vol, self.pan, self.clk,
                                      self.output.cookie())

        sh = (T('choices', *pan_laws.keys()), T('control', 'selector'))
        self[10] = atom.Atom(names='pan curve',
                             domain=domain.String(hints=sh),
                             init='default',
                             policy=atom.default_policy(self.__set_pan))

        # channel dicts
        self.channels = {}
        self.fxchannels = {}

        # adds subsystems numbered 1..24, which means effect channels cannot be called 1..24 ...
        for n in range(0, num_inputs):
            ss = Channel(self, n + 1, self.clk, self.mixer.create_channel(n))
            self.add_subsystem(str(n), ss)
            self.channels[n] = ss

        self.master_controls_input = bundles.ScalarInput(
            self.mixer.master_controls_cookie(), self.clk, signals=(1, 2))

        self[2] = atom.Atom()
        self[2][1] = atom.Atom(domain=domain.BoundedFloat(
            0,
            120,
            hints=(T('inc', 1), T('biginc', 10), T('control', 'updown'))),
                               init=100,
                               names='master volume',
                               policy=self.master_controls_input.notify_policy(
                                   1,
                                   policy.LopassStreamPolicy(100, 0.97),
                                   notify=self.volume_changed))
        self[2][2] = atom.Atom(domain=domain.BoundedFloat(
            -1,
            1,
            hints=(T('inc', 0.02), T('biginc', 0.2), T('control', 'updown'))),
                               init=0,
                               names='master pan',
                               policy=self.master_controls_input.policy(
                                   2, policy.LopassStreamPolicy(100, 0.97)))

        # verbs
        # verb to create a named effect channel
        self.add_verb2(
            1,
            'create([],None,role(None,[abstract,matches([effect])]), role(called,[abstract]))',
            self.__create_named_fx_chan)
        self.add_verb2(
            2,
            'create([un],None,role(None, [abstract,matches([effect])]), role(called,[abstract]))',
            self.__uncreate_named_fx_chan)

        self.add_verb2(
            3,
            'label([],None,role(None,[mass([channel])]),role(to,[abstract]))',
            self.__label)
        self.add_verb2(4, 'label([un],None,role(None,[mass([channel])]))',
                       self.__unlabel)
        self.add_verb2(
            5,
            'label([],None,role(None,[mass([effect])]),role(to,[abstract]))',
            self.__labelfx)
        self.add_verb2(6, 'label([un],None,role(None,[mass([effect])]))',
                       self.__unlabelfx)

        self.__timestamp = piw.tsd_time()
        self.__selected = None

        self.__pending = True
        self.__thing = piw.thing()
        piw.tsd_thing(self.__thing)
        self.__thing.set_slow_timer_handler(utils.notify(self.update))
        self.__thing.timer_slow(500)