CFugue
Documentation.cpp
1 /*
2  This is part of CFugue, a C++ Runtime environment for MIDI Score Programming
3  Copyright (C) 2009 Gopalakrishna Palem
4 
5  For links to further information, or to contact the author,
6  see <http://cfugue.sourceforge.net/>.
7 */
8 
9 /////////////////////////////////////////////////////////////////
10 // Main Page
11 /////////////////////////////////////////////////////////////////
12 /*! \mainpage CFugue, The C++ Music Programming Library
13 
14 \section mainPageContents Contents
15  - \ref overview
16  - \ref features
17  - \ref pageExamples "Examples"
18  - \ref pageMusicString "CFugue MusicString"
19  - \ref download "Download CFugue"
20  - \ref copyright "Contact us"
21 
22 \section overview Overview
23 
24 CFugue, meaning Carnatic Fugue or the C/C++ replacement of JFugue, is a high level Music Programming Library.
25 
26 CFugue makes it possible to play music notes directly from C/C++ programs,
27 without ever having to deal with the low-level MIDI complexities. This library
28 provides a beautiful abstraction that lets you concetrate on programming the <i>Music</i> rather
29 than worry about the MIDI nuances.
30 
31 CFugue has numerous features that make it possible to use it directly from many
32 platforms, including but not limited to ASP pages, .Net applications and even non-Windows
33 based systems.
34 
35 \section usage Usage
36 
37 Using CFugue to play music is as easy as writing plain music notes. Just create
38 a Player object and call the Play method on it, supplying the Music notes to be played. Simple.
39 <pre class="fragment">
40  \#include "CFugueLib.h"
41  void main()
42  {
43  CFugue::Player player; <span class="comment">// Create the Player Object</span>
44  player.Play("C D E F G A B"); <span class="comment">// Play the Music Notes on the default MIDI output port</span>
45  }
46 </pre>
47 And the music notes are not restricted to be of just Western sytle either. CFugue fully
48 supports both Western and Carnatic Music notations - with a simple hint from the \ref subKeySignatures "KeySignature"
49 directive, one should be able to switch between them seemlessly.
50 
51 For more usage demonstrations, please refer to \ref pageExamples "CFugue examples".
52 
53 \section features Features
54 CFugue is a C++ runtime environment for music note programming with below features:
55  - Highlevel music programming library with direct support for C++ bindings and .Net P/Invoke calls
56  - Provides COM interfaces to enable easy integration with ASP clients and COM compatible clients, such as Delphi, VB etc.
57  - Easy to use notation. Writing music for CFugue is as easy as writing plain music notes.
58  - Event subscription model allows easy extension of the library to allow advanced features such as customized music renderers and parsers.
59  - Platform compatible code to make the library accessible from a veriety of platforms such as Windows and multiple variants of Linux: OpenSuse, Ubuntu etc.
60  - Fully compatible with both Western style of music and Carnatic music. Offers below capabilities:
61  - Specifying simples notes (such as C, D, E .. for Western and S, R, G .. for Carnatic)
62  - Specifying note durations
63  - Specifying ties, chords, sequential notes and parallel notes
64  - Specifying Raga, Tala and Speed directives
65  - Specifying MIDI Instruments and tracks
66  - and more...
67 
68 For further details on CFugue music note specifications, please refer to \ref pageMusicString "CFugue MusicString".
69 
70 \section download Download
71 
72 CFugue is ready to be used in your applications. It can be found at the downloads section of http://sourceforge.net/projects/cfugue/
73 
74 \section limitations Limitations
75 
76 CFugue is under active development, with much of the features, such as rendering to sheet music, etc.
77 pending. By the time the development completes, we hope to have this Limitations section to be empty.
78 
79 \section copyright Copyright
80 
81 This is a product of CineFx Research Labs, made available free of charge for personal and research use.
82 For commercial usage, please contact the author.
83 
84 CFugue is distributed with the hope that it will be useful.
85 No warranty of what-so-ever is implied, including MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
86 
87  Author: <a href="http://gopalakrishna.palem.in/">Gopalakrishna Palem</a>
88 
89  Project: http://cfugue.sourceforge.net
90 
91  Copyright (C) 2009 <a href="http://cenacle.co.in">Cenacle Research India Private Limited</a>
92 
93 */
94 
95 /////////////////////////////////////////////////////////////////
96 // Examples page
97 /////////////////////////////////////////////////////////////////
98 
99 /*! \page pageExamples CFugue usage examples
100 
101 \section secExampleContents Contents
102  - \ref secCExamples
103  - \ref ancCExamplePlay "Playing the Notes"
104  - \ref ancCExampleSaveMIDI "Saving to MIDI file"
105  - \ref ancCExamplePlayOptions "Configuring Play Options"
106  - \ref ancCExampleParserEvents "Accessing the Parser events"
107  - \ref secCplusCplusExamples
108  - \ref ancPlay "Playing the Notes"
109  - \ref ancSaveMIDI "Saving to MIDI file"
110  - \ref ancAsynchPlay "Playing Asynchronously"
111  - \ref ancParserEvents "Accessing the Parser events"
112  - \ref secPInvokeUsage
113  - \ref subsecPInvokePlay "Playing the Notes"
114  - \ref subsecPInvokeSave "Saving to MIDI file"
115  - \ref ancPInvokeExampleParserEvents "Accessing the Parser events"
116  - \ref index "Back to main page"
117 
118 \section secCExamples C Examples
119 \subsection ancCExamplePlay Playing the Notes
120 <pre class="fragment">
121  \#include "CFugueLib.h"
122  void main()
123  {
124  CFugue::PlayMusicString("C D E F G A B"); <span class="comment">// Play the Music Notes on the default MIDI output port</span>
125  }
126 </pre>
127 Playing them Carnatic style:
128 <pre class="fragment">
129  \#include "CFugueLib.h"
130  void main()
131  {
132  CFugue::PlayMusicString("K[MELA_DEFAULT] S R G M P D N"); <span class="comment">// Play the Music Notes on the default MIDI output port</span>
133  }
134 </pre>
135 
136 \subsection ancCExampleSaveMIDI Saving Music Notes to MIDI output file
137 <pre class="fragment">
138  \#include "CFugueLib.h"
139  void main()
140  {
141  CFugue::SaveAsMidiFile("Cq Dw Ex", "MidiOutput.midi"); <span class="comment">// Save the Music Notes to Midi file directly, without playing</span>
142  }
143 </pre>
144 
145 \subsection ancCExamplePlayOptions Configuring the Play Options
146 
147 The <tt>PlayMusicString()</tt> method plays the music notes on default MIDI output port with default MIDI timer resolution. However, if you would like to configure these options, use the <tt>PlayMusicStringWithOpts()</tt> method. It works similar to the <tt>PlayMusicString()</tt> method, but directs the output based on the input options.
148 
149 <pre class="fragment">
150  \#include "CFugueLib.h"
151  void main()
152  {
153  CFugue::PlayMusicStringWithOpts(_T("Cq Dw Ex"), <span class="comment">// CFugue MusicString to be played</span>
154  MIDI_MAPPER, <span class="comment">// MIDI Output port</span>
155  48); <span class="comment">// MIDI Timer Resolution in MilliSeconds</span>
156  }
157 </pre>
158 
159 \subsection ancCExampleParserEvents Accessing the Parser events
160 
161 A MusicString need be parsed before it can be played or rendered as sheet output. While performing
162 the parsing operation, parser generates Trace events and Error events to let the caller
163 know of the status. Callers can handle these events and output the Trace and Error information
164 to a log file or appropriate UI.
165 
166 Use the <tt>PlayMusicStringCB()</tt> method to add listeners to the parser trace and error events.
167 Once subscribed, the attached listeners will be invoked during the parse phase. A sample demonstrating the procedure is below.
168 <pre class="fragment">
169  \#include "CFugueLib.h"
170  void __stdcall OnParseTrace(void* pUserData, const TCHAR* szTraceMsg)
171  {
172  OutputDebugString(_T("\n"));
173  OutputDebugString(szTraceMsg);
174  }
175  void __stdcall OnParseError(void* pUserData, long lErrCode, const TCHAR* szErrorMsg, const TCHAR* szToken);
176  {
177  OutputDebugString(_T("\nError --> "));
178  OutputDebugString(szErrMsg);
179  if(szToken != NULL)
180  {
181  OutputDebugString(_T("\t Token: "));
182  OutputDebugString(szToken);
183  }
184  }
185  void main()
186  {
187  CFugue::PlayMusicStringCB(_T("Cq Dw Ex"), <span class="comment">// CFugue MusicString to be played</span>
188  OnParseTrace, <span class="comment">// Parse Trace Event Handler</span>
189  OnParseError, <span class="comment">// Prase Error Event Handler</span>
190  NULL);
191  }
192 </pre>
193 Use <tt>PlayMusicStringWithOptsCB()</tt> method to subscribe handlers and also configure the Play options. Modified snippet looks like below.
194 <pre class="fragment">
195  void main()
196  {
197  CFugue::PlayMusicStringWithOptsCB(_T("Cq Dw Ex"), <span class="comment">// CFugue MusicString to be played</span>
198  MIDI_MAPPER, <span class="comment">// MIDI Output port</span>
199  48, <span class="comment">// MIDI Timer Resolution in MilliSeconds</span>
200  OnParseTrace, <span class="comment">// Parse Trace Event Handler</span>
201  OnParseError, <span class="comment">// Prase Error Event Handler</span>
202  NULL);
203  }
204 </pre>
205 
206 \section secCplusCplusExamples C++ Examples
207 \subsection ancPlay Playing the Notes
208 <pre class="fragment">
209  \#include "CFugueLib.h"
210  void main()
211  {
212  <span class="comment">// Create the Player Object</span>
213  CFugue::Player player;
214  <span class="comment">// Play the Music Notes on the default MIDI output port</span>
215  player.Play("C D E F G A B");
216  }
217 </pre>
218 Playing them Carnatic style:
219 <pre class="fragment">
220  \#include "CFugueLib.h"
221  void main()
222  {
223  <span class="comment">// Create the Player Object</span>
224  CFugue::Player player;
225  <span class="comment">// Play the Music Notes on the default MIDI output port</span>
226  player.Play("K[MELA_DEFAULT] S R G M P D N");
227  }
228 </pre>
229 
230 \subsection ancSaveMIDI Saving Music Notes to MIDI output file
231 <pre class="fragment">
232  \#include "CFugueLib.h"
233  void main()
234  {
235  <span class="comment">// Create the Player Object </span>
236  CFugue::Player player;
237  <span class="comment">// Save the Music Notes to Midi file directly, without playing</span>
238  player.SaveAsMidiFile("Cq Dw Ex", "MidiOutput.midi");
239  }
240 </pre>
241 Sometimes you might want to play the Notes first on the MIDI output and then save the played
242 content to an output file. You can achieve this using the Player::SaveToMidiFile() method.
243 You need to call this method <i>after</i> the call to Player::Play() or Player::PlayAsync().
244 <pre class="fragment">
245  \#include "CFugueLib.h"
246  void main()
247  {
248  <span class="comment">// Create the Player Object </span>
249  CFugue::Player player;
250  <span class="comment">// Play few Music Notes on MIDI output port</span>
251  player.Play("ci di K[MELA_22] Pa M G R");
252  <span class="comment">// Now, save that played content to a MIDI output file</span>
253  player.SaveToMidiFile("Output.mid");
254  }
255 </pre>
256 
257 \subsection ancAsynchPlay Asynchronous Play
258 
259 The Player::Play() method plays the music notes synchronously, i.e. the method
260 will not return till all the music notes are played completely. However, if you would like to play
261 the MusicString content asynchronously, you can use the Player::PlayAsync() method
262 instead. It works similar to the Play() method, except that it returns immediately.
263 
264 <pre class="fragment">
265  \#include "CFugueLib.h"
266  void main()
267  {
268  <span class="comment">// Create the Player object</span>
269  CFugue::Player player;
270  <span class="comment">// Start Playing Asynchronously </span>
271  if(player.PlayAsync("Cx Dh Ah."))
272  while(player.IsPlaying()) <span class="comment">// Wait while the play is in progress</span>
273  Sleep(1000);
274  <span class="comment">// Match every PlayAsync with a StopPlay</span>
275  player.StopPlay();
276  }
277 </pre>
278 At any time after the call to PlayAsync, the Player::IsPlaying() method can be used
279 to know if the play is still in progress. Player::StopPlay() allows you
280 to stop the play if it is still in progress. Calling StopPlay() after every PlayAsync()
281 call is a good practice (no matter if play is in progress or not). A typical usage of these methods
282 is demonstrated in the above code snippet.
283 
284 \subsection ancParserEvents Accessing the Parser events
285 
286 A MusicString need be parsed before it can be played or rendered as sheet output. While performing
287 the parsing operation, parser generates Trace events and Error events to let the caller
288 know of the status. Callers can handle these events and output the Trace and Error information
289 to a log file or appropriate UI.
290 
291 Use the Player::Parser() method to access the parser object associated with the player
292 and subscribe to its evTrace and evError events.
293 Once subscribed, the attached handlers will be invoked during the parse phase whenever any of the
294 Play or Save methods is invoked on the player. A sample demonstrating the procedure is below.
295 <pre class="fragment">
296  \#include "CFugueLib.h"
297  void OnParseTrace(const CFugue::CParser*,
298  CFugue::CParser::TraceEventHandlerArgs* pEvArgs)
299  {
300  OutputDebugString(_T("\n"));
301  OutputDebugString(pEvArgs->szTraceMsg);
302  }
303  void OnParseError(const CFugue::CParser*,
304  CFugue::CParser::ErrorEventHandlerArgs* pEvArgs)
305  {
306  OutputDebugString(_T("\nError --> "));
307  OutputDebugString(pEvArgs->szErrMsg);
308  if(pEvArgs->szToken)
309  {
310  OutputDebugString(_T("\t Token: "));
311  OutputDebugString(pEvArgs->szToken);
312  }
313  }
314  void main()
315  {
316  <span class="comment">// Create the Player Object</span>
317  CFugue::Player player;
318  <span class="comment">// Access the Player's Parser and Subscribe to its Trace and Error Events</span>
319  player.Parser().evTrace.Subscribe(&OnParseTrace);
320  player.Parser().evError.Subscribe(&OnParseError);
321  <span class="comment">// Parse the Notes and Save the content to a MIDI file</span>
322  player.SaveAsMidiFile(_T("Cq Dw Ex"), "MidiOutput.midi");
323  }
324 </pre>
325 
326 \section secPInvokeUsage P/Invoke usage
327 \subsection subsecPInvokePlay Playing the Notes
328 <pre class="fragment">
329 public static class CFugueLib
330 {
331  [DllImport("CFugueDll.Dll")]
332  public static extern bool PlayMusicString([MarshalAs(UnmanagedType.LPStr)] String szMusicNotes);
333 }
334 public static void Main()
335 {
336  CFugue::PlayMusicString("Cq Dw Ex");<span class="comment">// Play the Music Notes on default MIDI Output Port</span>
337 }
338 </pre>
339 \subsection subsecPInvokeSave Saving Music Notes to MIDI output file
340 <pre class="fragment">
341 public static class CFugueLib
342 {
343  [DllImport("CFugueDll.Dll")]
344  public static extern bool SaveAsMidiFile([MarshalAs(UnmanagedType.LPStr)] String szMusicNotes, [MarshalAs(UnmanagedType.LPStr)] String szOutputFilePath);
345 }
346 public static void Main()
347 {
348  CFugue::SaveAsMidiFile("Cq Dw Ex", "MidiOutput.mid");<span class="comment">// Save the Music Notes to a MIDI file</span>
349 }
350 </pre>
351 \subsection ancPInvokeExampleParserEvents Accessing the Parser events
352 
353 A MusicString need be parsed before it can be played or rendered as sheet output. While performing
354 the parsing operation, parser generates Trace events and Error events to let the caller
355 know of the status. Callers can handle these events and output the Trace and Error information
356 to a log file or appropriate UI.
357 
358 Use the <tt>PlayMusicStringCB()</tt> method to add listeners to the parser trace and error events.
359 Once subscribed, the attached listeners will be invoked during the parse phase. A sample demonstrating the procedure is below.
360 <pre class="fragment">
361  public static class CFugueLib
362  {
363  public delegate void ParserTraceDelegate(IntPtr userData, [MarshalAs(UnmanagedType.LPStr)] String szTraceMsg);
364  public delegate void ParserErrorDelegate(IntPtr userData, int errCode,
365  [MarshalAs(UnmanagedType.LPStr)] String szErrorMsg,
366  [MarshalAs(UnmanagedType.LPStr)] String szToken);
367  [DllImport("CFugueDll.Dll", CallingConvention = CallingConvention.Cdecl)]
368  public static extern void PlayMusicStringCB([MarshalAs(UnmanagedType.LPStr)] String szMusicNotes,
369  [MarshalAs(UnmanagedType.FunctionPtr)] ParserTraceDelegate td,
370  [MarshalAs(UnmanagedType.FunctionPtr)] ParserErrorDelegate ed,
371  IntPtr userData);
372  }
373  public void OnParseTrace(IntPtr userData, [MarshalAs(UnmanagedType.LPStr)] String szTraceMsg)
374  {
375  <span class="comment">// Do something with szTraceMsg ... </span>
376  }
377  public void OnParseError(IntPtr userData, int errCode, [MarshalAs(UnmanagedType.LPStr)] String szErrorMsg, [MarshalAs(UnmanagedType.LPStr)] String szToken)
378  {
379  <span class="comment">// Do something with szErrorMsg and szToken ... </span>
380  }
381 void main()
382 {
383  CFugueLib.PlayMusicStringWithOptsCB("C D E", <span class="comment">// CFugue MusicString to be played</span>
384  new CFugueLib.ParserTraceDelegate(OnParseTrace), <span class="comment">// Parse Trace Event Handler</span>
385  new CFugueLib.ParserErrorDelegate(OnParseError), <span class="comment">// Prase Error Event Handler</span>
386  IntPtr.Zero);
387  }
388 </pre>
389 Use <tt>PlayMusicStringWithOptsCB()</tt> method to subscribe handlers and also configure the Play options. Modified snippet looks like below.
390 <pre class="fragment">
391 void main()
392 {
393  CFugueLib.PlayMusicStringWithOptsCB("C D E", <span class="comment">// CFugue MusicString to be played</span>
394  MIDI_MAPPER, <span class="comment">// MIDI Output port</span>
395  48, <span class="comment">// MIDI Timer Resolution in MilliSeconds</span>
396  new CFugueLib.ParserTraceDelegate(OnParseTrace), <span class="comment">// Parse Trace Event Handler</span>
397  new CFugueLib.ParserErrorDelegate(OnParseError), <span class="comment">// Prase Error Event Handler</span>
398  IntPtr.Zero);
399  }
400 </pre>
401 
402 */
403 
404 
405 /////////////////////////////////////////////////////////////////
406 // CFugue MusicString page
407 /////////////////////////////////////////////////////////////////
408 /*! \page pageMusicString CFugue MusicString
409 
410 \section contents Contents
411  - \ref introduction
412  - \ref secMusicString
413  - \ref subsecNotes
414  - \ref subsubRoot
415  - \ref subsubOctave
416  - \ref subsubChord
417  - \ref subsubDuration
418  - \ref subsubVelocity
419  - \ref subsubConnectors
420  - \ref subRestNotes
421  - \ref subInstruments
422  - \ref subKeySignatures
423  - \ref subVoices
424  - \ref secInteroperation
425  - \ref index "Back to main page"
426 
427 \section introduction Introduction
428 One of the capabilities of CFugue that makes it so elegant and easy to use is the concept of Music Note Strings
429 (or simply <i>MusicString</i>s, as referred to by JFugue). MusicStrings provide the ability to specify
430 Music Notes and MIDI instructions as a sequence of characters (and tokens) in human readable form,
431 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 <i>Play()</i> method to play a Mid-C note and a C-Major chord. (Please refer \ref pageExamples "CFugue API examples" for more such examples.)
432 <pre class="fragment">
433  \#include "CFugueLib.h"
434  void main()
435  {
436  CFugue::Player player; <span class="comment">// Create the Player Object</span>
437  player.Play("C CMaj"); <span class="comment">// Play a Mid-C followed by C-Major Chord </span>
438  }
439 </pre>
440 Few more examples of MusicStrings:
441 <pre class="fragment">
442  CFugue::Player player; <span class="comment">// Create the Player Object</span>
443  player.Play("I[FLUTE] FMaj"); <span class="comment">// Play the F-Major chord with Flute </span>
444  player.Play("C D E F G A B"); <span class="comment">// Play all the mid octave notes </span>
445  player.Play("K[MELA] S R G M P D N"); <span class="comment">// Play all the mid octave (madhya sthayi) notes in Carnatic Music </span>
446  player.Play("C+D+E+F+G+A+B"); <span class="comment">// Play all the mid octave notes in parallel</span>
447  player.Play("CI CI CI GI FI GI D#I. FI. G#I GI. RI"); <span class="comment">// Notes with durations</span>
448  player.Play("K[HAMSADHWANI]T8S2 ( S' GA' R' S' R' S' N PA N S' RI' RI' )"); <span class="comment">// A piece of Vatapi Ganapathim in double speed </span>
449 </pre>
450 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.
451 
452 \section secMusicString Components of MusicString
453 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.
454 
455 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.
456 
457 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).
458 
459 Below are the first characters and their associated token classifications for CFugue MusicStrings:
460 \htmlonly
461 <table align="center">
462  <tr><td class="indexkey">Character</td> <td class="indexkey">API Constant</td> <td class="indexkey">Significance</td> </tr>
463  <tr><td class="indexkey">V </td> <td class="indexvalue">TOKEN_START_VOICE </td> <td class="indexvalue">Specifies a Voice token.</td></tr>
464  <tr><td class="indexkey">T </td> <td class="indexvalue">TOKEN_START_TEMPO </td> <td class="indexvalue">Specifies a Tempo token.</td></tr>
465  <tr><td class="indexkey">I </td> <td class="indexvalue">TOKEN_START_INSTRUMENT </td> <td class="indexvalue">Specifies a Instrument token.</td></tr>
466  <tr><td class="indexkey">L </td> <td class="indexvalue">TOKEN_START_LAYER </td> <td class="indexvalue">Specifies a Layer token.</td></tr>
467  <tr><td class="indexkey">K </td> <td class="indexvalue">TOKEN_START_KEYSIGNATURE </td> <td class="indexvalue">Specifies a KeySignature token.</td></tr>
468  <tr><td class="indexkey">X </td> <td class="indexvalue">TOKEN_START_CONTROLLER </td> <td class="indexvalue">Specifies a Controller token.</td></tr>
469  <tr><td class="indexkey">@ </td> <td class="indexvalue">TOKEN_START_TIME </td> <td class="indexvalue">Specifies a Time token.</td></tr>
470  <tr><td class="indexkey">* </td> <td class="indexvalue">TOKEN_START_KEYPRESSURE </td> <td class="indexvalue">Specifies a Keypressure token.</td></tr>
471  <tr><td class="indexkey">+ </td> <td class="indexvalue">TOKEN_START_CHANNELPRESSURE </td> <td class="indexvalue">Specifies a Channel pressure token.</td></tr>
472  <tr><td class="indexkey">& </td> <td class="indexvalue">TOKEN_START_PITCHBEND </td> <td class="indexvalue">Specifies a Pitchbend token. </td></tr>
473  <tr><td class="indexkey">| </td> <td class="indexvalue">TOKEN_START_MEASURE </td> <td class="indexvalue">Specifies a Measure token.</td></tr>
474  <tr><td class="indexkey">$ </td> <td class="indexvalue">TOKEN_START_DICTIONARY </td> <td class="indexvalue">Specifies a Dictionary token.</td></tr><!-- <tr><td>[ </td> <td>TOKEN_START_NOTE </td> <td>Specifies a numeric Note token.</td></tr> -->
475 </table>
476 \endhtmlonly
477 
478 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.
479 
480 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:
481 <pre class="fragment">
482  player.Play("C");
483  player.Play("FMaj");
484  player.Play("Cq+Eh+Gq");
485  player.Play("C6q+E4h+G8q D5Maj7w");
486  player.Play("T[120] V0 I[Flute] Cs B4s A4i B4i C");
487  player.Play("I[XyloPhone] K[Mela_29] S R G M P D N S'");
488 </pre>
489 
490 \subsection subsecNotes Specifying Notes
491 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:
492 \htmlonly
493 <table align="center">
494 <tr> <td class="indexvalue">Root[Octave][Chord][Duration][Velocity][Connectors]</td> </tr>
495 </table>
496 \endhtmlonly
497 
498 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.
499 
500 \subsubsection subsubRoot Root
501 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:
502 \htmlonly
503 <table align="center">
504  <tr> <td class="indexkey">Halfstep index</td> <td class="indexkey">Western Note</td> <td class="indexkey">Carnatic Swara</td> </tr>
505  <tr> <td class="indexvalue">0</td> <td class="indexvalue">C</td> <td class="indexvalue">S</td> </tr>
506  <tr> <td class="indexvalue">1</td> <td class="indexvalue">C#</td> <td class="indexvalue">R1</td> </tr>
507  <tr> <td class="indexvalue">2</td> <td class="indexvalue">D</td> <td class="indexvalue">R2</td> </tr>
508  <tr> <td class="indexvalue">3</td> <td class="indexvalue">E<i>b</i></td> <td class="indexvalue">G2</td> </tr>
509  <tr> <td class="indexvalue">4</td> <td class="indexvalue">E</td> <td class="indexvalue">G3</td> </tr>
510  <tr> <td class="indexvalue">5</td> <td class="indexvalue">F</td> <td class="indexvalue">M1</td> </tr>
511  <tr> <td class="indexvalue">6</td> <td class="indexvalue">F#</td> <td class="indexvalue">M2</td> </tr>
512  <tr> <td class="indexvalue">7</td> <td class="indexvalue">G</td> <td class="indexvalue">P</td> </tr>
513  <tr> <td class="indexvalue">8</td> <td class="indexvalue">G#</td> <td class="indexvalue">D1</td> </tr>
514  <tr> <td class="indexvalue">9</td> <td class="indexvalue">A</td> <td class="indexvalue">D2</td> </tr>
515  <tr> <td class="indexvalue">10</td> <td class="indexvalue">B<i>b</i></td> <td class="indexvalue">N2</td> </tr>
516  <tr> <td class="indexvalue">11</td> <td class="indexvalue">B</td> <td class="indexvalue">N3</td> </tr>
517 </table>
518 \endhtmlonly
519 
520 In addition, CFugue allows <i>#</i> and <i>b</i> modifiers for the Western style of notes to access one halfstep up or down the given note. Thus, one can use <i>D#</i> to indicate the note <i>Eb</i>, <i>Fb</i> to indicate the note <i>E</i> and so on. Repeating a modifier more than once is also supported. For example, <i>C##</i> signifies <i>D</i> and <i>Bbb</i> signifies <i>A</i>. However, it is advised to refrain from mixing <i>#</i> and <i>b</i> in the same token. For example, do not try something like <i>C\#b</i> to get back to <i>C</i>. Though CFugue understands such notation correctly, it is not always guaranteed to work.
521 
522 Similarily, for Carnatic music, CFugue allows <i>R3</i>, <i>G1</i>, <i>D3</i> and <i>N1</i> Swaras, which essentially are the same as <i>G2</i>, <i>R2</i>, <i>N2</i> and <i>D2</i> from the above, respectively.
523 
524 \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 \ref subKeySignatures "Key Signature" directive as shown below:
525 <pre class="fragment">
526  <span class="comment">// Switch to Carnatic mode and play some notes</span>
527  player.Play("K[MELA] S R G M P D N");
528 </pre> 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 \ref secInteroperation.
529 
530 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:
531 <pre class="fragment">
532  <span class="comment">// Play a Mid-C </span>
533  player.Play("[60]");
534 </pre>
535 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.
536 
537 \htmlonly
538 <table align="center">
539 <tr><td align="center" class="indexkey">Octave</td><td align="center" class="indexkey">C<br>S</td> <td align="center" class="indexkey">C#/D<i>b</i><br>R1</td> <td align="center" class="indexkey">D<br>R2/G1</td> <td align="center" class="indexkey">D#/E<i>b</i><br>R3/G2</td><td align="center" class="indexkey">E<br>G3</td><td align="center" class="indexkey">F<br>M1</td><td align="center" class="indexkey">F#/G<i>b</i><br>M2</td><td align="center" class="indexkey">G<br>P</td><td align="center" class="indexkey">G#/A<i>b</i><br>D1</td><td align="center" class="indexkey">A<br>D2/N1</td><td align="center" class="indexkey">A#/B<i>b</i><br>N2</td><td align="center" class="indexkey">B<br>N3</td> </tr>
540 <tr> <td align="center" class="indexkey">0</td>
541  <td align="center" class="indexvalue">0</td>
542  <td align="center" class="indexvalue">1</td>
543  <td align="center" class="indexvalue">2</td>
544  <td align="center" class="indexvalue">3</td>
545  <td align="center" class="indexvalue">4</td>
546  <td align="center" class="indexvalue">5</td>
547  <td align="center" class="indexvalue">6</td>
548  <td align="center" class="indexvalue">7</td>
549  <td align="center" class="indexvalue">8</td>
550  <td align="center" class="indexvalue">9</td>
551  <td align="center" class="indexvalue">10</td>
552  <td align="center" class="indexvalue">11</td>
553 </tr>
554 <tr> <td align="center" class="indexkey">1</td>
555  <td align="center" class="indexvalue">12</td>
556  <td align="center" class="indexvalue">13</td>
557  <td align="center" class="indexvalue">14</td>
558  <td align="center" class="indexvalue">15</td>
559  <td align="center" class="indexvalue">16</td>
560  <td align="center" class="indexvalue">17</td>
561  <td align="center" class="indexvalue">18</td>
562  <td align="center" class="indexvalue">19</td>
563  <td align="center" class="indexvalue">20</td>
564  <td align="center" class="indexvalue">21</td>
565  <td align="center" class="indexvalue">22</td>
566  <td align="center" class="indexvalue">23</td>
567 </tr>
568 <tr> <td align="center" class="indexkey">2</td>
569  <td align="center" class="indexvalue">24</td>
570  <td align="center" class="indexvalue">25</td>
571  <td align="center" class="indexvalue">26</td>
572  <td align="center" class="indexvalue">27</td>
573  <td align="center" class="indexvalue">28</td>
574  <td align="center" class="indexvalue">29</td>
575  <td align="center" class="indexvalue">30</td>
576  <td align="center" class="indexvalue">31</td>
577  <td align="center" class="indexvalue">32</td>
578  <td align="center" class="indexvalue">33</td>
579  <td align="center" class="indexvalue">34</td>
580  <td align="center" class="indexvalue">35</td>
581 </tr>
582 <tr> <td align="center" class="indexkey">3</td>
583  <td align="center" class="indexvalue">36</td>
584  <td align="center" class="indexvalue">37</td>
585  <td align="center" class="indexvalue">38</td>
586  <td align="center" class="indexvalue">39</td>
587  <td align="center" class="indexvalue">40</td>
588  <td align="center" class="indexvalue">41</td>
589  <td align="center" class="indexvalue">42</td>
590  <td align="center" class="indexvalue">43</td>
591  <td align="center" class="indexvalue">44</td>
592  <td align="center" class="indexvalue">45</td>
593  <td align="center" class="indexvalue">46</td>
594  <td align="center" class="indexvalue">47</td>
595 </tr>
596 <tr> <td align="center" class="indexkey">4</td>
597  <td align="center" class="indexvalue">48</td>
598  <td align="center" class="indexvalue">49</td>
599  <td align="center" class="indexvalue">50</td>
600  <td align="center" class="indexvalue">51</td>
601  <td align="center" class="indexvalue">52</td>
602  <td align="center" class="indexvalue">53</td>
603  <td align="center" class="indexvalue">54</td>
604  <td align="center" class="indexvalue">55</td>
605  <td align="center" class="indexvalue">56</td>
606  <td align="center" class="indexvalue">57</td>
607  <td align="center" class="indexvalue">58</td>
608  <td align="center" class="indexvalue">59</td>
609 </tr>
610 <tr> <td align="center" class="indexkey">5</td>
611  <td align="center" class="indexvalue">60</td>
612  <td align="center" class="indexvalue">61</td>
613  <td align="center" class="indexvalue">62</td>
614  <td align="center" class="indexvalue">63</td>
615  <td align="center" class="indexvalue">64</td>
616  <td align="center" class="indexvalue">65</td>
617  <td align="center" class="indexvalue">66</td>
618  <td align="center" class="indexvalue">67</td>
619  <td align="center" class="indexvalue">68</td>
620  <td align="center" class="indexvalue">69</td>
621  <td align="center" class="indexvalue">70</td>
622  <td align="center" class="indexvalue">71</td>
623 </tr>
624 <tr> <td align="center" class="indexkey">6</td>
625  <td align="center" class="indexvalue">72</td>
626  <td align="center" class="indexvalue">73</td>
627  <td align="center" class="indexvalue">74</td>
628  <td align="center" class="indexvalue">75</td>
629  <td align="center" class="indexvalue">76</td>
630  <td align="center" class="indexvalue">77</td>
631  <td align="center" class="indexvalue">78</td>
632  <td align="center" class="indexvalue">79</td>
633  <td align="center" class="indexvalue">80</td>
634  <td align="center" class="indexvalue">81</td>
635  <td align="center" class="indexvalue">82</td>
636  <td align="center" class="indexvalue">83</td>
637 </tr>
638 <tr> <td align="center" class="indexkey">7</td>
639  <td align="center" class="indexvalue">84</td>
640  <td align="center" class="indexvalue">85</td>
641  <td align="center" class="indexvalue">86</td>
642  <td align="center" class="indexvalue">87</td>
643  <td align="center" class="indexvalue">88</td>
644  <td align="center" class="indexvalue">89</td>
645  <td align="center" class="indexvalue">90</td>
646  <td align="center" class="indexvalue">91</td>
647  <td align="center" class="indexvalue">92</td>
648  <td align="center" class="indexvalue">93</td>
649  <td align="center" class="indexvalue">94</td>
650  <td align="center" class="indexvalue">95</td>
651 </tr>
652 <tr> <td align="center" class="indexkey">8</td>
653  <td align="center" class="indexvalue">96</td>
654  <td align="center" class="indexvalue">97</td>
655  <td align="center" class="indexvalue">98</td>
656  <td align="center" class="indexvalue">99</td>
657  <td align="center" class="indexvalue">100</td>
658  <td align="center" class="indexvalue">101</td>
659  <td align="center" class="indexvalue">102</td>
660  <td align="center" class="indexvalue">103</td>
661  <td align="center" class="indexvalue">104</td>
662  <td align="center" class="indexvalue">105</td>
663  <td align="center" class="indexvalue">106</td>
664  <td align="center" class="indexvalue">107</td>
665 </tr>
666 <tr> <td align="center" class="indexkey">9</td>
667  <td align="center" class="indexvalue">108</td>
668  <td align="center" class="indexvalue">109</td>
669  <td align="center" class="indexvalue">110</td>
670  <td align="center" class="indexvalue">111</td>
671  <td align="center" class="indexvalue">112</td>
672  <td align="center" class="indexvalue">113</td>
673  <td align="center" class="indexvalue">114</td>
674  <td align="center" class="indexvalue">115</td>
675  <td align="center" class="indexvalue">116</td>
676  <td align="center" class="indexvalue">117</td>
677  <td align="center" class="indexvalue">118</td>
678  <td align="center" class="indexvalue">119</td>
679 </tr>
680 <tr> <td align="center" class="indexkey">10</td>
681  <td align="center" class="indexvalue">120</td>
682  <td align="center" class="indexvalue">121</td>
683  <td align="center" class="indexvalue">122</td>
684  <td align="center" class="indexvalue">123</td>
685  <td align="center" class="indexvalue">124</td>
686  <td align="center" class="indexvalue">125</td>
687  <td align="center" class="indexvalue">126</td>
688  <td align="center" class="indexvalue">127</td>
689 </tr>
690 </table>\endhtmlonly
691 
692 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.
693 
694 \subsubsection subsubOctave Octave
695 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 <i>C2</i> to signify C note in 2nd octave or <i>Bb8</i> 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.
696 
697 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).
698 
699 For Carnatic music, there is no concept of absolute octaves. Instead it supports the concept of <i>Sthayis</i>, 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 <i>Sthayi</i>, which is usually referred to as medium sthayi, and varies above and below it, leading to upper sthayi notes and lower sthayi notes.
700 
701 In CFugue's Carnatic music notation, a plain note indicates a medium sthayi note. One can append the character <i>'</i> to get an upper sthayi note of it, and the character <i>.</i> to get a lower sthayi note of it. For example, <i>S'</i> is the upper sthayi note of the medium note <i>S</i>, with <i>S.</i> being its lower sthayi correspondent.
702 
703 Multiple <i>'</i> and <i>.</i> can be appended to a note to get more upper and lower sthayis, such as <i>P'''</i> or <i>D...</i>. However, do not mix <i>'</i> and <i>.</i> in a single token. For example, usage such as <i>S'.</i> is not valid. <i>S'.</i> is not same as <i>S</i> in CFugue.
704 
705 Below are few valid examples of notes with Octaves and Sthayis.
706 <pre class="fragment">
707  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 ");
708  player.Play(" S. R. G. M. P. D. N. S R G M P D N S' R1' G' M2' P' D1' N' ");
709 </pre>
710 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 \ref secInteroperation.
711 
712 \subsubsection subsubChord Chord
713 CFugue supports the below specified chords:
714 \htmlonly
715 <table align="center">
716  <tr><td align></td><td class="indexkey">Chord Name</td><td class="indexkey">Haflstep intervals</td></tr>
717 
718  <tr><td align="right">Major</td><td class="indexvalue">MAJ</td><td class="indexvalue"> {0,4,7}</td></tr>
719  <tr><td align="right">Minor</td><td class="indexvalue">MIN</td><td class="indexvalue"> {0,3,7}</td></tr>
720  <tr><td align="right">Augmented</td><td class="indexvalue">AUG</td><td class="indexvalue"> {0,4,8}</td></tr>
721  <tr><td align="right">Diminished</td><td class="indexvalue">DIM</td><td class="indexvalue"> {0,3,6}</td></tr>
722  <tr><td align="right">7th dominant</td><td class="indexvalue">DOM7</td><td class="indexvalue"> {0,4,7,1}</td></tr>
723  <tr><td align="right">Major 7th</td><td class="indexvalue">MAJ7</td><td class="indexvalue"> {0,4,7,11}</td></tr>
724  <tr><td align="right">Minor 7th</td><td class="indexvalue">MIN7</td><td class="indexvalue"> {0,3,7,1}</td></tr>
725  <tr><td align="right">Suspended 4th</td><td class="indexvalue">SUS4</td><td class="indexvalue"> {0,5,7}</td></tr>
726  <tr><td align="right">Suspended 2nd</td><td class="indexvalue">SUS2</td><td class="indexvalue"> {0,2,7}</td></tr>
727  <tr><td align="right">Major 6th</td><td class="indexvalue">MAJ6</td><td class="indexvalue"> {0,4,7,9}</td></tr>
728  <tr><td align="right">Minor 6th</td><td class="indexvalue">MIN6</td><td class="indexvalue"> {0,3,7,9}</td></tr>
729  <tr><td align="right">9th dominant</td><td class="indexvalue">DOM9</td><td class="indexvalue"> {0,4,7,10,14}</td></tr>
730  <tr><td align="right">9th Major</td><td class="indexvalue">MAJ9</td><td class="indexvalue"> {0,4,7,11,14}</td></tr>
731  <tr><td align="right">9th Minor</td><td class="indexvalue">MIN9</td><td class="indexvalue"> {0,3,7,10,14}</td></tr>
732  <tr><td align="right">Diminished 7th</td><td class="indexvalue">DIM7</td><td class="indexvalue"> {0,3,6,9}</td></tr>
733  <tr><td align="right">Add 9</td><td class="indexvalue">ADD9</td><td class="indexvalue"> {0,4,7,14}</td></tr>
734  <tr><td align="right">Minor 11th</td><td class="indexvalue">MIN11</td><td class="indexvalue"> {0,7,10,14,15,17}</td></tr>
735  <tr><td align="right">11th dominant</td><td class="indexvalue">DOM11</td><td class="indexvalue"> {0,7,10,14,17}</td></tr>
736  <tr><td align="right">13th dominant</td><td class="indexvalue">DOM13</td><td class="indexvalue"> {0,7,10,14,16,21}</td></tr>
737  <tr><td align="right">Major 13th</td><td class="indexvalue">MAJ13</td><td class="indexvalue"> {0,7,11,14,16,21}</td></tr>
738  <tr><td align="right">Minor 13th</td><td class="indexvalue">MIN13</td><td class="indexvalue"> {0,7,10,14,15,21}</td></tr>
739  <tr><td align="right">7-5 dominant</td><td class="indexvalue">DOM7_5</td><td class="indexvalue"> {0,4,6,1}</td></tr>
740  <tr><td align="right">7-5 dominant</td><td class="indexvalue">DOM7<5</td><td class="indexvalue"> {0,4,6,1}</td></tr>
741  <tr><td align="right">7+5 dominant</td><td class="indexvalue">DOM75</td><td class="indexvalue"> {0,4,8,1}</td></tr>
742  <tr><td align="right">7+5 dominant</td><td class="indexvalue">DOM7>5</td><td class="indexvalue"> {0,4,8,1}</td></tr>
743  <tr><td align="right">Major 7-5</td><td class="indexvalue">MAJ7_5</td><td class="indexvalue"> {0,4,6,11}</td></tr>
744  <tr><td align="right">Major 7-5</td><td class="indexvalue">MAJ7<5</td><td class="indexvalue"> {0,4,6,11}</td></tr>
745  <tr><td align="right">Major 7+5</td><td class="indexvalue">MAJ75</td><td class="indexvalue"> {0,4,8,11}</td></tr>
746  <tr><td align="right">Major 7+5</td><td class="indexvalue">MAJ7>5</td><td class="indexvalue"> {0,4,8,11}</td></tr>
747  <tr><td align="right">Minor Major 7</td><td class="indexvalue">MINMAJ7</td><td class="indexvalue"> {0,3,7,11}</td></tr>
748  <tr><td align="right">7-5-9 dominant</td><td class="indexvalue">DOM7_5_9</td><td class="indexvalue"> {0,4,6,10,13}</td></tr>
749  <tr><td align="right">7-5-9 dominant</td><td class="indexvalue">DOM7<5<9</td><td class="indexvalue"> {0,4,6,10,13}</td></tr>
750  <tr><td align="right">7-5+9 dominant</td><td class="indexvalue">DOM7_59</td><td class="indexvalue"> {0,4,6,10,15}</td></tr>
751  <tr><td align="right">7-5+9 dominant</td><td class="indexvalue">DOM7<5>9</td><td class="indexvalue"> {0,4,6,10,15}</td></tr>
752  <tr><td align="right">7+5-9 dominant</td><td class="indexvalue">DOM75_9</td><td class="indexvalue"> {0,4,8,10,13}</td></tr>
753  <tr><td align="right">7+5-9 dominant</td><td class="indexvalue">DOM7>5<9</td><td class="indexvalue"> {0,4,8,10,13}</td></tr>
754  <tr><td align="right">7+5+9 dominant</td><td class="indexvalue">DOM759</td><td class="indexvalue"> {0,4,8,10,15}</td></tr>
755  <tr><td align="right">7+5+9 dominant</td><td class="indexvalue">DOM7>5>9</td><td class="indexvalue"> {0,4,8,10,15}</td></tr>
756 </table>
757 \endhtmlonly
758 
759 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.
760 
761 To specify a chord in CFugue, specify the root and append it with the chord name from the above table. For example, <tt>CMAJ</tt> signifies the C-major chord, which, based on the above halfstep intervals {0, 4, 7}, will automatically expand to <tt>C+E+G</tt> notes (C=0, E=4, G=7).
762 
763 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 <tt>Bb7Maj</tt>.
764 
765 \anchor ancNoteChordInversions <b>Chord Inversions</b>
766 
767 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 <i>n</i> number of notes can have atmost <i>n</i> degree inversions.
768 
769 The character <tt>^</tt> indicates an inversion in CFugue. There are two ways to use it. The first is to specify <tt>^</tt> as many times as the degree of inversion after the chord name, and the second is to specify <tt>^</tt> after the chord name followed by the new bass note. For example, <tt>Cmaj^^</tt> and <tt>Cmaj^G</tt> are two ways of indicating the same: a second degree inversion for C-Major chord (that makes the <tt>G</tt> as the new bass note).
770 
771 
772 \subsubsection subsubDuration Duration
773 Duration in Western music indicates how long a note should be played. CFugue supports below durations for the Western music notes.
774 
775 \htmlonly
776 <table align="center">
777 <tr><td class="indexkey">Character</td><td class="indexkey">Duration</td> </tr>
778 <tr><td class="indexkey">W</td><td class="indexvalue">Whole Note </td></tr>
779 <tr><td class="indexkey">H</td><td class="indexvalue">Half Note </td></tr>
780 <tr><td class="indexkey">Q</td><td class="indexvalue">Quarter Note </td></tr>
781 <tr><td class="indexkey">I</td><td class="indexvalue">1/8th Note </td></tr>
782 <tr><td class="indexkey">S</td><td class="indexvalue">1/16th Note </td></tr>
783 <tr><td class="indexkey">T</td><td class="indexvalue">1/32th Note </td></tr>
784 <tr><td class="indexkey">X</td><td class="indexvalue">1/64th Note </td></tr>
785 <tr><td class="indexkey">O</td><td class="indexvalue">1/128th Note </td></tr>
786 </table>
787 \endhtmlonly
788 
789 These characters can be combined to form any aribtrary lengths of durations as required. For example, the token <tt>Bb6www</tt> indicates a B-Flat note in 6th octave for a duration of three whole notes, and the token <tt>F\#MajH</tt> indicates an F-sharp Major chord for a duration of half-note.
790 
791 CFugue also supports dotted durations. For example, a dotted quarter note would be a <tt>q</tt> followed by a dot (<tt>q.</tt>). Dotted durations indicate an addendum of extra half to the original duration. Thus a dotted quarter note = quarter note + 1/8th note;
792 
793 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 <tt>F#8/0.25</tt> signifies an F-sharp note in eight octave for a duration of quarter note (<tt>0.25</tt> is the quarter note portion of whole note). Similarily <tt>0.5</tt> signifies half-note and <tt>1.0</tt> signifies a while note. Values greater than <tt>1.0</tt> indicate a note that spans multiple measures. For example, the <tt>Bb6www</tt> token discussed above can be represeted numerically as <tt>Bb6/3.0</tt>.
794 
795 Below are few valid examples of duration specification:
796 <pre class="fragment">
797  player.Play("Gh"); <span class="comment">// G note in default octave for a half-note duration </span>
798  player.Play("[65]wq"); <span class="comment">// Middle-F (F5) for a whote+quarter note duration </span>
799  player.Play("C3i."); <span class="comment">// C3 dotted-eighth (1/8 + 1/16) duration </span>
800 </pre>
801 For Western music, if no duration is specified, a default duration of quarter note is assumed.
802 
803 In Carnatic music, durations for the notes are determined automatically based on the <i>Talam</i>. A <i>Talam</i> specifies the duration for a group of notes instead of an individual note. CFugue supports below Talams.
804 
805 \subsubsection subsubVelocity Velocity
806 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.
807 
808 In CFugue, attack and decay velocities can be specified using a pair of <tt>V</tt> followed by a numeric value in the range [0, 127] duo. The first <tt>V</tt> number pair stands for attack velocity, followed by the optional second <tt>V</tt> 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:
809 <pre class="fragment">
810  player.Play("C6V2V124"); <span class="comment">// C6 note with sharp attack 2 and longer decay 124. The first V stands for attack, second V for decay. </span>
811  player.Play("Bb3qhVV3"); <span class="comment">// B-Flat 3rd octave quarter+half duration with default Attack and sharp decay 3. First V value left unspecified, so attack takes default value </span>
812  player.Play("Bb3qhV1"); <span class="comment">// B-Flat 3rd octave quarter+half duration with sharp Attack 1 and default decay. Second V left unspecified, so decay takes default value</span>
813  player.Play("Bb3qh"); <span class="comment">// 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</span>
814 </pre>
815 
816 \subsubsection subsubConnectors Connectors
817 
818 \subsection subRestNotes Specifying Rests
819 Apart from the regular notes, CFugue also supports <i>Rest</i> 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 \ref subsubDuration for details on durations.
820 
821 Use the symbol <i>R</i> to specify a Rest note in Western music. The usual duration specificiers can be appended as usual. Below are few examples:
822 <pre class="fragment">
823  player.Play("R"); <span class="comment">// Rest note for the detault duration</span>
824  player.Play("Rw"); <span class="comment">// Rest note for a whole duration</span>
825 </pre>
826 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.
827 <pre class="fragment">
828  player.Play("Cw Rh Dw"); <span class="comment">// Can you "listen" the Rest note ?</span>
829 </pre>
830 For Carnatic music, the symbols <tt>,</tt> and <tt>;</tt> signify the Rest notes. The durations are based on the currently selected Talam. The <tt>,</tt> specifies a Rest note for one duration, while the <tt>;</tt> specifies a Rest note for two durations.
831 
832 These <tt>,</tt> and <tt>;</tt> 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 \ref secInteroperation.
833 
834 \subsection subInstruments Specifying Instruments
835 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 <b>I</b> at their beginning. Below are few examples of valid instrument tokens:
836 <pre class="fragment">
837  player.Play("I[PIANO]");
838  player.Play("I10");
839  player.Play("I[RAIN]");
840 </pre>
841 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:
842 <pre class="fragment">
843  player.Play("I[Piano] C D E F G A B"); <span class="comment">// Play an Octave using Piano instrument </span>
844  player.Play("I0 C D E I40 F G A B"); <span class="comment">// I0 is Piano and I40 is Violin</span>
845  player.Play("I[Flute] K[Kalyani] S R G M P D N"); <span class="comment">// Play an Octave in Kalyani Ragam with Flute</span>
846 </pre>
847 
848 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.
849 \htmlonly
850 <table align="center">
851 <tr>
852 <td valign=top><table>
853  <tr><td class="indexvalue">PIANO</td> <td class="indexvalue">0</td></tr>
854  <tr><td class="indexvalue">ACOUSTIC_GRAND</td> <td class="indexvalue">0</td></tr>
855  <tr><td class="indexvalue">BRIGHT_ACOUSTIC</td> <td class="indexvalue">1</td></tr>
856  <tr><td class="indexvalue">ELECTRIC_GRAND</td> <td class="indexvalue">2</td></tr>
857  <tr><td class="indexvalue">HONKEY_TONK</td> <td class="indexvalue">3</td></tr>
858  <tr><td class="indexvalue">ELECTRIC_PIANO_1</td> <td class="indexvalue">4</td></tr>
859  <tr><td class="indexvalue">ELECTRIC_PIANO_2</td> <td class="indexvalue">5</td></tr>
860  <tr><td class="indexvalue">HARPISCHORD</td> <td class="indexvalue">6</td></tr>
861  <tr><td class="indexvalue">CLAVINET</td> <td class="indexvalue">7</td></tr>
862 </table></td>
863 <td valign=top><table>
864  <tr><td class="indexvalue">CELESTA</td> <td class="indexvalue">8</td></tr>
865  <tr><td class="indexvalue">GLOCKENSPIEL</td> <td class="indexvalue">9</td></tr>
866  <tr><td class="indexvalue">MUSIC_BOX</td> <td class="indexvalue">10</td></tr>
867  <tr><td class="indexvalue">VIBRAPHONE</td> <td class="indexvalue">11</td></tr>
868  <tr><td class="indexvalue">MARIMBA</td> <td class="indexvalue">12</td></tr>
869  <tr><td class="indexvalue">XYLOPHONE</td> <td class="indexvalue">13</td></tr>
870  <tr><td class="indexvalue">TUBULAR_BELLS</td> <td class="indexvalue">14</td></tr>
871  <tr><td class="indexvalue">DULCIMER</td> <td class="indexvalue">15</td></tr>
872 </table></td>
873 <td valign=top><table>
874  <tr><td class="indexvalue">DRAWBAR_ORGAN</td> <td class="indexvalue">16</td></tr>
875  <tr><td class="indexvalue">PERCUSSIVE_ORGAN</td> <td class="indexvalue">17</td></tr>
876  <tr><td class="indexvalue">ROCK_ORGAN</td> <td class="indexvalue">18</td></tr>
877  <tr><td class="indexvalue">CHURCH_ORGAN</td> <td class="indexvalue">19</td></tr>
878  <tr><td class="indexvalue">REED_ORGAN</td> <td class="indexvalue">20</td></tr>
879  <tr><td class="indexvalue">ACCORDIAN</td> <td class="indexvalue">21</td></tr>
880  <tr><td class="indexvalue">HARMONICA</td> <td class="indexvalue">22</td></tr>
881  <tr><td class="indexvalue">TANGO_ACCORDIAN</td> <td class="indexvalue">23</td></tr>
882 </table></td>
883 <td valign=top><table>
884  <tr><td class="indexvalue">GUITAR</td> <td class="indexvalue">24</td></tr>
885  <tr><td class="indexvalue">NYLON_STRING_GUITAR</td> <td class="indexvalue">24</td></tr>
886  <tr><td class="indexvalue">STEEL_STRING_GUITAR</td> <td class="indexvalue">25</td></tr>
887  <tr><td class="indexvalue">ELECTRIC_JAZZ_GUITAR</td> <td class="indexvalue">26</td></tr>
888  <tr><td class="indexvalue">ELECTRIC_CLEAN_GUITAR</td> <td class="indexvalue">27</td></tr>
889  <tr><td class="indexvalue">ELECTRIC_MUTED_GUITAR</td> <td class="indexvalue">28</td></tr>
890  <tr><td class="indexvalue">OVERDRIVEN_GUITAR</td> <td class="indexvalue">29</td></tr>
891  <tr><td class="indexvalue">DISTORTION_GUITAR</td> <td class="indexvalue">30</td></tr>
892  <tr><td class="indexvalue">GUITAR_HARMONICS</td> <td class="indexvalue">31</td></tr>
893 </table></td>
894 </tr>
895 <tr>
896 <td valign=top><table>
897  <tr><td class="indexvalue">ACOUSTIC_BASS</td> <td class="indexvalue">32</td></tr>
898  <tr><td class="indexvalue">ELECTRIC_BASS_FINGER</td> <td class="indexvalue">33</td></tr>
899  <tr><td class="indexvalue">ELECTRIC_BASS_PICK</td> <td class="indexvalue">34</td></tr>
900  <tr><td class="indexvalue">FRETLESS_BASS</td> <td class="indexvalue">35</td></tr>
901  <tr><td class="indexvalue">SLAP_BASS_1</td> <td class="indexvalue">36</td></tr>
902  <tr><td class="indexvalue">SLAP_BASS_2</td> <td class="indexvalue">37</td></tr>
903  <tr><td class="indexvalue">SYNTH_BASS_1</td> <td class="indexvalue">38</td></tr>
904  <tr><td class="indexvalue">SYNTH_BASS_2</td> <td class="indexvalue">39</td></tr>
905 </table></td>
906 <td valign=top><table>
907  <tr><td class="indexvalue">VIOLIN</td> <td class="indexvalue">40</td></tr>
908  <tr><td class="indexvalue">VIOLA</td> <td class="indexvalue">41</td></tr>
909  <tr><td class="indexvalue">CELLO</td> <td class="indexvalue">42</td></tr>
910  <tr><td class="indexvalue">CONTRABASS</td> <td class="indexvalue">43</td></tr>
911  <tr><td class="indexvalue">TREMOLO_STRINGS</td> <td class="indexvalue">44</td></tr>
912  <tr><td class="indexvalue">PIZZICATO_STRINGS</td> <td class="indexvalue">45</td></tr>
913  <tr><td class="indexvalue">ORCHESTRAL_STRINGS</td> <td class="indexvalue">46</td></tr>
914  <tr><td class="indexvalue">TIMPANI</td> <td class="indexvalue">47</td></tr>
915 </table></td>
916 <td valign=top><table>
917  <tr><td class="indexvalue">STRING_ENSEMBLE_1</td> <td class="indexvalue">48</td></tr>
918  <tr><td class="indexvalue">STRING_ENSEMBLE_2</td> <td class="indexvalue">49</td></tr>
919  <tr><td class="indexvalue">SYNTH_STRINGS_1</td> <td class="indexvalue">50</td></tr>
920  <tr><td class="indexvalue">SYNTH_STRINGS_2</td> <td class="indexvalue">51</td></tr>
921  <tr><td class="indexvalue">CHOIR_AAHS</td> <td class="indexvalue">52</td></tr>
922  <tr><td class="indexvalue">VOICE_OOHS</td> <td class="indexvalue">53</td></tr>
923  <tr><td class="indexvalue">SYNTH_VOICE</td> <td class="indexvalue">54</td></tr>
924  <tr><td class="indexvalue">ORCHESTRA_HIT</td> <td class="indexvalue">55</td></tr>
925 </table></td>
926 <td valign=top><table>
927  <tr><td class="indexvalue">TRUMPET</td> <td class="indexvalue">56</td></tr>
928  <tr><td class="indexvalue">TROMBONE</td> <td class="indexvalue">57</td></tr>
929  <tr><td class="indexvalue">TUBA</td> <td class="indexvalue">58</td></tr>
930  <tr><td class="indexvalue">MUTED_TRUMPET</td> <td class="indexvalue">59</td></tr>
931  <tr><td class="indexvalue">FRENCH_HORN</td> <td class="indexvalue">60</td></tr>
932  <tr><td class="indexvalue">BRASS_SECTION</td> <td class="indexvalue">61</td></tr>
933  <tr><td class="indexvalue">SYNTHBRASS_1</td> <td class="indexvalue">62</td></tr>
934  <tr><td class="indexvalue">SYNTHBRASS_2</td> <td class="indexvalue">63</td></tr>
935 </table></td>
936 </tr>
937 <tr>
938 <td valign=top><table>
939  <tr><td class="indexvalue">SOPRANO_SAX</td> <td class="indexvalue">64</td></tr>
940  <tr><td class="indexvalue">ALTO_SAX</td> <td class="indexvalue">65</td></tr>
941  <tr><td class="indexvalue">TENOR_SAX</td> <td class="indexvalue">66</td></tr>
942  <tr><td class="indexvalue">BARITONE_SAX</td> <td class="indexvalue">67</td></tr>
943  <tr><td class="indexvalue">OBOE</td> <td class="indexvalue">68</td></tr>
944  <tr><td class="indexvalue">ENGLISH_HORN</td> <td class="indexvalue">69</td></tr>
945  <tr><td class="indexvalue">BASSOON</td> <td class="indexvalue">70</td></tr>
946  <tr><td class="indexvalue">CLARINET</td> <td class="indexvalue">71</td></tr>
947 </table></td>
948 <td valign=top><table>
949  <tr><td class="indexvalue">PICCOLO</td> <td class="indexvalue">72</td></tr>
950  <tr><td class="indexvalue">FLUTE</td> <td class="indexvalue">73</td></tr>
951  <tr><td class="indexvalue">RECORDER</td> <td class="indexvalue">74</td></tr>
952  <tr><td class="indexvalue">PAN_FLUTE</td> <td class="indexvalue">75</td></tr>
953  <tr><td class="indexvalue">BLOWN_BOTTLE</td> <td class="indexvalue">76</td></tr>
954  <tr><td class="indexvalue">SKAKUHACHI</td> <td class="indexvalue">77</td></tr>
955  <tr><td class="indexvalue">WHISTLE</td> <td class="indexvalue">78</td></tr>
956  <tr><td class="indexvalue">OCARINA</td> <td class="indexvalue">79</td></tr>
957 </table></td>
958 <td valign=top><table>
959  <tr><td class="indexvalue">LEAD_SQUARE <i>or</i> SQUARE</td> <td class="indexvalue">80</td></tr>
960  <tr><td class="indexvalue">LEAD_SAWTOOTH <i>or</i> SAWTOOTH</td> <td class="indexvalue">81</td></tr>
961  <tr><td class="indexvalue">LEAD_CALLIOPE <i>or</i> CALLIOPE</td> <td class="indexvalue">82</td></tr>
962  <tr><td class="indexvalue">LEAD_CHIFF <i>or</i> CHIFF</td> <td class="indexvalue">83</td></tr>
963  <tr><td class="indexvalue">LEAD_CHARANG <i>or</i> CHARANG</td> <td class="indexvalue">84</td></tr>
964  <tr><td class="indexvalue">LEAD_VOICE <i>or</i> VOICE</td> <td class="indexvalue">85</td></tr>
965  <tr><td class="indexvalue">LEAD_FIFTHS <i>or</i> FIFTHS</td> <td class="indexvalue">86</td></tr>
966  <tr><td class="indexvalue">LEAD_BASSLEAD <i>or</i> BASSLEAD</td> <td class="indexvalue">87</td></tr>
967 </table></td>
968 <td valign=top><table>
969  <tr><td class="indexvalue">PAD_NEW_AGE <i>or</i> NEW_AGE</td> <td class="indexvalue">88</td></tr>
970  <tr><td class="indexvalue">PAD_WARM <i>or</i> WARM</td> <td class="indexvalue">89</td></tr>
971  <tr><td class="indexvalue">PAD_POLYSYNTH <i>or</i> POLYSYNTH</td> <td class="indexvalue">90</td></tr>
972  <tr><td class="indexvalue">PAD_CHOIR <i>or</i> CHOIR</td> <td class="indexvalue">91</td></tr>
973  <tr><td class="indexvalue">PAD_BOWED <i>or</i> BOWED</td> <td class="indexvalue">92</td></tr>
974  <tr><td class="indexvalue">PAD_METALLIC <i>or</i> METALLIC</td> <td class="indexvalue">93</td></tr>
975  <tr><td class="indexvalue">PAD_HALO <i>or</i> HALO</td> <td class="indexvalue">94</td></tr>
976  <tr><td class="indexvalue">PAD_SWEEP <i>or</i> SWEEP</td> <td class="indexvalue">95</td></tr>
977 </table></td>
978 </tr>
979 <tr>
980 <td valign=top><table>
981  <tr><td class="indexvalue">FX_RAIN <i>or</i> RAIN</td> <td class="indexvalue">96</td></tr>
982  <tr><td class="indexvalue">FX_SOUNDTRACK <i>or</i> SOUNDTRACK</td> <td class="indexvalue">97</td></tr>
983  <tr><td class="indexvalue">FX_CRYSTAL <i>or</i> CRYSTAL</td> <td class="indexvalue">98</td></tr>
984  <tr><td class="indexvalue">FX_ATMOSPHERE <i>or</i> ATMOSPHERE</td> <td class="indexvalue">99</td></tr>
985  <tr><td class="indexvalue">FX_BRIGHTNESS <i>or</i> BRIGHTNESS</td> <td class="indexvalue">100</td></tr>
986  <tr><td class="indexvalue">FX_GOBLINS <i>or</i> GOBLINS</td> <td class="indexvalue">101</td></tr>
987  <tr><td class="indexvalue">FX_ECHOES <i>or</i> ECHOES</td> <td class="indexvalue">102</td></tr>
988  <tr><td class="indexvalue">FX_SCI-FI <i>or</i> SCI-FI</td> <td class="indexvalue">103</td></tr>
989 </table></td>
990 <td valign=top><table>
991  <tr><td class="indexvalue">SITAR</td> <td class="indexvalue">104</td></tr>
992  <tr><td class="indexvalue">BANJO</td> <td class="indexvalue">105</td></tr>
993  <tr><td class="indexvalue">SHAMISEN</td> <td class="indexvalue">106</td></tr>
994  <tr><td class="indexvalue">KOTO</td> <td class="indexvalue">107</td></tr>
995  <tr><td class="indexvalue">KALIMBA</td> <td class="indexvalue">108</td></tr>
996  <tr><td class="indexvalue">BAGPIPE</td> <td class="indexvalue">109</td></tr>
997  <tr><td class="indexvalue">FIDDLE</td> <td class="indexvalue">110</td></tr>
998  <tr><td class="indexvalue">SHANAI</td> <td class="indexvalue">111</td></tr>
999 </table></td>
1000 <td valign=top><table>
1001  <tr><td class="indexvalue">TINKLE_BELL</td> <td class="indexvalue">112</td></tr>
1002  <tr><td class="indexvalue">AGOGO</td> <td class="indexvalue">113</td></tr>
1003  <tr><td class="indexvalue">STEEL_DRUMS</td> <td class="indexvalue">114</td></tr>
1004  <tr><td class="indexvalue">WOODBLOCK</td> <td class="indexvalue">115</td></tr>
1005  <tr><td class="indexvalue">TAIKO_DRUM</td> <td class="indexvalue">116</td></tr>
1006  <tr><td class="indexvalue">MELODIC_TOM</td> <td class="indexvalue">117</td></tr>
1007  <tr><td class="indexvalue">SYNTH_DRUM</td> <td class="indexvalue">118</td></tr>
1008  <tr><td class="indexvalue">REVERSE_CYMBAL</td> <td class="indexvalue">119</td></tr>
1009 </table></td>
1010 <td valign=top><table>
1011  <tr><td class="indexvalue">GUITAR_FRET_NOISE</td> <td class="indexvalue">120</td></tr>
1012  <tr><td class="indexvalue">BREATH_NOISE</td> <td class="indexvalue">121</td></tr>
1013  <tr><td class="indexvalue">SEASHORE</td> <td class="indexvalue">122</td></tr>
1014  <tr><td class="indexvalue">BIRD_TWEET</td> <td class="indexvalue">123</td></tr>
1015  <tr><td class="indexvalue">TELEPHONE_RING</td> <td class="indexvalue">124</td></tr>
1016  <tr><td class="indexvalue">HELICOPTER</td> <td class="indexvalue">125</td></tr>
1017  <tr><td class="indexvalue">APPLAUSE</td> <td class="indexvalue">126</td></tr>
1018  <tr><td class="indexvalue">GUNSHOT</td> <td class="indexvalue">127</td></tr>
1019 </table></td>
1020 </tr>
1021 </table>
1022 \endhtmlonly
1023 
1024 \subsection subKeySignatures Specifying Key Signatures
1025 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.
1026 
1027 In CFugue, KeySignature tokens are identified with character <b>K</b> at their beginning. Below are few examples of valid KeySignature tokens:
1028 <pre class="fragment">
1029  player.Play("K[CMAJ]");
1030  player.Play("K[F#MAJ]");
1031  player.Play("K[KANAKANGI]");
1032 </pre>
1033 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:
1034 <pre class="fragment">
1035  player.Play("K[CMaj] C D E F G A B"); <span class="comment">// Play an Octave in CMajor Scale </span>
1036  player.Play("K[FMaj] C D E F G A B"); <span class="comment">// Play an Octave in FMajor Scale </span>
1037  player.Play("K[Kalyani] S R G M P D N"); <span class="comment">// Play an Octave in Kalyani Ragam</span>
1038  player.Play("K[Kanakangi] S R G M P D N"); <span class="comment">// Play an Octave in Kanakangi Ragam</span>
1039 </pre>
1040 
1041 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.
1042 
1043 For example, in the above, when K[FMaj] is specified, the B note in the octave will be treated as B<i>b</i> automatically. Similarily, for K[Kalyani], the M note will be treated as M2 automatically.
1044 
1045 When no KeySignature is specified, CFugue assumes these default Values: K[CMaj] for Western and K[Shankarabharanam] for Carnatic.
1046 
1047 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 <i>n</i> 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.
1048 <pre class="fragment">
1049  player.Play("K[CMaj] C D E F G A B"); <span class="comment">// Play an Octave in CMajor Scale </span>
1050  player.Play("K[FMaj] C D E F G A Bn"); <span class="comment">// B is declared as natural. FMaj is ignored for B</span>
1051  player.Play("K[Shankarabharanam] S R G M P D N"); <span class="comment">// Play an Octave in Shankarabharanam Ragam</span>
1052  player.Play("K[Kalyani] S R G M1 P D N"); <span class="comment">// M1 declared explicitly. Kalyani is ignored for M</span>
1053  player.Play("K[FMaj] C D E F G A [71]"); <span class="comment">// [71] is numeric note. FMaj is ignored for it</span>
1054 </pre>
1055  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.
1056 
1057  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 \ref KeySignatureTable "KeySignatures table".
1058 
1059  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.
1060 
1061  \anchor KeySignatureTable \htmlonly
1062  <table align="center" border="1">
1063  <caption ALIGN=bottom><br/>KeySignatures supported by CFugue</caption>
1064  <tr>
1065  <td valign=top>
1066  <table align="center">
1067  <tr><td class="indexkey">Scale Name</td><td class="indexkey">Note Values</td></tr>
1068  <tr><td class="indexvalue">CBMAJ</td><td class="indexvalue">{ Cb Db Eb Fb Gb Ab Bb }</td></tr>
1069  <tr><td class="indexvalue">ABMIN</td><td class="indexvalue">{ Cb Db Eb Fb Gb Ab Bb }</td></tr>
1070 
1071  <tr><td class="indexvalue">GBMAJ</td><td class="indexvalue">{ Cb Db Eb F Gb Ab Bb }</td></tr>
1072  <tr><td class="indexvalue">EBMIN</td><td class="indexvalue">{ Cb Db Eb F Gb Ab Bb }</td></tr>
1073 
1074  <tr><td class="indexvalue">DBMAJ</td><td class="indexvalue">{ C Db Eb F Gb Ab Bb }</td></tr>
1075  <tr><td class="indexvalue">BBMIN</td><td class="indexvalue">{ C Db Eb F Gb Ab Bb }</td></tr>
1076 
1077  <tr><td class="indexvalue">ABMAJ</td><td class="indexvalue">{ C Db Eb F G Ab Bb }</td></tr>
1078  <tr><td class="indexvalue">FMIN</td><td class="indexvalue">{ C Db Eb F G Ab Bb }</td></tr>
1079 
1080  <tr><td class="indexvalue">EBMAJ</td><td class="indexvalue">{ C D Eb F G Ab Bb }</td></tr>
1081  <tr><td class="indexvalue">CMIN</td><td class="indexvalue">{ C D Eb F G Ab Bb }</td></tr>
1082 
1083  <tr><td class="indexvalue">BBMAJ</td><td class="indexvalue">{ C D Eb F G A Bb }</td></tr>
1084  <tr><td class="indexvalue">GMIN</td><td class="indexvalue">{ C D Eb F G A Bb }</td></tr>
1085 
1086  <tr><td class="indexvalue">FMAJ</td><td class="indexvalue">{ C D E F G A Bb }</td></tr>
1087  <tr><td class="indexvalue">DMIN</td><td class="indexvalue">{ C D E F G A Bb }</td></tr>
1088 
1089  <tr><td class="indexvalue">CMAJ</td><td class="indexvalue">{ C D E F G A B }</td></tr>
1090  <tr><td class="indexvalue">AMIN</td><td class="indexvalue">{ C D E F G A B }</td></tr>
1091 
1092  <tr><td class="indexvalue">GMAJ</td><td class="indexvalue">{ C D E F# G A B }</td></tr>
1093  <tr><td class="indexvalue">EMIN</td><td class="indexvalue">{ C D E F# G A B }</td></tr>
1094 
1095  <tr><td class="indexvalue">DMAJ</td><td class="indexvalue">{ C# D E F# G A B }</td></tr>
1096  <tr><td class="indexvalue">BMIN</td><td class="indexvalue">{ C# D E F# G A B }</td></tr>
1097 
1098  <tr><td class="indexvalue">AMAJ</td><td class="indexvalue">{ C# D E F# G# A B }</td></tr>
1099  <tr><td class="indexvalue">F#MIN</td><td class="indexvalue">{ C# D E F# G# A B }</td></tr>
1100 
1101  <tr><td class="indexvalue">EMAJ</td><td class="indexvalue">{ C# D# E F# G# A B }</td></tr>
1102  <tr><td class="indexvalue">C#MIN</td><td class="indexvalue">{ C# D# E F# G# A B }</td></tr>
1103 
1104  <tr><td class="indexvalue">BMAJ</td><td class="indexvalue">{ C# D# E F# G# A# B }</td></tr>
1105  <tr><td class="indexvalue">G#MIN</td><td class="indexvalue">{ C# D# E F# G# A# B }</td></tr>
1106 
1107  <tr><td class="indexvalue">F#MAJ</td><td class="indexvalue">{ C# D# E# F# G# A# B }</td></tr>
1108  <tr><td class="indexvalue">D#MIN</td><td class="indexvalue">{ C# D# E# F# G# A# B }</td></tr>
1109 
1110  <tr><td class="indexvalue">C#MAJ</td><td class="indexvalue">{ C# D# E# F# G# A# B# }</td></tr>
1111  <tr><td class="indexvalue">A#MIN</td><td class="indexvalue">{ C# D# E# F# G# A# B# }</td></tr>
1112  </table>
1113  </td>
1114  <td valign=top>
1115  <table align="center">
1116  <tr><td class="indexkey">Raga Name</td><td class="indexkey">Mela_x</td><td class="indexkey">Swara Values</td></tr>
1117  <tr><td class="indexvalue">KANAKANGI</td><td class="indexvalue">MELA_1 </td><td class="indexvalue">{ S R1 G1 M1 P D1 N1 }</td></tr>
1118  <tr><td class="indexvalue">RATNANGI</td><td class="indexvalue">MELA_2 </td><td class="indexvalue">{ S R1 G1 M1 P D1 N2 }</td></tr>
1119  <tr><td class="indexvalue">GANAMURTHI</td><td class="indexvalue">MELA_3 </td><td class="indexvalue">{ S R1 G1 M1 P D1 N3 }</td></tr>
1120  <tr><td class="indexvalue">VANASPATHI</td><td class="indexvalue">MELA_4 </td><td class="indexvalue">{ S R1 G1 M1 P D2 N2 }</td></tr>
1121  <tr><td class="indexvalue">MANAVATHI</td><td class="indexvalue">MELA_5 </td><td class="indexvalue">{ S R1 G1 M1 P D2 N3 }</td></tr>
1122  <tr><td class="indexvalue">TANARUPI</td><td class="indexvalue">MELA_6 </td><td class="indexvalue">{ S R1 G1 M1 P D3 N3 }</td></tr>
1123  <tr><td class="indexvalue">SENAVATHI</td><td class="indexvalue">MELA_7 </td><td class="indexvalue">{ S R1 G2 M1 P D1 N1 }</td></tr>
1124  <tr><td class="indexvalue">HANUMATHODI</td><td class="indexvalue">MELA_8 </td><td class="indexvalue">{ S R1 G2 M1 P D1 N2 }</td></tr>
1125  <tr><td class="indexvalue">DHENUKA</td><td class="indexvalue">MELA_9 </td><td class="indexvalue">{ S R1 G2 M1 P D1 N3 }</td></tr>
1126  <tr><td class="indexvalue">NATAKAPRIYA</td><td class="indexvalue">MELA_10</td><td class="indexvalue">{ S R1 G2 M1 P D2 N2 }</td></tr>
1127  <tr><td class="indexvalue">KOKILAPRIYA</td><td class="indexvalue">MELA_11</td><td class="indexvalue">{ S R1 G2 M1 P D2 N3 }</td></tr>
1128  <tr><td class="indexvalue">RUPAVATHI</td><td class="indexvalue">MELA_12</td><td class="indexvalue">{ S R1 G2 M1 P D3 N3 }</td></tr>
1129  <tr><td class="indexvalue">GAYAKAPRIYA</td><td class="indexvalue">MELA_13</td><td class="indexvalue">{ S R1 G3 M1 P D1 N1 }</td></tr>
1130  <tr><td class="indexvalue">VAKULABHARANAM</td><td class="indexvalue">MELA_14</td><td class="indexvalue">{ S R1 G3 M1 P D1 N2 }</td></tr>
1131  <tr><td class="indexvalue">MAYAMALAVAGOWLA</td><td class="indexvalue">MELA_15</td><td class="indexvalue">{ S R1 G3 M1 P D1 N3 }</td></tr>
1132  <tr><td class="indexvalue">CHAKRAVAKAM</td><td class="indexvalue">MELA_16</td><td class="indexvalue">{ S R1 G3 M1 P D2 N2 }</td></tr>
1133  <tr><td class="indexvalue">SURYAKANTHAM</td><td class="indexvalue">MELA_17</td><td class="indexvalue">{ S R1 G3 M1 P D2 N3 }</td></tr>
1134  <tr><td class="indexvalue">HATAKAMBARI</td><td class="indexvalue">MELA_18</td><td class="indexvalue">{ S R1 G3 M1 P D3 N3 }</td></tr>
1135  <tr><td class="indexvalue">JHANKARADHWANI</td><td class="indexvalue">MELA_19</td><td class="indexvalue">{ S R2 G2 M1 P D1 N1 }</td></tr>
1136  <tr><td class="indexvalue">NATABHAIRAVI</td><td class="indexvalue">MELA_20</td><td class="indexvalue">{ S R2 G2 M1 P D1 N2 }</td></tr>
1137  <tr><td class="indexvalue">KEERAVANI</td><td class="indexvalue">MELA_21</td><td class="indexvalue">{ S R2 G2 M1 P D1 N3 }</td></tr>
1138  <tr><td class="indexvalue">KHARAHARAPRIYA</td><td class="indexvalue">MELA_22</td><td class="indexvalue">{ S R2 G2 M1 P D2 N2 }</td></tr>
1139  <tr><td class="indexvalue">GOWRIMANOHARI</td><td class="indexvalue">MELA_23</td><td class="indexvalue">{ S R2 G2 M1 P D2 N3 }</td></tr>
1140  <tr><td class="indexvalue">VARUNAPRIYA</td><td class="indexvalue">MELA_24</td><td class="indexvalue">{ S R2 G2 M1 P D3 N3 }</td></tr>
1141  <tr><td class="indexvalue">MARARANJANI</td><td class="indexvalue">MELA_25</td><td class="indexvalue">{ S R2 G3 M1 P D1 N1 }</td></tr>
1142  <tr><td class="indexvalue">CHARUKESHI</td><td class="indexvalue">MELA_26</td><td class="indexvalue">{ S R2 G3 M1 P D1 N2 }</td></tr>
1143  <tr><td class="indexvalue">SARASANGI</td><td class="indexvalue">MELA_27</td><td class="indexvalue">{ S R2 G3 M1 P D1 N3 }</td></tr>
1144  <tr><td class="indexvalue">HARIKHAMBHOJI</td><td class="indexvalue">MELA_28</td><td class="indexvalue">{ S R2 G3 M1 P D2 N2 }</td></tr>
1145  <tr><td class="indexvalue">DHEERASHANKARABHARANAM</td><td class="indexvalue">MELA_29</td><td class="indexvalue">{ S R2 G3 M1 P D2 N3 }</td></tr>
1146  <tr><td class="indexvalue">SHANKARABHARANAM</td><td class="indexvalue">MELA_29</td><td class="indexvalue">{ S R2 G3 M1 P D2 N3 }</td></tr>
1147  <tr><td class="indexvalue">NAGANANDINI</td><td class="indexvalue">MELA_30</td><td class="indexvalue">{ S R2 G3 M1 P D3 N3 }</td></tr>
1148  <tr><td class="indexvalue">YAGAPRIYA</td><td class="indexvalue">MELA_31</td><td class="indexvalue">{ S R3 G3 M1 P D1 N1 }</td></tr>
1149  <tr><td class="indexvalue">RAGAVARDHINI</td><td class="indexvalue">MELA_32</td><td class="indexvalue">{ S R3 G3 M1 P D1 N2 }</td></tr>
1150  <tr><td class="indexvalue">GANGEYABHUSHINI</td><td class="indexvalue">MELA_33</td><td class="indexvalue">{ S R3 G3 M1 P D1 N3 }</td></tr>
1151  <tr><td class="indexvalue">VAGADHISHWARI</td><td class="indexvalue">MELA_34</td><td class="indexvalue">{ S R3 G3 M1 P D2 N2 }</td></tr>
1152  <tr><td class="indexvalue">SHULINI</td><td class="indexvalue">MELA_35</td><td class="indexvalue">{ S R3 G3 M1 P D2 N3 }</td></tr>
1153  <tr><td class="indexvalue">CHALANATTAI</td><td class="indexvalue">MELA_36</td><td class="indexvalue">{ S R3 G3 M1 P D3 N3 }</td></tr>
1154  <tr><td class="indexvalue">SALAGAM</td><td class="indexvalue">MELA_37</td><td class="indexvalue">{ S R1 G1 M2 P D1 N1 }</td></tr>
1155  <tr><td class="indexvalue">JALARNAVAM</td><td class="indexvalue">MELA_38</td><td class="indexvalue">{ S R1 G1 M2 P D1 N2 }</td></tr>
1156  <tr><td class="indexvalue">JHALAVARALI</td><td class="indexvalue">MELA_39</td><td class="indexvalue">{ S R1 G1 M2 P D1 N3 }</td></tr>
1157  <tr><td class="indexvalue">NAVANEETHAM</td><td class="indexvalue">MELA_40</td><td class="indexvalue">{ S R1 G1 M2 P D2 N2 }</td></tr>
1158  <tr><td class="indexvalue">PAVANI</td><td class="indexvalue">MELA_41</td><td class="indexvalue">{ S R1 G1 M2 P D2 N3 }</td></tr>
1159  <tr><td class="indexvalue">RAGHUPRIYA</td><td class="indexvalue">MELA_42</td><td class="indexvalue">{ S R1 G1 M2 P D3 N3 }</td></tr>
1160  <tr><td class="indexvalue">GAVAMBODHI</td><td class="indexvalue">MELA_43</td><td class="indexvalue">{ S R1 G2 M2 P D1 N1 }</td></tr>
1161  <tr><td class="indexvalue">BHAVAPRIYA</td><td class="indexvalue">MELA_44</td><td class="indexvalue">{ S R1 G2 M2 P D1 N2 }</td></tr>
1162  <tr><td class="indexvalue">SHUBHAPANTUVARALI</td><td class="indexvalue">MELA_45</td><td class="indexvalue">{ S R1 G2 M2 P D1 N3 }</td></tr>
1163  <tr><td class="indexvalue">PANTUVARALI</td><td class="indexvalue">MELA_45</td><td class="indexvalue">{ S R1 G2 M2 P D1 N3 }</td></tr>
1164  <tr><td class="indexvalue">SHADVIDHAMARGINI</td><td class="indexvalue">MELA_46</td><td class="indexvalue">{ S R1 G2 M2 P D2 N2 }</td></tr>
1165  <tr><td class="indexvalue">SUVARNANGI</td><td class="indexvalue">MELA_47</td><td class="indexvalue">{ S R1 G2 M2 P D2 N3 }</td></tr>
1166  <tr><td class="indexvalue">DIVYAMANI</td><td class="indexvalue">MELA_48</td><td class="indexvalue">{ S R1 G2 M2 P D3 N3 }</td></tr>
1167  <tr><td class="indexvalue">DHAVALAMBARI</td><td class="indexvalue">MELA_49</td><td class="indexvalue">{ S R1 G3 M2 P D1 N1 }</td></tr>
1168  <tr><td class="indexvalue">NAMANARAYANI</td><td class="indexvalue">MELA_50</td><td class="indexvalue">{ S R1 G3 M2 P D1 N2 }</td></tr>
1169  <tr><td class="indexvalue">KAMAVARDHINI</td><td class="indexvalue">MELA_51</td><td class="indexvalue">{ S R1 G3 M2 P D1 N3 }</td></tr>
1170  <tr><td class="indexvalue">RAMAPRIYA</td><td class="indexvalue">MELA_52</td><td class="indexvalue">{ S R1 G3 M2 P D2 N2 }</td></tr>
1171  <tr><td class="indexvalue">GAMANASHRAMA</td><td class="indexvalue">MELA_53</td><td class="indexvalue">{ S R1 G3 M2 P D2 N3 }</td></tr>
1172  <tr><td class="indexvalue">VISHWAMBHARI</td><td class="indexvalue">MELA_54</td><td class="indexvalue">{ S R1 G3 M2 P D3 N3 }</td></tr>
1173  <tr><td class="indexvalue">SHYAMALANGI</td><td class="indexvalue">MELA_55</td><td class="indexvalue">{ S R2 G2 M2 P D1 N1 }</td></tr>
1174  <tr><td class="indexvalue">SHANMUKHAPRIYA</td><td class="indexvalue">MELA_56</td><td class="indexvalue">{ S R2 G2 M2 P D1 N2 }</td></tr>
1175  <tr><td class="indexvalue">SIMHENDRAMADHYAMAM</td><td class="indexvalue">MELA_57</td><td class="indexvalue">{ S R2 G2 M2 P D1 N3 }</td></tr>
1176  <tr><td class="indexvalue">HEMAVATHI</td><td class="indexvalue">MELA_58</td><td class="indexvalue">{ S R2 G2 M2 P D2 N2 }</td></tr>
1177  <tr><td class="indexvalue">DHARMAVATHI</td><td class="indexvalue">MELA_59</td><td class="indexvalue">{ S R2 G2 M2 P D2 N3 }</td></tr>
1178  <tr><td class="indexvalue">NEETHIMATHI</td><td class="indexvalue">MELA_60</td><td class="indexvalue">{ S R2 G2 M2 P D3 N3 }</td></tr>
1179  <tr><td class="indexvalue">KANTHAMANI</td><td class="indexvalue">MELA_61</td><td class="indexvalue">{ S R2 G3 M2 P D1 N1 }</td></tr>
1180  <tr><td class="indexvalue">RISHABHAPRIYA</td><td class="indexvalue">MELA_62</td><td class="indexvalue">{ S R2 G3 M2 P D1 N2 }</td></tr>
1181  <tr><td class="indexvalue">LATHANGI</td><td class="indexvalue">MELA_63</td><td class="indexvalue">{ S R2 G3 M2 P D1 N3 }</td></tr>
1182  <tr><td class="indexvalue">VACHASPATHI</td><td class="indexvalue">MELA_64</td><td class="indexvalue">{ S R2 G3 M2 P D2 N2 }</td></tr>
1183  <tr><td class="indexvalue">MECHAKALYANI</td><td class="indexvalue">MELA_65</td><td class="indexvalue">{ S R2 G3 M2 P D2 N3 }</td></tr>
1184  <tr><td class="indexvalue">KALYANI</td><td class="indexvalue">MELA_65</td><td class="indexvalue">{ S R2 G3 M2 P D2 N3 }</td></tr>
1185  <tr><td class="indexvalue">CHITRAMBARI</td><td class="indexvalue">MELA_66</td><td class="indexvalue">{ S R2 G3 M2 P D3 N3 }</td></tr>
1186  <tr><td class="indexvalue">SUCHARITRA</td><td class="indexvalue">MELA_67</td><td class="indexvalue">{ S R3 G3 M2 P D1 N1 }</td></tr>
1187  <tr><td class="indexvalue">JYOTHISWARUPINI</td><td class="indexvalue">MELA_68</td><td class="indexvalue">{ S R3 G3 M2 P D1 N2 }</td></tr>
1188  <tr><td class="indexvalue">DHATUVARDHINI</td><td class="indexvalue">MELA_69</td><td class="indexvalue">{ S R3 G3 M2 P D1 N3 }</td></tr>
1189  <tr><td class="indexvalue">NASIKABHUSHINI</td><td class="indexvalue">MELA_70</td><td class="indexvalue">{ S R3 G3 M2 P D2 N2 }</td></tr>
1190  <tr><td class="indexvalue">KOSALAM</td><td class="indexvalue">MELA_71</td><td class="indexvalue">{ S R3 G3 M2 P D2 N3 }</td></tr>
1191  <tr><td class="indexvalue">RASIKAPRIYA</td><td class="indexvalue">MELA_72</td><td class="indexvalue">{ S R3 G3 M2 P D3 N3 }</td></tr>
1192  </table>
1193  </td>
1194  <td valign=top>
1195  <table align="center">
1196  <tr><td class="indexkey">Somemore Ragas</td><td class="indexkey">Janya Mela</td></tr>
1197  <tr><td class="indexvalue">BILAHARI</td><td class="indexvalue">MELA_29</td></tr>
1198  <tr><td class="indexvalue">HAMSADHWANI</td><td class="indexvalue">MELA_29</td></tr>
1199  <tr><td class="indexvalue">HINDOLAM</td><td class="indexvalue">MELA_20</td></tr>
1200  <tr><td class="indexvalue">KAMBHOJI</td><td class="indexvalue">MELA_28</td></tr>
1201  <tr><td class="indexvalue">MADHYAMAVATHI</td><td class="indexvalue">MELA_22</td></tr>
1202  <tr><td class="indexvalue">MOHANAM</td><td class="indexvalue">MELA_28</td></tr>
1203  <tr><td class="indexvalue">NEELAMBARI</td><td class="indexvalue">MELA_29</td></tr>
1204  </table>
1205  </td>
1206  </tr>
1207  </table>
1208  \endhtmlonly
1209 
1210 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.
1211 
1212 For further details on how to interoperate between Western and Carnatic style of music, refer \ref secInteroperation.
1213 
1214 \subsection subVoices Specifying Channels / Tracks
1215 Channels / Tracks are referred to as <i>voices</i> in CFugue. The tokens that start with character <b>V</b> are considered as voice tokens.
1216 
1217 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.
1218 
1219 By default, <i>V0</i> is implied at the beginning.
1220 
1221 Be noted that channels/tracks/voices play in parallel. For example, the MusicString <tt>CMAJ V1 CMIN</tt> plays CMAJ chord on channel 0 in <i>parallel</i> with CMIN chord on channel 1. Just because <tt>V1 CMIN</tt> comes <i>after</i> 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.
1222 
1223 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 <i>after</i> the CMAJ chord completes playing on channel 0, you need to insert a Rest note with sufficient duration on channel 1, something like <tt>CMAJ V1 R CMIN</tt>. This makes the Rest note play in parallel with CMAJ, effectively making CMIN play after CMAJ is completed.
1224 
1225 \section secInteroperation Interoperating Western and Carnatic Music
1226 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
1227 Carnatic music Swaras side by side with Western Notes, it is also possible to transform between
1228 the two notations with same ease.
1229 
1230 \note In addition, the same principles can be adapted for Hindustani music also to make it work side by side with Western music.
1231 
1232 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.
1233 */
1234 
1235 /////////////////////////////////////////////////////////////////
1236 // Future page
1237 /////////////////////////////////////////////////////////////////
1238 /*! \page pageFuture CFugue Future
1239 \section future The Future
1240 
1241 With CFugue still in its infancy, the future of Music Note programming is still shining bright upon it.
1242 The possibilities of what can be achieved through high-level MIDI note programming are endless. From
1243 automated Music analysis, recognition and generation to experimental cross genre Music research, all
1244 are going to benefit immesenly from this work. We have kept all the options open, to ensure we include
1245 the new developments in the work as and when we discover the scope for improvements.
1246 
1247 */
1248 
1249 /* Code that generates MIDI Note numbers for all notes
1250 #include <stdio.h>
1251 #include <stdlib.h>
1252 void main(int argc, char* argv[])
1253 {
1254  printf("\n<table>");
1255  printf("\n<tr><td align=\"center\" class=\"indexkey\">Octave</td><td align=\"center\" class=\"indexkey\">C<br>S</td> <td align=\"center\" class=\"indexkey\">C#/D<i>b</i><br>R1</td> <td align=\"center\" class=\"indexkey\">D<br>R2/G1</td> <td align=\"center\" class=\"indexkey\">D#/E<i>b</i><br>R3/G2</td><td align=\"center\" class=\"indexkey\">E<br>G3</td><td align=\"center\" class=\"indexkey\">F<br>M1</td><td align=\"center\" class=\"indexkey\">F#/G<i>b</i><br>M2</td><td align=\"center\" class=\"indexkey\">G<br>P</td><td align=\"center\" class=\"indexkey\">G#/A<i>b</i><br>D1</td><td align=\"center\" class=\"indexkey\">A<br>D2/N1</td><td align=\"center\" class=\"indexkey\">A#/B<i>b</i><br>N2</td><td align=\"center\" class=\"indexkey\">B<br>N3</td> </tr>");
1256 
1257  for(int octave=0, nMidiNumber=0; octave <= 10; ++octave)
1258  {
1259  printf("\n<tr> <td align=\"center\" class=\"indexkey\">%d</td>", octave);
1260  for(int halfstep = 0; halfstep <= 11; ++halfstep, nMidiNumber++)
1261  {
1262  if(nMidiNumber < 128) printf("\n\t<td align=\"center\" class=\"indexvalue\">%d</td>", nMidiNumber);
1263  }
1264  printf("\n</tr>");
1265  }
1266 
1267  printf("\n</table>\n");
1268 }
1269 */

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