multi-platform real-time ‘intro’ in R using rdyncall

[This article was first published on "R" you ready?, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Guest post by Daniel Adler.

Below is a real-time audio-visual multimedia demonstration – or in short ‘an intro’ – written in 100% pure R. It requires no compilation and runs across major platforms via the package rdyncall and preinstalled precompiled standard libraries such as OpenGL and SDL libraries. This ‘happy-birthday’ production runs about 3 minutes and comprises typical effects of the home computer oldschool demoscene era such as a rotating cube, multi-layer star field, text scrollers, still images and flashes while playing a nice Amiga Soundtracker module tune. Check out the video screen-cast (with sound) or enjoy a smooth framerate using the R version at this website.

The rdyncall package used for this video facilitates a dynamic middleware between R and  C libraries and offers an improved Foreign Function Interface for R. It enables developers to ‘script’ system-level code in R such as OpenGL visualizations, multimedia applications, computer games or simply to call a single system service without the need for writing C code. The FFI toolkit offered by the package is flexible enough to address low-level C interfacing issues directly in R. R bindings to the C libraries are created dynamically with a single interface function ‘dynport’ similar to ‘library’ and the C interface is made available in R as if it is an extension to the language. Support for handling foreign C data types and callbacks is offered by helper utilities. An extendable repository of cross-platform bindings is delivered with the package that contains bindings to OpenGL 1, OpenGL 3, SDL, Expat, ODE, CUDA, OpenCL and more.

The implementation of rdyncall is based on libraries of the DynCall project that offers a dynamic call facility between interpreted languages and precompiled native code with support for almost all basic C types (in constrast to ‘.C’ in R). Call kernels – implemented in Assembly – offer a Foreign Function Interface solution that is small in size and generic in its application. The libraries have been ported across a large set of processor architectures (i386,AMD64,ARM,PowerPC 32-bit, MIPS 32/64-bit, SPARC 32/64-bit) and operating-systems including major R platforms.

The rdyncall package comes with a couple of demos, a comprehensive manual and vignette that gives further details.

Have fun!

To leave a comment for the author, please follow the link and comment on their blog: "R" you ready?. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)