home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / s / sng829.zip / SNG829.CRD < prev   
Text File  |  1993-02-26  |  6KB  |  210 lines

  1.  
  2.  
  3.  BUG ALERT!  The previous posting of this program had a small error.
  4.  If you asked for a C dorian, you'd get a D dorian. All other modes
  5.  were shifted too. Here is the correct version:
  6.  
  7.  -------------------------------------------------------------------
  8.  
  9.  Here's a nifty little program I wrote to help guitar players learn
  10.  their scales.
  11.  
  12.  You specify the starting note and the mode (Ionian,Lydian, etc), and
  13.  it produces two diagrams.
  14.  
  15.    o  The first is just a picture of the guitar neck showing where the all
  16.       of the notes are.
  17.  
  18.    o  The second shows you where the notes are for the particular tonic/mode
  19.       that you desire.
  20.  
  21.  My Ibanez has 24 frets, but if you have fewer, you can easily modify
  22.  the program (just change MAXFRETS).
  23.  
  24.  You can also easily modify the program to produce scales for different
  25.  tunings by changing the "guitar" array. EX: for the King's X/Pearl
  26.  Jam/Sound Garden/Neil Young "D" tuning, set it to {4,11,7,2,9,2}
  27.  
  28.  With a little doing, you should be able to modify for instruments
  29.  with different number of stings (change MAXFRETS and fix draw_bound()
  30.  where it draws the "pearl inlays" on the neck).
  31.  
  32.      BE FOREWARNED! This can produce W I D E output!
  33.      columns required = 6 + 6 * MAXFRETS
  34.      Example: 6 + 6 * 24 frets = 150 columns needed.
  35.  
  36.  Good luck!
  37.  
  38. --------------------------------------------------------------------
  39.  
  40. #include <stdio.h>
  41.  
  42. /* Version 1.1   C dorian was really a D dorian, etc.   */
  43.  
  44. /* guitar_scales.c                                      */
  45. /* By William A. Huston                                 */
  46. /* huston@ap040.ti.com or  huston@mksol.dseg.ti.com     */
  47.  
  48. /* Submitted to the alt.guitar 3 Jun 92                 */
  49.  
  50. /* You are free to use/copy/modify, as long as you keep */
  51. /* all of these comments intact. Thanks and enjoy!      */
  52.  
  53. /* change this to be the number of frets desired.       */
  54. /* BE FOREWARNED! This can produce W I D E output!      */
  55. /* columns required = 6 + 6 * MAXFRETS                  */
  56. /* Example: 6 + 6 * 24 frets = 150 columns needed       */
  57.  
  58. #define MAXFRET 24
  59. #define STRING 6
  60.  
  61. char *note_text[12] =
  62.      { "  C  ",               /*   0   */
  63.                 "C#/Db",      /*   1   */
  64.        "  D  ",               /*   2   */
  65.                 "D#/Eb",      /*   3   */
  66.        "  E  ",               /*   4   */
  67.        "  F  ",               /*   5   */
  68.                 "F#/Gb",      /*   6   */
  69.        "  G  ",               /*   7   */
  70.                 "G#/Ab",      /*   8   */
  71.        "  A  ",               /*   9   */
  72.                 "A#/Bb",      /*   10   */
  73.        "  B  " };             /*   11   */
  74.  
  75.  
  76. /* change the following if you use a non-standard tuning */
  77. char guitar[STRING] = {4,11,7,2,9,4} ;     /* E=4 (hi), B=11, G,D,A,E (lo) */
  78.  
  79. char mode_start[7] = {0,2,4,5,7,9,11}  ;   /* intervals relative to tonic for ionian */
  80.  
  81. char *mode_text[7] = {"Ionian","Dorian","Phrygian",
  82.                       "Lydian","Mixolydian","Aeolian","Locrian"};
  83. char note_value[12];
  84.  
  85. void draw_bound(int string)
  86. {
  87.   int fret;
  88.       printf("\n     ");
  89.       for (fret =1; fret <= MAXFRET; fret ++)
  90.         {
  91.          if (((string == 2) && ((fret == 3 ) || (fret == 5 ) || (fret == 7 ) || (fret ==9 ) ||
  92.                                 (fret == 15) || (fret == 17) || (fret == 19) || (fret ==21)
  93.                                )
  94.              ) ||
  95.              (((string == 1) || (string == 3)) &&
  96.               ((fret == 12)  || (fret == 24))
  97.              )
  98.             )
  99.              printf("|=(*)=");        /* a pearl inlay! */
  100.          else
  101.              printf("|=====");
  102.         }
  103.     printf("|\n");
  104.  
  105. }
  106.  
  107.  
  108. /* draw the top line */
  109.  
  110. void draw_first()
  111. {
  112.   int fret;
  113.   printf("\n\n     ");
  114.   for (fret =1;fret <=MAXFRET;fret++)
  115.       printf("|=====");
  116.   printf("|\n");
  117.  
  118. }
  119.  
  120.  
  121. main(argc,argv)
  122. int argc;
  123. char *argv[];
  124. {
  125.   static int tonic = -1;
  126.   static int mode = -1;
  127.   char junk[100];
  128.  
  129.   int k,x,i,string,fret,crap;
  130.  
  131.   if (argc == 3)
  132.     {
  133.       sscanf(argv[1],"%d",&tonic);
  134.       sscanf(argv[2],"%d",&mode);
  135.     }
  136.  
  137.   while (tonic <0 || tonic >11)
  138.     {
  139.       for (x=0;x<12;x++)
  140.          printf ("\t\t%3d : %s\n",x,note_text[x]);
  141.       printf("\n  What tonic?  ");
  142.       gets(junk);
  143.       sscanf(junk,"%d",&tonic);
  144.       if (tonic <0 || tonic >11)
  145.           printf("*** %d is an invalid input!\n",tonic);
  146.         else
  147.           printf("The tonic you selected was %d (%s)\n",tonic,note_text[tonic]);
  148.     }
  149.  
  150.   while (mode <0 || mode >6)
  151.     {
  152.       for (x=0;x<7;x++)
  153.          printf ("\t\t%3d : %s\n",x,mode_text[x]);
  154.       printf("\n  What mode?  ");
  155.       gets(junk);
  156.       sscanf(junk,"%d",&mode);
  157.       if (mode <0 || mode >11)
  158.         printf("*** %d is an invalid input!\n",mode);
  159.     }
  160.  
  161.   printf("\nYou have picked a %s %s scale.\n\n",note_text[tonic],mode_text[mode]);
  162.  
  163.   k = mode_start[mode];
  164.  
  165.   for (x=0;x<7;x++)
  166.   {
  167.     i = mode_start[(x+mode) % 7]; 
  168.     printf("%2d: %s\n",x+1,note_text[(tonic+i-k+12) % 12]);
  169.     note_value[(tonic+i-k+12) % 12] = x + 1 ;
  170.   }
  171.  
  172.    /* print neck all notes */
  173.  
  174.   draw_first();
  175.   for (string =0; string <STRING; string++)
  176.     {
  177.       for (fret =0;fret <=MAXFRET;fret++)
  178.            printf("%s|",note_text[(guitar[string]+fret) % 12]);
  179.       draw_bound(string);
  180.     }
  181.   printf("\n\n     ");
  182.  
  183.   for (fret =1;fret <=MAXFRET ;fret++)
  184.       printf("  %2d  ",fret);
  185.   printf("\n");
  186.  
  187.   /* print scale on neck */
  188.  
  189.   draw_first();
  190.   for (string = 0; string <STRING; string++)
  191.     {
  192.       for (fret =0;fret <=MAXFRET;fret++)
  193.         {
  194.           if ( note_value[ (guitar[string]+fret) % 12 ])
  195.               printf("%3d  |",note_value[ (guitar[string]+fret) % 12 ]);
  196.             else
  197.               printf("     |");
  198.         }
  199.       draw_bound(string);
  200.     }
  201.  
  202. }
  203.  
  204.  
  205.  
  206. -- 
  207. Bill Huston      214-480-4610 
  208. Texas Instruments (Dallas/Forest Ln), ICC
  209. MSG: ZAPA    email: huston@ap040.csc.ti.com
  210.