Skip to content

alloy/art.c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

art.c: The Artsy universe in C major and C Ruby.

This program plays musical notes in the major C scale in near real-time as users interact with artsy.net. If you are lucky enough–or are actually bidding/offering/buying a work while reading this 🤘–you may even hear a bell being struck.

Why?

This is my entry for the 2019 edition of the Artsy Salon, an annual art exhibition in which Artsy employees show-case their work.

Artsy historically uses the Ruby programming language a lot, as such using it’s VM (virtual machine) here is solely out of sentiment about Artsy’s platform origins and as a tribute to my life-long love for Ruby. However, being inspired by Ruby’s long-lost artist ‘_why the lucky stiff’ I couldn’t simply write Ruby, instead the entire Ruby program is written in the C programming language using Ruby’s C programming interface.

There is no good reason to do this, other than to question yourself how things really work. Taking the mechanics of a ‘reality’ (such as a VM) for granted is limiting to one’s understanding of the space it lives in.

How?

All of Artsy’s analytics events go through segment.com, which in turn sends those aggregated events to the HTTP server in this project so it can turn those events into an audible representation.

The HTTP server is a plain Ruby Rack app, except using the C Ruby API, and the sound is produced using a CoreAudio and CoreMIDI stack that runs in a Grand Central Dispatch background thread to which the app enqueues notes to play based on the type of event that occurred.

Installation

  1. On macOS you can use the system Ruby, but if you prefer a newer version of Ruby install one with a dynamic (shared) library product. E.g.:

    $ ruby-install ruby 2.6.3 -- --enable-shared
  2. Install Bundler, if necessary:

    $ gem install bundler
  3. Install project gems:

    $ bundle install

Run

  1. Install ngrok from https://dashboard.ngrok.com/get-started

  2. Start the server, which is enough for local development work:

    $ rake -s
  3. If actually consuming events from a segment.com webhook, start a forwarding tunnel from serveo.net:

    $ ssh -R my-example-subdomain:80:localhost:8080 serveo.net
  4. …and point the segment.com webhook to it. E.g. https://my-example-subdomain.serveo.net/webhooks/analytics

  5. When letting this run for extended periods, it is best to use autossh as it will automatically reconnect.

    $ brew install autossh
    $ autossh -M 0 -R my-example-subdomain:80:localhost:8080 serveo.net

Development

  • Most-all communication in the app must be done through the Ruby runtime. I.e. rather than a C function call, expose the C function as a Ruby method an invoke that instead.

  • Install clang-format:

$ brew install clang-format

About

Artsy Salon 2019 art exhibition entry.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published