Talks
My Ruby is a Paintbrush. My Ruby is a Synth

Summarized using AI

My Ruby is a Paintbrush. My Ruby is a Synth

Jan Krutisch • May 25, 2018 • Sofia, Bulgaria

In the presentation titled "My Ruby is a Paintbrush. My Ruby is a Synth," Jan Krutisch explores creative applications of Ruby in graphics and sound during the Balkan Ruby 2018 event. The talk emphasizes the versatility of Ruby in generating both 2D and 3D graphics as well as in music production. Key points discussed include:

  • Introduction to Ruby Projects: Jan outlines his work with the dependency management tool, Depfu, designed to automate updates in Ruby and JavaScript projects, encouraging audience members to engage with him for further discussion.
  • 2D Graphics Generation: He showcases offline graphics generation through a GitHub project called "Calgon," which is responsible for creating customizable calendar sheets. He introduces the Prom library for generating PDFs, easing the graphics creation process.
  • Generative Art with JRuby: Jan discusses the JRuby Art framework that enables programming generative art using Ruby syntax, alongside adaptations of Processing examples. A simple event-handling JRuby program illustrates how interactive designs are initiated.
  • Visualizations and Gosu: He presents a visualization tool for Rails applications and discusses Gosu, a Ruby game-building library that simplifies 2D game development.
  • Exploring 3D Graphics: Jan introduces 3D programming through the Mitsu library, which enhances usability for Ruby developers working with OpenGL. Basic and more complex examples, including a spinning cube and sine wave designs, depict what can be achieved through such programming.
  • 3D Modeling and Printing: He discusses SketchUp's Ruby API for scripting 3D models and the implications of merging code creation with 3D printing, emphasizing accessibility in creating physical objects.
  • Sound and Music Programming: The presentation transitions to audio programming with Sonic Pi and Ruby Synth. Jan highlights the ease of creating sound through code and demonstrates generating simple sound waveforms and melodies using MIDI commands.
  • Interactive Experiences: He wraps up by showcasing a version of Minesweeper incorporated with MIDI controls via a Launchpad, illustrating the potential of integrating interactive elements into coding projects.

In conclusion, Jan's talk emphasizes the significance and wide-ranging applications of Ruby in creative technology fields, encouraging developers to explore and experiment with their own projects. His playful demonstrations and varied examples underscore the creative possibilities inherent in programming.

My Ruby is a Paintbrush. My Ruby is a Synth
Jan Krutisch • May 25, 2018 • Sofia, Bulgaria

Jan is a software developer, tech writer, speaker and multi purpose geek.

Balkan Ruby 2018

00:00:11 Thank you very much for inviting me and for allowing me to see Sofia for the first time.
00:00:18 I'm really enjoying myself here; it's a great city, and the weather is wonderful.
00:00:27 My name is Jan, and when I'm not working on creative projects with Ruby, I run a company with a friend called "Depfu." I’m wearing a t-shirt that says "Depfu" on it.
00:00:42 If you haven't heard of it, it's a fantastic service that automates dependency updates for Ruby projects. We’ve also added support for JavaScript, so you can receive pull requests on your GitHub projects whenever a dependency is updated.
00:00:59 It's free for open source and private repositories, so if you'd like to try it out, please do and let me know what you think.
00:01:18 If you want to discuss dependency management or updates, feel free to come to me afterwards—I also have stickers to give away.
00:01:31 With that, I’d like to begin my talk, but first, I need to warn you.
00:01:42 This presentation is quite technical and filled with code. I don't want you to strain yourself trying to understand everything that is shown.
00:01:59 I have a diverse array of code examples from various projects, and there is a GitHub repository with all the source code, which I will push after this presentation.
00:02:20 So again, don't worry if you don't comprehend everything right away; you can always read through it later.
00:02:39 To kick things off, let's start with 2D graphics.
00:02:46 The first topic is the offline generation of graphics, and my example relates to creating calendar sheets.
00:02:58 I have a project on GitHub called "Calgon," or "Cal Jam," which creates calendar sheets. The backstory is a bit amusing; for reasons I can't quite recall, my mother receives a calendar each Christmas featuring photographs taken by my girlfriend and me throughout the year.
00:03:18 Every Christmas, she receives twelve new calendar sheets for the upcoming year with our best photos.
00:03:43 Initially, I used a bundled software that came with my printer to print calendars by dragging in photos. However, I ended up printing blank pages with the calendars and pasting actual photo prints onto them, which worked well.
00:04:10 The software was customizable, allowing me to adjust fonts and designs to my liking. Yet when my printer eventually broke down, the bundled software couldn't function with the new one.
00:04:29 Frustrated by my unsuccessful search through various software options, I decided that creating a simple solution was achievable, leading me to build a program for generating beautiful calendar sheets.
00:04:53 Using the Prom library, which is easy to work with, I was able to quickly create customizable, minimalistic calendar sheets.
00:05:11 Does anyone here have experience with Prom? A few hands, good!
00:05:24 Prom is written by Alexander Mannkuta and others and is fantastic for creating PDFs. It resembles working in visual design software, using bounding boxes for text placement, making layout designs straightforward.
00:05:44 That's an overview of offline graphics, which may not be thrilling, but it's a demonstration of how such projects can originate.
00:05:56 Moving on, the next topic is 2D vector graphics. How many of you are familiar with this book? One person? That's alright.
00:06:08 This book, originally a German publication called "Ginetta T," is now mainly available in English. It’s a rare combination of being both a visually stunning coffee table book and a tutorial on programming.
00:06:23 It teaches readers how to use Processing. How many here have used Processing? Good! Processing is a neat 2D graphics prototyping tool, but it's primarily Java-based.
00:06:41 While I don't despise Java, I certainly prefer Ruby. Hence, there's a framework called JRuby Art.
00:06:55 Maintained by Martin Trout, this library lets you create similar 2D graphics but with elegant Ruby syntax.
00:07:20 Here's a very simple JRuby Art program that allows for event handling for key presses and mouse clicks. I'll show you how this looks, although it might be interesting while handling a microphone.
00:07:51 This JRuby program takes a moment to boot up, but it showcases the power of generative art because there are numerous designs that can emerge from it.
00:08:12 When I click the mouse button, it changes the random seed that generates designs. Essentially, the code divides the space into a grid and randomly decides how to draw lines.
00:08:31 You can also adjust line endings with key presses, changing the appearance and thickness slightly. This example, adapted from the book, highlights how simple yet effective generative art can be.
00:08:53 Next, I'll show you a more complex project, which is also part of the book. This sunburst graph serves as a visualization of a Rails application, displaying its file structure and file sizes.
00:09:12 As you can see, it structures the services and files in a visually appealing manner, making it easier to understand the hierarchy.
00:09:32 However, I encountered a few compatibility issues when converting from Processing. Certain features aren’t yet functional.
00:09:47 But as you can see, it demonstrates how JRuby Art can create effective visualizations with relatively simple code.
00:10:13 Let's move on to Gosu. How many of you have tried using Gosu? Excellent! Gosu is a game-building library primarily using C++ but with Ruby bindings.
00:10:54 It provides smooth game development experiences and offers functionality for constructing 2D graphics, events, and more.
00:11:06 Here’s a simple Gosu program consisting of a few hundred lines of code, showcasing how enjoyable Ruby game development can be.
00:11:37 Now let’s transition to discussing 3D graphics. Ruby has OpenGL bindings, but who here has experience working with OpenGL? Yes, it’s a challenging API, isn't it?
00:12:10 There's a library called Mitsu, inspired by Three.js, that simplifies the creation of 3D graphics in Ruby. Mitsu is designed for better usability and higher abstraction.
00:12:41 3D programming can be more complex than 2D, as it requires setting up renderers, geometries, materials, lighting, and cameras.
00:13:00 Let me show you a basic "Hello World" example of a spinning cube.
00:13:37 The cube is a simple starting point for 3D programming. I’ll demonstrate how it operates.
00:14:08 As displayed, the absence of lighting makes the cube appear somewhat bland, but it’s a straightforward representation of 3D programming.
00:14:30 Now, I’ll show you another example that uses sine waves and binary decoding, resulting in a visually attractive design.
00:15:01 This piece is created with a few lines of code, yet it showcases the power of what we can create through visual programming.
00:15:15 Next, I want to discuss SketchUp. How many of you have worked with SketchUp, formerly known as Google SketchUp? Great!
00:15:43 This 3D modeling software, unfortunately, no longer offers a fully free version, though the last year's version is available for free.
00:16:01 What’s exciting about SketchUp is its Ruby API. Six years ago, I wrote some articles for a German tech magazine on scripting in SketchUp with Ruby.
00:16:32 Despite the limitations of the free version, it allows for model creation and offers a creative outlet for 3D design.
00:16:55 Let's take a look at generating a 3D object from scratch using Ruby. I will also show you how to create a simple cube.
00:17:36 Now, if you bear with me, I will start SketchUp and show you what I can do with my Ruby scripting capabilities.
00:18:03 I’ll create a randomized pixel ground and a 3D object using simple Ruby code to demonstrate.
00:18:31 3D printing has become cheap and accessible, and I brought along a physical representation of one of my projects.
00:19:01 It’s not very polished, but it represents the concept of creating something digital that can become a physical object.
00:19:24 Thanks to 3D printers, you can realize designs generated through your own software and turn them into tangible creations.
00:19:54 Ultimately, I examined the standard Wavefront object format that describes 3D objects.
00:20:15 This format is human-readable and can be invoked to generate 3D shapes without needing complex editors.
00:20:37 I find that rather interesting, as it merges code creation and 3D printing very neatly.
00:20:54 Now I want to pivot to the topic of sound and music.
00:21:10 The first tool I’d like to introduce is Sonic Pi—how many of you have played with it?
00:21:33 Great! Sonic Pi is a fascinating project that combines music and programming, created by Sam Aaron and Cariann.
00:21:50 It serves both as a performing tool and an educational platform, especially fun for teaching programming to children.
00:22:14 Let me demonstrate a very basic program that consists of a bass drum and a basic loop.
00:22:30 This introduction showcases the ease of generating sound through code, whether playing simple samples or arranging a full concert.
00:24:07 Sonic Pi also supports rich musical compositions. Here's a short piece demonstrating its potential.
00:24:25 As you see, it can create quite complex music. If you haven't explored Sonic Pi yet, I strongly encourage you to do so.
00:24:53 Next, let’s discuss Ruby Synth, another project that leverages Ruby for audio generation.
00:25:15 The challenge arises in sending generated sounds to the sound card.
00:25:33 One of my favorite open-source tools for handling audio is Sox. How many of you are familiar with Sox?
00:26:05 It's a powerful tool for audio conversions and has been around since 1991.
00:26:18 Using specific parameters, you can pipe sound generated in Ruby directly to Sox to hear it in real time.
00:26:50 Let’s now explore generating sound waveforms which can be quite simple. What do you think the simplest waveform to generate is?
00:27:14 Many might say sine waves, but the simplest might just be a rectangle wave—a simple on/off signal.
00:27:40 That generates relatively simple sound data for the output. Here’s a demonstration of this concept.
00:28:08 Now, let’s add some musical notes, but instead of standard note names, I’ll be using MIDI note numbers.
00:28:40 MIDI allows us to send musical signals as digital data, enabling easy manipulation of sound.
00:29:12 Let me show you how to implement some simple melodies using Ruby and MIDI commands.
00:29:55 Alright, let's make this audio playback properly, integrating MIDI commands to illustrate what we can do.
00:30:10 It's important to note that professional musicians can create fascinating patterns and tunes with the right tools.
00:30:30 Furthermore, there's the potential to control physical devices, lighting, or interactive performances using MIDI.
00:31:10 With a simple MIDI controller, such as this Launchpad, you can interface easily and trigger sounds interactively.
00:31:40 Let me demonstrate how interactive light controls can be integrated into coding projects, enhancing creative expression.
00:32:01 To conclude, I took a version of Minesweeper made with Gosu and demonstrated it on the Launchpad!
00:32:25 If you're interested in trying it out later, let me know.
00:32:57 I appreciate your attention and enthusiasm. Thank you very much!
Explore all talks recorded at Balkan Ruby 2018
+12