Skip to content

SampleRate

Overview

Measures the sample rate of the input signal

Discussion

Sample rate measurement module. The module is designed measure the sample rate of the signal on single channel. Seperate modules are required to measure the sample rate on different channels. The module compares the measured sample rate with the allowable sample rates and estimates the nearest value. The measured sample rate will be displayed on the inspector.

The module can also compute the sample rate averaged over multiple blocks. .numBlocksToAverage specifies how many blocks to use for the averaging.

The module also optionally outputs the measured sample rate on an output pin. This option is selected by setting the argument SROUTPIN to true. The sample rate value is output an an integer.

Module Pack

Advanced

ClassID

classID = 1318

Type Definition

typedef struct _ModuleSampleRate
{
ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
FLOAT32 procSpeed;                            // Processor clock speed in MHz
INT32 numBlocksToAverage;                     // Number of blocks to process before the sample rate is retured
INT32 lastCount;                              // Holds the last call cycle count
INT32 averageDeltaCount;                      // Holds the average delta count of numBlocksToAverage calls
INT32 SRArrayLength;                          // Number of sample rates that can be estimated
INT32 initialized;                            // Specifies whether the last cycle counter has been initialized
INT32 dataValid;                              // Indicates whether the sample rate measurement is valid
FLOAT32 measuredSR;                           // Readback variable.  Displays the measured sample rate on the inspector
FLOAT32 prevMeasuredSR;                       // Last measured sample rate
FLOAT32 prevPrevMeasuredSR;                   // Previous to last measured sample rate
INT32 SROutPin;                               // Boolean specifies whether module will have output pin
INT32 blockCounter;                           // Counts up to numBlocksToAverage
FLOAT32* allowableSR;                         // Array of possible sample rates
} ModuleSampleRateClass;

Variables

Properties

Name Type Usage isHidden Default Value Range Units
procSpeed float parameter 0 10 Unrestricted
numBlocksToAverage int parameter 0 100 1:16384
lastCount int state 0 0 Unrestricted
averageDeltaCount int state 0 0 Unrestricted
SRArrayLength int const 0 3 Unrestricted
initialized int state 0 0 Unrestricted
dataValid int state 0 0 0:1
measuredSR float state 0 48000 Unrestricted
prevMeasuredSR float state 0 0 Unrestricted
prevPrevMeasuredSR float state 0 0 Unrestricted
SROutPin int const 0 1 Unrestricted
blockCounter int state 0 0 Unrestricted
allowableSR float* parameter 0 [3 x 1] Unrestricted

Pins

Input Pins

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

Output Pins

Name out
Description Measured sample rate
Data Type int

Matlab Usage

File Name: measure_sample_rate_module.m 
 M=measure_sample_rate_module(NAME, SRARRAYLEN, SROUTPIN) 
 Creates a sample rate measure module for use with the Audio 
 Weaver.  Arguments: 
     NAME - name of the module. 
     SRARRAYLEN - Array length of the allowable sample rates 
     SROUTPIN - Boolean which specifies whether module outputs detected  
                sample rate that can be used as the input to sample rate 
                switch module 

Copyright (c) 2026 DSP Concepts, Inc.