Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
Labels (1)
avatar
Master Guru

Business Need: Build Tool Notifications + Fun

SonicPi is an open source, multiple platform live music synthesizer tool for building music via coding. It's a pretty neat environment and runs on a Mac, RPi, Windows machine or Linux machine. I found a command-line tool that can trigger SonicPi to play your code. I have wired up a dataflow from NiFi to SonicPi, so I can trigger music on demand. My thought is I will tie this into Jenkins and play different songs depending on what's going on. Such as Test Failures, Build Complete, Build Broken, New Deployment, based on various steps in the SDLC.

Note: The machine this running on will need Ruby, Gem, Apache NiFi, Sonic Pi and a sound card.

Step 1:

To trigger Sonic Pi, you must install Sonic Pi Cli, via gem install sonic-pi-cli.

Step 2:

Run the SonicPI software and have it up and running. As you can see it's a pretty awesome environment, somewhere between a nice IDE and a music tracker.

10693-sonicp3.png

Step 3: ExecuteStreamCommand This calls the command line tool to trigger Sonic Pi.

10694-sonicpi2.png

NiFi 1.1 Tool

10692-sonicpi1.png

Shell Script

cat /Volumes/Transcend/Apps/nifi-1.1.0.2.1.1.0-2/nifi.rb | /usr/local/bin/sonic_pi

Example SonicPi Code

sample :bass_trance_c
sleep 1
sample :bass_thick_c
sleep 1
use_synth :prophet
play 30, release: 2
sleep 0.25
play 30
sleep 0.25
play 30
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :prophet
play 30
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :prophet
play 30
sleep 0.25
use_synth :prophet
play 30
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
play 30
sleep 0.25
play 30
sleep 0.25
sample :bass_trance_c
sleep 1
sample :bass_thick_c
sleep 1
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :dsaw
play 30
sleep 0.25
sample :ambi_drone
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :dark_ambience
play 30, release: 2
sleep 0.25
use_synth :dark_ambience
play 30, release: 2
sleep 0.25
use_synth :dark_ambience
play 30, release: 2
sleep 0.25
use_synth :dark_ambience
play 30, release: 2
sleep 0.25
use_synth :dark_ambience
play 30, release: 2
sleep 0.25
use_synth :dark_ambience
play 30, release: 2
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
use_synth :prophet
play 30, release: 2
sleep 0.25
sample :bass_trance_c
sleep 1
sample :bass_thick_c
sleep 1

Reference:

Apache NiFi Template:

sonicpi.xml

2,501 Views
Comments
avatar
Master Guru

We could have NiFi rewrite, update and add to the sonicPI code so the music is constantly changing