<< >>
justin = { main feed , music , code , askjf , pubkey };recent comments
search
[ present ... 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ... past ]
October 18, 2008
Music
freeform jam with josh


October 15, 2008
Music
post grump


October 11, 2008
Music
freeform jam with brennewtbider


October 3, 2008
Music
freeform jam with schwa


October 1, 2008
stumbling in code

So while playing with some code to model a resonating spring (F=-k*pos), I discovered that the model I was using produced a very good sine wave approximation. This isn't normally something terribly interesting, as you can approximate sine/cosines very easily, but it was actually quite low complexity -- an iterative approximation with only 2 multiplies and 3 adds per sample. It can also generate the cos() (well, a 90 degree shifted signal) for each point for just one additional multiply.

The error is pretty low for the first few cycles, though after a bit it does drift in relation to the correct wave. I'm not going to spend too much more time on this, but if anybody wants to see if there's some way to correct it, go for it (it may just be rounding error, though, of course).

Here is the code:

    // setup:
    double cos_sc = PI/period_samples; // PI/n for a period of n
    double pos=0; // actually sin(initial_state), 1 for cos(), 0 for sin()
    double vel=1/cos_sc; // actually cos(initial_state)/cos_sc, 0 for cos(),1/cos_sc for sin()
    double tmp = cos_sc*cos_sc;
    double tmp2 = 1.0/(1.0+tmp);
    double mul1 = (1.0-tmp)*tmp2;
    double mul2 = tmp*2.0*tmp2;

    // per-sample calculation
    double output_value=pos;
    // double cosine_output = vel*cos_sc;

    // iterate to next sample
    double newpos = pos*mul1 + vel*mul2;
    vel -= (pos+newpos);
    pos = newpos;

Ta-da! If anybody wants to go and do some fancy pants math to show why this works, too, I'd love to hear it... :)



3 Comments


September 28, 2008
Music
freeform jam with brennewtjoshdan


September 27, 2008
Music
brenjoshdan - 1 -- [6:52]
brenjoshdan - 2 -- [54:06]
brenjoshdan - 3 -- [26:31]


September 16, 2008
Music
freeform jam with brennewt and solo


September 8, 2008
Music
kerosene new rough


September 6, 2008
mobile update

Another tag, yay

Recordings:

kerosene

7 Comments


September 3, 2008
Come on, sf dpw

Time to request a hearing, as I do not have any "graffiti" but they seem to think I do....

7 Comments


August 23, 2008
Music
brennewt - 1 -- [45:23]
brennewt - 2 -- [42:25]


August 21, 2008
After 18 hours

The smiley face was me...

Recordings:

bren - 1 -- [23:55]
bren - 2 -- [25:42]
bren - 3 -- [32:27]

5 Comments


August 20, 2008
Front door

We'll see if this works-- both with the kids and with the city...

7 Comments


August 10, 2008
Interesting sense of humor

(note the car #)

8 Comments


August 2, 2008
cures for jet lag:

The 3 Cs: caffeine, calories, and cocktails... Of course you need the right amount of all, and the right sequencing, but if you get that all is forgiven.

And days like this don't hurt either...

2 Comments


July 28, 2008
Spring Cleaning

Found my laptop with ergonomic keyboard!

Recordings:

freeform jam with newtchr

1 Comment


July 25, 2008
I love PHP

Can I just say it? It's such a great tool. I know, I know, it's for web pages, you say.. But I've been using it for tasks people would use perl for, and it's great. Converting Windows .rc files into SWELL-able C++, converting at&t assembly syntax to intel syntax for Jesusonic, such great things. Hooray for PHP. Easy to install on Win32 (just unzip), comes on OS X, it's a good time. A+.

Thank you that is all.

Recordings:

freeform jam with chr

2 Comments


July 23, 2008
Music
brenchr - 1 -- [79:16]
brenchr - 2 -- [25:26]


July 20, 2008
Music
brenbidernewt - 1 -- [8:10]
brenbidernewt - 2 -- [104:38]
brenbidernewt - 3 -- [30:29]


July 9, 2008
Music
freeform jam with brennewt


July 3, 2008
Cubs vs Giants

Still hot out, for now.. Time to shotgun a contraband Bud Lite in the bathroom...

3 Comments


June 25, 2008
Music
bren - 1 -- [44:15]
bren - 2 -- [15:40]


June 23, 2008
Rad toy

Woohoo the tiny maudio ekeys 37, $49, arrived... It's small, and light.

3 Comments


June 19, 2008
Music
demarcate


June 15, 2008
REAPER at Bonnaroo

(thanks to Matt @ Open Labs)

7 Comments


June 14, 2008
best wallpaper ever

(courtesy the Hilton Sonoma Wine Country Inn in Santa Rosa)

1 Comment


June 14, 2008
this was in may

(and it ruled)

Comment...


June 14, 2008
milton, MA



"My friend Will, he's wicked smart."



Comment...


[ present ... 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ... past ]
search : rss : recent comments : Copyright © 2024 Justin Frankel