Skip to content

ToggleButton

Overview

Converts momentary button signals to toggles

Discussion

This module works inconjunction with momentary buttons and converts the presses to toggles. That is, the output is 0 until the first 0->1 transition on the input pin. The output is then fixed at a value of 1 until the next 0->1 transition on the input pin.

The module accepts integer inputs of size numChannels = 1 and different blockSizes. The inputs are integers and a transition is counted as any value which is larger than the previous.

Module Pack

Standard

ClassID

classID = 40

Type Definition

typedef struct _ModuleToggleButton
{
ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
INT32 inState;                                // Last input to the module
INT32 outState;                               // Last output of the module
} ModuleToggleButtonClass;

Variables

Properties

Name Type Usage isHidden Default Value Range Units
inState int state 1 0 Unrestricted
outState int state 1 0 Unrestricted

Pins

Input Pins

Name in
Description audio input
Data type int
Channel range 1
Block size range Unrestricted
Sample rate range Unrestricted
Complex support Real

Output Pins

Name out
Description audio output
Data Type int

Matlab Usage

File Name: toggle_button_module.m 
 M = toggle_button_module(NAME) 
 Audio Weaver module which converts a binary momentary switch input to a  
 toggle button.  Arguments: 
    NAME - name of the module. 

Copyright (c) 2026 DSP Concepts, Inc.