Last active
August 3, 2025 19:32
-
-
Save sletz/960f204a49924dbe4b71184ddb4c9423 to your computer and use it in GitHub Desktop.
Faust linsweep/logsweep test signals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //================ Test signal generators =================== | |
| // Different signal generators for testing purposes. | |
| //============================================================ | |
| sweep_env(fs, fe, dur, mode) = environment { | |
| sweep = sin(phase(mode)) | |
| with { | |
| T = dur * ma.SR; // duration in samples | |
| k = log(fe/fs) / dur; // exponential rate for logarithmic sweep | |
| // current time in seconds, looping every dur | |
| t = ba.time % int(T) / ma.SR; | |
| // Linear phase | |
| phase(0) = 2*ma.PI * (fs*t + (fe-fs)*t*t/(2*dur)); | |
| // Logarithmic phase | |
| phase(1) = 2*ma.PI * fs * (exp(k*t) - 1) / k; | |
| }; | |
| }; | |
| // -----------------`(an.)logsweep`----------------- | |
| // Logarithmic sine sweep generator. | |
| // | |
| // #### Usage | |
| // | |
| // ``` | |
| // logsweep(fs,fe,dur) : _ | |
| // ``` | |
| // | |
| // Where: | |
| // | |
| // * `fs`: start frequency in Hz | |
| // * `fe`: end frequency in Hz | |
| // * `dur`: duration of the sweep in seconds | |
| // ------------------------------------------------ | |
| logsweep(fs, fe, dur) = sweep_env(fs, fe, dur, 1).sweep; | |
| // -----------------`(an.)linsweep`----------------- | |
| // Linear sine sweep generator. | |
| // #### Usage | |
| // | |
| // ``` | |
| // linsweep(fs,fe,dur) : _ | |
| // ``` | |
| // | |
| // Where: | |
| // | |
| // * `fs`: start frequency in Hz | |
| // * `fe`: end frequency in Hz | |
| // * `dur`: duration of the sweep in seconds | |
| // ------------------------------------------------ | |
| linsweep(fs, fe, dur) = sweep_env(fs, fe, dur, 0).sweep; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment