Friday, August 9, 2024

Working on music program - improving note frequencies

CALCULATED FREQUENCIES OF NOTES USING ORIGINAL PROGRAM VALUES

When I looked at the table of note values and fitted them to the desired note pitches, I saw that these were not ideal. The ratio of the counts for notes in the two octaves should be powers of two, but differed. For example, the bottom note which I believe is E, has a count of 213 but the middle E was 105 and the top E was 51 according to the program. 

RECALCULATED TO GET CLOSE TO CORRECT PITCHES

I put together a spreadsheet to calculate the frequency of the counter values in the program as the divider into the frequency of the inner loop at 17.5 KHz. I compared it to the correct pitch values for the notes and then calculated the closest integer to achieve the proper frequency. 

Pgm count

frequency

note

desired

new count

Integer

Ifreq

deviation

213

82.16

E

82.41

212.35

212

82.55

100.17%

201

87.06

F

87.31

200.44

200

87.50

100.22%

189

92.59

F#

92.5

189.19

189

92.59

100.10%

179

97.77

G

98

178.57

178

98.31

100.32%

169

103.55

Ab

103.83

168.54

168

104.17

100.32%

159

110.06

A

110

159.09

159

110.06

100.06%

150

116.67

Bb

116.54

150.16

150

116.67

100.11%

142

123.24

B

123.47

141.73

141

124.11

100.52%

134

130.60

C

130.81

133.78

133

131.58

100.59%

124

141.13

C#

138.59

126.27

126

138.89

100.22%

118

148.31

D

146.83

119.19

119

147.06

100.16%

111

157.66

Eb

155.56

112.50

112

156.25

100.44%

105

166.67

E

164.81

106.18

106

165.09

100.17%

99

176.77

F

174.61

100.22

100

175.00

100.22%

93

188.17

F#

185

94.59

94

186.17

100.63%

88

198.86

G

196

89.29

89

196.63

100.32%

83

210.84

Ab

207.65

84.28

84

208.33

100.33%

78

224.36

A

220

79.55

79

221.52

100.69%

74

236.49

Bb

233.08

75.08

75

233.33

100.11%

69

253.62

B

246.94

70.87

70

250.00

101.24%

65

269.23

C

261.63

66.89

66

265.15

101.35%

61

286.89

C#

277.18

63.14

63

277.78

100.22%

57

307.02

D

293.66

59.59

59

296.61

101.00%

54

324.07

Eb

311.13

56.25

56

312.50

100.44%

51

343.14

E

329.63

53.09

53

330.19

100.17%

As you can see, the worst note is only 1.35% off pitch while many are fractions of a percent. Since the speed of the IBM 1130 depends on the actual numerical value for operations like addition and subtraction, the time in the inner loop will be a bit fuzzy, drifting around the 17.5KHz rate. 

The new ratios are much closer to the powers of two they should be, with my three E notes at 53, 106 and 212. I coded using these new values as part of the port over to assembler and the demo monitor system. 

No comments:

Post a Comment