The base40 system is a method for encoding pitches as integers in such a way that the diatonic interval with chromatic alteration is represented as the difference between any two numbers in the system. It can be used to encoding diatonic pitches names with chromatic alterations up to double sharps or flats. The base40 pitch space can be built up from the property that a minor second is a difference of 5 between two pitch numbers, and major seconds are a difference of 6. The C chroma value is set to the value 2 rather than 0 so that the octave values for C♭ and C♭♭ remain in the same octave as C♮ just above these pitches when using division by the base to extract the octave number. Here is a complete table of the base40 chroma, using C=2 as the reference:
Base40 chroma values (pitch classes) 
  
0  =  C♭♭ 
1  =  C♭ 
2  =  C♮ 
3  =  C♯ 
4  =  C♯♯ 

5  =  [D♭♭♭] 
6  =  D♭♭ 
7  =  D♭ 
8  =  D♮ 
9  =  D♯ 
10  =  D♯♯ 

11  =  [E♭♭♭] 
12  =  E♭♭ 
13  =  E♭ 
14  =  E♮ 
15  =  E♯ 
16  =  E♯♯ 

  
17  =  F♭♭ 
18  =  F♭ 
19  =  F♮ 
20  =  F♯ 
21  =  F♯♯ 

22  =  unused 
23  =  G♭♭ 
24  =  G♭ 
25  =  G♮ 
26  =  G♯ 
27  =  G♯♯ 

28  =  [A♭♭♭] 
29  =  A♭♭ 
30  =  A♭ 
31  =  A♮ 
32  =  A♯ 
33  =  A♯♯ 

34  =  [B♭♭♭] 
35  =  B♭♭ 
36  =  B♭ 
37  =  B♮ 
38  =  B♯ 
39  =  B♯♯ 

The "base40" name for the system refers to the property that an octave is represented by the integer 40. C4 is 162 while C5 is 162+40=202. To extract the octave number from a pitch value, just divide by 40. To extract the chroma from the pitch value, subtract the octave times 40.
octave = value / 40
chroma = value  octave * 40
To calculate an absolute pitch such as G4 (The G above middle C), multiply the octave by 40 and add the chroma value for the G pitchclass:
pitch = octave * 40 + chroma
G4 = 4 * 40 + 25 = 160 + 25 = 185
Alternatively, G4 can be calculated by adding 3 halfsteps (major seconds) and one minor second to C4 (represented as the number 162 in base40):
G4 = C4 + 3 * M2 + m2 = 162 + 3 * 6 + 5 = 162 + 23 = 185
Note that base40 pitch representations preserve chromatic alterations of diatonic pitchclasses (up to double sharps/flats). Therefore F♯4 (180) is not in the same as the base40 pitch G♭4 (184).
1 Intervals
A useful property of the base40 system is that the difference between pitch numbers in the base40 system represent onetoone mappings with diatonic intervals with chromatic alterations:
Base40 interval classes (d=diminished, m=minor, M=major, P=perfect, A=augmented) 
  
2  =  dd1 
1  =  d1 
0  =  P1 
1  =  A1 
2  =  AA1 
  

3  =  [dd2] 
4  =  d2 
5  =  m2 
6  =  M2 
7  =  A2 
8  =  AA2 
  

9  =  [dd3] 
10  =  d3 
11  =  m3 
12  =  M3 
13  =  A3 
14  =  AA3 
  

  
15  =  dd4 
16  =  d4 
17  =  P4 
18  =  A4 
19  =  AA4 
  

20  =  unused 
21  =  dd5 
22  =  d5 
23  =  P5 
24  =  A5 
25  =  AA5 
  

26  =  [dd6] 
27  =  d6 
28  =  m6 
29  =  M6 
30  =  A6 
31  =  AA6 
  

32  =  [dd7] 
33  =  d7 
34  =  m7 
35  =  M7 
36  =  A7 
37  =  AA7 
(40  =  octave) 

As an example, consider the interval between E4 (174) and C4 (162) which is 174162 = 12, representing a major third according to the table
shown above. All intervals can be constructed by observing that major seconds are 6 and minor seconds are 5, so note that a major third, consisting
of two major seconds, is 6 + 6 = 12. Below is an example segment of music with the pitches labeled in
the base40 system. Try subtracting values and comparing the results to numbers in the base40 intervalclass table above.
2 Transposition
Transposition of notes within the base40 system is simple: just add a constant interval to the base40 pitch numbers. Below is an example which transpose the music up a major second. In the base40 system, a major second is represented by the integer 6, so add 6 to all of the pitch numbers in the original music to transpose them up a major second.
3 References
4 Exercises