This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
tonegen_design [2022/03/17 02:34] dpisuperadmin [Minimal Tone Generator with Volume Control] |
tonegen_design [2022/03/20 03:45] dpisuperadmin |
||
---|---|---|---|
Line 12: | Line 12: | ||
==== Minimal Tone Generator with Volume Control ==== | ==== Minimal Tone Generator with Volume Control ==== | ||
- | A full synthesizer, as described below, | + | A full synthesizer may take more that its fair share of FPGA logic. |
The API for a simple tone generator might specify the musical note to play, the volume in the range of 0 to 100, and the number of milliseconds to play the note. We might also want to play a file of notes where each line the the file has the note, volume, and duration. | The API for a simple tone generator might specify the musical note to play, the volume in the range of 0 to 100, and the number of milliseconds to play the note. We might also want to play a file of notes where each line the the file has the note, volume, and duration. | ||
- | dpset tonegen | + | dpset tonegen |
- | dpset tonegen | + | dpset tonegen |
{{ wiki: | {{ wiki: | ||
Line 155: | Line 155: | ||
grid on; | grid on; | ||
print -dpng '/ | print -dpng '/ | ||
- | |||
- | % Generate 100 points on an log curve and map the gain | ||
- | % to setting in pwm - nonlinear DAC scheme. | ||
- | % the actual table to use in the API driver modules. | ||
- | % Manually add {0,0,0,0} and {15, | ||
- | |||
- | % Get the target gains | ||
- | x = 1:1:100; | ||
- | out = exp((5 .* x) ./ 100) ./ 150; | ||
- | target_idx = 1; | ||
- | % loop past all possible gains recording the first to pass out(target_idx) | ||
- | idx = 0; | ||
- | for i3 = 0:15; | ||
- | for i2 = 0:15; | ||
- | for i1 = 0:15; | ||
- | for i0 = 0:15; | ||
- | idx = idx +1; | ||
- | | ||
- | if outval > out(target_idx), | ||
- | | ||
- | | ||
- | | ||
- | end | ||
- | end | ||
- | end | ||
- | end | ||
- | end | ||
*/ | */ |