MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Linear and Exponential Chirp Functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110634] Linear and Exponential Chirp Functions
  • From: telefunkenvf14 <rgorka at gmail.com>
  • Date: Tue, 29 Jun 2010 08:40:03 -0400 (EDT)

Group:

A while back I needed an exponential chirp function and was only able
to track down a linear version by Will Robertson. Hopefully someone
will find these useful.

linearChirp::usage = "linearChirp[f0_, f1_, t_, T_] generates a linear
chirp signal with initial frequency f0 and ending frequency f1 at time
T seconds; t represents the time index variable."

expChirp::usage = "expChirp[f0_, f1_, t_, T_] generates an exponential
chirp signal with initial frequency f0 and ending frequency f1 at time
T seconds; t represents the time index variable."

Attributes[linearChirp] = {NumericFunction}
linearChirp[f0_, f1_, t_, T_] :=Sin[2*Pi*t*(f0 + ((f1 - f0)/T*t)/2)]

Attributes[expChirp] = {NumericFunction}
expChirp[f0_, f1_, t_, T_] :=Sin[(2*f0*(-1 + (f1/f0)^(t/T))*Pi*T)/
Log[f1/f0]]

------------------------------------ Example Uses
------------------------------------------
(*Just gives you the function; plug a value in for t to get the
function value*)
linearChirp[10, 30, t, 1]

(*Compare plots... change the 10 to a 1 to see more of a difference*)
Plot[linearChirp[10, 30, t, 1], {t, 0, 1}]
Plot[expChirp[10, 30, t, 1], {t, 0, 1}]

(*Create a 40 second expChirp with starting frequency 20Hz, ending
frequency 400Hz. Evaluate[] forces the function to evaluate first---
speeds things up. Note that SampleDepth and SampleRate are overkill
for this example; my goal was to avoid digital shenanigans later.*)

Play[Evaluate@expChirp[20, 400, t, 40], {t, 0, 40}, SampleDepth -> 24,
SampleRate -> 44100]]

-RG



  • Prev by Date: Re: numerical integration
  • Next by Date: Re: Export to .xlsx or .ods ?
  • Previous by thread: Re: Exporting a List of Tables with different Lengths to a tabulator
  • Next by thread: Run Package vs Needs