Skip to content

DelayNChanV2

Overview

Module with different time delay for each channel specified in samples

Discussion

This time delay module has multiple input and multiple output channels. The delay in samples of each output channel can be independently set by the currentDelay array. The initial number of channels is specified at construction time and this also equals the length of the currentDelay array. Actual size of the currentDelay and numChannels argument is updated in the prebuild function based on the channel count in the input pin . Delays are specified in samples and are in the range of [0 MaxDelayPerChannel].

At construction time, you specify the maximum delay (maxDelay) of each channel in comma separated string. The maxDelay determines the size of the internal state buffer. The size of the maxDelay argument string is updated based on the number of channels from the input pin. i.e. if the default module is instantiated with 1 channel and with 500 maxDelay and if the input pin is with 6 channels then the size of maxDelay argument will be 6 values with remaining 5 values as default number of 100. The size of the internal state buffer equals sum of (maxDelay + 1) of each channel, samples. The delay in samples per channel is specified by the currentDelay array. Delays can be adjusted at run-time. Please note that there is no range check for currentDelay in the inspector and it can go beyond maxDelay for that channel. But it is clipped to valid range on the target side before applying the current delay. However, the module is not smoothly updating and you may get audible clicks when adjusting the currentDelay at run-time.

Module Pack

Advanced

ClassID

classID = 1384

Type Definition

typedef struct _ModuleDelayNChanV2
{
ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
INT32 stateHeap;                              // Heap in which to allocate memory.
INT32 maxDelayTotal;                          // Total max delay of all channels.
INT32* maxDelay;                              // Maximum delay per channel, in samples.
INT32* currentDelay;                          // Current delay per channel, in samples.
INT32* stateIndex;                            // Index of the oldest state variable in the array of state variables.
FLOAT32* state;                               // State variable array.
void * hardware_specific_struct_pointer;      // Usually NULL, but for optimizations, this may point to a struct that varies based on the target platform
} ModuleDelayNChanV2Class;

Variables

Properties

Name Type Usage isHidden Default Value Range Units
stateHeap int const 1 561 Unrestricted
maxDelayTotal int state 1 133 Unrestricted
maxDelay int* const 0 [1 x 1] Unrestricted samples
currentDelay int* parameter 0 [1 x 1] Unrestricted samples
stateIndex int* state 1 [1 x 1] Unrestricted
state float* state 1 [133 x 1] Unrestricted
hardware_specific_struct_pointer void * state 1 Unrestricted

Pins

Input Pins

Name in
Description audio input
Data type {float, int, fract32}
Channel range Unrestricted
Block size range Unrestricted
Sample rate range Unrestricted
Complex support Real

Output Pins

Name out
Description audio output
Data Type {float, int, fract32}

Matlab Usage

File Name: delaynchan_v2_module.m 
 M=delaynchan_v2_module(NAME, NUMCHANNELS, MEMHEAP, MAXDELAY) 
 Creates a multi-channel time delay. The module has a multichannel input pin 
 and an multichannel output pin. Each output channel is a delayed 
 version of the corresponding input channel with different delay times  
 per channel. 

 Arguments: 
    NAME - name of the module. 
    NUMCHANNELS - number of channels for the module. 
    MEMHEAP - specifies the memory heap to use to allocate the main 
         state buffer. This is a string and follows the memory allocation 
         enumeration in Framework.h. Allowable values are: 
            'AWE_HEAP_FAST' - always use internal DM memory. 
            'AWE_HEAP_FASTB' - always use internal PM memory. 
            'AWE_HEAP_SLOW' - always use external memory. 
            'AWE_HEAP_FAST2SLOW' - use internal memory. If this fails 
               then use external memory (the default). 
            'AWE_HEAP_FASTB2SLOW' - use internal memory. If this fails 
               then use external memory. 
    MAXDELAY - maximum delay per channel, in samples. It is a comma 
              separated string with each value per channel. 

Copyright (c) 2026 DSP Concepts, Inc.