Hello, A shortvideothisweekshowingfastandsimpleapproximationoffthesinefunction.
Ifyou'rewatchingthisvideo, I'm goingtoassumeyou'vealreadysearchedGoogleforapproximationsofthesinefunctionon a wellawareofftheseveraltechniquesthatarethepeopleusefordifferentplatforms.
So I'm goingtoleaveallofthecaveatsandtheusecasesoffthisapproachtotheendofthevideoonJustgetstuckinwiththegutsofitNow.
Now, ifyou'vewatchedanyofmypreviousvideosonsoundsynthesis, you'llknowthatweusethesinefunction a lot.
Now, assumingwe'reusingfloatingpoint, onewaytohandletheperiodofsteelwouldbetousesomethingalongthelinesof a floatingpointmoduleisfunctionwhichwouldtakeourexinputondhe.
Lateron, however, thisfunctioniscomplex, requiring a floatingpointdivideonitmaynotbesupportedonallplatforms, and I thinkthere's a betterwaytodothisandwhat I'm goingtodoinsteadisnormalizedtheinputtobetweenzeroandone.
Ofcourse, bydividingitbytwopiinthiscase, I wanttokeepitnodividesbecausethey'reusuallyquitecomplicatedtodoso.
Soifwejustcopyoverourfirsthalf, whichwasminus 16 Nexttakezeroon X takeno 0.5 routes.
Andifweah, justtidythisup a littlebit, we'vegotminus 16 Excword.
Takezero x Takeno 0.5 x ontheconstantdisappears.
Nottime.
Notquitefivethatgoesawayon.
Wefillthatoutnowtobe 16 minus 16 x squirt.
Uh, takeeight x Andprogrammersgetveryexcitedwhentheyseesixteensandeightsandfoursandtwosbecauseitusuallymeanstosomescopeforsomebitfieldmanipulationtomoreoptimizedthemathematicsinvolved.
Nowwe'redoingthisallinfloatingpoint.
Butif I didwanttoconvertthisto a fixedpoint, ofcourse, multipliedby 16 istheequivalentoffshifting?