CFugue
CFugue MusicString

Contents

Introduction

One of the capabilities of CFugue that makes it so elegant and easy to use is the concept of Music Note Strings (or simply MusicStrings, as referred to by JFugue). MusicStrings provide the ability to specify Music Notes and MIDI instructions as a sequence of characters (and tokens) in human readable form, as opposed to the usual complex binary data byte form. This makes it easy to learn and master. Below is an example of a MusicString supplied to the Play() method to play a Mid-C note and a C-Major chord. (Please refer CFugue API examples for more such examples.)

    #include "CFugueLib.h"
    void main()
    {       
        CFugue::Player player; // Create the Player Object        
        player.Play("C CMaj"); // Play a Mid-C followed by C-Major Chord 
    }

Few more examples of MusicStrings:

    CFugue::Player player; // Create the Player Object    
    player.Play("I[FLUTE] FMaj"); // Play the F-Major chord with Flute 
    player.Play("C D E F G A B"); // Play all the mid octave notes 
    player.Play("K[MELA] S R G M P D N"); // Play all the mid octave (madhya sthayi) notes in Carnatic Music 
    player.Play("C+D+E+F+G+A+B"); // Play all the mid octave notes in parallel    
    player.Play("CI CI CI GI FI GI D#I. FI. G#I GI. RI"); // Notes with durations
    player.Play("K[HAMSADHWANI]T8S2 ( S' GA' R'  S' R' S' N   PA N S'  RI' RI' )"); // A piece of Vatapi Ganapathim in double speed 

In the following we discuss at length the details of what constitues a MusicString and how it can be used for creating music with CFugue.

Components of MusicString

In CFugue, a valid MusicString is formed out of a series of music tokens. Tokens are nothing but sequences of alpha numeric charaters. Seperated with whitespace, each of them represents either a music note related data or a CFugue related command. The first character of a token usually determines if the token should be considered as a note token or a command token.

Typical examples of note tokens are notes, chords, ties and so on, while MIDI instructions, such as instrument change, voice command etc. are few examples of CFugue related commands.

When CFugue parses a MusicString, it uses the first character of the tokens to identify the notes and commands. If no decision can be made about a token, CFugue will simply ignore the token and moves on (observe that this is unlike any typical parser behavior, where an unrecognized token will halt the parsing).

Below are the first characters and their associated token classifications for CFugue MusicStrings:

Character API Constant Significance
V TOKEN_START_VOICE Specifies a Voice token.
T TOKEN_START_TEMPO Specifies a Tempo token.
I TOKEN_START_INSTRUMENT Specifies a Instrument token.
L TOKEN_START_LAYER Specifies a Layer token.
K TOKEN_START_KEYSIGNATURE Specifies a KeySignature token.
X TOKEN_START_CONTROLLER Specifies a Controller token.
@ TOKEN_START_TIME Specifies a Time token.
* TOKEN_START_KEYPRESSURE Specifies a Keypressure token.
+ TOKEN_START_CHANNELPRESSURE Specifies a Channel pressure token.
& TOKEN_START_PITCHBEND Specifies a Pitchbend token.
| TOKEN_START_MEASURE Specifies a Measure token.
$ TOKEN_START_DICTIONARY Specifies a Dictionary token.

Each of these will be explained in detail in later parts of this discussion. For now, when a token starts with a character that is different from all of these shown above, CFugue tries to read that token as a note token. If it succeeds in that, it will generate note events for further processing. And if it fails, it will ignore the token and moves on.

CFugue MusicStrings are case-insensitive. That is, the characters can be used in any case, either upper or lower, while creating the MusicStrings. CFugue will internally convert all the supplied MusicStrings to upper case before processing them. Use this fact to your advantage by mixing the case for your MusicString tokens and making them more readable and easy to understand. Examples of few valid MusicStrings that showcase this advantage are:

    player.Play("C");
    player.Play("FMaj");
    player.Play("Cq+Eh+Gq");
    player.Play("C6q+E4h+G8q D5Maj7w");
    player.Play("T[120] V0 I[Flute] Cs B4s A4i B4i C");
    player.Play("I[XyloPhone] K[Mela_29] S R G M P D N S'");

Specifying Notes

Specifying music notes in CFugue MusicStrings is simple and straight forward. Just indicate the root of the note followed by its optional attributes, such as octave, duration, any additional connectors etc. and you are done. Thus the structure of a valid note token is:

Root[Octave][Chord][Duration][Velocity][Connectors]

Except for the Root, all others in the above are optional. And when they are present, they have to be in the order specified above. Changing the order will cause incorrect results.

Root

The root is specified either by a note name or by its MIDI numeric value. Alphabets such as C, D, E .. indicate the names for the Western style and S, R, G .. indicate the names for the Carnatic style. The complete list is as shown below for the two systems:

Halfstep index Western Note Carnatic Swara
0 C S
1 C# R1
2 D R2
3 Eb G2
4 E G3
5 F M1
6 F# M2
7 G P
8 G# D1
9 A D2
10 Bb N2
11 B N3

In addition, CFugue allows # and b modifiers for the Western style of notes to access one halfstep up or down the given note. Thus, one can use D# to indicate the note Eb, Fb to indicate the note E and so on. Repeating a modifier more than once is also supported. For example, C## signifies D and Bbb signifies A. However, it is advised to refrain from mixing # and b in the same token. For example, do not try something like C#b to get back to C. Though CFugue understands such notation correctly, it is not always guaranteed to work.

Similarily, for Carnatic music, CFugue allows R3, G1, D3 and N1 Swaras, which essentially are the same as G2, R2, N2 and D2 from the above, respectively.

Note
Before we can pass any Carnatic music notes to CFugue for parsing, it need to be informed that we are indeed passing Carnatic style of notes and not Western style of notes. That is, we need to tell CFugue to use Carnatic note parser and not the default Western note parser for the notes we are about to supply. We do this by using the Key Signature directive as shown below:
    // Switch to Carnatic mode and play some notes
    player.Play("K[MELA] S R G M P D N"); 
The K[MELA] directive informs the parser to switch to Carnatic mode of parsing and to interpret the subsequent notes in that mode. For further discussion on this, please refer Interoperating Western and Carnatic Music.

Music notes can also be specified using their MIDI numeric value directly. Usually, when a note is specified using its name, such as C, D, E .. or S, R, G.., it is treated as a relative note. Its absolute position will be internally re-computed based on the Octave specifiers and the Scale/Raga settings. On the otherhand, when a note is specified with its MIDI numeric value directly, it is treated as an absolute note and will not be affected by the current Scale or Octave settings. An example of such numeric note is:

    // Play a Mid-C 
    player.Play("[60]");

Observe that we need to enclose the numeric value in square brackets []. Failing to do so might result in CFugue ignoring the token. Below is the complete listing of MIDI numeric values for all the notes.

OctaveC
S
C#/Db
R1
D
R2/G1
D#/Eb
R3/G2
E
G3
F
M1
F#/Gb
M2
G
P
G#/Ab
D1
A
D2/N1
A#/Bb
N2
B
N3
0 0 1 2 3 4 5 6 7 8 9 10 11
1 12 13 14 15 16 17 18 19 20 21 22 23
2 24 25 26 27 28 29 30 31 32 33 34 35
3 36 37 38 39 40 41 42 43 44 45 46 47
4 48 49 50 51 52 53 54 55 56 57 58 59
5 60 61 62 63 64 65 66 67 68 69 70 71
6 72 73 74 75 76 77 78 79 80 81 82 83
7 84 85 86 87 88 89 90 91 92 93 94 95
8 96 97 98 99 100 101 102 103 104 105 106 107
9 108 109 110 111 112 113 114 115 116 117 118 119
10 120 121 122 123 124 125 126 127

Be informed that when you specify a note using its MIDI numeric value, you cannot use the Octave field in the token anymore. Octave fields are only applicable for notes specified using their names.

Octave

For Western music, CFugue supports octaves in the range [0, 10]. You can specify an octave for a non-numeric note by appending the octave number to it, such as C2 to signify C note in 2nd octave or Bb8 to signify B-flat note in 8th octave. Observe that CFugue starts the octave numbering at 0 (instead of -1 used by some other representations). Middle-C in CFugue is C5, which is MIDI note value 60.

Octaves are optional. If you do not specify any octave value for a note, a default value of Octave 5 will be used for that note (unless it is a chord note, in which case a default value of 3 will be used).

For Carnatic music, there is no concept of absolute octaves. Instead it supports the concept of Sthayis, which is a relative value that changes from instrument to instrument and from person to person. Typically each singer will be having his/her own base Sthayi, which is usually referred to as medium sthayi, and varies above and below it, leading to upper sthayi notes and lower sthayi notes.

In CFugue's Carnatic music notation, a plain note indicates a medium sthayi note. One can append the character ' to get an upper sthayi note of it, and the character . to get a lower sthayi note of it. For example, S' is the upper sthayi note of the medium note S, with S. being its lower sthayi correspondent.

Multiple ' and . can be appended to a note to get more upper and lower sthayis, such as P''' or D.... However, do not mix ' and . in a single token. For example, usage such as S'. is not valid. S'. is not same as S in CFugue.

Below are few valid examples of notes with Octaves and Sthayis.

    player.Play(" C4 D4 E4 F4 G4 A4 B4    C D E F G A B    C6 C#6 E6 F#6 G6 Ab6 B6 "); 
    player.Play(" S. R. G. M. P. D. N.    S R G M P D N    S' R1' G' M2' P' D1' N' "); 

For compatibility between Western and Carnatic music, CFugue defines the default medium sthayi as Octave 5. Thus, both of the above two lines produce the same results. For further details on how to interoperate between Western and Carnatic style of music, refer Interoperating Western and Carnatic Music.

Chord

CFugue supports the below specified chords:

Chord NameHaflstep intervals
MajorMAJ {0,4,7}
MinorMIN {0,3,7}
AugmentedAUG {0,4,8}
DiminishedDIM {0,3,6}
7th dominantDOM7 {0,4,7,1}
Major 7thMAJ7 {0,4,7,11}
Minor 7thMIN7 {0,3,7,1}
Suspended 4thSUS4 {0,5,7}
Suspended 2ndSUS2 {0,2,7}
Major 6thMAJ6 {0,4,7,9}
Minor 6thMIN6 {0,3,7,9}
9th dominantDOM9 {0,4,7,10,14}
9th MajorMAJ9 {0,4,7,11,14}
9th MinorMIN9 {0,3,7,10,14}
Diminished 7thDIM7 {0,3,6,9}
Add 9ADD9 {0,4,7,14}
Minor 11thMIN11 {0,7,10,14,15,17}
11th dominantDOM11 {0,7,10,14,17}
13th dominantDOM13 {0,7,10,14,16,21}
Major 13thMAJ13 {0,7,11,14,16,21}
Minor 13thMIN13 {0,7,10,14,15,21}
7-5 dominantDOM7_5 {0,4,6,1}
7-5 dominantDOM7<5 {0,4,6,1}
7+5 dominantDOM75 {0,4,8,1}
7+5 dominantDOM7>5 {0,4,8,1}
Major 7-5MAJ7_5 {0,4,6,11}
Major 7-5MAJ7<5 {0,4,6,11}
Major 7+5MAJ75 {0,4,8,11}
Major 7+5MAJ7>5 {0,4,8,11}
Minor Major 7MINMAJ7 {0,3,7,11}
7-5-9 dominantDOM7_5_9 {0,4,6,10,13}
7-5-9 dominantDOM7<5<9 {0,4,6,10,13}
7-5+9 dominantDOM7_59 {0,4,6,10,15}
7-5+9 dominantDOM7<5>9 {0,4,6,10,15}
7+5-9 dominantDOM75_9 {0,4,8,10,13}
7+5-9 dominantDOM7>5<9 {0,4,8,10,13}
7+5+9 dominantDOM759 {0,4,8,10,15}
7+5+9 dominantDOM7>5>9 {0,4,8,10,15}

In the above haflstep intervals, zero indicates the root note. Other values are relative haflstep values from it, which will be adjusted based on the root note.

To specify a chord in CFugue, specify the root and append it with the chord name from the above table. For example, CMAJ signifies the C-major chord, which, based on the above halfstep intervals {0, 4, 7}, will automatically expand to C+E+G notes (C=0, E=4, G=7).

The default octave for the chord notes is 3. To specify an explicit octave value for a chord, append the chord root with the octave number. For example, a B-Flat, 7th Octave, major chord will be Bb7Maj.

Chord Inversions

A chord inversion indicates a different way of playing a chord. The degree of inversion indicates how many notes in the chord that need be shifted in the octave. A first degree inversion indicates that one note (the root note) should be moved up an octave, while the second degree inversion indicates that two notes (the root note and the second note) should be moved to one octave heigherr. When the note is moved up an octave heigher, the remaining notes in the chord become the new bass notes. Typically a chord with n number of notes can have atmost n degree inversions.

The character ^ indicates an inversion in CFugue. There are two ways to use it. The first is to specify ^ as many times as the degree of inversion after the chord name, and the second is to specify ^ after the chord name followed by the new bass note. For example, Cmaj^^ and Cmaj^G are two ways of indicating the same: a second degree inversion for C-Major chord (that makes the G as the new bass note).

Duration

Duration in Western music indicates how long a note should be played. CFugue supports below durations for the Western music notes.

CharacterDuration
WWhole Note
HHalf Note
QQuarter Note
I1/8th Note
S1/16th Note
T1/32th Note
X1/64th Note
O1/128th Note

These characters can be combined to form any aribtrary lengths of durations as required. For example, the token Bb6www indicates a B-Flat note in 6th octave for a duration of three whole notes, and the token F#MajH indicates an F-sharp Major chord for a duration of half-note.

CFugue also supports dotted durations. For example, a dotted quarter note would be a q followed by a dot (q.). Dotted durations indicate an addendum of extra half to the original duration. Thus a dotted quarter note = quarter note + 1/8th note;

Further, CFugue supports numeric durations also. Use the slash character followed by the decimal portion of whole note to indicate a numeric duration. For example, the token F#8/0.25 signifies an F-sharp note in eight octave for a duration of quarter note (0.25 is the quarter note portion of whole note). Similarily 0.5 signifies half-note and 1.0 signifies a while note. Values greater than 1.0 indicate a note that spans multiple measures. For example, the Bb6www token discussed above can be represeted numerically as Bb6/3.0.

Below are few valid examples of duration specification:

    player.Play("Gh"); // G note in default octave for a half-note duration 
    player.Play("[65]wq"); // Middle-F (F5) for a whote+quarter note duration 
    player.Play("C3i."); // C3 dotted-eighth (1/8 + 1/16) duration 

For Western music, if no duration is specified, a default duration of quarter note is assumed.

In Carnatic music, durations for the notes are determined automatically based on the Talam. A Talam specifies the duration for a group of notes instead of an individual note. CFugue supports below Talams.

Velocity

CFugue supports attack and decay velocities for notes. These values indicate how a note should be played in terms of its "take off" and "landing" volumes. For example, a note with long attack will sound like being built over a period of time, while a note with long decay sounds like a bell or a string that continues to resonate long after it has been struck.

In CFugue, attack and decay velocities can be specified using a pair of V followed by a numeric value in the range [0, 127] duo. The first V number pair stands for attack velocity, followed by the optional second V number pair that stand for decay velocity. Both are optional and are independent of each other. Low numeric values indicate quicker attack (or decay), while high values signify longer attack (or decay). And the default value, if unspecified, is 64. Below are few examples of valid usage:

    player.Play("C6V2V124"); // C6 note with sharp attack 2 and longer decay 124. The first V stands for attack, second V for decay. 
    player.Play("Bb3qhVV3"); // B-Flat 3rd octave quarter+half duration with default Attack and sharp decay 3. First V value left unspecified, so attack takes default value 
    player.Play("Bb3qhV1"); // B-Flat 3rd octave quarter+half duration with sharp Attack 1 and default decay. Second V left unspecified, so decay takes default value
    player.Play("Bb3qh"); // B-Flat 3rd octave quarter+half duration with default Attack and default decay - No V at all, so both attack and decay take default values

Connectors

Specifying Rests

Apart from the regular notes, CFugue also supports Rest notes. Rest notes are nothing but periods of silence. Their use is similar to that of sounded notes, except that Rest notes do not support anything other than a Duration. That is, Rest notes do not have Octaves or Velocities or Connectors. And the durations specifications for Rest notes are same as that of the usual notes. Refer to Duration for details on durations.

Use the symbol R to specify a Rest note in Western music. The usual duration specificiers can be appended as usual. Below are few examples:

    player.Play("R"); // Rest note for the detault duration
    player.Play("Rw"); // Rest note for a whole duration

Obviously, you would not be listening any sound being output when you run the above lines of code. Rest notes are designed to be used in conjunct with other regular notes. Usually it is rare that you would want to program MusicStrings made of only rest notes. Place them amidst of regular music notes to actually listen them, such as shown in the below example.

    player.Play("Cw Rh Dw"); // Can you "listen" the Rest note ?

For Carnatic music, the symbols , and ; signify the Rest notes. The durations are based on the currently selected Talam. The , specifies a Rest note for one duration, while the ; specifies a Rest note for two durations.

These , and ; can also be used in Western music notation, in which case they both act as the default Rest note with no explicit duration. For more details on mixing the Western and Carnatic music notations, please refer Interoperating Western and Carnatic Music.

Specifying Instruments

Instrument tokens in MusicStrings indicates which instrument should be used to play the subsequent notes in the strings. In CFugue, instrument tokens are identified with character I at their beginning. Below are few examples of valid instrument tokens:

    player.Play("I[PIANO]"); 
    player.Play("I10"); 
    player.Play("I[RAIN]"); 

Ofcourse, the above does not produce any music output since there are no notes specified in the input. Usually one supplies a series of note tokens after an instrument token for generting music using the specified instrument. Examples are as shown below:

    player.Play("I[Piano] C D E F G A B"); // Play an Octave using Piano instrument 
    player.Play("I0 C D E I40 F G A B"); // I0 is Piano and I40 is Violin
    player.Play("I[Flute] K[Kalyani] S R G M P D N"); // Play an Octave in Kalyani Ragam with Flute 

Complete list of intruments supported by CFugue is as shown below. In the MusicStrings these instruments can be specified either by their name or their MIDI instrument number indicated.

PIANO 0
ACOUSTIC_GRAND 0
BRIGHT_ACOUSTIC 1
ELECTRIC_GRAND 2
HONKEY_TONK 3
ELECTRIC_PIANO_1 4
ELECTRIC_PIANO_2 5
HARPISCHORD 6
CLAVINET 7
CELESTA 8
GLOCKENSPIEL 9
MUSIC_BOX 10
VIBRAPHONE 11
MARIMBA 12
XYLOPHONE 13
TUBULAR_BELLS 14
DULCIMER 15
DRAWBAR_ORGAN 16
PERCUSSIVE_ORGAN 17
ROCK_ORGAN 18
CHURCH_ORGAN 19
REED_ORGAN 20
ACCORDIAN 21
HARMONICA 22
TANGO_ACCORDIAN 23
GUITAR 24
NYLON_STRING_GUITAR 24
STEEL_STRING_GUITAR 25
ELECTRIC_JAZZ_GUITAR 26
ELECTRIC_CLEAN_GUITAR 27
ELECTRIC_MUTED_GUITAR 28
OVERDRIVEN_GUITAR 29
DISTORTION_GUITAR 30
GUITAR_HARMONICS 31
ACOUSTIC_BASS 32
ELECTRIC_BASS_FINGER 33
ELECTRIC_BASS_PICK 34
FRETLESS_BASS 35
SLAP_BASS_1 36
SLAP_BASS_2 37
SYNTH_BASS_1 38
SYNTH_BASS_2 39
VIOLIN 40
VIOLA 41
CELLO 42
CONTRABASS 43
TREMOLO_STRINGS 44
PIZZICATO_STRINGS 45
ORCHESTRAL_STRINGS 46
TIMPANI 47
STRING_ENSEMBLE_1 48
STRING_ENSEMBLE_2 49
SYNTH_STRINGS_1 50
SYNTH_STRINGS_2 51
CHOIR_AAHS 52
VOICE_OOHS 53
SYNTH_VOICE 54
ORCHESTRA_HIT 55
TRUMPET 56
TROMBONE 57
TUBA 58
MUTED_TRUMPET 59
FRENCH_HORN 60
BRASS_SECTION 61
SYNTHBRASS_1 62
SYNTHBRASS_2 63
SOPRANO_SAX 64
ALTO_SAX 65
TENOR_SAX 66
BARITONE_SAX 67
OBOE 68
ENGLISH_HORN 69
BASSOON 70
CLARINET 71
PICCOLO 72
FLUTE 73
RECORDER 74
PAN_FLUTE 75
BLOWN_BOTTLE 76
SKAKUHACHI 77
WHISTLE 78
OCARINA 79
LEAD_SQUARE or SQUARE 80
LEAD_SAWTOOTH or SAWTOOTH 81
LEAD_CALLIOPE or CALLIOPE 82
LEAD_CHIFF or CHIFF 83
LEAD_CHARANG or CHARANG 84
LEAD_VOICE or VOICE 85
LEAD_FIFTHS or FIFTHS 86
LEAD_BASSLEAD or BASSLEAD 87
PAD_NEW_AGE or NEW_AGE 88
PAD_WARM or WARM 89
PAD_POLYSYNTH or POLYSYNTH 90
PAD_CHOIR or CHOIR 91
PAD_BOWED or BOWED 92
PAD_METALLIC or METALLIC 93
PAD_HALO or HALO 94
PAD_SWEEP or SWEEP 95
FX_RAIN or RAIN 96
FX_SOUNDTRACK or SOUNDTRACK 97
FX_CRYSTAL or CRYSTAL 98
FX_ATMOSPHERE or ATMOSPHERE 99
FX_BRIGHTNESS or BRIGHTNESS 100
FX_GOBLINS or GOBLINS 101
FX_ECHOES or ECHOES 102
FX_SCI-FI or SCI-FI 103
SITAR 104
BANJO 105
SHAMISEN 106
KOTO 107
KALIMBA 108
BAGPIPE 109
FIDDLE 110
SHANAI 111
TINKLE_BELL 112
AGOGO 113
STEEL_DRUMS 114
WOODBLOCK 115
TAIKO_DRUM 116
MELODIC_TOM 117
SYNTH_DRUM 118
REVERSE_CYMBAL 119
GUITAR_FRET_NOISE 120
BREATH_NOISE 121
SEASHORE 122
BIRD_TWEET 123
TELEPHONE_RING 124
HELICOPTER 125
APPLAUSE 126
GUNSHOT 127

Specifying Key Signatures

KeySignature specification is one of the powerful features of CFugue MusicStrings that makes it easy to write music notes and keep them simple and clean. A KeySignature essentially indicates how CFugue should interpret the notes it encouters during the MusicString parsing.

In CFugue, KeySignature tokens are identified with character K at their beginning. Below are few examples of valid KeySignature tokens:

    player.Play("K[CMAJ]"); 
    player.Play("K[F#MAJ]"); 
    player.Play("K[KANAKANGI]"); 

Ofcourse, the above does not produce any music output since there are no notes specified in the input. Usually one supplies a series of note tokens after a KeySignature token for generting music as per the supplied Key. Examples are as shown below:

    player.Play("K[CMaj] C D E F G A B"); // Play an Octave in CMajor Scale 
    player.Play("K[FMaj] C D E F G A B"); // Play an Octave in FMajor Scale 
    player.Play("K[Kalyani] S R G M P D N"); // Play an Octave in Kalyani Ragam 
    player.Play("K[Kanakangi] S R G M P D N"); // Play an Octave in Kanakangi Ragam 

When a note is specified using its name, CFugue considers it as a relative half-step value within an octave. The KeySignature directive helps CFugue compute the absolute MIDI numeric value of the note based on the selected Scale/Ragam value. When one specifies tokens such as K[CMaj] or K[Kalyani] in the MusicStrings, CFugue starts interpreting the named notes C, D, E.. S, R, G.. according to their values in CMajor Scale or Kalyani Raga.

For example, in the above, when K[FMaj] is specified, the B note in the octave will be treated as Bb automatically. Similarily, for K[Kalyani], the M note will be treated as M2 automatically.

When no KeySignature is specified, CFugue assumes these default Values: K[CMaj] for Western and K[Shankarabharanam] for Carnatic.

When a KeySignature is specified, it will be applied for all subsequent notes. However, if you do not want the KeySignature to be applied to any specific note, you have to either use the MIDI numeric value directly or use the note modifier n to declare it as a natural note. (Note modifiers are not applicable for Carnatic music. You have to explicitly specify the complete name, such as R1, R2 etc. to make it a natural note.) Natural notes are not affected by KeySignature. By definition, all MIDI numeric notes are natural notes. Thus, the below all five produce the same result.

    player.Play("K[CMaj] C D E F G A B"); // Play an Octave in CMajor Scale 
    player.Play("K[FMaj] C D E F G A Bn"); // B is declared as natural. FMaj is ignored for B
    player.Play("K[Shankarabharanam] S R G M P D N"); // Play an Octave in Shankarabharanam Ragam 
    player.Play("K[Kalyani] S R G M1 P D N"); // M1 declared explicitly. Kalyani is ignored for M 
    player.Play("K[FMaj] C D E F G A [71]"); // [71] is numeric note. FMaj is ignored for it

KeySignatures are applicable for the whole song, independent of tracks. They can be redefined as many times as one wants throughout the song. CFugue will use the latest definition that precedes a note to process the note.

KeySignatures support both Carnatic and Western music modes. In Western mode, a total of 15 KeySignatures are present. These are accessible through their names, such as CMAJ, DMAJ, F#MIN etc. Complete list of the names is given in the KeySignatures table.

In Carnatic mode, all the basic 72 KeySignatures, known as Melakartha Janya Ragas, are supported. These are accessible through MELA_x macro, where x specifies a number in the range [1, 72]. In addition, for convenience, MELA_0 and MELA_DEFAULT are available, that map to Melakartha 29 (Shankarabharanam). Further, numerous ragas are accessible directly through their names, such as KALYANI, MOHANA etc. Thus one can either use the MELA_x macro or the raga name for the KeySignature. For example, K[Mela_65] and K[Kalyani] both give same results. Refer to the below listing for complete set of mappings between raga names and their associated Melakartha janyas. Note that when using an incomplete raga (one that does not use all the seven swaras), the missing notes in the raga will default to their corresponding values in the Melakartha janya of the raga.


KeySignatures supported by CFugue
Scale NameNote Values
CBMAJ{ Cb Db Eb Fb Gb Ab Bb }
ABMIN{ Cb Db Eb Fb Gb Ab Bb }
GBMAJ{ Cb Db Eb F Gb Ab Bb }
EBMIN{ Cb Db Eb F Gb Ab Bb }
DBMAJ{ C Db Eb F Gb Ab Bb }
BBMIN{ C Db Eb F Gb Ab Bb }
ABMAJ{ C Db Eb F G Ab Bb }
FMIN{ C Db Eb F G Ab Bb }
EBMAJ{ C D Eb F G Ab Bb }
CMIN{ C D Eb F G Ab Bb }
BBMAJ{ C D Eb F G A Bb }
GMIN{ C D Eb F G A Bb }
FMAJ{ C D E F G A Bb }
DMIN{ C D E F G A Bb }
CMAJ{ C D E F G A B }
AMIN{ C D E F G A B }
GMAJ{ C D E F# G A B }
EMIN{ C D E F# G A B }
DMAJ{ C# D E F# G A B }
BMIN{ C# D E F# G A B }
AMAJ{ C# D E F# G# A B }
F#MIN{ C# D E F# G# A B }
EMAJ{ C# D# E F# G# A B }
C#MIN{ C# D# E F# G# A B }
BMAJ{ C# D# E F# G# A# B }
G#MIN{ C# D# E F# G# A# B }
F#MAJ{ C# D# E# F# G# A# B }
D#MIN{ C# D# E# F# G# A# B }
C#MAJ{ C# D# E# F# G# A# B# }
A#MIN{ C# D# E# F# G# A# B# }
Raga NameMela_xSwara Values
KANAKANGIMELA_1 { S R1 G1 M1 P D1 N1 }
RATNANGIMELA_2 { S R1 G1 M1 P D1 N2 }
GANAMURTHIMELA_3 { S R1 G1 M1 P D1 N3 }
VANASPATHIMELA_4 { S R1 G1 M1 P D2 N2 }
MANAVATHIMELA_5 { S R1 G1 M1 P D2 N3 }
TANARUPIMELA_6 { S R1 G1 M1 P D3 N3 }
SENAVATHIMELA_7 { S R1 G2 M1 P D1 N1 }
HANUMATHODIMELA_8 { S R1 G2 M1 P D1 N2 }
DHENUKAMELA_9 { S R1 G2 M1 P D1 N3 }
NATAKAPRIYAMELA_10{ S R1 G2 M1 P D2 N2 }
KOKILAPRIYAMELA_11{ S R1 G2 M1 P D2 N3 }
RUPAVATHIMELA_12{ S R1 G2 M1 P D3 N3 }
GAYAKAPRIYAMELA_13{ S R1 G3 M1 P D1 N1 }
VAKULABHARANAMMELA_14{ S R1 G3 M1 P D1 N2 }
MAYAMALAVAGOWLAMELA_15{ S R1 G3 M1 P D1 N3 }
CHAKRAVAKAMMELA_16{ S R1 G3 M1 P D2 N2 }
SURYAKANTHAMMELA_17{ S R1 G3 M1 P D2 N3 }
HATAKAMBARIMELA_18{ S R1 G3 M1 P D3 N3 }
JHANKARADHWANIMELA_19{ S R2 G2 M1 P D1 N1 }
NATABHAIRAVIMELA_20{ S R2 G2 M1 P D1 N2 }
KEERAVANIMELA_21{ S R2 G2 M1 P D1 N3 }
KHARAHARAPRIYAMELA_22{ S R2 G2 M1 P D2 N2 }
GOWRIMANOHARIMELA_23{ S R2 G2 M1 P D2 N3 }
VARUNAPRIYAMELA_24{ S R2 G2 M1 P D3 N3 }
MARARANJANIMELA_25{ S R2 G3 M1 P D1 N1 }
CHARUKESHIMELA_26{ S R2 G3 M1 P D1 N2 }
SARASANGIMELA_27{ S R2 G3 M1 P D1 N3 }
HARIKHAMBHOJIMELA_28{ S R2 G3 M1 P D2 N2 }
DHEERASHANKARABHARANAMMELA_29{ S R2 G3 M1 P D2 N3 }
SHANKARABHARANAMMELA_29{ S R2 G3 M1 P D2 N3 }
NAGANANDINIMELA_30{ S R2 G3 M1 P D3 N3 }
YAGAPRIYAMELA_31{ S R3 G3 M1 P D1 N1 }
RAGAVARDHINIMELA_32{ S R3 G3 M1 P D1 N2 }
GANGEYABHUSHINIMELA_33{ S R3 G3 M1 P D1 N3 }
VAGADHISHWARIMELA_34{ S R3 G3 M1 P D2 N2 }
SHULINIMELA_35{ S R3 G3 M1 P D2 N3 }
CHALANATTAIMELA_36{ S R3 G3 M1 P D3 N3 }
SALAGAMMELA_37{ S R1 G1 M2 P D1 N1 }
JALARNAVAMMELA_38{ S R1 G1 M2 P D1 N2 }
JHALAVARALIMELA_39{ S R1 G1 M2 P D1 N3 }
NAVANEETHAMMELA_40{ S R1 G1 M2 P D2 N2 }
PAVANIMELA_41{ S R1 G1 M2 P D2 N3 }
RAGHUPRIYAMELA_42{ S R1 G1 M2 P D3 N3 }
GAVAMBODHIMELA_43{ S R1 G2 M2 P D1 N1 }
BHAVAPRIYAMELA_44{ S R1 G2 M2 P D1 N2 }
SHUBHAPANTUVARALIMELA_45{ S R1 G2 M2 P D1 N3 }
PANTUVARALIMELA_45{ S R1 G2 M2 P D1 N3 }
SHADVIDHAMARGINIMELA_46{ S R1 G2 M2 P D2 N2 }
SUVARNANGIMELA_47{ S R1 G2 M2 P D2 N3 }
DIVYAMANIMELA_48{ S R1 G2 M2 P D3 N3 }
DHAVALAMBARIMELA_49{ S R1 G3 M2 P D1 N1 }
NAMANARAYANIMELA_50{ S R1 G3 M2 P D1 N2 }
KAMAVARDHINIMELA_51{ S R1 G3 M2 P D1 N3 }
RAMAPRIYAMELA_52{ S R1 G3 M2 P D2 N2 }
GAMANASHRAMAMELA_53{ S R1 G3 M2 P D2 N3 }
VISHWAMBHARIMELA_54{ S R1 G3 M2 P D3 N3 }
SHYAMALANGIMELA_55{ S R2 G2 M2 P D1 N1 }
SHANMUKHAPRIYAMELA_56{ S R2 G2 M2 P D1 N2 }
SIMHENDRAMADHYAMAMMELA_57{ S R2 G2 M2 P D1 N3 }
HEMAVATHIMELA_58{ S R2 G2 M2 P D2 N2 }
DHARMAVATHIMELA_59{ S R2 G2 M2 P D2 N3 }
NEETHIMATHIMELA_60{ S R2 G2 M2 P D3 N3 }
KANTHAMANIMELA_61{ S R2 G3 M2 P D1 N1 }
RISHABHAPRIYAMELA_62{ S R2 G3 M2 P D1 N2 }
LATHANGIMELA_63{ S R2 G3 M2 P D1 N3 }
VACHASPATHIMELA_64{ S R2 G3 M2 P D2 N2 }
MECHAKALYANIMELA_65{ S R2 G3 M2 P D2 N3 }
KALYANIMELA_65{ S R2 G3 M2 P D2 N3 }
CHITRAMBARIMELA_66{ S R2 G3 M2 P D3 N3 }
SUCHARITRAMELA_67{ S R3 G3 M2 P D1 N1 }
JYOTHISWARUPINIMELA_68{ S R3 G3 M2 P D1 N2 }
DHATUVARDHINIMELA_69{ S R3 G3 M2 P D1 N3 }
NASIKABHUSHINIMELA_70{ S R3 G3 M2 P D2 N2 }
KOSALAMMELA_71{ S R3 G3 M2 P D2 N3 }
RASIKAPRIYAMELA_72{ S R3 G3 M2 P D3 N3 }
Somemore RagasJanya Mela
BILAHARIMELA_29
HAMSADHWANIMELA_29
HINDOLAMMELA_20
KAMBHOJIMELA_28
MADHYAMAVATHIMELA_22
MOHANAMMELA_28
NEELAMBARIMELA_29

For CFugue, Western is the default mode, and CMajor is the default KeySignature. All Parsers start in Western mode with CMajor scale set to their default. If you rather want the Parser to use a Carnatic mode, then you should explicitly supply a KeySignature token with an appropriate value before passing on any Carnatic music notes.

For further details on how to interoperate between Western and Carnatic style of music, refer Interoperating Western and Carnatic Music.

Specifying Channels / Tracks

Channels / Tracks are referred to as voices in CFugue. The tokens that start with character V are considered as voice tokens.

CFugue supports all the 16 channels of MIDI, which are accessible through V0 to 15. Whenever CFugue encounters a voice token in the MusicString, it changes the current track to the specified one in the token, inserting all the subsequent notes into this newly set track. When you want to switch back to your old track to insert notes into it, you simply supply another voice token with the corresponding track number.

By default, V0 is implied at the beginning.

Be noted that channels/tracks/voices play in parallel. For example, the MusicString CMAJ V1 CMIN plays CMAJ chord on channel 0 in parallel with CMIN chord on channel 1. Just because V1 CMIN comes after CMAJ in the Music String does not make it wait till CMAJ completes playing. Channels play independent of each other and certain MIDI players allow you to turn off selective tracks, so that you can listen only few tracks of your choice.

In CFugue, if you would like to sync the channels, you have to use the Rest notes. For example, to make CMIN chord on channel 1 play after the CMAJ chord completes playing on channel 0, you need to insert a Rest note with sufficient duration on channel 1, something like CMAJ V1 R CMIN. This makes the Rest note play in parallel with CMAJ, effectively making CMIN play after CMAJ is completed.

Interoperating Western and Carnatic Music

A powerful feature of CFugue's MusicString is its ability to work with both Western and Carnatic music with same ease. For the first time in the music world, it is now not only possible to specify Carnatic music Swaras side by side with Western Notes, it is also possible to transform between the two notations with same ease.

Note
In addition, the same principles can be adapted for Hindustani music also to make it work side by side with Western music.

By default CFugue starts parsing the notes in Western mode. However, when it encounters the K[] signature token with Carnatic music mela as key, it switches to Carnatic music parsing mode.


CFugue, the C++ Music Programming Library © Copyright 2009 Cenacle Research India Private Limited Gopalakrishna Palem