Bdanilko / EdPy

A compiler for a subset of python2 to be used on the Microbric Edison robot
GNU General Public License v2.0
18 stars 12 forks source link

Notes Ed.NOTE_x_y are wrong #8

Open PSLLSP opened 5 years ago

PSLLSP commented 5 years ago

Ed.PlayTone(note, duration) plays wrong tones. Ed.NOTE_x_y constants are wrong.

https://meetedison.com/content/EdPy-app-documentation-guide.pdf http://pages.mtu.edu/~suits/notefreqs.html

There is a formula in documentation how to calculate parameter tone from frequency. note = 8000000/freq, for freq 1kHz is calculated note 8000.

Ed.NOTE_C_7 has value 15289 and it should play frequency 2093Hz that is really C7. In the real, value 15289 plays frequency 523Hz, that is C5 (8000000/15289 is 253.25Hz).

I have no idea what is source of this confusion why C5 tone is marked as C7 tone.

    "Ed.NOTE_A_6": 18181,        # 1760 Hz, 18181 count
    "Ed.NOTE_A_SHARP_6": 17167,  # 1864 Hz, 17167 count
    "Ed.NOTE_B_SHARP_6": 17167,  # 1864 Hz, 17167 count, NAME KEPT FOR COMPATIBILITY
    "Ed.NOTE_B_6": 16202,        # 1975 Hz, 16202 count
    "Ed.NOTE_C_7": 15289,        # 2093 Hz, 15289 count
    "Ed.NOTE_C_SHARP_7": 14433,  # 2217 Hz, 14433 count
    "Ed.NOTE_D_7": 13622,        # 2349 Hz, 13622 count
    "Ed.NOTE_D_SHARP_7": 12856,  # 2489 Hz, 12856 count
    "Ed.NOTE_E_7": 12135,        # 2637 Hz, 12135 count
    "Ed.NOTE_E_SHARP_7": 12135,  # 2637 Hz, 12135 count, NAME KEPT FOR COMPATIBILITY
    "Ed.NOTE_F_7": 11457,        # 2793 Hz, 11457 count
    "Ed.NOTE_F_SHARP_7": 10814,  # 2959 Hz, 10814 count
    "Ed.NOTE_G_7": 10207,        # 3135 Hz, 10207 count
    "Ed.NOTE_G_SHARP_7": 9632,   # 3322 Hz, 9632 count
    "Ed.NOTE_A_7": 9090,         # 3520 Hz, 9090 count
    "Ed.NOTE_A_SHARP_7": 8581,   # 3729 Hz, 8581 count
    "Ed.NOTE_B_SHARP_7": 8581,   # 3729 Hz, 8581 count, NAME KEPT FOR COMPATIBILITY
    "Ed.NOTE_B_7": 8099,         # 3951 Hz, 8099 count
    "Ed.NOTE_C_8": 7644,         # 4186 Hz, 7644 count
    "Ed.NOTE_REST": 0,
BenMicrobr commented 5 years ago

Hi I'm Ben from Meet Edison

Edison was designed to be an affordable computer science learning tool for students at the earlier stages of their journey into coding. While we have always aimed to make Edison a powerful tool with a wide range of capabilities, in lots of ways, the ‘guts’ of Edison are incredibly simple. It appears there is an issue in the firmware that is playing lower notes than expected

However, as the note played is simply 2 octaves lower, and is still the same musical note (c5 and c7 are both c). This is not a major bug and will not be added to our bug backlog

Additionally, this repository is not the best place to report bugs and issues. We do not continuously monitor this repository. For future bugs and issues, please send them directly to us, via our contact form: https://meetedison.com/edison-robot-support/contact-us/

PSLLSP commented 5 years ago

Maybe that documentation is just not correct. I read again chapter related to Ed.PlayTone() and it has two formulas to calculate period, first parameter of PlayTone():

1) To convert a frequency into a period, divide the number 8,000,000 by the desired frequency. For example, to play a 1kHz (1000 cycles per second) sound: 8,000,000/1,000 = 8,000

2) To determine the period to use to exactly match the Ed.NOTE constants, divide the number 32,000,000 by the desired frequency of that musical note and use the result as the note input parameter.

Point 1) is at the begging and point 2) is at the end of the chapter. I tried to verify what is correct with Audacity software (audio editor), I used FFT filter and I think that first formula is correct and values for notes are really shifted.