r/embedded•
ke151

Popular Tunes as List of Notes / Frequencies?

Off topic

Hi all, for a class I am taking, I had to come up with a function that takes input in Hz and plays the associated tone on a buzzer. I have completed my assignment, but was just curious if anyone knew of a good source for a list of notes or frequencies for popular tunes or songs. Just looking to see if I can add a quick little "Easter egg" / stretch goal for fun to the assignment.

Thanks in advance for any suggestions! I did try googling around some without great luck. I'm sure it can be figured out but no need to reinvent the wheel!

Posted Feb 2, 2020, 11:52 PM UTC

79
Ikkepop•

You could grab some midi tunes and grabbing the main melody with some midi editor

11
ke151OP•

Thanks for the suggestion I'll look into it!

2
CelloVerp•

Midi files are a nice source - not sure what language you're using, but if you're using python, https://mido.readthedocs.io/en/latest/ will read midi files, and it's very easy to iterate through the notes.

Note Frequency = 440Hz * 2^( (note - 69) / 12 )

where note is the midi note number (69 is the note number for A above middle C, whose frequency is 440Hz).

Timing is another challenge; let us know if you want help with that. There are easy tricks for that too.

10
ke151OP•

Thanks for the suggestion, link, and equation.

I am using ARM assembly for the assignment. My function does play a note for a customizable time and I also have a selectable wait duration function, so I should be able to semi-easily convert a midi to a series of frequency, duration, wait duration. Likely I'll just take the easy way out and hard code it step by step rather than try to develop yet another function that can take all those inputs - this was supposed to be quick and easy!

2
Allan-H•
4
ke151OP•

Thanks for the link, looks like a great source! I'll also have to play with beep in Linux for completeness.

1
Allan-H•

I had to

sudo modprobe pcspkr

to get beep to work on my laptop.

1
ke151OP•

Thanks for the tip. I know my laptop does have a speaker because it complains at me when I hit the wrong buttons trying to get to UEFI setup.

1
[deleted]•

[deleted]

1
SAI_Peregrinus•

https://thesession.org/tunes for Irish, mostly in ABC format (pretty easy to parse list of notes) and MIDI.

1