justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[newer questions][unreplied] | [replied] | [recent comments] | [all]
[older questions]

Question: Maybe this guy could be added to your list of respected programmers? bellard.org/
Asked by Will (24.234.85.x) on February 8 2013, 12:57am
Reply on February 8 2013, 9:00pm (edited at February 8 2013, 9:01pm):
    I don't really keep a list, but I saw that javascript PC emulator and thought it was completely awesome.
Comment...
Question: Still use winamp?Or use other players?
Asked by gepao (84.79.188.x) on February 8 2013, 12:11am
Reply on February 8 2013, 9:01pm:
    Yep, mostly. Or my iphone.
Comment...
Question: Will you let us style askjf to look better? :P
Asked by Will (24.234.85.x) on February 7 2013, 11:25pm
Reply on February 8 2013, 9:01pm:
    Is it really worth bothering? give me yur css.
Comment...
Question: What blogs do you read?
Asked by ees. (69.15.110.x) on February 7 2013, 7:36pm
Reply on February 7 2013, 7:54pm:
    Off the top of my head, The Old New Thing, Coding Horror, virtualdub.org (rarely, it isn't often updated). I also end up reading blogs via twitter (Paul Krugman, Steven Wittens, others too).
Comment...
Question: What language would you imagine that aliens code in?
Asked by NuttyProfessor (76.226.116.x) on February 7 2013, 2:21am
Reply on February 7 2013, 2:50am:
    assembly, no doubt, but I can't imagine the instruction set.
Comment...
Question: On your b-tree code, wouldn't the lh operand in the return recursively execute before the rh, throwing off the original reqs?
Asked by Will (24.234.85.x) on February 6 2013, 10:44pm
Reply on February 7 2013, 2:49am (edited at February 7 2013, 3:42am):
    Yes (it processes left before right), but no, it does what (as I understood, anyway) the requirements specified, since each top level call to the recursive function only prints a single level of the tree, so the left-to-rightness is what you want. Edit: here, this might be easier to understand (exact same function, just more clear code):
    f(h, levelToPrint, currentLevel) {
        if (currentLevel > levelToPrint) return 0;
        if (!h) {
            if (currentLevel == levelToPrint) print("(null)");
            return 0;
        }
        if (currentLevel == levelToPrint) {
            print(h);
            return 1;
        }
        return f(h.left,levelToPrint, currentLevel+1) + f(h.right,levelToPrint, currentLevel+1);
    }
    
    levelToPrint=0;
    while (f(tree,levelToPrint++,0)) print("\n");
    
Comment...
Question: I was so blind aghhhhh - Justin, thank you so much for opening my eyes with the delay class - you are genius :)
Asked by Franci (89.142.37.x) on February 6 2013, 8:30pm
Reply on February 7 2013, 2:49am:
    Glad I could help!
Comment...
Question: why is reaWASAPI tagged as "experimental"? do you personnaly use it?
Asked by frenchos (46.218.205.x) on February 6 2013, 5:08pm
Reply on February 7 2013, 2:49am:
    Sometimes, but it can be finicky to get it to work right depending on the hardware, exclusive/shared modes, etc.
Comment...
Question: The tracker seems to have ground to a halt. Elevated FRs seem forgotten as nothing happens with them?
Asked by Tinny (88.207.125.x) on February 6 2013, 9:52am
Reply on February 6 2013, 3:08pm:
    Yeah, the tracker isn't terribly enjoyable to use as a developer. :/
Comment...
Question: Does raping the tertiary operator produce faster machine code than writing legible code (the later version)?
Asked by Will (70.173.150.x) on February 6 2013, 8:35am
Reply on February 6 2013, 2:43pm:
    I don't think so, but part of me wanted the two-line f().
Comment...
Question: There was talk a while back about creating an open source plugin SDK, to get around the VST restrictions, and progress on that?
Asked by Mick (203.149.85.x) on February 6 2013, 2:47am
Reply on February 6 2013, 4:13am:
    Not enough of a point, VST is just lenient enough to make it not worth bothering I think.
Comment...
Question: What's a good algorithm to display a binary tree from the top down one level at a time left to right?
Asked by Will (24.234.85.x) on February 5 2013, 10:34pm
Reply on February 6 2013, 4:11am (edited at February 6 2013, 4:37am):
    The obvious way I'd imagine doing it would be O(N*log(N)), which seems reasonable enough I guess?
    f(h, level) {
        if (level == 0) print(h); // h might be null
        return h && level >= 0 ? level==0 ? 1 : f(h.left,level-1) + f(h.right,level-1) : 0;
    }
    
    l=0;
    while (f(tree,l++)) print("\n");
    
    Edit: updated to print null leaves for levels that are printed...
    Edit: further updated to overuse the tertiary operator. Regretting this, here is the less obfuscated version:
    f(h, level) {
        if (level < 0) return 0;
        if (!h) {
            if (level == 0) print("(null)");
            return 0;
        }
        if (level == 0) {
            print(h);
            return 1;
        }
        return f(h.left,level-1) + f(h.right,level-1);
    }
    
    l=0;
    while (f(tree,l++)) print("\n");
    
Comment...
Question: I want to make function which returns input data shifted by x samples (like plugin latency)
Asked by Franci (46.122.98.x) on February 5 2013, 6:57pm
Reply on February 6 2013, 4:02am (edited at February 6 2013, 4:03am):
    Ah, like a FIFO queue? How about:
    class delay {
        double *m_buf;
        int m_len,m_pos;
    public:
        delay(int len) { m_len=len; m_buf=(double*)calloc(sizeof(double),len); m_pos=0; }
        ~delay() { free(m_buf); }
        double process(double in) {
            double ret=m_buf[m_pos];
            m_buf[m_pos]=in;
            if (++m_pos>=m_len) m_pos=0;
            return ret;
        }
    };
    
Comment...
Question: I am trying to program a function which would create a latency on buffer - any ideas where to get an example code ?
Asked by franci (86.61.125.x) on February 3 2013, 5:52pm
Reply on February 4 2013, 11:31pm:
    You want to create a delay line?
Comment...
Question: Have you ever wanted to own a tractor?
Asked by Pinkaso (208.64.185.x) on February 2 2013, 4:59pm
Reply on February 4 2013, 11:31pm:
    I can't say that I have.
Comment...
Question: Did you coin the phrase "skin" for custom UI graphics? If not, where'd you get it?
Asked by Will (70.173.150.x) on February 2 2013, 5:27am
Reply on February 2 2013, 2:32pm:
    We took the term which was used for Quake characters and applied it to UI graphics.. Not sure if it was the first time that was done, but Quake's use of the term was the inspiration.
Comment...
Question: Re: 6k loc. so what you're saying is that i have to beat you too! LOL. I take the argument back -♥- Any plans for something new?
Asked by gio (94.66.27.x) on January 31 2013, 4:49pm
Reply on February 2 2013, 2:31pm:
    Working on a cool inevitable feature for REAPER at the moment. Trying to keep my function size down... ;)
Comment...
Question: is it possible to explain LICE_GradRect(...) a little bit? thanks
Asked by gio (94.66.27.x) on January 31 2013, 1:17pm
Reply on January 31 2013, 4:15pm:
    Sure. LICE_GradRect lets you draw gradients.
    void LICE_GradRect(LICE_IBitmap *dest, int dstx, int dsty, int dstw, int dsth,
                          float ir, float ig, float ib, float ia,
                          float drdx, float dgdx, float dbdx, float dadx,
                          float drdy, float dgdy, float dbdy, float dady,
                          int mode);
    
    dstx-dsth: position/size of rectangle
    ir-ia: RGBA values [0..1] at top left
    drdx-dadx: RGBA deltas (per pixel) moving towards right.
    drdy-dady: RGBA deltas (per pixel) moving towards bottom.

    So, for example:
          LICE_GradRect(framebuffer,0,0,100,100,
              0,0,0,1.0,
              1.0 * 0.01,0.5 * 0.01,0.0 * 0.01,0.0,
              0.0 * 0.01,0.5 * 0.01,1.0 * 0.01,0.0, LICE_BLIT_MODE_COPY);
     
    This will make a 100px square, which is black at the top left, orange (full red, half green) top right, blueish on the bottom left (full blue, half green), and white in the bottom right. The 0.01 multipliers on the deltas reflects the size of the rectangle (1.0/100.0).
Comment...
Question: how is brennan doing? his site is down, i always thought he is a cool guy. loved winamp3 with all faults, etc. { good times } :)
Asked by gio (94.66.27.x) on January 31 2013, 11:53am
Reply on January 31 2013, 4:16pm:
    Hmm we should let him know this, I think his ISP had to change his static IP and he needs to update his DNS.
Comment...
Question: At the opposite desk I have the guy who wrote a function with around 6000 loc. Should I beat him? :s
Asked by gio (94.66.27.x) on January 31 2013, 7:52am
Reply on January 31 2013, 4:19pm:
    Hm I have plenty of 11,000 line functions for which I despise myself. To be fair they are usually giant switch() statements for commands etc.
Comment...
[newer questions][unreplied] | [replied] | [recent comments] | [all]
[older questions]
Copyright 2025 Justin Frankel. | RSS