Audio Oscillator
Libraries:
Audio Toolbox /
Sources
Description
The Audio Oscillator block generates tunable waveforms. Typical uses include the generation of test signals for test benches, and the generation of control signals for audio effects. Parameters of the Audio Oscillator block specify the type of waveform generated.
Examples
Generate Variable-Frequency Tones in Simulink
Examine the Audio Oscillator block in a Simulink® model and tune the parameters.
Ports
Input
F — Frequency (Hz)
nonnegative scalar | vector of nonnegative values
Dependencies
To enable this port, select Specify frequency from input port for the Frequency (Hz) parameter.
Data Types: single
| double
A — Amplitude
nonnegative scalar | vector of nonnegative values
Dependencies
To enable this port, select Specify amplitude from input port for the Amplitude parameter.
Data Types: single
| double
DC — DC offset
scalar | vector
Dependencies
To enable this port, select Specify DC offset from input port for the DC offset parameter.
Data Types: single
| double
Output
Port_1 — Output signal
vector
The Audio Oscillator block outputs a periodic signal defined by the parameters of the block.
Data Types: single
| double
Parameters
If a parameter is listed as tunable, then you can change its value during simulation.
Frequency (Hz) — Frequency of generated waveform
100
(default) | nonnegative scalar | vector of nonnegative values
If Signal type is set to
sine
, specify Frequency (Hz) as a scalar or as a vector. If Frequency (Hz) is set to an N-element vector, then the output from the block is the single-channel sum of N sinusoids. If Frequency (Hz) is set to an N-element vector, then Amplitude, Phase offset, and DC offset must be scalars or N-element vectors.For square waveforms, specify Frequency (Hz) as a scalar.
For sawtooth waveforms, specify Frequency (Hz) as a scalar.
To specify Frequency (Hz) from an input port, select Specify frequency from input port.
Tunable: Yes
Amplitude — Amplitude of generated waveform
1
(default) | nonnegative scalar | vector of nonnegative values
If Signal type is set to
sine
, specify Amplitude as a scalar or as a vector. If Amplitude is set to an N-element vector, then the output from the block is the single-channel sum of N sinusoids. If Amplitude is set to an N-element vector, then Frequency (Hz), Phase offset, and DC offset must be scalars or N-element vectors.For square waveforms, specify Amplitude as a scalar.
For sawtooth waveforms, specify Amplitude as a scalar.
To specify Amplitude from an input port, select Specify amplitude from input port.
Tunable: Yes
Phase offset — Normalized phase offset of generated waveform
0
(default) | scalar in the range [0, 1] | vector with values in the range [0, 1]
The phase offset range, [0,1]
, corresponds to a normalized 2π
radians interval.
If Signal type is set to
sine
, specify Phase offset as a scalar or as a vector. If Phase offset is set to an N-element vector, then the output from the block is the single-channel sum of N sinusoids. If Phase offset is set to an N-element vector, then Frequency (Hz), Amplitude, and DC offset must be scalars or N-element vectors.For square waveforms, specify Amplitude as a scalar.
For sawtooth waveforms, specify Amplitude as a scalar.
DC offset — Value added to each element of generated waveform
0
(default) | scalar | vector
If Signal type is set to
sine
, specify DC offset as a scalar or as a vector. If DC offset is set to an N-element vector, then the output from the block is the single-channel sum of N sinusoids. If DC offset is set to an N-element vector, then Frequency (Hz), Amplitude, and Phase offset must be scalars or N-element vectors.For square waveforms, specify Amplitude as a scalar.
For sawtooth waveforms, specify Amplitude as a scalar.
To specify DC offset from an input port, select Specify DC offset from input port.
Tunable: Yes
Duty cycle — Square waveform duty cycle
0.5
(default) | scalar in the range [0, 1]
Square waveform duty cycle is the percentage of one period in which the waveform is above the median amplitude. A duty cycle value of 1 or 0 is equivalent to a DC signal.
Dependencies
To enable this parameter, set Signal type to
square
.
Width — Sawtooth width
1
(default) | scalar in the range [0, 1]
Sawtooth width determines the point in a sawtooth waveform period at which the maximum occurs.
Dependencies
To enable this property, set Signal type to
sawtooth
.
Samples per frame — Number of samples per frame
512
(default) | positive integer
Number of samples per frame, specified as a positive integer.
Sample rate (Hz) — Sample rate of generated waveform
44100
(default) | positive scalar
The sample rate must be greater than twice the value specified in Frequency (Hz).
Output data type — Data type of generated waveform
double
(default) | single
Data type of generated waveform, specified as double
or
single
.
Tunable: No
Simulate using — Specify type of simulation to run
Code generation
(default) | Interpreted execution
Code generation
– Simulate the model using generated C code. The first time you run a simulation, Simulink® generates C code for the block. The C code is reused for subsequent simulations, as long as the model does not change. This option requires additional startup time, but the speed of the subsequent simulations is comparable toInterpreted execution
.Interpreted execution
– Simulate model using the MATLAB® interpreter. This option reduces startup time and the simulation has speed comparable toCode generation
. In this mode, you can debug the source code of the block.
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2020a
See Also
Wavetable Synthesizer | audioOscillator
| Audio Device Writer
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)