Skip to content

Commit

Permalink
update docs and simpletest; adj env parameter order
Browse files Browse the repository at this point in the history
match parameter order to envelope object
  • Loading branch information
CedarGroveStudios committed Feb 15, 2024
1 parent 0861258 commit 5d2fb6a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
29 changes: 28 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ Usage Example

.. code-block:: python
import board
import displayio
import synthio
import adafruit_ili9341
from cedargrove_wavebuilder import WaveBuilder, WaveShape
from cedargrove_waveviz import WaveViz
Expand Down Expand Up @@ -111,21 +113,46 @@ Usage Example
debug=False,
)
# Create a synthio.Envelope object
env = synthio.Envelope(
attack_time=0.05,
attack_level=1.0,
decay_time=0.1,
release_time=0.1,
sustain_level=0.5,
)
# Display a small version on the bottom layer
splash.append(
WaveViz(wave.wave_table, x=20, y=80, width=25, height=25, back_color=0x0000A0)
)
# Display a full-sized version on the top layer
# Display a full-sized version on the middle layer
splash.append(
WaveViz(wave.wave_table, x=0, y=0, width=300, height=240, back_color=None)
)
# Display the envelope object on the top layer
splash.append(
WaveViz(
env,
x=150,
y=170,
width=80,
height=40,
plot_color=0xFFFFFF,
back_color=0x800080,
envelope_plot=True,
)
)
while True:
pass
Documentation
=============
API documentation for this library can be found in `Cedargrove_WaveViz <https://github.com/CedarGroveStudios/CircuitPython_WaveViz/blob/main/media/pseudo_rtd_cedargrove_waveviz.pdf>`_.
Expand Down
8 changes: 4 additions & 4 deletions cedargrove_waveviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ def _plot_envelope(self):
on the attack and release time values."""
# Get the five envelope values from the wave table
a_time = self._wave_table[0] # Attack time
a_level = self._wave_table[1] # Attack level
d_time = self._wave_table[2] # Decay time
s_level = self._wave_table[3] # Sustain level
r_time = self._wave_table[4] # Release time
a_level = self._wave_table[3] # Attack level
d_time = self._wave_table[1] # Decay time
s_level = self._wave_table[4] # Sustain level
r_time = self._wave_table[2] # Release time

x_points = array("h", [])
y_points = array("h", [])
Expand Down
27 changes: 26 additions & 1 deletion examples/waveviz_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import board
import displayio
import synthio
import adafruit_ili9341
from cedargrove_wavebuilder import WaveBuilder, WaveShape
from cedargrove_waveviz import WaveViz
Expand Down Expand Up @@ -44,15 +45,39 @@
debug=False,
)

# Create a synthio.Envelope object
env = synthio.Envelope(
attack_time=0.05,
attack_level=1.0,
decay_time=0.1,
release_time=0.1,
sustain_level=0.5,
)


# Display a small version on the bottom layer
splash.append(
WaveViz(wave.wave_table, x=20, y=80, width=25, height=25, back_color=0x0000A0)
)

# Display a full-sized version on the top layer
# Display a full-sized version on the middle layer
splash.append(
WaveViz(wave.wave_table, x=0, y=0, width=300, height=240, back_color=None)
)

# Display the envelope object on the top layer
splash.append(
WaveViz(
env,
x=150,
y=170,
width=80,
height=40,
plot_color=0xFFFFFF,
back_color=0x800080,
envelope_plot=True,
)
)

while True:
pass

0 comments on commit 5d2fb6a

Please sign in to comment.