import Axon
from Kamaelia.Apps.Jam.Audio.Polyphony import Polyphoniser

class Synth(Axon.Component.component):
    polyphony = 8
    polyphoniser = Polyphoniser

    def __init__(self, voiceGenerator, **argd):
        super(Synth, self).__init__(**argd)
        polyphoniser = self.polyphoniser(**argd).activate()
        self.link((self, "inbox"), (polyphoniser, "inbox"), passthrough=1)

        for index, voice in enumerate(voiceGenerator()):
            voice = voice.activate()
            self.link((polyphoniser, "voice%i" % index), (voice, "inbox"))

    def main(self):
        while 1:
            if not self.anyReady():
                self.pause()
            yield 1

@@ -1,213 +1,1631 @@
-import Axon%0Afrom Kamaelia.Apps.Jam.Audio.Polyphony import Polyphoniser%0A%0Aclass Synth(Axon.Component.component):%0A    polyphony = 8%0A    polyphoniser = Polyphoniser%0A%0A    def __init__(self, voiceGenerator, **argd):
+%22%22%22%0A=============%0ASynth Builder%0A=============%0A%0AA simple component for connecting a polyphony component to a number of voices.  This means less typing is needed, and provides a simple way to encapsulate a synth system in a single component.  The component takes a generator as an argument which provides the Synth with its voices, allowing more flexibility in how which voices are used, and how they are created.%0A%0AExample Usage%0A-------------%0AAn 8 voice sine synth%0A%0Adef voiceGenerator():%0A    for i in range(8):%0A        yield SineVoice()%0A%0APipeline(PianoRoll(),%0A         Synth(voiceGenerator, polyphony=8)).run()%0A%0AHow it works%0A------------%0AThe component creates the polyphoniser, and links up its %22inbox%22 inbox to the polyphoniser's %22inbox%22 inbox.  It then loops over the voice generator, linking the voice outputs from the polyphoniser to the voices which are created.%0A%0A%22%22%22%0Aimport Axon%0Afrom Kamaelia.Apps.Jam.Audio.Polyphony import Polyphoniser%0A%0Aclass Synth(Axon.Component.component):%0A    %22%22%22%0A    Synth(voiceGenerator, %5Bpolyphoniser, polyphony%5D) -%3E new Synth component%0A    %0A    Creates a synth system from a polyphony component and a number of generated%0A    voices%0A%0A    Arguments:%0A    - voiceGenerator -- A generator which yields non-activated voice components%0A%0A    Keyword Arguments:%0A    - polyphoniser -- The component to use as a polyphoniser%0A    - polyphony    -- The number of simultaneous voices the synth will have%0A    %22%22%22%0A%0A    polyphony = 8%0A    polyphoniser = Polyphoniser%0A%0A    def __init__(self, voiceGenerator, **argd):%0A        %22%22%22%0A        x.__init__(...) initializes x; see x.__class__.__doc__ for signature%0A        %22%22%22
 %0A   
@@ -1991,16 +1991,42 @@
 (self):%0A
+        %22%22%22 Main loop %22%22%22%0A
         

Add documentation to the Synth component