Code of Music Week 10: Melody Project – Thomas Tai

Project Link (Temporary): http://thomastai.com:3001/
Project Code: https://github.com/thomastai1666/Open-Orchestra

Video Demo

Introduction

For this week’s project, we were asked to design and implement an interactive exploration of melody. I was inspired by the projects we saw in class, and other projects I have seen on the internet. Most notably, I like the strings example from Chrome’s music lab and the “In C” web performance of Terry Riley’s piece In C. Since we are all separated right now, I thought it would be a great time to make a networked application to make music together.

Chrome Music Lab: Strings

Design

When I think of music, it is often represented on a score like the one shown below. The higher the line, the higher the frequency of the note. The lower the line, the lower the frequency of the note is. This was my first choice for the interface. 

Source: https://blog.flat.io/music-theory-ryhthm-measure/

I made mockups of my interface in Sketch, which later evolved and changed as I used predefined bootstrap styles and added buttons and features as I was designing the application. I drew inspiration from stringed instruments and decided on using an Orchestra (cello, bass, violin, viola) as my instruments.

Code

Due to time constraints, many of the components that are used were from other projects. Most of my work was to bring together to components to make the interface I desired. I defined an Instrument object which also inherits the Magenta Player and Tone Player. For networking, I used the socket.IO library which makes use of the shiny new web sockets introduced a few years ago. I send the note value and instrument name of each note being played to all the other users online. It is somewhat hacked together like some of the code, but it works just fine. When a player plucks the string, the data is sent to the Piano Genie model to predict a suitable note to play. It makes use of LSTM (Long short term memory) model to find a suitable sequence.

Future Work

There are some minor changes I would like to make if given the time. I find when too many notes are played at once, the chords tend to be in disharmony. This is a limitation of the Piano Genie model I used in the project. It wasn’t intended for use with string instruments, so it certainly isn’t optimized for this purpose. In fact, there are probably better ways to choose notes that don’t use a machine learning model. I found using a simple scale made more pleasing sounds.

Sources and Attribution

Chrome Experiments Strings: https://musiclab.chromeexperiments.com/Strings/

String Code:
https://experiments.withgoogle.com/jam-with-chrome

Clef Images: 
https://en.wikipedia.org/wiki/Clef

Magenta Library and Demo Code: 
https://magenta.tensorflow.org/pianogenie

Socket.IO
https://socket.io/

Code of Music Week 9: Sequencer – Thomas Tai

Introduction

For this week’s task, we were asked to create a Melody Sequencer. We were to use the Tone.js Sampler and set each track to play a different pitch. I added a different number of steps but kept the same pitches, just several octaves higher than the one from class. There are exactly 8 different frequencies or one octave of notes from the C major scale.

Demo

Link: https://editor.p5js.org/thomastai/sketches/9rjFm1j9A

Process

I started with the code from the previous drum machine. I added 4 more tracks for a total of 8 frequencies on this sequencer. If I had more time, I would add a button to control the number of octaves. The colors were chosen from a rainbow I found online that I found aesthetically pleasing and added to an array. Using the included css stylesheet, I added custom css to customize the look and feel of the slider and buttons. I also added a much needed play and pause button since Tone.js can randomly stop and pause without notice. I found the harp soundfile from freewavesamples.com and used the Tone.js sampler to create the other pitches on the scale. Overall, I’m pleased with the sound but I think the chords could be improved as there is some distortion when multiple notes are played. I would like to also experiment with different types of input and interfaces as this melody sequencer is quite simple.

Code of Music: Week 3 Reading Response

For this week’s reading, we were asked to continue reading This is your brain on music, chapter 2. Some of the most fundamental concepts in music are tempo, meter, and rhythm. Tempo refers to the speed at which music is played and meter refers to the first beat of the pattern. Rhythm, which refers to the length of notes, is a fundamental aspect to all types of music. One interesting aspect about rhythm is that we can predict what happens next in the song. Similar to language, music also has structure and pattern. When a note doesn’t belong, we can instantly feel and recognize that something is off. Recurrent Neural Networks which were originally used for language processing are now being used to generate music.

Music is subjective, but listeners can tell when something sounds unpleasant or out of tune. Our brains can discern chords that are harmonious and disharmonious. Multiple notes that form integer frequencies will be in harmony, while other notes may clash and feel out of place. Music may not appear to be science, but the fundamental physics of sound involve math. According to the author, “The particular notes found in our major scale trace their roots back to the ancient Greeks and their notions of consonance.” The major scales generate frequencies that are in harmony, which is why orchestras will use the same key when playing a piece together. While we as the listeners don’t care about the music theory behind a song, we subconsciously judge it for its harmony and rhythm.

The tempo of a piece is the speed of the beat measured in beats per minutes. With the time signature, which specifies how many beats are contained in each measure as a fraction, we can express exactly how a piece should be played. Many songs in the western world are written in common time in which there are four beats in a measure. Loudness is another important element of music, which is scientifically measured in decibels. A song will typically have changes in loudness which are indicated by the composer. Dynamics, along with other elements in music such as rhythm, pitch, melody, and harmony make up the basic building blocks of music. While we don’t know exactly how the brain processes music, we can certainly appreciate songs for the joy they bring.

Code of Music: Week 2 Rhythmically Interesting Song

This video is about a rave that happens on a remote island with thousands of crabs snapping their claws to the beat of electronic music.  I picked this song because it has an addicting and interesting beat that matches perfectly with the visuals. The song is very basic – there are three sections with the melody repeating every 2 measures for the intro and outro. Most of the notes seem to be synthesized and the tempo is around 120 bpm. Despite the simplicity of the song, it has reached 90+ million views on Youtube which shows how music doesn’t need to be complex.

Code of Music: Week 1: Catalog + Ideas

Introduction 

For this assignment, we had to study and describe a musical composition using words to develop a catalog of attributes. There are multiple ways to describe a piece of music, and it is ultimately up to the listener to interpret it. Some common attributes of music include harmony, melody, rhythm, form, and key. I choose to analyze a midi file from classicalarchives.com to be able to see the multiple layers that make up an entire piece. The name of the piece is Antonio Vivaldi: La primavera (Spring) in E, RV269, Op.8, No.1 which was originally composed in 1723 and rewritten using digital midi technology. Attached below is one performance by a talented group.

Catalog of Attributes 

Beat: 90 Beats Per Minute

Sound Elements: Violin I, Violin II, Violin III, Viola, Cello, Double Bass

Harmony: Cello and Bass mostly play one quarter note repeatedly which provides the beat for other instruments.

Melody: Fast and lively sound (ball dance music), distinct baroque style, noticeable contrast in dynamics, one common theme repeated, notes going up and down, many trills that sound like bird chirps.

Rhythm: Common Time

Form: The composition has three main sections that go from quick to slow to quick again. 

Possible Idea

Spring is a classic piece that many musicians play both in orchestras and as a solo piece. The piece is part of four different concertos called Spring, Summer, Autumn, and Winter. It would be interesting to train a neural network to generate Vivaldi music based on the time of year.  We could create a website that generates the piece and users could come and listen. However, this could be difficult to do without a deep understanding of machine learning and procedurally generated computer music. Another possible alternative would be to take parts from each piece and mix them together. 

Image Source: https://www.washingtonpost.com/weather/2019/11/17/snow-fall-color-comparing-beauty-all-four-seasons-tidal-basin-photos/