castleraider

changeset 290:3d47f40dec57

Added a document discussing sound-related issues.
author David Boddie <david@boddie.org.uk>
date Sun Mar 30 19:57:12 2014 +0200
parents 2cfa1c17205f
children 789d97ee40d7
files documents/sound.txt
diffstat 1 files changed, 29 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/documents/sound.txt	Sun Mar 30 19:57:12 2014 +0200
     1.3 @@ -0,0 +1,29 @@
     1.4 +Sound
     1.5 +-----
     1.6 +
     1.7 +According to the Electron Advanced User Guide (page 212), the counter at 0xfe06
     1.8 +can be used to generate sounds when bit 1 of 0xfe07 is set. The formula for
     1.9 +calculating the frequency using the counter value, v, is as follows:
    1.10 +
    1.11 +    frequency = 1000000 / (16 * (v + 1)) Hz
    1.12 +
    1.13 +If we know the frequency we want, the value required can be determined using
    1.14 +the formula:
    1.15 +
    1.16 +    v = 1000000 / (16 * frequency) - 1
    1.17 +
    1.18 +According to Wikipedia [1], the first A above middle C is 440 Hz, so the value
    1.19 +required to generate this note is
    1.20 +
    1.21 +    v = 1000000 / (16 * 440) - 1
    1.22 +    v = 141
    1.23 +
    1.24 +We can generate values for many of the standard notes using another formula [2]
    1.25 +from Wikipedia:
    1.26 +
    1.27 +    f(n) = 2**((n - 49)/12) * 440 Hz
    1.28 +
    1.29 +where n = 49 is the first A above middle C, which is itself n = 40.
    1.30 +
    1.31 +[1] https://en.wikipedia.org/wiki/Scientific_pitch_notation
    1.32 +[2] https://en.wikipedia.org/wiki/Piano_key_frequencies