Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a swept-frequency sinusoidal function
ResourceFunction["ChirpFunction"][] generates a function for a chirp signal. |
“InitialFrequency" | 1 | initial frequency in Hz |
“FinalFrequency" | 100 | final frequency in Hz |
"Duration" | 1 | final time in seconds |
"Magnitude" | 1 | height of the sinusoidal peaks |
"ChirpType" | "Logarithmic" | indicates how the frequency should change. Accepted values are "Logarithmic" and "Linear" |
"Sinusoid" | Cos | Sin will give a smooth start. Cos will give an abrupt start. |
"AmplitudeRampFraction" | 0 | fraction of window length for amplitude ramps. Accepts values from 0 to 0.5. |
ChirpFunction returns a compiled function:
In[1]:= |
Out[1]= |
The default cosine base sinusoid goes from 1 Hz to 100 Hz logarithmically over the a time of one second:
In[2]:= |
Out[2]= |
Adjust the frequency range for audibility and hear the result:
In[3]:= |
Out[4]= |
By varying the frequency linearly, the initial lower frequencies are deemphasized:
In[5]:= |
Out[6]= |
Start the signal at zero:
In[7]:= |
Out[8]= |
See the effect of amplitude ramps using the option "AmplitudeRampFraction":
In[9]:= |
Out[10]= |
Options can be provided as an Association:
In[11]:= |
Out[12]= |
Use a longer duration:
In[13]:= |
Out[14]= |
The following examples show the effect of the chirp configuration on the power spectrum:
In[15]:= |
Logarithmic chirp:
In[16]:= |
Out[17]= |
Linear chirp:
In[18]:= |
Out[19]= |
Amplitude adjusted linear chirp:
In[20]:= |
Out[21]= |
Amplitude adjusted logarithmic chirp:
In[22]:= |
Out[23]= |
Change the initial frequency:
In[24]:= |
Out[24]= |
Change the final frequency:
In[25]:= |
Out[25]= |
Change how long it takes to go from the initial to the final frequency:
In[26]:= |
Out[26]= |
Change the magnitude (peak values):
In[27]:= |
Out[27]= |
Change the function type used to vary the frequency:
In[28]:= |
Out[28]= |
A Sin sinusoid results in a smooth rise whereas Cos starts high resembling a step:
In[29]:= |
Out[29]= |
Amplitude ramps can help reduce transient response effects at the start and end:
In[30]:= |
Out[30]= |
The resulting function is not intended to be evaluated for times greater than the specified duration. Doing so will produce unexpected results without warning:
In[31]:= |
Out[32]= |
Create an interactive chirp:
In[33]:= |
Out[33]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License