Saturday, August 19, 2023

Rick and Morty theme on Sonic Pi.

I first started with a MIDI and converted that to something I could feed in to chatGPT, XML to the resuce. 

Turning MusicXML into Sonic Pi Script: My Journey with ChatGPT-4

Music has always been a fascinating space where art and technology dance together, and my recent foray into turning a MusicXML file into a Sonic Pi script was an adventure filled with highs, lows, and invaluable assistance.

Why Sonic Pi?

Sonic Pi is an incredible tool that lets you write music using code, which offers an immense array of possibilities for music composers, enthusiasts, and developers. The idea of converting a MusicXML file, a standard open format to represent musical notation, into a Sonic Pi script can streamline the process of creating live-coded music.

The Challenges Ahead

However, the journey wasn't as straightforward as I initially anticipated. While MusicXML provides detailed information about every note, measure, and the dynamics of a musical piece, Sonic Pi has its own syntax and requirements. The challenge was to map the intricacies of one format into the simplicity and power of the other.

Enter ChatGPT-4

That's when ChatGPT-4, OpenAI's latest language model, came into the picture. Given the complexities involved in my task, I approached ChatGPT-4, hoping to bridge my knowledge gaps and simplify the conversion process.

To my surprise, not only did ChatGPT-4 understand the nuances of both MusicXML and Sonic Pi, but it also provided step-by-step guidance on how to proceed. Instead of having to pore over documentation and do manual conversions, ChatGPT-4 offered a streamlined method, saving both time and potential frustration.

ChatGPT-4 in Action

For instance, while handling dynamics and note durations from the XML, ChatGPT-4's solution accounted for the intricacies of how Sonic Pi interprets rests, note lengths, and more. The model even provided insights into making the arrangement more pleasing, ensuring that the final script didn't just sound technically right, but musically vibrant.

Lessons Learned

This experience has been a testament to the potential of language models in assisting creative projects. While Sonic Pi lets us code music, ChatGPT-4 can act as a bridge, interpreter, or even a mentor in this space.

The balance of music and technology has found a new harmony with tools like these. Whether you're an expert in music theory trying to dabble in live coding or a programmer keen on exploring musical landscapes, the combination of MusicXML, Sonic Pi, and ChatGPT-4 is a trio that can help you hit the right notes.

In Conclusion

As I reflect on this journey, it's evident that the fusion of art and tech will continue to evolve, offering endless possibilities. With the support of advanced AI like ChatGPT-4, even the most daunting tasks can become achievable, and the boundary between coding and composing blurs, giving birth to a symphony of innovation.


Attempt 1

# Setting the BPM use_bpm 86 # Define the notes notes1 = [:Bb4, :Db5, :C5, :Eb5, :Ab4, :Gb4] durations1 = [0.75, 0.25, 0.25, 0.25, 0.25, 0.25] # duration in beats for measure 1 notes2 = [:F4] durations2 = [4] # duration in beats for measure 2 (tied to next measure) notes3 = [:Bb4, :Db5, :C5, :Eb5, :Ab5, :Gb5] durations3 = [0.75, 0.25, 0.25, 0.25, 0.25, 0.25] # duration in beats for measure 4 notes4 = [:F5, :Bb4] durations4 = [2, 2] # duration in beats for measure 5 notes5 = [:Bb4, :C5, :C5, :Db5] durations5 = [0.5, 2, 0.25, 0.25] # duration in beats for measure 6 notes6 = [:C5, :Eb5, :Ab5, :Gb5, :F5] durations6 = [0.25, 0.25, 0.25, 0.25, 2] # duration in beats for measure 7 # Play the notes notes1.zip(durations1).each do |note, duration| play note, sustain: duration sleep duration end play notes2[0], sustain: 8 # Considering the tie across measures sleep 8 notes3.zip(durations3).each do |note, duration| play note, sustain: duration sleep duration end notes4.zip(durations4).each do |note, duration| play note, sustain: duration sleep duration end notes5.zip(durations5).each do |note, duration| play note, sustain: duration sleep duration end notes6.zip(durations6).each do |note, duration| play note, sustain: duration sleep duration end

Attempt 2


# Set up BPM use_bpm 86 # Set up Synth (Mallets, since the MuseScore instrument was a Mallet Synthesizer) use_synth :fm # Function for dynamics def dynamic_value(d) return d.to_f / 127.0 end # Play the melody play_pattern_timed [:Bb4, :Db5, :C5, :Eb5, :Ab4, :Gb4], [1.5, 0.5, 0.5, 0.5, 0.5, 0.5], amp: dynamic_value(105.56) play :F4, sustain: 4, amp: dynamic_value(105.56) sleep 4 play :F4, sustain: 4, amp: dynamic_value(105.56) sleep 4 play_pattern_timed [:Bb4, :Db5, :C5, :Eb5, :Ab5, :Gb5], [1.5, 0.5, 0.5, 0.5, 0.5, 0.5], amp: dynamic_value(105.56) play_pattern_timed [:F5, :Bb4, :Bb4, :C5], [2, 2, 1, 1], amp: dynamic_value(105.56) play_pattern_timed [:C5, :Eb5, :Ab5, :Gb5, :F5], [0.5, 0.5, 0.5, 0.5, 2], amp: dynamic_value(105.56)

No comments: