What?! No 'Chirp' function in MMA? Here you go...

Applied Science, Chemical Engineering, Civil Engineering, Control Systems, Electrical Engineering, Fluid Mechanics, Image Processing, Mechanical Engineering, Robotics, Signal Processing, Computational Geometry, Computer Graphics, Data Structures, Algorithm Development, Numerical Analysis, Cryptography, etc.
Forum Rules
By using the Wolfram Faculty Program Forum, you agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, or sexually oriented material. Wolfram Faculty Program Forum administrators have the right to remove, edit, move or close any topic at any time should we see fit.

Personal Information: Posts in this forum may be viewed by non-members; however, the forum prohibits non-members from viewing your profile. Although your email address is hidden from both non-members and members, your account is initially configured to allow members to contact you via email through the forum. If you wish to hide your profile, or prohibit others from contacting you directly, you may change these settings by updating your profile through the User Control Panel.

Attachments: Attachments are not currently enabled on this forum. To share a file with others on this site, simply upload your file to the online storage service of your choice and include a link to the file within your post. If your school does not offer an online file storage and sharing service, the following sites provide free basic online file storage and sharing: Mozy, FilesAnywhere, Adrive, and KeepandShare.

What?! No 'Chirp' function in MMA? Here you go...

I posted this on MathGroup and figured someone here might find it useful as well.

----------------------------------

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

telefunkenvf14

Posts: 46
Joined: Tue Apr 27, 2010 7:40 pm
Location: Lincoln, NE
Department: Economics

Who is online

Users browsing this forum: No registered users and 1 guest