Creating PWM wavetablesfor loop syntax The for loop syntax is a way to loop through the array elements in order. By iterating, multiple files can be generated in sequence. This can be used to generate multiple single-cycle waveforms. for loop
The above code loops through the numbers 1 through 5. When executed, it generates five sine waves from the base note to the fifth overtone in sequential numbers. Sawtooth and Square wave There are Sawtooth and Square functions in the signal package. The value of width for sawtooth accepts values from 0 to 1. Values of 0 and 1 are sawtooth waves, and 0.5 is a triangle wave. The value of duty for square accepts values from 0 to 100. By varying the value, PWM can be performed. Waveforms that can be created in Octave
Two optional features can be used to create Wavetables. Saw to Triangle The script below creates a wavetable that changes from a sawtooth wave to a triangle wave by gradually changing the value of width. Saw to Triangle
Pulse Width Modulation The following script creates a PWM wavetable by gradually varying the value of duty. PWM
|