Team:Peking/DNA to music

DNA to Music

The coding style based on commands is well-performed in converting existing music to DNA, and to some extent, can ensure the rhythm of the compositions will not be disturbed severely. However, this coding method itself does not involve the music theory, which means that decoding a natural gene sequence in this way is mostly likely to result in a very unpleasing noise. In order to let human-beings gain a deeper insight into the beauty of life, we exploited a new set of coding system based on the music theory of composition, to convert the natural DNA sequence to musical composition

In this system, a piece of music is composed on a hierarchical order. By reading the DNA sequence in order, the frame, paragraph, and specific melody of the music composition are reflected in turn. Our fundamental idea is to divide each step of composing music into a series of smaller and more specific steps, and select a series of patterns for each smaller step according to the rules of music theory, where the selection of particular pattern depends on the base sequence of DNA. Not only can this method confine the composition of music to the music theory, making the music produced by DNA be able to understood by human beings, but also guarantee a variety of music derived from different DNA sequence since the diversity of steps and the branching structure (different former sequence always determine the way of interpretation for the latter sequence).

The composition of a piece of music can be roughly divided into two steps:

1. Determine the frame of the whole composition. This includes the tonality, the number of paragraphs, and the arrangement of the paragraphs.

2. Compose each paragraph in turn. To facilitate coding, we stipulate that a paragraph has four phrases, and a phrase has four bars. We compose the music in phrases. This process can be divided into the following small steps:

(1) Determine the rhythm pattern of the phrase (i.e. the number and duration of the notes in a phrase). This step confirms the backbone of the whole composition, and the following work is to determine the pitch of each note.

(2) Determine the chord progression of the phrase and the root note of each bar. This step controls the mood advancements and the changes of the phrase and even the whole paragraph, which plays a vital role in making the music derived from the sequence audible. By now, the pitches of the most significant part of the notes have been determined.

(3) Fill up the phrase using the chord outer notes. This step decorates the phrase, making it richer and more attractive.

Not only does this coding method allows us to understand s the beauty of life, but also allows us to gain a deeper insight into the nature of life. During the development of organism, the expression product of the upstream gene will affect the expression of the downstream genes. Resembling the generation of music, the process that the genetic information produces life is a hierarchical process of gradually unfolding a picture scroll, just as the original intention of "evolve"? Precisely because of this mechanism, if mutation occurs on the codon which corresponds to the earlier steps of the music generation, the style of the whole composition will vary greatly. Similarly, if mutations occur on the upstream gene of a regulation network, the form of life will become completely different.

The concrete coding method as follows:

Module 1: Determine the frame

Step 1: Determine the fundamental structure of the whole composition

In general pop music, there exists the phenomenon of repetition (i.e. the former paragraph occurs again later in the same way). To make the music derived from DNA sequence be more in line with people's aesthetics, we designed the following pattern, where A, B, and C paragraph denote the verses, and D, E paragraph denote the chorus. (p.s. each letter for one paragraph)

Base Pattern
A A B D E A B D E
T A B D E B D E
C A B C D E B C D E
G A B C D E C D E

Step 2: Determine the tonality of the whole composition

The tonality determines the characteristics of the melody for the whole composition, which is of great significance. Considering that the randomness of the genome cannot bear too many variations, we selected the most common tonality in pop music, the natural major and natural minor, in the principle of simplicity. All the following operations consider the natural major as the default tonality. If the composition is determined to be of natural minor, all the things we will do is to decrease the pitch of the three notes E, A, B by one semitone respectively after the whole composition is completed. (See Module 5)

Base Tonality
A natural major
T natural major
C natural minor
G natural minor

When we complete the Module 1, the paragraphs that need to be independently designed are then determined. From front to back, each independently designed paragraph is divided into four phrases, each phrase is divided into four bars, and each bar is divided into four beats. Now we perform the following module 2-4 on each phrase.

Module 2: Determine the rhythm of the phrase

Step 1: Determine the basic rhythmic pattern of the phrase

Each bar has eight basic rhythmic patterns. We will use the combination of these eight patterns to design a moving music.

Dividing the four bars of a phrase into sixteen beats, we correspond the codons and rhythm patterns according to the following table for each beat (i.e. a quarter note) from front to back (except for the last beat of the whole phrase).

Bases No. of rhythm pattern
AA, AT, CA, CG
AG, AC
TA, TC
TG, TT
CC, CT
GA, GG
GC, GT

Since the last beat of the whole phrase is the end of the phrase, it is better not to use too dense rhythm. Therefore, for the last beat, we only chose two rhythm patterns:

Bases No. of rhythm pattern
A, T
G, C

The No. of rhythm pattern corresponds as the picture below:

Step 2: The first-place rest decoration

Sometimes the first note of the phrase can be a rest. Apply the following operation on the first note of the phrase:

Base Rest at the first place
A, T Yes
C, G No

If the first note is determined to be a rest, we will regard this note as a normal note to manipulate during Module 3-4, but convert it into a rest with equal duration after these to modules are finished.

Module 3: Determine the root notes

The root notes determine the main melody trend, and they are the core of the whole composition. Operation method: divide the phrase into four bars, apply the step1 and step2 on the first bar, and then apply former two steps on the second bar, and so on.

Step 1: Determine the chord of the bar

The chord is the foundation of root notes. Firstly, we need to determine the chord progression, and based on which, we choose the root note of each bar from the chord of this bar.

We tentatively stipulate the range of melodic progression is between the C of unaccented octave and the C of three-lined octave, which means the pitches of all notes are within this range. We constrain the chords to C, F, and G, where C chord is called the tonic chord, G chord is called the dominant chord, and F chord is called the sub dominant chord. The conversion of these three chords is the most common form of the chord progression. We have eight chords as follows:

C3 F3 G3 C4
F4 G4 C5 F5

1. If this bar is the first bar of the whole paragraph, we will apply the following codon table:

Base Chord
A C5
T C4
C C4
G C5

Note: The symbols in the table correspond to the lowest note of a chord among the four notes in a chord. For instance, C3 chord has C3, E3, G3, C4 four notes; F3 chord has F3, A3, C4, F4 four notes; G3 chord has G3, B3, D4, G4 four notes. These four notes are called the 1st, 3rd, 5th, 8th note of this chord from low to high respectively. The 8th note of the F5 chord exceeds the purview of C3-C6, so we stipulate C5 as the 8th note.

2. To ensure the continuity of the phrase, if this bar is not the first bar or the last bar of the whole paragraph, the chord of this bar will be determined by the chord of previous bar and the base jointly according to the following table:

Chord of previous bar Base chord of this bar Base Chord of this bar Base Chord of this bar Base Chord of this bar
Cn A F(n-1) T G(n-1) C Cn G Fn
Fn A G(n-1) T Cn C Fn G Gn
Gn A Cn T Fn C Gn G C(n+1)

If the chord attained by this operation exceeds the 8 chords as specified above, then raise an octave (if the chord is too low) or decrease an octave (if the chord is too high).

3. The last bar of the whole paragraph needs to conclude the paragraph, which means it should be tonic chord. Therefore, the chord of the last bar is determined to be the C3, C4, or C5 chord which nearest to the chord of previous bar.

Step 2: Determine the root note

Normal condition:

For the first note of the first beat and the third beat, correspond each to the note from the chord of this bar according to the codon. The first note of the first beat is called the root note of this bar.

corresponding method: if this bar is the first bar of the whole paragraph, we will apply the following codon table:

Base Note Base Note
A 1st T 3rd
C 5th G 8th

If it is not the first bar of the paragraph, first judge among the four notes of the chord in this bar, how many notes have a distance from the previous chord note less than an octave.

- if only one note meets the criteria, choose it as the chord note

- if two notes meet the criteria, apply the following table:

Base Note Base Note
A, T The lower one C, G The higher one

- if three notes meet the criteria, apply the following table:

Base Note Base Note
A The lowest one T The middle one
C The highest one G The middle one

Special condition:

If the first beat and the third beat of the bar meet the following two points at the same time, we will treat it as a special case:

(1) There is continuity between the first note of the beat and the last note of the previous beat

(2) The duration of the part that the first note of the beat is less than (not equal to) half of the total duration of the legato note.

Treatment of special conditions:

(1) If the duration of the part that the first note of the beat is less than (not equal to) the note after, then that note will be regarded as the chord note of the beat, corresponding according the codon table.

(2) If (1) is not met, apply the rules as follows:

a. If this special condition occurs at the first beat of a bar, consider whether the pitch of this note is set previously. If it is, which means this note is a passing tone for the previous bar, then regard this note as the root note for this bar, set its pitch according to the codon and remain other attributes of the bar unchanged; If it is not, which means this note is the root note for the previous bar, then remain it unchanged and treat this bar as no root note and chord.

b. If this special condition occurs at the third beat of the bar, then regard the first note of the beat as a passing tone (i.e. empty its pitch and keep the rhythm, we will give it a pitch in the next module), and remain the chord of the bar unchanged.

Module 4: Determine the chord outer notes of the phrase

Any note between the adjacent chord notes (i.e. the notes determined in module 3) is called the chord outer note, which can assist the progression of chords, making the music smoother and richer. Compared with the chord note, the chord outer notes are selected more flexible, which just requires not having a huge span between the two notes in general. We will fill in the chord outer notes in turn for every two adjacent chord notes.

If there are no chord outer notes between two adjacent chord notes, then skip directly to the next pair of adjacent chord notes.

If there are several chord outer notes between two adjacent chord notes, then determine the pitch of them one by one from left to right.

The corresponding rules are as follows:

(note: all the notes and all the second, third, etc. need to be taken within the diatonic scale of the C major)

1. If the two adjoining notes are the same chord note, the rules are as follows:

Base Pitch of the passing tone
A, T downward second of adjoining note
C, G upward second of adjoining note

the two adjoining notes refer to at the left and right side of the chord outer note to be set, the nearest notes whose pitch has already been set (rather than the note that only the rhythm not the pitch is set)

2. If the two adjoining notes form a second (their midi coding value difference is 1 or 2), the rules are as follows:

Base Pitch of the passing tone
A, T downward second of the lower note
C, G upward second of the higher note

3. If the two adjoining notes form a third (their midi coding value difference is 3 or 4), the rules are as follows:

Base Pitch of the passing tone
A downward second of the lower note
C, G upward second of the lower note (downward second of the higher note)
T upward second of the higher note

4. If the two adjoining notes form a fourth (their midi coding value difference is 5 or 6), the rules are as follows:

Base Pitch of the passing tone
A downward second of the lower note
C upward second of the lower note
G downward second of the higher note
T upward second of the higher note

5. If the two adjoining notes form a fifth (their midi coding value difference is 7 or 8), the rules are as follow:

Base Pitch of the passing tone
A upward second of the lower note (downward fourth of the higher note)
C upward third of the lower note (downward third of the higher note)
G downward second of the higher note (upward fourth of the lower note)
T between the adjoining two notes, if the first is lower, set the downward second of the first note; otherwise, set the upward of the first note

6. If the two adjoining notes are greater than fifth (their midi coding value difference is larger than 8), the rules are as follow (need two bases):

Bases Pitch of the passing tone
AA, AT downward fifth of the left nearest note
AC, AG downward fourth of the left nearest note
GA, GT downward third of the left nearest note
GC, GG downward second of the left nearest note
CA, CT upward second of the left nearest note
CC, CG upward third of the left nearest note
TA, TT upward fourth of the left nearest note
TC, TG upward fifth of the left nearest note

Module 5: Adjust the major and minor of the composition

This step does not require bases. If the tonality is determined to be a major in Module 1, then do nothing; if the tonality is determined to be a minor in Module 1, then change all E to bE, change all A to bA, change all B to bB.