diff --git a/README.rst b/README.rst index 1eb8f61..0264ea5 100644 --- a/README.rst +++ b/README.rst @@ -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 @@ -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 `_. diff --git a/cedargrove_waveviz.py b/cedargrove_waveviz.py index ad1ffdd..00f4e98 100644 --- a/cedargrove_waveviz.py +++ b/cedargrove_waveviz.py @@ -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", []) diff --git a/examples/waveviz_simpletest.py b/examples/waveviz_simpletest.py index bd72618..075df63 100644 --- a/examples/waveviz_simpletest.py +++ b/examples/waveviz_simpletest.py @@ -3,6 +3,7 @@ import board import displayio +import synthio import adafruit_ili9341 from cedargrove_wavebuilder import WaveBuilder, WaveShape from cedargrove_waveviz import WaveViz @@ -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