Coder Social home page Coder Social logo

Question on code about moppy2 HOT 1 CLOSED

Besteciler avatar Besteciler commented on July 20, 2024
Question on code

from moppy2.

Comments (1)

Sammy1Am avatar Sammy1Am commented on July 20, 2024

Hi there, a reasonable question.

Musical notes are given note names or letters, and these names repeat each octave. So to differentiate between different octaves, a number can be added to the note name. For example, A4 is an octave above A3.

Musical notes each have a certain pitch or frequency. For example, an A4 has a frequency of 440Hz (i.e. if it was a sine wave, the wave would repeat 440 times per second). Going up an octave represents a doubling of frequency, so an A5 has a frequency of 880Hz.

Floppy drives generate notes by stepping their stepper motor at the desired frequency, but in code this is implemented by taking a step, waiting a certain amount of time, and then taking another step. The amount of time between steps is call the period, and is the inverse of frequency (i.e. 1/frequency). So the period of an A4 is 1/440 or 0.0022727... seconds.

Many micro controllers allow you keep track of time in microseconds, so these periods are converted to microseconds and stored in that array to be looked up. Essentially the array allows us to take an incoming note like C3 and determine that the motor should be stepped every 7645 microseconds.

from moppy2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.