/** VisActor.actorNew() */ JNIEXPORT jint JNICALL Java_org_libvisual_android_VisActor_actorNew(JNIEnv * env, jobject obj, jstring name) { LOGI("VisActor.actorNew()"); /* result */ VisActor *a = NULL; /* get name string */ jboolean isCopy; const char *actorName = (*env)->GetStringUTFChars(env, name, &isCopy); /* actor valid ? */ if(!(visual_plugin_registry_has_plugin(VISUAL_PLUGIN_TYPE_ACTOR, actorName))) { LOGE("Invalid actor-plugin: \"%s\"", actorName); goto _van_exit; } /* create new actor */ a = visual_actor_new(actorName); /* set random seed */ VisPluginData *plugin_data = visual_actor_get_plugin(a); VisRandomContext *r_context = visual_plugin_get_random_context (plugin_data); visual_random_context_set_seed(r_context, time(NULL)); _van_exit: (*env)->ReleaseStringUTFChars(env, name, actorName); return (jint) a; }
int main (int argc, char **argv) { // print warm welcome std::cerr << argv[0] << " v0.1\n"; // initialize libvisual once (this is meant to be called only once, // visual_init() after visual_quit() results in undefined state) visual_log_set_verbosity(VISUAL_LOG_DEBUG); visual_init (&argc, &argv); try { // parse commandline arguments if (_parse_args(argc, argv) != EXIT_SUCCESS) throw std::runtime_error ("Failed to parse arguments"); // create new VisBin for video output VisBin *bin = visual_bin_new(); visual_bin_set_supported_depth(bin, VISUAL_VIDEO_DEPTH_ALL); visual_bin_switch_set_style(bin, VISUAL_SWITCH_STYLE_MORPH); // initialize actor plugin std::cerr << "Loading actor '" << actor_name << "'...\n"; VisActor *actor = visual_actor_new (actor_name.c_str ()); if (!actor) throw std::runtime_error ("Failed to load actor '" + actor_name + "'"); // Set random seed if (have_seed) { VisPluginData *plugin_data = visual_actor_get_plugin(actor); VisRandomContext *r_context = visual_plugin_get_random_context (plugin_data); visual_random_context_set_seed (r_context, seed); seed++; } // initialize input plugin std::cerr << "Loading input '" << input_name << "'...\n"; VisInput *input = visual_input_new(input_name.c_str()); if (!input) { throw std::runtime_error ("Failed to load input '" + input_name + "'"); } // Pick the best display depth int depthflag = visual_actor_get_supported_depth (actor); VisVideoDepth depth; if (depthflag == VISUAL_VIDEO_DEPTH_GL) { depth = visual_video_depth_get_highest (depthflag); } else { depth = visual_video_depth_get_highest_nogl (depthflag); } visual_bin_set_depth (bin, depth); VisVideoAttributeOptions const* vidoptions = visual_actor_get_video_attribute_options(actor); // initialize display SADisplay display (driver_name); // create display display.create(depth, vidoptions, width, height, true); VisVideo *video = display.get_video(); if(!video) throw std::runtime_error("Failed to get VisVideo from display"); // put it all together visual_bin_connect(bin, actor, input); visual_bin_set_video(bin, video); visual_bin_realize(bin); visual_bin_sync(bin, FALSE); visual_bin_depth_changed(bin); // get a queue to handle events VisEventQueue localqueue; // main loop bool running = true; bool visible = true; while (running) { LV::Event ev; // Handle all events display.drain_events(localqueue); LV::EventQueue* pluginqueue = visual_plugin_get_eventqueue(visual_actor_get_plugin (bin->actor)); while (localqueue.poll(ev)) { if(ev.type != VISUAL_EVENT_RESIZE) pluginqueue->add (ev); switch (ev.type) { case VISUAL_EVENT_PARAM: { break; } case VISUAL_EVENT_RESIZE: { display.lock(); width = ev.event.resize.width; height = ev.event.resize.height; display.create(depth, vidoptions, width, height, true); video = display.get_video (); visual_bin_set_video (bin, video); visual_actor_video_negotiate (bin->actor, depth, FALSE, FALSE); display.unlock(); break; } case VISUAL_EVENT_MOUSEMOTION: { break; } case VISUAL_EVENT_MOUSEBUTTONDOWN: { // switch to next actor v_cycleActor(1); v_cycleMorph(); visual_bin_set_morph_by_name(bin, morph_name.c_str()); visual_bin_switch_actor_by_name(bin, actor_name.c_str()); // get new actor actor = visual_bin_get_actor(bin); // handle depth of new actor depthflag = visual_actor_get_supported_depth(actor); if (depthflag == VISUAL_VIDEO_DEPTH_GL) { visual_bin_set_depth(bin, VISUAL_VIDEO_DEPTH_GL); } else { depth = visual_video_depth_get_highest(depthflag); if ((bin->depthflag & depth) > 0) visual_bin_set_depth(bin, depth); else visual_bin_set_depth(bin, visual_video_depth_get_highest_nogl(bin->depthflag)); } bin->depthforcedmain = bin->depth; break; } case VISUAL_EVENT_MOUSEBUTTONUP: { break; } case VISUAL_EVENT_KEYDOWN: { switch(ev.event.keyboard.keysym.sym) { case VKEY_ESCAPE: { running = false; break; } case VKEY_TAB: { break; } default: break; } break; } case VISUAL_EVENT_KEYUP: { break; } case VISUAL_EVENT_QUIT: { running = FALSE; break; } case VISUAL_EVENT_VISIBILITY: { visible = ev.event.visibility.is_visible; break; } default: { break; } } } if (visual_bin_depth_changed(bin)) { display.lock(); display.create(depth, vidoptions, width, height, true); VisVideo *video = display.get_video(); visual_bin_set_video(bin, video); visual_bin_sync(bin, TRUE); display.unlock(); } // Do a run cycle if (!visible) continue; display.lock(); visual_bin_run(bin); display.unlock(); display.update_all(); display.set_fps_limit(framerate); } } catch (std::exception& error) { std::cerr << error.what () << std::endl; } //printf ("Total frames: %d, average fps: %f\n", display_fps_total (display), display_fps_average (display)); visual_quit (); return EXIT_SUCCESS; }
/* Main plugin stuff */ const VisPluginInfo *get_plugin_info (void) { static VisActorPlugin actor = { .requisition = lv_flower_requisition, .palette = lv_flower_palette, .render = lv_flower_render, .vidoptions.depth = VISUAL_VIDEO_DEPTH_GL }; static VisPluginInfo info = { .type = VISUAL_PLUGIN_TYPE_ACTOR, .plugname = "flower", .name = "libvisual Pseudotoad flower, yellow rose of texas", .author = N_("Original by: Antti Silvast <*****@*****.**>, Port by: Dennis Smit <*****@*****.**>"), .version = "0.1", .about = N_("Libvisual yellow rose of texas port"), .help = N_("This renders an awesome responsive flower"), .license = VISUAL_PLUGIN_LICENSE_GPL, .init = lv_flower_init, .cleanup = lv_flower_cleanup, .events = lv_flower_events, .plugin = VISUAL_OBJECT (&actor) }; VISUAL_VIDEO_ATTR_OPTIONS_GL_ENTRY(actor.vidoptions, VISUAL_GL_ATTRIBUTE_RED_SIZE, 5); VISUAL_VIDEO_ATTR_OPTIONS_GL_ENTRY(actor.vidoptions, VISUAL_GL_ATTRIBUTE_GREEN_SIZE, 5); VISUAL_VIDEO_ATTR_OPTIONS_GL_ENTRY(actor.vidoptions, VISUAL_GL_ATTRIBUTE_BLUE_SIZE, 5); VISUAL_VIDEO_ATTR_OPTIONS_GL_ENTRY(actor.vidoptions, VISUAL_GL_ATTRIBUTE_DEPTH_SIZE, 16); VISUAL_VIDEO_ATTR_OPTIONS_GL_ENTRY(actor.vidoptions, VISUAL_GL_ATTRIBUTE_DOUBLEBUFFER, 1); VISUAL_VIDEO_ATTR_OPTIONS_GL_ENTRY(actor.vidoptions, VISUAL_GL_ATTRIBUTE_RGBA, 1); return &info; } static int lv_flower_init (VisPluginData *plugin) { FlowerPrivate *priv; float b; int i; #if ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); #endif priv = visual_mem_new0 (FlowerPrivate, 1); visual_object_set_private (VISUAL_OBJECT (plugin), priv); priv->rcxt = visual_plugin_get_random_context (plugin); visual_random_context_float (priv->rcxt); init_flower (&priv->flower); priv->flower.rotx = visual_random_context_float (priv->rcxt) * 360.0; priv->flower.roty = visual_random_context_float (priv->rcxt) * 360.0; priv->flower.tension = (visual_random_context_float (priv->rcxt) - 0.5) * 8.0; priv->flower.continuity = (visual_random_context_float (priv->rcxt) - 0.5) * 16.0; priv->flower.timer = visual_timer_new (); priv->nof_bands = NOTCH_BANDS; for (i = 0; i < priv->nof_bands; i++) { b = 80.0 + i * (22000.0 - 80.0) / priv->nof_bands; priv->notch[i] = init_notch (b); } priv->t = visual_timer_new (); return 0; }
const VisPluginInfo *get_plugin_info (void) { static VisActorPlugin actor = { .requisition = act_jakdaw_requisition, .palette = act_jakdaw_palette, .render = act_jakdaw_render, .vidoptions.depth = VISUAL_VIDEO_DEPTH_32BIT }; static VisPluginInfo info = { .type = VISUAL_PLUGIN_TYPE_ACTOR, .plugname = "jakdaw", .name = "Jakdaw plugin", .author = N_("Original by: Christopher Wilson <*****@*****.**>, Port by: Dennis Smit <*****@*****.**>"), .version = "0.0.1", .about = N_("jakdaw visual plugin"), .help = N_("This is the libvisual port of the xmms Jakdaw plugin"), .license = VISUAL_PLUGIN_LICENSE_GPL, .init = act_jakdaw_init, .cleanup = act_jakdaw_cleanup, .events = act_jakdaw_events, .plugin = VISUAL_OBJECT (&actor) }; return &info; } static int act_jakdaw_init (VisPluginData *plugin) { JakdawPrivate *priv; VisParamContainer *paramcontainer = visual_plugin_get_params (plugin); static VisParamEntry params[] = { VISUAL_PARAM_LIST_ENTRY_INTEGER ("zoom mode", FEEDBACK_ZOOMRIPPLE), VISUAL_PARAM_LIST_ENTRY_INTEGER ("plotter trigger", PLOTTER_COLOUR_MUSICTRIG), VISUAL_PARAM_LIST_ENTRY_INTEGER ("plotter type", PLOTTER_SCOPE_LINES), VISUAL_PARAM_LIST_END }; /* static VisParamEntry zoomparamchoices[] = { VISUAL_PARAM_LIST_ENTRY_INTEGER ("Zoom ripple", FEEDBACK_ZOOMRIPPLE), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Blur only", FEEDBACK_BLURONLY), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Zoom rotate", FEEDBACK_ZOOMROTATE), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Scroll", FEEDBACK_SCROLL), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Into screen", FEEDBACK_INTOSCREEN), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Ripple", FEEDBACK_NEWRIPPLE), VISUAL_PARAM_LIST_END }; static VisParamEntry colorparamchoices[] = { VISUAL_PARAM_LIST_ENTRY_INTEGER ("Solid", PLOTTER_COLOUR_SOLID), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Random", PLOTTER_COLOUR_RANDOM), VISUAL_PARAM_LIST_ENTRY_INTEGER ("On music", PLOTTER_COLOUR_MUSICTRIG), VISUAL_PARAM_LIST_END }; static VisParamEntry scopeparamchoices[] = { VISUAL_PARAM_LIST_ENTRY_INTEGER ("Lines", PLOTTER_SCOPE_LINES), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Dots", PLOTTER_SCOPE_DOTS), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Solid", PLOTTER_SCOPE_SOLID), VISUAL_PARAM_LIST_ENTRY_INTEGER ("Nothing", PLOTTER_SCOPE_NOTHING), VISUAL_PARAM_LIST_END }; */ #if ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); #endif priv = visual_mem_new0 (JakdawPrivate, 1); visual_object_set_private (VISUAL_OBJECT (plugin), priv); priv->rcontext = visual_plugin_get_random_context (plugin); priv->decay_rate = 1; priv->zoom_ripplesize = 32; priv->zoom_ripplefact = 0.1; priv->zoom_zoomfact = 0.9; priv->plotter_amplitude = 0.5; /* FIXME make param of this one as well */ priv->plotter_scopecolor = 0xff00ff; visual_param_container_add_many (paramcontainer, params); priv->pcmbuf = visual_buffer_new_allocate (512 * sizeof (float)); priv->freqbuf = visual_buffer_new_allocate (256 * sizeof (float)); return 0; }
const VisPluginInfo *get_plugin_info (void) { static VisActorPlugin actor = { .requisition = act_infinite_requisition, .palette = act_infinite_palette, .render = act_infinite_render, .vidoptions.depth = VISUAL_VIDEO_DEPTH_8BIT }; static VisPluginInfo info = { .type = VISUAL_PLUGIN_TYPE_ACTOR, .plugname = "infinite", .name = "infinite plugin", .author = N_("Original by: Julien Carme <*****@*****.**>, Port by: Dennis Smit <*****@*****.**>"), .version = "0.1", .about = N_("Infinite visual plugin"), .help = N_("This is the libvisual plugin for the infinite visual"), .license = VISUAL_PLUGIN_LICENSE_GPL, .init = act_infinite_init, .cleanup = act_infinite_cleanup, .events = act_infinite_events, .plugin = VISUAL_OBJECT (&actor) }; return &info; } static int act_infinite_init (VisPluginData *plugin) { InfinitePrivate *priv; #if ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); #endif visual_return_val_if_fail (plugin != NULL, -1); priv = visual_mem_new0 (InfinitePrivate, 1); visual_object_set_private (VISUAL_OBJECT (plugin), priv); priv->rcontext = visual_plugin_get_random_context (plugin); priv->plugwidth = 32; priv->plugheight = 32; priv->pal = visual_palette_new (256); _inf_init_renderer (priv); _inf_load_random_effect(priv, &priv->current_effect); priv->color = visual_random_context_int_range (priv->rcontext, 0, NB_PALETTES - 1); _inf_change_color(priv, priv->old_color, priv->color, 256); priv->old_color = priv->color; priv->color = visual_random_context_int_range (priv->rcontext, 0, NB_PALETTES - 1); return 0; }
const VisPluginInfo *get_plugin_info (void) { static VisActorPlugin actor = { .requisition = act_bumpscope_requisition, .palette = act_bumpscope_palette, .render = act_bumpscope_render, .vidoptions.depth = VISUAL_VIDEO_DEPTH_8BIT }; static VisPluginInfo info = { .type = VISUAL_PLUGIN_TYPE_ACTOR, .plugname = "bumpscope", .name = "Bumpscope plugin", .author = N_("Original by: Zinx Verituse <*****@*****.**>, Port by: Dennis Smit <*****@*****.**>"), .version = "0.0.1", .about = N_("Bumpscope visual plugin"), .help = N_("This is the libvisual port of the xmms Bumpscope plugin"), .license = VISUAL_PLUGIN_LICENSE_GPL, .init = act_bumpscope_init, .cleanup = act_bumpscope_cleanup, .events = act_bumpscope_events, .plugin = &actor }; return &info; } static int act_bumpscope_init (VisPluginData *plugin) { #if ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); #endif VisParamList *params = visual_plugin_get_params (plugin); visual_param_list_add_many (params, visual_param_new_color_rgb ("color", N_("The light's color"), 122, 204, 255, NULL), visual_param_new_integer ("light_size", N_("The size of the light"), 256, visual_param_in_range_integer (0, 1000)), visual_param_new_bool ("color_cycle", N_("Whether to cycle colors"), TRUE, NULL), visual_param_new_bool ("moving_light", N_("Whether the light moves with the mouse"), TRUE, NULL), visual_param_new_bool ("diamond", N_("Whether to use a diamond shape light"), FALSE, NULL), NULL); BumpscopePrivate *priv = visual_mem_new0 (BumpscopePrivate, 1); visual_plugin_set_private (plugin, priv); priv->phongres = 256; priv->rcontext = visual_plugin_get_random_context (plugin); priv->pal = visual_palette_new (256); priv->pcmbuf = visual_buffer_new_allocate (512 * sizeof (float)); return TRUE; } static void act_bumpscope_cleanup (VisPluginData *plugin) { BumpscopePrivate *priv = visual_plugin_get_private (plugin); __bumpscope_cleanup (priv); visual_palette_free (priv->pal); visual_buffer_unref (priv->pcmbuf); visual_mem_free (priv); }