screenshot: Randomly filled melody in LMMS; under Bhupali raag pattern, with 4/4 time signature.
How I experiemented and achieved practically random, though incomplete, SARGAM generation.
This page is also a bookmark to some useful articles in the same area.
Plese notify me if something is wrong, or misleading in the text below. I won't accept pull requests in this project, but I will accept:
- a new issue,
- a disucssion thread.
Dedicated to experiement lovers who:
- is interested in basics of classical music and raag database
- knows some programming language, like C-Sharp
- knows LMMS as open source music making software
- is interested in sound design
It is a linear succession of musical tones percieved as single entity. I will try to create a sound piece as melody, by taking random notes permitted within a raag.
I spent several weeks in the year 2022 in re-search of random ambient melody to be created with LMMS. I came up with a new tiny software that fills these notations as defined in the classical way. Then immediately, it was possible to create an XML .xpt file that LMMS understands. It is the capability of LMMS to export and import notations in XML format, so that portion of sounds can be shared within projects.
By this, an instant sound is possible and you can change instruments and tempo, beats and effects for different tonal qualities, without altering the SARGAM notes. Change of digital instrument would render entirely different sound experience, and mood to the listener.
The software is written in C# and uses SQLite Database. The source code will be available separately, shortly.
Other tools used are:
- Visual Studio with .net 7 (as of this writing)
- Entity Framework with support to SQLite
- DB Browser for SQLite
- LMMS - GitHub
- Some external audio player
It consists of these major elements:
- Database of raag and thaat, eg. as found here or here.
- Random SARGAM Generator
- SWAR Converter - convert SARGAM to English scales
- Ability to generate .xpt pattern files for LMMS
- Song structure creator
Linking capabilitiesto authorship roles: lyricist, musician, singer, composer and director.
Primarily, the notes have to stay within a limited range as defined by their melody pattern called the raag. Any SARGAM is likely to automatically classify under one of the 10 Thaats.
You can find this database at various websites including:
- Wikipedia
- Sharda.org
- The World of Hindusthani Ragas
- p-sarkar
- Raag Time
- Raag - Time Association
- Raag Index - Tanarang
- SwarGanga
- etc.
Thanks to the websites that supply at least:
- name of raag
- Aroha (ascending notes)
- Avaroha (descending notes)
- other information like time of performance, etc.
I had to combine information from these links in order to identify how I should handle the notations for use with a computer. Thus I ended up with a basic software that also parses a written piece of notations.
SARGAM is a short form created from the first basic musical notes - SA RE GA MA (PA DHA NI). There are 12 notes including sharps and flats.
x | C | C# | D | D# | E | F | F# | G | G# | A | A# | B |
---|---|---|---|---|---|---|---|---|---|---|---|---|
SARGAMs | S | r | R | g | G | m | M | P | d | D | n | N |
Each English note corresponds to a variable SARGAM note.
Yes, SARGAM notes are variable. S, and P do not have sharps or flats. You can assume any key on a piano as starting note - SA and keep on counting 12 notes from there.
SARAGM generation is a picking up of those notes to create a melody; in a written form. Another person or software should be able to recreate the similar sound as intended by the original author.
There will be factors around a melody, like: timing, tempo, and expectations of occurence of next note in the sequence.
The different note sequences has been already documented in the classical music.
- Thaat - Parent Scale
- Raag - Melody Pattern
- Song structure - eg. ABAACB that is a structure of a song
- Note population - what note to pick next is based on note population
Frequency- how frequently should a note occur is not addressed- sharing Time length - two notes are played in the given time length
- Notes skipping - not to accept immediate next or previous note, but to jump into the other note behind or ahead.
- Tempo - How fast to play a melody
- Time Signature - eg. 4/4, 2/2, 3/4
- Beat
- Rhythm
- more from glossaries: tanarang, wikipedia
You do not know which note comes next. It may return back, repeat (continue same note) or move ahead. To return or move ahead, there are 2 notes possible (I allow to skip by one-note).
It picks up next note from these 5 possible notes randomly.
- return 2 notes back
- return 1 note back
- continue same note
- move ahead by 1 note
- move ahead by 2 notes
The core of the project is to create a randomized sound as melody in this unexeted behaviour. Luckily there is a database of notes and Raags that have been already documented since the old times. I will generate sound based on these rules, and the database.
The randomization should create new and unfamiliar melody, yet, hoping to be pleasant to hear.
Technically, a raag could be a named combination of musical notes. It could be a permutation of allowed notes. There is much more to explore. And, many of them are already been lost permanently. They should have unique structures, evolved and popularized over differnt anceint times.
Another reading on permutaion.
Raag Bhupali is assumed to be over 4,000 years old system. It's melody pattern has been loved by so many people in various generations and hence it thrived for so long.
It's ascending and descending notes are expectedly inverted. Data entry to this raag is easy, and the human ear can find out if something is not right. Since the usage of only major pentatonic notes (no shaprs, no flats) it is a perfect pick up for my project.
Another reason I picked up this raag is due to relatively abundance of information available.
- Influence on human brain waves
- Music in motion
- Short Takes: Bhoopali
- chandrakantha.com
- Meet Kalakar
- Bansuri Bliss
Many people already know the Bhupali in some forms. So, it will be easier to collect feedbacks on the sound produced.
The basic notations set used in raag Bhupali are: SA, RE, GA, PA, DHA, SA* and returning as SA*, DHA, PA, GA, RE, SA.
My randomization is based on the notations per raag. For this, I needed a database of notations in each raag. Everytime I want to invoke the randomizer, I should feed the raag, compulsorily.
Another raag Durgaa has a different set of notes allowed.
SA RE MA PA DHA SA*
.
The randomizer is going to pick different set of notes for Durgaa and Bhupali.
For example, a random note of +2 with respect to SA
will be MA
for Durgaa, and GA
for Bhupali.
That is hence, a huge difference in the sounds of these two raags.
In the code,
string sargams = sargamizer.lyrics(lines, numerator, denominator, raag_name_selected, population_data)
These are the parameters:
lines
: how long the sargam text should benumerator
: part of time signature defining how many bars should there be in each line.denominator
: part of time signature defining how many notes per bar should there be.raag_name_selected
: Currently active raag.population_data
: population of notes for randomization.
x | C | C# | D | D# | E | F | F# | G | G# | A | A# | B |
---|---|---|---|---|---|---|---|---|---|---|---|---|
C0 Octave Notes | S.... | r.... | R.... | g.... | G.... | m.... | M'.... | P.... | d.... | D.... | n.... | N.... |
C1 Octave Notes | S... | r... | R... | g... | G... | m... | M'... | P... | d... | D... | n... | N... |
C2 Octave Notes | S.. | r.. | R.. | g.. | G.. | m.. | M'.. | P.. | d.. | D.. | n.. | N.. |
C3 Octave Notes | S. | r. | R. | g. | G. | m. | M'. | P. | d. | D. | n. | N. |
C4 Octave Notes | S | r | R | g | G | m | M | P | d | D | n | N |
C5 Octave Notes | S* | r* | R* | g* | G* | m* | M'* | P* | d* | D* | n* | N* |
C6 Octave Notes | S** | r** | R** | g** | G** | m** | M'** | P** | d** | D** | n** | N** |
C7 Octave Notes | S*** | r*** | R*** | g*** | G*** | m*** | M'*** | P*** | d*** | D*** | n*** | N*** |
C8 Octave Notes | S**** | r**** | R**** | g**** | G**** | m**** | M'**** | P**** | d**** | D**** | n**** | N**** |
C9 Octave Notes | S***** | r***** | R***** | g***** | G***** | m***** | M'***** | P***** | d***** | D***** | n***** | N***** |
There was a clear problem of how to write the SARGAM and the English scales that match to several keys of a piano. I found out some classical systems of writing these notes called Bhatkhande system and some other ways. The purpose is to exactly reproduce the melody for ear by reading a written form of SARGAM.
I had another problem as well:
- the notes should have been understood by the computer.
- typing the notes should be easy using a QWERTY keyboard.
- notations should be convertible to the form understood by melody software.
I proudly happened to recreate the written notation system for use with computer; ultimately with slight modifications and limitations. Only problem is the lower or higher the octave, it is relatively difficult to read the note by human note. Or otherwise, it is clearly a non-confising and printable notation.
For example, notations from C4 octave would be:
- S R G M' P D N
- r g M d n
Notations from C5 octave would be:
- S* R* G* M'* P* D* N*
- r* g* M* d* n*
Notations from C3 octave would be:
- S. R. G. M'. P. D. N.
- r. g. M. d. n.
Notations from C2 octave would be:
- S.. R.. G.. M'.. P.. D.. N..
- r.. g.. M.. d.. n..
Notations from C6 octave would be:
- S** R** G** M'** P** D** N**
- r** g** M** d** n**
Number of dots or stars would decrease or increase the octave number from C4.
For example, S.
and S**
. You can range from C-1 to G9 key notes.
For example: S....
For many users, C3, C4 and C5 octaves should be ok. This has definitely clearer, short and non-confusing notes.
When the note extends to another time length, it will be represented with a hyphen in that time.
eg. S - - - | S - S -
, and S* - - -
.
There are many other unicode characters that look like a hyphen. I tried to include some of them.
When a beat uses two or more notes, sperate them with a comma. eg. S,R
.
One comma means two notes together.
And two or more commas in a beat might produce a digital glitch or crackling sound in the software (quantization error).
Three commas would be too quick notes served in 1 beat.
But, it opened a new opportunity of notation like: R,-,-,G
and R,G,-,-
which are differently stressed sylables.
You can probably adjust the grace notes / meend here.
Unfortunately R,-,-,-
is same as R
but with CPU loads.
The below notation is written as: S - R,G P
.
Combination R and G share same time length as S, -, and P.
Also,
- ~ and _ will be continuation markers
- x as silecne
- pipe | or a slash / as bar separator
- comma ( , ) would list notes that share the time equally.
There are some other glossaries that time-share a note. Meend / Glissando, Gamak, Kan - Grace Note, Khitka, Aandolan, etc. @realisim's SARGAM seems to be better in this case. I am currently unable to handle such ornamentations.
I noticed, many SARGAM authors use their own conventions to write and educate. And they are incompatible due to their choice of format selection and presention styles. They come in audio form, written/printed with pen or typed in computer, or in a digital image form, for example.
- embedded in devanagari lipi and this
- typed in computer, in roman short forms
- in a diary, motion video
- photograph of a diary
- Live, as to show the key pressed
- Oral explanations
- PDF like display
- in interactive websites and animations
- in books
- in verbal trainings and recitements
- scanned pages from old scripts / print outs
- staff notations
Note: these notations might have been copyrighted, registered, non-original or modified ones from the different scale. I am concerned with the different mechanisms of their presentation only.
It would have been better, if there were one-language to write these notes and parse them in computer regardless of instrument being used. I am not talking about staff notes but SARGAM in written form.
- SARGAM representation that a computer can parse well without confusion.
- Notations to sharps, flats and other octave changes are recognized.
- Can accept any keys from C-1 to G9 ie, 127 keys piano
- Randomly melodic note generation
- Creating XPT file for LMMS
- Conversion of the SARGAM Notes into English Scales
- You have to save the note yourself if you need it to replay in the future.
- It re-generates a new set of notes.
- Does not recognize the style of singing
- Does not prevent the history of how it was designed earlier.
- Usage in other beat making software has not been researched.
A user can self-define a melody structure of one's choice. There are 10 different varieties of notations available. Each difference is subject to change in notation's timing and frequency. Everytime you generate a new notation, it will be random.
Each letter (group_name from A to J) corresponds to one line of lyrics through out the melody. A, B, C, D, E, F, G, H, I, J are the differnt parts of lyrics-line styles that you can repeat.
You have to make a combination of these lines to create the structure for your own melody. To ease the user, I create a random lyrics per letter once while you generate your melody. And, this lyrics is preseved in your work.
If you generate ABABCB song structure, then, there will be repeatitions of the notations. The pattern A, pattern B and pattern C will be preseved. If you are lucky enough to get more pleasing notation, you can recognize it through out rest of the the song.
For example, the song structure of ABABCB would give:
1: D E C C D C D,E G - G E C D E E D,E
2: E - D,C E,E D G G E D C C D,D C E - E
3: D E C C D C D,E G - G E C D E E D,E
4: E - D,C E,E D G G E D C C D,D C E - E
5: D D - E A C* A - C* A C* C* G A A -
6: E - D,C E,E D G G E D C C D,D C E - E
Notice how line #1 matches A, line 2 matches B, line 3 re-matches A, and so on.
listen to this corresponding audio. | Or, import the .xpt File in LMMS piano roll editor | Download full project
If you fill up SARGAM, it can give you the possible raags that matches it.
But there are always a multiple match due to:
- Some notes are skipped in your SARGAM.
- It really matches to many other raags.
When the notations match to many other raags, it is worth mentioning that a raag was also a way of singing it with various styles of stresses on the syllables. Hence, officially, there are raags made of exactly similar set of notes, yet different names, presentation styles, different times for performance, and diffence to human ears, and serve different moods.
After all, a random melody to be created. Out of many thousands possible, here is one.
Listen or download, and view .xpt clip. Data for Trance Pluck instrument was random. Other plugins: Synth Tom and Kick Solid.
Check the code below to determine how the randomization has been implemented.
int[] steps = new int[] { -3, -2, -1, +0, +1, +2, +3 };
int[] percentage = new int[] { 0, 1, 1, 2, 5, 1, 0 };
int s = 0;
foreach (int step in steps)
{
int random_count = percentage[s++];
for (int rc = 0; rc < random_count; ++rc)
hops.Add(step);
}
A step
is a note's jump distance (hop) from one pitch to another.
In case of Bhupali, with a random step of +2
, next note after S
would be G
.
But if the step was -1
the next note selected will be D.
.
The percentage chances of appearance of -1
is 10%.
The percentage chances of appearance of +1
is 50%.
The population of note being -3 and +3 are 0% in this particular example.
So, after S
, the next note could be something between -2 and +2 note away, with a maximum chance of being R
(+1, 50%).
But it might yield anything out of -2: P.
, -1: D.
, +0: S
, +1: R
, +2: G
.
For the next loop, the starting note will the the one just selected.
And again, another random note is picked up from new point.
A biger jump distance, eg: -4 or +4 would create a very different/nasty pitch. It can include notes from another octave. -3 and +3 aren't even polite to ears. So, the maximum population of notes has to stay within -2, -1, -, +1, +2 range.
Meanwhile, I am unable to address:
- vaadi
- samvaadi
- Varjit - auto excluded becase it does not appear in the database
- nyaasa (landing) notes.
CREATE TABLE "classical_raags" (
"raag_id" TEXT NOT NULL,
"thaat_id" TEXT NOT NULL,
"raag_number" INTEGER NOT NULL,
"raag_name" TEXT NOT NULL,
"raag_thaat" TEXT NOT NULL,
"raag_ascending" TEXT NOT NULL,
"raag_descending" TEXT NOT NULL,
"raag_varjit" TEXT NOT NULL,
"raag_pakad" TEXT NOT NULL,
"raag_chalan" TEXT NOT NULL,
"raag_vaadi" TEXT NOT NULL,
"raag_samvaadi" TEXT NOT NULL,
"raag_vivadi" TEXT NOT NULL,
"raag_nyasa" TEXT NOT NULL,
"raag_timing" TEXT NOT NULL,
"raag_notes" TEXT NOT NULL,
"raag_processed" TEXT NOT NULL,
PRIMARY KEY("raag_id")
);
Population data is store as:
CREATE TABLE "population" (
"population_id" TEXT NOT NULL,
"population_name" TEXT NOT NULL,
"population_lines" TEXT NOT NULL,
"step_minus3" TEXT NOT NULL,
"step_minus2" TEXT NOT NULL,
"step_minus1" TEXT NOT NULL,
"step_zero0" TEXT NOT NULL,
"step_plus1" TEXT NOT NULL,
"step_plus2" TEXT NOT NULL,
"step_plus3" TEXT NOT NULL,
"group_name" TEXT NOT NULL UNIQUE,
PRIMARY KEY("population_id")
);
step_minus3 means -3, and its database value is the population count. Similar for other populations of -2, -1, +0, +1, +2, +3 notes.
Unique column group_name
is associated in the melody struture.
For example, my example data has:
Population Name | Group Name | Sample Population | Notes |
---|---|---|---|
Aalap | A | 0, 1, 3, 2, 3, 0, 0 | Longer notes |
Aalap Closer | B | 0, 3, 2, 3, 2, 3, 0 | - |
Chorus | C | - | - |
Sthaai | D | - | Most prominent part |
Antaraa | E | - | - |
Bridge | F | - | Contrasting sound, relief |
Closer | G | - | - |
Sanchaari | H | - | - |
Aabhog | I | - | - |
Outro | J | - | relatively longer notes, ending a sound |
Random | ? | - | Each time generates a new set of notes |
The purpose of pushing these population configuration to database is to allow a user too change the basic behaviour (or reaction) of the application, without having to compile the software.
However, you can now write a lyrically recitable poetry with these group names. Please see melody structure above.
The raag database would serve the list of possible notes (I considerd ascending notes only; and hence the implementation is incomplete.)
The random number generated between -3 and +3 is a swinging index.
It's purpose is to help us pick a note from the array of notes.
Notes are aligned circulalry in the array. S*
and next +1 note should have been: R*
.
But since I have not implemented the descending notes and there is no new jump into higher octave (taar saptak), it is underterministic.
Sometimes, notes stay static at S*
for few times, yielding notes like: S* S*,S* S* -
in the peaks.
Same thing happens at the valleys of the notes: S
repeats in bottom instead of going into lower octave (mandhra saptak).
I am just looking for some ambience in the final output. But, you can regenerate your own varieties and use then in different ways.
It should ideally support other raags as well.
Plese let me know your interests in the un-sanitized source codes I have now.
In this experientation, I:
- solved the problem of parsing written/typed SARGAM notations.
- got more skills on C# and xml handling.
- built APIs around this theme.
- enhanced skills on LMMS instrumentation.
- gained more information about classical music in theories.
- brought up a software to write SARGAM notations that can be conveted into melodious audio.
- opened an opportunity of raag detection for a given SARGAM.
- collaborated with some authors.
- gained confidence in the areas covered.
- The pictures attached are for representation only.
- Randomization attempt does not supress creativity in note selection.
- This article was written by human hands, not AI generated.
- I do not have affilitions to the third party links.
- Everything in this project is an experiment.
- The included project is at some point, generated randomly, and it should not match to existing melodies.
- Choice of instrument preset can lead to different experience.