Changeset 2995
- Timestamp:
- Jun 1, 2012 8:31:33 PM (12 months ago)
- File:
-
- 1 edited
-
forth/lib/isin.fth (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
forth/lib/isin.fth
r2994 r2995 28 28 2/ to #cycle/4 29 29 ; 30 : u*/ ( u1 unum udenom -- u2 ) >r um* r> um/mod nip ; 30 31 : set-period ( cycle/4 -- ) 31 32 dup to #cycle/4 ( cycle/4 ) … … 33 34 2* dup to #cycle ( cycle ) 34 35 fs over / to freq ( period ) 35 pi swap / fs *to fstep ( )36 pi fs rot u*/ to fstep ( ) 36 37 ; 37 38 38 39 \ Multiply two fractional numbers where the scale factor is 2^15 39 \ : times ( n1 n2 -- n3 ) d# 32767 */ ; \ Insignificantly more accurate, but slower 40 : times ( n1 n2 -- n3 ) * d# 15 rshift ; 40 : times ( n1 n2 -- n3 ) d# 32767 u*/ ; 41 41 42 42 \ Computes (1 - (theta^2 / divisor) * last) … … 49 49 50 50 : icos ( index -- frac ) 51 fstep fs 2/ */ to theta51 fstep fs 2/ u*/ to theta 52 52 theta dup times to thetasq 53 53 one d# 90 cos-step d# 56 cos-step d# 30 cos-step d# 12 cos-step 2 cos-step one min … … 60 60 \ This is good for the first quadrant only, i.e. 0 <= index <= fs / freq / 4 61 61 : calc-sin ( index -- frac ) 62 fstep fs 2/ */ to theta62 fstep fs 2/ u*/ to theta 63 63 theta dup times to thetasq 64 64 one d# 72 sin-step d# 42 sin-step d# 20 sin-step 6 sin-step theta times one min
Note: See TracChangeset
for help on using the changeset viewer.
