In this first example, we'll build a simple programmable gain stage between the audio input and output.
import zrna
# First we create an API client
# and open a connection
z = zrna.api.Client()
z.connect()
# Clear the active circuit
z.clear()
# Declare modules
audio_in = z.AudioIn()
g = z.GainInv()
audio_out = z.AudioOut()
# Add the modules to our circuit
z.add(audio_in)
z.add(g)
z.add(audio_out)
# Wire the modules together
audio_in.output.connect(g.input)
g.output.connect(audio_out.input)
# Set the circuit in motion
z.run()
# At this point the hardware is running
# an inverting gain stage with unity gain
# between the audio input and output
# We can adjust the gain in real time
# by simply assigning a new value to
# the GainInv's gain parameter
g.gain = 10
# This causes the hardware to update the
# running circuit accordingly which makes it easy
# to manipulate circuit parameters however we like
# For example we can create a simple
# stutter effect by adjusting the gain
# in a loop:
import time
while True:
g.gain = 1.0
time.sleep(0.5)
g.gain = 10.0
time.sleep(0.5)