예제 #1
0
float VinylControlXwax::getAngle() {
    double when;
    float pos = timecoder_get_position(&timecoder, &when);

    if (pos == -1)
        return -1.0;

    float rps = timecoder_revs_per_sec(&timecoder);
    //invert angle to make vinyl spin direction correct
    return 360 - ((int)(when * 360.0 * rps) % 360);
}
예제 #2
0
파일: interface.c 프로젝트: huuh/huuwax
static void draw_spinner(SDL_Surface *surface, const struct rect *rect,
                         struct player *pl)
{
    int x, y, r, c, rangle, pangle;
    double elapsed, remain, rps;
    Uint8 *rp, *p;
    SDL_Color col;

    x = rect->x;
    y = rect->y;

    elapsed = player_get_elapsed(pl);
    remain = player_get_remain(pl);

    rps = timecoder_revs_per_sec(pl->timecoder);
    rangle = (int)(player_get_position(pl) * 1024 * rps) % 1024;

    if (elapsed < 0 || remain < 0)
        col = warn_col;
    else
        col = ok_col;

    for (r = 0; r < spinner_size; r++) {

        /* Store a pointer to this row of the framebuffer */

        rp = surface->pixels + (y + r) * surface->pitch;

        for (c = 0; c < spinner_size; c++) {

            /* Use the lookup table to provide the angle at each
             * pixel */

            pangle = spinner_angle[r * spinner_size + c];

            /* Calculate the final pixel location and set it */

            p = rp + (x + c) * surface->format->BytesPerPixel;

            if ((rangle - pangle + 1024) % 1024 < 512) {
                p[0] = col.b >> 2;
                p[1] = col.g >> 2;
                p[2] = col.r >> 2;
            } else {
                p[0] = col.b;
                p[1] = col.g;
                p[2] = col.r;
            }
        }