jdxi_editor.ui.widgets.pitch.pwm_plot

This module defines the ADSRPlot class, address QWidget subclass that visualizes an ADSR (Attack, Decay, Sustain, Release) envelope using Matplotlib. The plot displays the envelope’s progression over time, with adjustable parameters for attack, decay, sustain, and release times, as well as initial, peak, and sustain amplitudes.

The plot is rendered in address QWidget, and the background and text colors are customized for better visibility, with the envelope plotted in orange on address dark gray background.

Classes:

  • ADSRPlot: A QWidget subclass that generates and displays an ADSR envelope plot.

Methods:

  • __init__(self): Initializes the widget and sets up the figure and layout for the plot.

  • plot_envelope(self): Generates and plots the ADSR envelope based on the current envelope parameters.

  • set_values(self, envelope): Updates the envelope parameters and refreshes the plot.

Customization:

  • The plot background is dark gray (#333333), with all plot elements (ticks, labels, title) in orange for better visibility against the dark background.

  • The time is represented in seconds, and the amplitude in address range from 0 to 1.

Classes

PWMPlot

Base class for plot widgets that provides common shading functionality.

Functions

generate_square_wave(→ numpy.ndarray)

Generates a square wave with a given duty cycle (width ∈ [0, 1]).

Module Contents

jdxi_editor.ui.widgets.pitch.pwm_plot.generate_square_wave(width: float, mod_depth: float, sample_rate: int, duration: float) numpy.ndarray[source]

Generates a square wave with a given duty cycle (width ∈ [0, 1]).

class jdxi_editor.ui.widgets.pitch.pwm_plot.PWMPlot(width: int = JDXi.UI.Style.ADSR_PLOT_WIDTH, height: int = JDXi.UI.Style.ADSR_PLOT_HEIGHT, envelope: dict = None, parent: PySide6.QtWidgets.QWidget = None)[source]

Bases: jdxi_editor.ui.widgets.plot.base.BasePlotWidget

Base class for plot widgets that provides common shading functionality.

point_moved = None[source]
parent = None[source]
enabled = True[source]
envelope = None[source]
sample_rate = 256[source]
attack_x = 0.1[source]
decay_x = 0.3[source]
peak_level = 0.5[source]
release_x = 0.7[source]
dragging = None[source]
set_values(envelope: dict) None[source]

Update envelope values and trigger address redraw

Parameters:

envelope – dict

Returns:

None

mousePressEvent(event)[source]
mouseMoveEvent(event)[source]
mouseReleaseEvent(event)[source]
setEnabled(enabled)[source]
draw_custom_ticks(ctx: jdxi_editor.ui.widgets.plot.base.PlotContext, config: jdxi_editor.ui.widgets.plot.base.PlotConfig) None[source]

Draw custom tick marks for PWMPlot.

draw_grid_hook(ctx: jdxi_editor.ui.widgets.plot.base.PlotContext, config: jdxi_editor.ui.widgets.plot.base.PlotConfig) None[source]

Draw grid for PWMPlot with custom Y callback.

envelope_parameters()[source]

Generate pulse width envelope

get_plot_config() jdxi_editor.ui.widgets.plot.base.PlotConfig[source]

Get plot configuration with PWMPlot-specific settings.

get_y_range() tuple[float, float][source]

Get Y range for PWMPlot (-0.2 to 1.2).

zero_at_bottom() bool[source]

PWMPlot does not have zero at bottom (uses y_max/y_min scaling).

get_title() str[source]

Get plot title.

get_x_label() str[source]

Get X-axis label.

get_y_label() str[source]

Get Y-axis label.

draw_data(ctx: jdxi_editor.ui.widgets.plot.base.PlotContext, config: jdxi_editor.ui.widgets.plot.base.PlotConfig) None[source]

Draw PWMPlot envelope data.