Main Archive Specials Wiki | FAQ Links Submit Forum

Fast sine wave calculation

Type : waveform generation
References : James McCartney in Computer Music Journal, also the Julius O. Smith paper

Notes :
(posted by Niels Gorisse)
If you change the frequency, the amplitude rises (pitch lower) or lowers (pitch rise) a LOT I fixed the first problem by thinking about what actually goes wrong. The answer was to recalculate the phase for that frequency and the last value, and then continue normally.

Code :
ip = phase of the first output sample in radians
w = freq*pi / samplerate
b1 = 2.0 * cos(w)


y0 = b1*y1 - y2
y2 = y1
y1 = y0

output is in y0 (y0 = sin(ip + n*freq*pi / samplerate), n= 0, 1, 2, ... I *think*)

Later note by James McCartney:
if you unroll such a loop by 3 you can even eliminate the assigns!!

y0 = b1*y1 - y2
y2 = b1*y0 - y1
y1 = b1*y2 - y0


Added on : 22/04/03 by kainhart[at]hotmail[ DOT ]com
Comment :
try using this to make sine waves with frequency less that 1. I did and it gives very rough half triangle-like waves. Is there any way to fix this? I want to use a sine generated for LFO so I need one that works for low frequencies.

Added on : 24/10/06 by asynth[ AT ]io[ DOT ]com
Comment :
looks like the formula has gotten munged.
w = freq * twopi / samplerate

Added on : 28/08/13 by joi[ AT ]nea[ DOT ]ufsc[ DOT ]br
Comment :
Hey Rodrigo, great site! Learning a lot already. I was wrineondg, is there a way to make the sine wave not sound as tinny with riffwave.js? It sounds a lot cleaner in the Firefox example, and I'm guessing it's from the fact that you need to round it for riffwave? Is there any way to get around that?

Added on : 29/08/13 by la[ DOT ]cantina[ AT ]vp[ DOT ]pl
Comment :
Kewl you should come up with that. <a href="">Exetnlelc!</a>

Added on : 29/08/13 by jennifergreen[ AT ]fairpoint[ DOT ]net
Comment :
hi can we do a link exchange? i know that this is too much to ask but i'm hnivag trouble right now marketing my blog so I'm expanding my presence by doing link exchanges. I already added you in my blogroll so If you have the time you can check it out. My blog's a tech blog now shifting with anime and gaming. I hope you do have a time putting me in your sidebarthanks a lot!!kyle [url=]xezivf[/url] [link=]oefkjqltn[/link]

Added on : 30/08/13 by dcrock323[ AT ]gmail[ DOT ]com
Comment :
hello, do you mind doing a blog link exchange? my blog is about news of <a href="">firuges</a> with mostly about PVC's. I already put your link in my blog, and hoping that I could be in your blog list too, thanks

Added on : 07/09/13 by trinakhol[ AT ]yahoo[ DOT ]com
Comment :
Hi  in England.. I'm from Liverpool been here in the U.S. forever thugoh.  I went back home in 2009 and stayed with relatives in Leamington Spa and enjoyed every minute.  I love Tiff & company they make me laugh, you make me laugh.  I left a messaage on one of your amazon discussion pages.  Glad I found your series, I'm now playing catch up and having fun reading about Tiff crawling through the prickly bush. [url=]mdaxssosf[/url] [link=]rgvixai[/link]

Added on : 03/03/14 by 005fbff9n[ AT ]hotmail[ DOT ]com
Comment :
Common insurance Quotes Chimp are run and created by customers of policy contract. Unlike an inventory firm, where purchasing an insurance plan provides the possessor no-interest in the insurance firm it self, the action of investing in an insurance policy from a shared firm makes the buyer a balanced person who owns such corporation. Officially, customers possess the corporation but use small handle over mgmt.

Added on : 25/06/17 by buddyray[ AT ]bestemail[ DOT ]stream
Comment :
wh0cd364789 [url=]levitra at lowest cost[/url] [url=]Arimidex By Mail Order[/url] [url=]Ampicillin Quick Shipment[/url]

Added on : 10/09/17 by rpedson[ AT ]rainmail[ DOT ]top
Comment :
[url=]payday loans for bad credit[/url]

Added on : 13/09/17 by gwalker[ AT ]bestemail[ DOT ]stream
Comment :
[url=]cialis over the counter[/url] [url=]cialis 5mg[/url] [url=]buy cialis online[/url]

Added on : 13/09/17 by jwhutch[ AT ]jaggernautemail[ DOT ]win
Comment :
[url=]cialis from canada[/url]

Added on : 13/09/17 by roni377[ AT ]snailmail[ DOT ]men
Comment :
[url=]buy cialis online[/url] [url=]cialis online[/url] [url=]buy cialis online[/url] [url=]buy cialis online[/url] [url=]more help[/url]

Added on : 13/09/17 by littleblueclaw[ AT ]sgdfhghtj5[ DOT ]live
Comment :
[url=]kamagra jelly usa[/url]

Added on : 13/09/17 by davisrg[ AT ]hostnow[ DOT ]men
Comment :
[url=]buy clindamycin[/url] [url=]purchase valtrex online[/url] [url=]tadalis sx without prescription[/url] [url=]prescription amoxicillin[/url]

Added on : 13/09/17 by jboghosian[ AT ]mypop3[ DOT ]win
Comment :
[url=]generic viagra price comparison[/url] [url=]valtrex[/url] [url=]furosemide 20 mg[/url] [url=]elimite[/url]

Added on : 13/09/17 by jamesnew4066[ AT ]simply-email[ DOT ]bid
Comment :
[url=]atarax[/url] [url=]rogaine propecia[/url] [url=]celebrex from canada[/url]

Added on : 13/09/17 by mattie[ AT ]emailme[ DOT ]win
Comment :
[url=]azithromycin[/url] [url=]cialis[/url] [url=]home page[/url] [url=]colchicine drug[/url]

Added on : 13/09/17 by sloanzone5[ AT ]freechatemails[ DOT ]bid
Comment :
[url=]phenergan without a prescription[/url] [url=]zetia tab 10mg[/url] [url=]acomplia rimonabant[/url]

Added on : 14/09/17 by vonreis[ AT ]free-chat-emails[ DOT ]bid
Comment :
[url=]tretinoin 0.025 cream[/url] [url=]azithromycin online[/url] [url=]buy paxil online[/url] [url=]indocin[/url]

Added on : 14/09/17 by job6551[ AT ]freewebpages[ DOT ]top
Comment :
[url=]diclofenac gel[/url]

Added on : 14/09/17 by stephine[ AT ]simplemailserver[ DOT ]bid
Comment :
[url=]clonidine[/url] [url=]plavix generic[/url] [url=]wellbutrin[/url]

Added on : 14/09/17 by toi[ AT ]securesmtp[ DOT ]download
Comment :
[url=]tadacip 20 mg[/url] [url=]soft tabs viagra[/url] [url=]doxycycline hyc 100mg[/url] [url=]where can i buy albuterol[/url]

Added on : 14/09/17 by adele[ AT ]mail-server[ DOT ]bid
Comment :
[url=]allopurinol[/url] [url=]levitra[/url] [url=]purchase augmentin[/url] [url=]vardenafil 20 mg[/url]

Added on : 14/09/17 by standard655[ AT ]bqhost[ DOT ]top
Comment :
[url=]atarax[/url] [url=]hydrochlorothiazide 25mg tablets[/url] [url=]cephalexin[/url] [url=]our site[/url]

Added on : 14/09/17 by tonyobrien1972[ AT ]wwwemail[ DOT ]bid
Comment :
[url=]fluoxetine 10 mg[/url] [url=]allopurinol[/url] [url=]rimonabant[/url] [url=]generic sildalis[/url]

Added on : 14/09/17 by alexanderlaschinski[ AT ]livemail[ DOT ]stream
Comment :
[url=]citalopram[/url] [url=]keflex 250 mg[/url] [url=]buy amoxicillin[/url] [url=]antabuse[/url]

Added on : 14/09/17 by bleplast[ AT ]rainmail[ DOT ]top
Comment :
[url=]payday loans online[/url] [url=]buy essay online[/url]

Added on : 15/09/17 by jackiebligh[ AT ]youripost[ DOT ]download
Comment :
[url=]cialis prescription[/url] [url=]buy cialis online[/url] [url=]Cialis From Canada[/url] [url=]cialis from canada[/url]

Added on : 15/09/17 by svimmeltor[ AT ]youripost[ DOT ]download
Comment :
[url=]generic cialis from canada[/url] [url=]buy cialis online[/url] [url=]buy cialis online[/url] [url=]buy cialis online[/url] [url=]generic viagra cialis[/url]

Added on : 16/09/17 by jocapet[ AT ]rainmail[ DOT ]top
Comment :
[url=]online payday loans direct lenders[/url]

Added on : 17/09/17 by briandavies1945[ AT ]sgdfhghtj5[ DOT ]reisen
Comment :
[url=]Generic Viagra Online[/url] [url=]buy fluoxetine[/url]

Added on : 17/09/17 by cecile[ AT ]evropost[ DOT ]top
Comment :
[url=]payday loans[/url]

Added on : 17/09/17 by raven9283[ AT ]mypop3[ DOT ]win
Comment :
[url=]fluoxetine 20 mg[/url] [url=]Bupropion SR 150 Mg[/url]

Added on : 18/09/17 by kpoloman[ AT ]regiopost[ DOT ]top
Comment :
[url=]More Bonuses[/url]

Added on : 19/09/17 by kyuchan[ AT ]mailmonster[ DOT ]stream
Comment :
[url=]trazodone 100mg[/url] [url=]vardenafil tablets 20 mg[/url]

Added on : 20/09/17 by mkoren0306[ AT ]yourfreemail[ DOT ]stream
Comment :
[url=]doxycycline price[/url]

Added on : 21/09/17 by desilaloo[ AT ]freewebpages[ DOT ]stream
Comment :
[url=]buy colchicine[/url] [url=]erythromycin online[/url] [url=]Doxycycline 100 Mg[/url]

Add your own comment
Comments are displayed in fixed width, no HTML code allowed!


Are you human?

Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion