Geek
bullet

Raga Morphing using Hamming Distance (October, 2005)

bullet

Introduction

Raga Morphing is a new concept combining elements of Hindustani Classical Music and Information & Coding Theory in Computer Science. The desired effect of this invention in a concert is to be able to glide across the raga landscape, explore the variety of moods that characterize each raga, and understand the subtle differences and relationships between different ragas. One can also use this analysis to find the best sequence of ragas that go together elegantly to compose a musical piece with interlocking ragas while manipulating the listener's mood expertly.

Raga Morphing is a concept where an aesthetically pleasing smooth transition is made from one raga to another. The raga transitions are highlighted by keeping the lyrics of the bandish (composition) the same. The term morphing, derived from metamorphosing, refers to an animation/graphical technique in which one image is gradually transformed into another. Raga Morphing is an analogous musical technique where one raga is smoothly blended into another.

Do not confuse Raga Morphing with Raagmala in which the transitions from one raga to another has no mathematical significance. Ragamala literally means a garland of ragas. Each line (or verse) of a composition is rendered in different ragas hung on a common theme. Raga Morphing differs in that it creates an aesthetic path between ragas. Each raga's personality is highlighted and contrasted with those of the previous and next raga in the path.

I would like to point out, that the traversal, by definition contains ragas very close to each other. From a performance standpoint, performing such closely placed ragas sequentially is very challenging. An added challenge is to create the bandish on the fly for the current raga, using the lyrics from a common bandish. This makes it even harder to render. An analogy to raga morphing is clearing an obstacle course on a rink with narrow lanes while ice skating. Now add an oil spill to the ice and make the ice paper thin in some places! This analogy puts the difficulty of this experiment in perspective.

bullet

Applications

1. Understanding the subtle (and not so subtle) differences between neighboring ragas, from both an educational and performance stand point.

2. Understanding the differences in the moods generated by Ragas separated by a small distance.

3. Understanding the clustering properties (distance relationships) of ragas separated by a small distance.

4. While composing melodies, one can use ragas different in only one or two notes, while shifting the emotions conveyed by a large amount.

5. The Hamming Distance relationship allows the computation of a distance graph of known ragas. The graph makes counter-intuitive relationships between ragas visible.

6. From a musical composition view point, the "neighborhood" of a Raga (the set of ragas separated by a small distance) provide the composer with a raga-pool to compose from. The pool is special in that the ragas have small differences in their notes, but a much larger difference in the moods they generate. The composer can thus create a wide variety of moods within a basic framework by using only a few additional notes.

bullet

Recordings

This Raga Morphing experiment was recorded as part of a live concert in April 2006, California. The first part is an explanation of the experiment while the second part is the actual morphing. The Morphing is done using Din-ki-Puriya as the starting Raga and Kalawati as the end Raga. The sequence of the ragas used is Din-ki-Puriya arrow Lalit arrow Bhairav arrow Bhatiyar arrow Ahir Bhairav arrow Kalawati.

bullet

Formalization

Imagine picking two arbitrary ragas. Select one to be the Start raga Start Raga R_s and the other to be the End Raga End Raga R_s. Now imagine a series of intermediate ragas (R_1, R_2 ... R_n) such that the transition from Rs to Re is made as smooth as possible, and aesthetically pleasing. Then the sequence (R_s, R_1, R_2 ... R_n, R_e) is called the traversal sequence. I have attempted to formalize the problem as a Hamming Graph. The Hamming Distance (in information theory) is defined as a measure of the difference, or distance between two given sequences, or sets. Simply, its just the number of position-wise differences between the sets.

A Raga Raga R can be represented as an triple containing a set of Notes (or swar) Set of Notes, N, a set of Transitions Set of Transitions, T and a set of Nuances (or Lagaav) Set of Nuances/Lagav, L.

The set of notes Set of Notes, N is calculated by taking every possible legal note in the raga as defined by the transitions Set of Transitions, T, discarding duplicate entries and sorting the set in an ascending order.

Mathematically, a raga Raga R={N, T, L|

Let us now define the hamming distance between two ragas R_a and R_b as

HD(Ra , Rb) = | Na - Nb |

where the subtraction is a note-wise, note sensitive, note-relaxed difference. By note-wise, I mean that the two set of notes are sorted in ascending order by the note-ordering, and then compared. By note sensitive, I mean that if two notes are being compared, then suddha, komal (flat) and teevra (sharp) will be considered different. By note-relaxed, I mean that if the base note remains the same while changing to one of suddha, komal or teevra, then the distance is considered as one instead of two. This 'relaxation' of the hamming distance rule lends itself to a more aesthetically structured entity-relationship graph.

bullet

Examples

1. Hamming Distance (Malkauns, Jogkauns)

For example, let us calculate the Hamming Distance of Malkauns and Jogkauns. Here, Malkauns is a proper subset of Jogkauns.

Underlined notes are komal (flat), overlined notes are teevra (sharp), and those without any adornment are shuddha.

N_Malkauns = {Sa, Ga, Ma, Dha, Ni}

N_Jogkauns = {Sa, Ga, Ga, Ma, Pa, Dha, Ni, Ni}

HD(Malkauns, Jogkauns) = 3

2. Hamming Distance (Malkauns, Odhav Bageshree)

N_Malkauns = {Sa, Ga, Ma, Dha, Ni}

N_Odhav_bageshree = {Sa, Ga, Ma, Dha, Ni}

HD(Malkauns, Odhav Bageshree) = 1

3. Hamming Distance (Bhairavi, Bilaskhani Todi)

N_Bhairavi = {Sa, Re, Ga, Ma, Pa, Dha, Ni}

N_Bilaskhani_Todi = {Sa, Re, Ga, Ma, Pa, Dha, Ni}

HD(Bhairavi, Bilaskhani_Todi) = 0

bullet

Hamming Distance Raga Graph (3.5MB PNG (4922 x 3632), dot file)

With this formalization, we can now create a graph of ragas, where the nodes are the Ragas, and edges connect the ragas based on the Hamming Distance between nodes. Each edge has a weight equal to the hamming distance between the connecting nodes.

The graph below was created with a program I wrote in C++. The program takes as input a file containing information about Ragas (Name, Swars, Time) and computes a Hamming distance graph. It them converts the graph from an adjacency matrix format into a DOT undirected graph specification. DOTTY was used to lay the graph out and Inkscape used to scale the SVG output image.

The Red connecting edges are between ragas of same swars (HD = 0), Blue edges connect Ragas with HD = 1, Green edges connect Ragas with HD = 2.

(Click on the image to see details)

Raga Morphing Zoom

Note: This is not a complete graph and is work in progress.

bullet

Graph Analysis

This graph encodes the hamming distance relationship and uncovers a fairly complex structure. It also gives insight into some very unusual relationships (like Jogkauns and Bhairav, Bhatiyar and Bhinna Shadaj, Ambika and Malkans, Bairagi Bhairav and Megh Malhar etc). The raga time has also been depicted using color coding for the nodes.

Ragas connected by Red edges (Bihag, Maru Bihag, Shyam Kalyan and Yaman Kalyan; Gawati, Bhimpalas, Kafi, Nayaki Kanada and Bageshree etc) represent ragas with a distance of zero from one another. An interesting thing to notice about these ragas with zero distance is that they can sound very different because of different transition rules and nuances. Similarly, a small hamming distance doesn't necessarily imply the shortest aesthetic distance. Sometimes, zero distance transitions must need to be made for preserving the aesthetic continuity of the raga traversal sequence. Thus in a concert, I can chose the ragas that give the best effect.

An important insight is that the mood of ragas separated by a small distance need not be small at all. In fact, in most of the raga-morphing experiments, the feel or mood of the raga separated by a small hamming distance was almost always largely different, adding to the beauty of the experiment.

Inspired by the "Six degrees of separation", I conjecture that the maximum distance from any given raga (using the completed graph) to any other given raga is about six.

bullet

Algorithmic Analysis

We now simplify the Raga Morphing problem to a shortest weighted-traversal, where each step in the traversal chooses a node (Raga) that is a direct neighbor and has the least hamming distance from the source raga.

The algorithm for generating a traversal sequence given the start and end raga can be expressed as follows (pseudo code). Note that the heuristic is supplied to it as an argument along with the start and end raga. The algorithm is described to formalize the morphing mechanism and as an aide to understanding the Raga Morphing concept. In a concert, the graph will be built dynamically in my head and the traversal shall be performed on it!

Raga [] Do_Raga_Morph(Raga start, Raga end, Heuristic heuristic)

{

Raga [] traversal = allocate_raga_vector();

Raga current = start;

int index = 0;

// repeat while we are not at the end raga

while (current != end) {

traversal [index++] = current;

/* Chose a neighbor of our current raga with minimum hamming distance using some heuristic do determine the best path to take. As a classical vocalist, I know trivially what path to take. */

current = chose_neighbour_with_min_distance(current, heuristic);

}

// terminate the vector

traversal [index] = END;

return traversal;

}

bullet

Future Work

† The total set of ragas is calculated using the 'Jaati' property of ragas. A raga has an ascending swar transition called Aaroha, and a descending transition called Avaroha. Each of these in turn can have 5 (Odhav Jaati), 6 (Shadav Jaati) and 7 (Sampoorna Jaati). In order to simplify the calculation, we neglect any ragas that have more than 7 notes in either the Aaroha or Avaroha.

The estimated number of total ragas then will be:
{ (12C5) * (12C5) } + { (12C5) * (12C6) } + { (12C5) * (12C7) } +
{ (12C6) * (12C5) } + { (12C6) * (12C6) } + { (12C6) * (12C7) } +
{ (12C7) * (12C5) } + { (12C7) * (12C6) } + { (12C7) * (12C7) } = 6.2 Million