コード例 #1
0
ファイル: blursk.cpp プロジェクト: PyroOS/Pyro
/* This is a generic rendering function.  It works for all signal styles.
 * The input always looks like one big PCM sample; if the input is really
 * a spectrum, then it will have been transformed by blurk_render_pcm()
 * into 256 PCM samples, with 20000 meaning "no sound" and smaller/negative
 * values representing a lot of sound.  This particular transformation was
 * chosen simply because the normal PCM plotter can then produce a nice-looking
 * spectrum graph.
 *
 * This function supports a variety of ways to plot the [pseudo-]PCM samples.
 * In addition to the usual line graph, it can also mirror the line graph or
 * produce a "bead" graph by passing the data off to render_bead().
 * The decision of how to plot is based on the value of "variation".
 */
static void update_image(gint32 loudness, gint ndata, gint16 *data)
{
	gint	i, y, thick, quiet, center;
	gint	beat;
	guchar	*img;
	gint	width, height, bpl;

#if 0
	/* If events are pending, then skip this frame */
	if (gdk_events_pending())
		return;
#endif

	/* If we completed a resize operation a few seconds ago, then save the
	 * new size now.
	 */
	if (savewhen != 0L && time(NULL) >= savewhen)
	{
		//config_write(FALSE, NULL, NULL);
		savewhen = 0L;
	}

	/* If we're supposed to be in fullscreen mode, and aren't, then
	 * toggle fullscreen mode now.
	 */
#if 0	 
	if (config.fullscreen_desired && !fullscreen_method)
		blursk_fullscreen(FALSE);
#endif

	/* Detect whether this is a beat, and choose a line thickness */
	beat = detect_beat(loudness, &thick, &quiet);

	/* If quiet, then maybe choose a new preset */
	//if (quiet)
		//preset_quiet();

	/* Perform the blurring.  This also affects whether the center of the
	 * signal will be moved lower in the window.
	 */
	center = img_height/2 + blur(beat, quiet);

	/* Perform the fade or solid flash */
	if (beat && !strcmp(config.flash_style, "Full flash"))
		i = 60;
	else
	{
		switch (config.fade_speed[0])
		{
		  case 'S':	i = -1;	break;	/* Slow */
		  case 'M':	i = -3;	break;	/* Medium */
		  case 'F':	i = -9;	break;	/* Fast */
		  default:	i = 0;		/* None */
		}
	}
	if (i != 0)
		loopfade(i);

	/* special processing for "Invert" & bitmap logo flashes */
	if (beat)
	{
		if (!strcmp(config.flash_style, "Invert flash"))
			img_invert();
		else if ((i = bitmap_index(config.flash_style)) >= 0)
			bitmap_flash(i);
	}

	/* Maybe change hue on beats */
	if (beat)
		color_beat();

	/* Add the signal data to the image */
	render(thick, center, ndata, data);

	/* Add floaters */
	drawfloaters(beat);

	/* shift the "ripple effect" from one frame to another */
	img_rippleshift += 3; /* cyclic, since img_rippleshift is a guchar */

	/* Apply the overall effect, if any */
	if (!strcmp(config.overall_effect, "Bump effect"))
	{
		img = img_bump(&width, &height, &bpl);
	}
	else if (!strcmp(config.overall_effect, "Anti-fade effect"))
	{
		img = img_travel(&width, &height, &bpl);
	}
	else if (!strcmp(config.overall_effect, "Ripple effect"))
	{
		img = img_ripple(&width, &height, &bpl);
	}
	else /* "Normal effect" */
	{
		img = img_expand(&width, &height, &bpl);
	}

	/* show info about the track */
	img = show_info(img, height, bpl);

	/* Allow the background color to change */
	color_bg(ndata, data);

	/* Copy the image into the window.  This also converts from
	 * 8-bits to 16/24/32 if necessary.
	 */
#if 0	 
	GDK_THREADS_ENTER();
#if HAVE_XV
	if (!xv_putimg(img, width, height, bpl))
#endif
		gdk_draw_indexed_image(area->window,
			area->style->white_gc,
			0, 0, width, height, GDK_RGB_DITHER_NONE,
			img, bpl, color_map);
	GDK_THREADS_LEAVE();
#endif
	/* Convert colors */
	uint32* pDst = (uint32*)blursk_bitmap->LockRaster();
	uint8* pSrc = img;
	

	for( y = 0; y < height; y++ )
	{
		for( i = 0; i < width; i++ )
		{
			*pDst++ = color_map[*pSrc++];
		}
		pSrc += bpl - width;
	}
	
	blursk_view->DrawBitmap( blursk_bitmap, blursk_bitmap->GetBounds(), blursk_bitmap->GetBounds() );
	blursk_view->Flush();
}
コード例 #2
0
ファイル: blursk.c プロジェクト: Libvisual/LibVisualAndroid
/* This is a generic rendering function.  It works for all signal styles.
 * The input always looks like one big PCM sample; if the input is really
 * a spectrum, then it will have been transformed by blurk_render_pcm()
 * into 256 PCM samples, with 20000 meaning "no sound" and smaller/negative
 * values representing a lot of sound.  This particular transformation was
 * chosen simply because the normal PCM plotter can then produce a nice-looking
 * spectrum graph.
 *
 * This function supports a variety of ways to plot the [pseudo-]PCM samples.
 * In addition to the usual line graph, it can also mirror the line graph or
 * produce a "bead" graph by passing the data off to render_bead().
 * The decision of how to plot is based on the value of "variation".
 */
static void update_image(BlurskPrivate *priv, int32_t loudness, int ndata, int16_t *data)
{
    int i, thick, quiet, center;
    int beat;
    int width, height, bpl;


    /* Detect whether this is a beat, and choose a line thickness */
    beat = detect_beat(loudness, &thick, &quiet);

    /* Perform the blurring.  This also affects whether the center of the
     * signal will be moved lower in the window.
     */
    center = img_height/2 + blur(priv, beat, quiet);

    /* Perform the fade or solid flash */
    if (beat && !strcmp(config.flash_style, "Full flash"))
        i = 60;
    else
    {
        switch (config.fade_speed[0])
        {
          case 'S': i = -1; break;  /* Slow */
          case 'M': i = -3; break;  /* Medium */
          case 'F': i = -9; break;  /* Fast */
          case 'N':
          default:  i = 0;      /* None */
        }
    }
    if (i != 0)
        loopfade(i);

    /* special processing for "Invert" & bitmap logo flashes */
    if (beat)
    {
        if (!strcmp(config.flash_style, "Invert flash"))
            img_invert();
        else if ((i = bitmap_index(config.flash_style)) >= 0)
            bitmap_flash(i);
    }

    /* Maybe change hue on beats */
    if (beat)
        color_beat(priv);

    /* Add the signal data to the image */
    render(thick, center, ndata, data);

    /* Add floaters */
    drawfloaters(beat);

    /* shift the "ripple effect" from one frame to another */
    img_rippleshift += 3; /* cyclic, since img_rippleshift is a unsigned char */

    /* Apply the overall effect, if any */
    if (!strcmp(config.overall_effect, "Bump effect"))
    {
        priv->rgb_buf = img_bump(&width, &height, &bpl);
    }
    else if (!strcmp(config.overall_effect, "Anti-fade effect"))
    {
        priv->rgb_buf = img_travel(&width, &height, &bpl);
    }
    else if (!strcmp(config.overall_effect, "Ripple effect"))
    {
        priv->rgb_buf = img_ripple(&width, &height, &bpl);
    }
    else /* "Normal effect" */
    {
        priv->rgb_buf = img_expand(&width, &height, &bpl);
    }

    priv->rgb_buf = show_info(priv->rgb_buf, height, bpl);

    /* Allow the background color to change */
    color_bg(priv, ndata, data);
}