コード例 #1
0
ファイル: page.c プロジェクト: HybridDog/schismtracker
static void vis_fft(void)
{
	int i, y;
	/*this is the size of vis_overlay.width*/
	unsigned char outfft[120];

	if (_vis_virgin) {
		vgamem_ovl_alloc(&vis_overlay);
		_vis_virgin = 0;
	}
	_draw_vis_box();
	song_lock_audio();

	vgamem_ovl_clear(&vis_overlay,0);
	_get_columns_from_fft(outfft,current_fft_data);
	for (i = 0; i < 120; i++) {
		y = outfft[i];
		/*reduce range */
		y >>= 3;
		if (y > 15) y = 15;
		if (y > 0) {
		       vgamem_ovl_drawline(&vis_overlay,i,15-y,i,15,5);
		}
	}
	vgamem_ovl_apply(&vis_overlay);

	song_unlock_audio();
}
コード例 #2
0
static void _draw_sample_data_8(struct vgamem_overlay *r,
        signed char *data, unsigned long length, unsigned int inputchans, unsigned int outputchans)
{
        unsigned long pos;
        unsigned int cc, co;
        int level, xs, ys, xe, ye, step;
        int nh, np;
        int chip;

        nh = (r->height / outputchans);
        np = r->height - (nh / 2);

        length /= inputchans;
        chip = (length < (unsigned int) r->width * 2);

        for (cc = 0; cc < outputchans; cc++) {
                pos = 0;
                co = 0;
                step = MAX(1, (length / r->width) >> 8);
                level=0;
                do {
                        level+=ceil(data[(pos * inputchans) + cc+co] * nh / (float)(SCHAR_MAX - SCHAR_MIN + 1));
                } while (co++ < inputchans-outputchans);
                xs = 0;
                ys = (np - 1) - level;
                ys = CLAMP(ys, 0, r->height - 1);
                do {
                        pos += step;
                        co = 0;
                        level=0;
                        do {
                                level+=ceil(data[(pos * inputchans) + cc+co] * nh / (SCHAR_MAX - SCHAR_MIN + 1));
                        } while (co++ < inputchans-outputchans);
                        xe = pos * r->width / length;
                        ye = (np - 1) - level;
                        xe = CLAMP(xe, 0, r->width - 1);
                        ye = CLAMP(ye, 0, r->height - 1);
                        // 'ye' is more or less useless for small samples, but this is much cleaner
                        // code than writing nearly the same loop four different times :P
                        vgamem_ovl_drawline(r, xs, ys, xe, chip ? ys : ye, SAMPLE_DATA_COLOR);
                        xs = xe;
                        ys = ye;
                } while (pos < length);
                np -= nh;
        }
}
コード例 #3
0
static void _draw_sample_data_16(struct vgamem_overlay *r,
         signed short *data, unsigned long length, unsigned int inputchans, unsigned int outputchans)
{
        unsigned long pos;
        unsigned int cc, co;
        int level, xs, ys, xe, ye, step;
        int nh, np;
        int chip;

        nh = (r->height / outputchans);
        np = r->height - (nh / 2);

        length /= inputchans;
        chip = (length < (unsigned int) r->width * 2);

        for (cc = 0; cc < outputchans; cc++) {
                pos = 0;
                co = 0;
                step = MAX(1, (length / r->width) >> 8);
                level=0;
                do {
                        level += ceil(data[(pos * inputchans) + cc+co] * nh / (float)(SHRT_MAX - SHRT_MIN + 1));
                } while(co++ < inputchans-outputchans);
                xs = 0;
                ys = (np - 1) - level;
                ys = CLAMP(ys, 0, r->height - 1);
                do {
                        pos += step;
                        co = 0;
                        level = 0;
                        do {
                                level = ceil(data[(pos * inputchans) + cc+co] * nh / (float)(SHRT_MAX - SHRT_MIN + 1));
                        } while (co++ < inputchans-outputchans);
                        xe = pos * r->width / length;
                        ye = (np - 1) - level;
                        xe = CLAMP(xe, 0, r->width - 1);
                        ye = CLAMP(ye, 0, r->height - 1);
                        vgamem_ovl_drawline(r, xs, ys, xe, chip ? ys : ye, SAMPLE_DATA_COLOR);
                        xs = xe;
                        ys = ye;
                } while (pos < length);
                np -= nh;
        }
}