Sammy1Am / MoppyClassic

Moppy has been replaced with Moppy 2.0!
568 stars 190 forks source link

Micro Period Calculations #161

Closed dmadison closed 7 years ago

dmadison commented 7 years ago

I'm not sure if the repository is still being maintained, but I'm working on some expansions of the Moppy code and I'm wondering: how were the "microPeriods" for the notes determined? Is there a formula you used?

Thanks for the help!

Sammy1Am commented 7 years ago

Not a lot of maintenance / contributions from myself for quite a while, but there's always a bit of activity.

The microPeriods are the period (time between wave peaks) of the MIDI note in microseconds. I used this table to determine the frequency for a particular note and followed this formula:

(1 / <frequency>) * 1000000 or just 1000000 / <frequency>

At MoppyPlayerOutput.java:84 , we're essentially dividing this period in half (so that the ticks happen twice as fast) because in the Arduino code each tick only toggles the state of the pin. In other words, we send an ON and an OFF once per calculated period.

dmadison commented 7 years ago

Awesome! Thanks for the quick response, that's all very clear.