hp41programs

Chords 564 Chords for the HP-41
 

Overview
 

-The following program ( actually 2 routines ) performs the Chords <> Notes conversion:
-"C-N" displays the notes of a given chord.
-"N-C" searches the chord(s) corresponding to ( 3 to 6 ) given notes without regard of order.

-"N-C" identifies 47 types of chords, namely ( for example in C ):

CMaj ,  CMin , C- , C/4 , C5+ , C5+ 9 , C5+ 9- , C5- , C6 , CMin6 , C7 , C7- , C7 5+ , C7 5- , CMin7 , CMin7+ , CMin7 5- , CMaj7 , CMaj7 5+
CMaj7 5- , C7/4 , CMin7/4 , C7/6 , CMin7/6 , CMaj7/6 , Cadd9 , CMinadd9 , C9 , CMin9 , C9 5+ , C9 5- , CMaj9 , CMin9 7+ , C9+ , C9- , C9- 5+
C9/6 , CMin9/6 , C11 , CMin11 , C11+ , CMaj11 , C13 , CMin13 , CMaj13 , C13 9- , C13 5-9-

-Other notations are sometimes used, for instance,    C13 (b5 b9) = C13 5-9- = thirteenth chord with diminished fifth and diminished ninth ...

-These chords are coded as follows:  we use the relations   A = 0 , Bb = 1 , B = 2 , ....... , Ab = 11 , A = 12 , .....
  Let's take for example A11 ( eleventh chord )

  A11 = A Db E G B D = 0 4 7 10 14 17  whence, modulo 12:   0 4 7 10 2 5  rearranged in increasing order:  0 2 4 5 7 10
  then we take the difference between 2 consecutive integers:   2-0 = 2 , 4-2 = 2 , 5-4 = 1 , 7-5 = 2 , 10-7 = 3
  which finally yields   22123   for eleventh chords   ( the dominant doesn't change the final result )
  22123 is the content of X-register at line 467 and similarly for the other chords.

-"C-N" finds the same chords, plus a few extra ones ...
 "C-N" will work if the left part of the alpha string ( after the dominant and a possible MAJ or MIN ) is one of the following symbols:
  13  11  11+  9  9+  9-  7  7+  7-  -  /4   5+  5-  and if the rest of the string only contains one ( or several ) of the characters:
   6  4  5+  5-  7+  7-  9  9+  9-  11+
 

Program Listing
 

Data Registers:  C-N:   R00 = dominant ;  R01 = 11th or 13th  ;  R02 = 9th ; R03 = 7th ; R04 = 6th ; R05 = 5th ; R06 = 4th ; R07 = 3rd ; R08 = 1
                              N-C:  R00 =  --------  ;  R01 to Rnn = the n notes of the chord ( n < 7 )
                              R09-R10-R11: temp
Flags: /
Subroutines: /

-Line   01 = LBL "C-N"           Chord >>>> Notes
-Line 177 = LBL "N-C"           Notes >>>> Chord(s)

-Lines 17 to 21 eliminate the possible spaces ( ASCII code = 32 ) at the left of the string.
-The characters different from  A B C D E F G # b are simply ignored.
-The "append" character is denoted ~
-Lines 255 to 271 sort the content of registers R01 thru Rnn in increasing order ( n = the number of notes )

-Line 310 may be replaced by    " "    ( 1 space )
-Line 361 may be replaced by    "7+ 5-"
-Line 373 may be replaced by     "7+"
-Line 377 may be replaced by     "7+ 5+"
-Line 392 may be replaced by     "7 5+9-"
-Line 420 may be replaced by      "9 7+"
-Line 445 may be replaced by      "7+/6"
-Line 465 may be replaced by     "11 7+"
-Line 476 may be replaced by     "13 7+"

-Line 502 is a three-byte GTO
 
 

  01  LBL "C-N"
  02  CLX
  03  STO 04
  04  STO 06
  05  SIGN
  06  STO 08
  07  11
  08  STO 03
  09  ST+ X
  10  STO 01
  11  15
  12  STO 02
  13  8
  14  STO 05
  15  5
  16  STO 07
  17  LBL 00
  18  32
  19  ATOX
  20  X=Y?
  21  GTO 00
  22  XEQ 05
  23  STO 00
  24  CLX
  25  LBL 01
  26  X#0?
  27  SIGN
  28  ST+ 00
  29  29 
  30  ATOX 
  31  X=Y?
  32  GTO 01
  33  98 
  34  X=Y?
  35  CHS
  36  X<0?
  37  GTO 01
  38  X<>Y
  39  XTOA
  40  SIGN
  41  CHS
  42  AROT
  43  ASTO 09
  44  ASHF
  45  ASTO 10
  46  "MIN"
  47  XEQ 08
  48  X#0?
  49  GTO 02
  50  3
  51  AROT
  52  ASTO 09
  53  ASHF
  54  ASTO 10
  55  DSE 07
  56  LBL 02
  57  "MAJ"
  58  XEQ 08
  59  X#0?
  60  GTO 02
  61  3
  62  AROT
  63  ASTO 09
  64  ASHF
  65  ASTO 10
  66  ISG 03
  67  LBL 02
  68  "13"
  69  XEQ 08
  70  X=0?
  71  GTO 02
  72  18
  73  STO 01
  74  "11"
  75  XEQ 08
  76  X=0?
  77  GTO 02
  78  CLX
  79  STO 01
  80  57 
  81  POSA
  82  X=0?
  83  GTO 02
  84  CLX
  85  STO 02        
  86  55 
  87  POSA
  88  0
  89  X#Y?
  90  STO 03
  91  LBL 02
  92  4
  93  "6"
  94  10
  95  XEQ 07
  96  "7-"
  97  XEQ 08
  98  45 
  99  POSA
100  *
101  X=0?
102  DSE 05
103  X=0?
104  DSE 07
105  52 
106  POSA
107  X<0?
108  GTO 02
109  6
110  STO 06
111  LBL 02
112  5
113  "5+"
114  9
115  XEQ 07
116  5
117  "5-"
118  7
119  XEQ 07
120  3
121  "7+"
122  12
123  XEQ 07
124  3
125  "7-"
126  10
127  XEQ 07
128  57
129  POSA
130  X<0?
131  GTO 02
132  15
133  STO 02
134  LBL 02
135  2
136  "9+"
137  16
138  XEQ 07
139  2
140  "9-"
141  14
142  XEQ 07
143  1
144  "11+"
145  19
146  XEQ 07
147  RCL 06
148  RCL 07
149  -
150  1
151  -
152  X=0?
153  STO 07
154  "7/6"
155  XEQ 08
156  X=0?
157  GTO 02
158  RCL 03
159  RCL 04
160  -
161  1
162  -
163  X=0?
164  STO 03
165  LBL 02
166  " " 
167  8
168  STO 09
169  LBL 03
170  RCL IND 09
171  X#0?
172  XEQ 06
173  DSE 09
174  GTO 03
175  TONE 9
176  PROMPT
177  LBL "N-C"
178  CLX
179  STO 07
180  LBL 04
181  ATOX
182  X=0?
183  GTO 02
184  98
185  X=Y?
186  DSE IND 07
187  CLX
188  29 
189  X=Y?
190  ISG IND 07
191  ENTER^
192  68
193  RCL Z
194  -
195  X^2
196  9
197  X<Y?
198  GTO 04
199  R^
200  XEQ 05
201  ISG 07
202  CLX
203  STO IND 07
204  GTO 04
205  LBL 05
206  .61
207  /
208  106
209  -
210  INT
211  RTN
212  LBL 06
213  RCL 00
214  +
215  12
216  MOD
217  STO 11
218  .59
219  *
220  65.1
221  +
222  XTOA
223  RCL 11
224  X=0?
225  "~b"
226  6
227  -
228  ABS
229  4
230  X=Y?
231  "~b"
232  SIGN
233  X=Y?
234  "~b" 
235  RTN
236  LBL 07
237  XEQ 08
238  X<0?
239  RTN
240  X<>Y
241  STO IND Z
242  RTN
243  LBL 08
244  ENTER^
245  ASTOX
246  CLA
247  ARCL 09
248  ARCL 10
249  POSA
250  RTN
251  LBL 02
252  RCL 07
253  STO 00
254  STO 08
255  LBL 09
256  RCL 00
257  RCL 00
258  RCL IND X
259  LBL 10
260  RCL IND Z
261  X>Y?
262  STO Z
263  X>Y?
264  +
265  RDN
266  DSE Z
267  GTO 10
268  X<> IND 00
269  STO IND Y
270  DSE 00
271  GTO 09
272  LBL 11
273  RCL 07
274  RCL 01
275  ST+ 00
276  LBL 12
277  ST- IND Y
278  DSE Y
279  GTO 12
280  RCL 07
281  .1
282  %
283  2
284  +
285  0
286  STO 09
287  LBL 13
288  10
289  *
290  RCL IND Y
291  ST+ Y
292  X<> 09
293  -
294  ISG Y
295  GTO 13
296  33
297  X=Y?
298  "-"
299  1
300  +
301  X=Y?
302  "MIN"
303  8
304  +
305  X=Y?
306  "5-"
307  1
308  +
309  X=Y?
310  "MAJ"
311  LASTX
312  +
313  X=Y?
314  "5+"
315  8
316  +
317  X=Y?
318  "/4"
319  82
320  +
321  X=Y?
322  "5+ 9-"
323  90
324  STO 09
325  +
326  X=Y?
327  "5+ 9"
328  DSE X
329  X=Y?
330  "add9"
331  9
332  -
333  X=Y?
334  "MINadd9"
335  CLX
336  334
337  X=Y?
338  "MIN7 5-"
339  DSE X
340  X=Y?
341  "7-"
342  9
343  +
344  X=Y?
345  "MIN6"
346  1
347  +
348  X=Y?
349  "MIN7"
350  LASTX        
351  +
352  X=Y?
353  "MIN7+"
354  80
355  +
356  X=Y?
357  "7 5-"
358  1
359  +
360  X=Y?
361  "MAJ7 5-"
362  7
363  +
364  X=Y?
365  "6"
366  1
367  +
368  X=Y?
369  "7"
370  LASTX
371  +
372  X=Y?
373  "MAJ7"
374  9
375  +
376  X=Y?
377  "MAJ7 5+"
378  DSE X
379  X=Y?
380  "7 5+"
381  81
382  +
383  X=Y?
384  "7/4"
385  810
386  +
387  X=Y?
388  "9-"
389  9
390  +
391  X=Y?
392  "9- 5+"
393  800
394  +
395  X=Y?
396  "MIN9/6"
397  1
398  +
399  X=Y?
400  "MIN9"
401  LASTX
402  +
403  X=Y?
404  "MIN9 7+"
405  80
406  +
407  X=Y?
408  "9 5-"
409  8
410  +
411  X=Y?
412  "9/6"
413  1
414  +
415  X=Y?
416  "9"
417  LASTX
418  +
419  X=Y?
420  "MAJ9"
421  8
422  +
423  X=Y?
424  "9 5+"
425  891
426  +
427  X=Y?
428  "9+"
429  RCL 09
430  +
431  X=Y?
432  "MIN7/4"
433  198
434  STO 10        
435  +
436  X=Y?
437  "MIN7/6"
438  900
439  +
440  X=Y?
441  "7/6"
442  1
443  +
444  X=Y?
445  "MAJ7/6"
446  8909
447  +
448  X=Y?
449  "13 5-9-"
450  RCL 09
451  +
452  X=Y?
453  "13 9-"
454  7902
455  +
456  X=Y?
457  "MIN11"
458  RCL 10
459  +
460  X=Y?
461  "MIN13"
462  703
463  +
464  X=Y?
465  "MAJ11"
466  DSE X
467  X=Y?
468  "11"
469  RCL 09
470  +
471  X=Y?
472  "11+"
473  109
474  +
475  X=Y?
476  "MAJ13"
477  DSE X
478  X=Y?
479  "13"
480  ALENG
481  X=0?
482  GTO 02
483  ASTO 09
484  ASHF
485  ASTO 10
486  " " 
487  1
488  XEQ 06
489  ARCL 09
490  ARCL 10
491  TONE 9
492  PROMPT
493  LBL 02
494  CLA
495  RCL 07
496  12
497  LBL 14
498  X<> IND Y
499  DSE Y
500  GTO 14
501  DSE 08
502  GTO 11
503  BEEP
504  END

 
    ( 934 bytes / SIZE 012 )
 
 

      STACK        INPUTS      OUTPUTS
           X             /             /

      All the inouts/outputs are in the alpha "register"
 
"C-N" examples:     Execution time = 20 to 50 seconds

    "CMAJ"         ( or simply "C" )         XEQ "C-N"  >>>>   ( TONE 9 )   " CEG"                     3 notes:  C E G
    "C-"                                                 XEQ "C-N"  >>>>   ( TONE 9 )   " CEbGb"                 3 notes:  C Eb Gb
    "D7-"                                               XEQ "C-N"  >>>>   ( TONE 9 )   " DFAbB"                4 notes:  D F Ab B
    "Bb5+ 9-"                                        XEQ "C-N"  >>>>   ( TONE 9 )   " BbDGbB"              4 notes:  Bb D Gb B
    "Aadd9"  ( or "A   9" )                      XEQ "C-N"  >>>>   ( TONE 9 )   " ADbEB"                4 notes:  A Db E B
    "A9"                                                 XEQ "C-N"  >>>>   ( TONE 9 )   " ADbEGB"             5 notes:  A Db E G B
    "C#13 5-9-"  ( or  "Db13 5-9-" )      XEQ "C-N"  >>>>   ( TONE 9 )   " DbFGBDBb"         6 notes:  Db F G B D Bb

-You can add space(s) at the left or the right of the alpha string or between 2 groups of symbols,
  for instance, you can key in:  "  CMAJ7  5+ " or " CMAJ75+" ,   but not  "C MAJ  7  5  +"
                                       and  "Bb5+   9-"  but  neither  "Bb  5  + 9-"  nor "B b 5+9-"
 

"N-C" examples:     Execution time = 17 to 80 seconds

    "CEG"                  XEQ "N-C"    >>>>  ( TONE 9 )     " CMAJ"
                                        R/S         >>>>     ( BEEP )            0                   ( no other chord )

    "DFAbB"             XEQ "N-C"    >>>>   ( TONE 9 )     " Ab7-"
                                        R/S         >>>>   ( TONE 9 )     " B7-"
                                        R/S         >>>>   ( TONE 9 )     " D7-"
                                        R/S         >>>>   ( TONE 9 )     " F7-"
                                        R/S         >>>>     ( BEEP )            0                   ( no other chord )

    "ABCDbG#Ab"   XEQ "N-C"    >>>>     ( BEEP )            0                   ( unknown chord )

    "A#EbbF#B"        XEQ "N-C"    >>>>   ( TONE 9 )    " Bb5+ 9-"
                                       R/S          >>>>   ( TONE 9 )    " BMIN7+"
                                       R/S          >>>>     ( BEEP )            0                   ( no other chord )

-Strictly speaking, "Bb5+ 9-" =  Bb D Gb B  and  "BMIN7+" =  B D Gb Bb  are not quite identical.
-Practically, however, they are usually obtained by the same fingerings on a guitar.
 

Notes:   ( I mean "remarks" )
 

-Don't key in more than 6 notes before executing "N-C". All these notes must be different.
-You can key in several b and several #  ( for instance  Bbb instead of A , C## instead of D )
-The character "#" ( alpha shift SIN ) doesn't appear very clearly on the HP-41 ( 35 XTOA would be better but not very easy to handle )
  if you want to replace it by another one, replace lines 29 and 188 by the corresponding ASCII code ( for example 100 or E2 if you replace "#" by "d" )
-If you use the notations "7+" , "9 7+" , "11 7+" , "13 7+" which are equivalent to
  "MAJ7" , "MAJ9" , "MAJ11" , "MAJ13"  respectively, lines 57 to 67 may be deleted.
-Several bytes can be saved if you omit some spaces ( for example line 449   "135-9-" instead of "13 5-9-" ) but the display is less legible.

-If you wish that "N-C" identifies another chord, say  MIN/4 , insert  CLX  322  X=Y?  "MIN/4"  after line 479
 ( the intervals between 2 consecutive notes of this chord are  3  2  2 )
-Similarly, if you want to delete one of the chords, say  MAJ7+ 5- , delete line 358 to 361 after replacing line 362 by 8 ( instead of 7 )
 so that the next content of X-register is unchanged.

-If you key in  "Cadd11"  XEQ "C-N"  you'll get  " CEG"  ( the "11" will not be taken into account )
-In order to identify this chord, add   1  "11"  18   XEQ 07   after line 146.