예제 #1
0
    def __init__(self):
        # Register 0 ($400C)
        self.length_ctr_halt: bool = False
        self.constant_volume: bool = False
        self.volume_envelope: int = 0

        # Register 1 ($400E)
        self.mode: int = 0
        self.period: int = 0

        # Register 2 ($400F)
        self.length_ctr_load: int = 0

        self._length_ctr: int = 0

        # Nasty tricks will have to be used here...

        print("Generating noise wave tables...")

        seq_0 = []
        sr = 1
        prev_val = -1
        for i in range(0, 32767 * 2, 2):
            val = (sr & 1) ^ 1
            if val != prev_val:
                seq_0.append((i, val))
                seq_0.append((i + 1, val))

            feedback = ((sr & 1) ^ ((sr >> 1) & 1)) % 2
            sr = (sr >> 1) | (feedback << 14)

        seq_1 = []
        prev_val = -1
        for i in range(0, 93 * 2, 2):
            val = (sr & 1) ^ 1
            if val != prev_val:
                seq_1.append((i, val))
                seq_1.append((i + 1, val))

            feedback = ((sr & 1) ^ ((sr >> 6) & 1)) % 2
            sr = (sr >> 1) | (feedback << 14)

        self.table = []
        self.table.append(pyo.LinTable(seq_0, 32767 * 2))
        self.table.append(pyo.LinTable(seq_1, 93 * 2))

        print("...done!")

        self.output = pyo.Osc(self.table[0], freq=0, phase=0, interp=1, mul=0)
예제 #2
0
    def __init__(self):
        # Register 0: $4000 / $4004
        self.duty_cycle: int = 0
        self.length_ctr_halt: bool = False
        self.constant_volume: bool = False
        self.volume_envelope: int = 0

        # Register 1: $4001 / $4005
        self.sweep_enabled: bool = False
        self.sweep_period: int = 0
        self.sweep_negate: bool = False
        self.sweep_shift: int = 0

        # Register 2: $4002 / $4006
        self.timer_low: int = 0

        # Register 3: $4003 / $4007
        self.timer_high: int = 0
        self.length_ctr_load = 0

        self._length_ctr: int = 0

        # Create one table per duty cycle value
        self.sequence = [
            [(0, 0.), (7, 0.), (8, 1.), (16, 1.), (17, 0.)],  # 12.5% Duty
            [(0, 0.), (7, 0.), (8, 1.), (24, 1.), (25, 0.)],  # 25% Duty
            [(0, 0.), (7, 0.), (8, 1.), (40, 1.), (41, 0.)],  # 50% Duty
            [(0, 1.), (7, 1.), (8, 0.), (16, 0.), (17, 1.)]
        ]  # 75% Duty

        self.linear_table = pyo.LinTable(self.sequence[2], size=64)

        # Pulse wave output
        self.output = pyo.Osc(self.linear_table, 0, interp=1, mul=0)
예제 #3
0
 def __init__(self):
    self.trig = pyo.Trig()
    decaytable = pyo.LinTable(list=[(0, 1.0), (8191, 0.0)])
    self.env = pyo.TrigEnv(self.trig, table=decaytable, dur=0.6, mul=.25)
    waveform = pyo.SquareTable()
    self.osc = pyo.Osc(waveform, freq=[0.,0.], mul=self.env[0])
    self.output = self.osc.out()
예제 #4
0
 def create_synth_sawtooth_line(self):
     '''Create a sawtooth wave synthesizer using the PYO
     LinTable module.'''
     self.log.debug('creating sawtooth synth [lintable]')
     t = pyo.LinTable([(0, 1), (8191, -1)])
     return pyo.Osc(table=t,
                    mul=0,
                    freq=[FREQ_C4, FREQ_C4])
예제 #5
0
 def __init__(self):
    self.trig = pyo.Trig()
    decaytable = pyo.LinTable(list=[(0,0), (100, 1.0), (8191, 0.0)])
    self.env = pyo.TrigEnv(self.trig, table=decaytable, dur=0.6, mul=[0,0])
    self.spectrum = [1.]+[0.]*15  # 16 total
    self.waveform = pyo.HarmTable(self.spectrum)
    self.osc = pyo.Osc(self.waveform, freq=[0.,0.], mul=self.env)
    self.filter = pyo.Biquad(self.osc, freq=[300.,300.], type=2, q=2.)
    self.output = self.filter.out()
예제 #6
0
 def create_synth_triangle_line(self):
     '''Create a triangle wave synthesizer using the PYO
     LinTable module.'''
     self.log.debug('creating triangle synth [lintable]')
     t = pyo.LinTable([(0, 0), (8192//4, 1), (8192//2, 0),
                       (3*(8192//4), -1), (8191, 0)])
     return pyo.Osc(table=t,
                    mul=0,
                    freq=[FREQ_C4, FREQ_C4])
예제 #7
0
 def __init__(self):
    self.trig = pyo.Trig()
    decaytable = pyo.LinTable(list=[(0,0), (100, 1.0), (8191, 0.0)])
    self.env = pyo.TrigEnv(self.trig, table=decaytable, dur=0.3, mul=.25)
    self.osc = pyo.Sine(freq=[0.,0.], mul=self.env[0])
    self.output = self.osc.out()
예제 #8
0
 def __init__(self, freq):
    self.trig = pyo.Trig()
    decaytable = pyo.LinTable(list=[(0, 1.0), (8191, 0.0)])
    self.env = pyo.TrigEnv(self.trig, table=decaytable, dur=0.6, mul=0.2)
    self.osc = pyo.Sine(freq=freq, mul=self.env).mix(2)
    self.output = self.osc.out()