# Sonic Pi plays musical box on visor.live

**URL:** <https://in-thread.sonic-pi.net/t/sonic-pi-plays-musical-box-on-visor-live/2309>\
**Category:** Creations & Ideas\
**Created:** [April 24, 2019, 4:37pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-plays-musical-box-on-visor-live/2309 "2019-04-24T16:37:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [April 24, 2019, 4:37pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-plays-musical-box-on-visor-live/2309/1 "2019-04-24T16:37:23Z")

</div>

I’v spent further time with Visor.live over the last few days.  
@samaaron posted a [link](https://twitter.com/samaaron/status/1118551129019826182) to a superb musical box playing Elfin Lied Lilium on 24th April by Dan Trante

The percussive bell like quality of this piece was ideal for driving a visualiser and I decided to give it a go. First I had to type in the code from the tweeted video. I then transcribed it into MuseScore3 as the rhythms were quite complex, involving time signature changes and incorporating one triplet. (beatifully coded by Dan).  
From the score I picked out the notes at the start of each bar (bl) together with the notes at changes in the overall melody line (mel). Finally I picked out the prominent notes in the bass accompaniment (bass). These three lists then generated three hashes, which were interrogated by an incrementing “tick”. When a positive mactch occured, a midi\_cc signal was sent from Sonic Pi to the visor.live app, and this was used to switch on and off various graphical elements. I arranged for the piece to repeat a determined number of times: in the video it is three, and then because the tune never resolves to finish I added a final chord to finish it nicely.

On the visor.live side I used version 0.4.0 and worked with a polygon shape. I used one large polygon in the centre, and a 10x10 array of smaller ones to fill the screen. I added facilities to alter colours, and rotate these independently.

It was an interesting project to do, involving a whole lot of problems to solve, but I think the end result is quite nice.

Here is a video of it in action:

I have posted all the code in a [gist](https://gist.github.com/rbnpi/77f2e0356b118f37677ab2fc8b2cbac5) if anyone wants to try it out. But be warned, it needs quite a high end machine as very resource intensive.

---

<div class="post-metadata">

**Author:** ![darinwilson](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/darinwilson/32/798_2.png) [@darinwilson](https://in-thread.sonic-pi.net/u/darinwilson)\
**Post date:** [April 25, 2019, 6:39pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-plays-musical-box-on-visor-live/2309/2 "2019-04-25T18:39:41Z")

</div>

That’s really cool! I’ve been enjoying all the visualizations you’ve been posting - it’s such a neat way to use Sonic Pi!
