Skip to content

Source code for a simple command line program which calculates musical note duration in milliseconds. Currently only works on Linux as it depends on the argp.h header

Notifications You must be signed in to change notification settings

RiffLord/terminal-note-durations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

ms

ms is a simple command line program which calculates musical note duration in milliseconds. The program is intended to work like a typical command, with the user specifying a mandatory BPM value (as an integer or double) and two optional commands: one for a note value (supporting all values from a whole note to a two hundred fifty-sixth note) and one to specify that the note should be dotted. The syntax conforms to standard Linux commands with short and long options. Type ./ms --help or ./ms -? (omit the ./ if you have added the program to your PATH variable) to view the full list of options. If only the BPM value is provided the program will calculate the duration of a standard quarter note.

Purpose

The purpose of this program is to provide a quick and easy reference to the durations of standard note values. This information can be useful when setting the parameters of time-based effects such as reverb and delay so that the tails and echoes stay in sync with the tempo of one's composition (the greater your use of these effects the more this helps maintain a clear mix). Although many time-based effects (especially VST plugins) have options to sync to a track's tempo, sometimes you might want to fine tune to a specific amount for finer control.

Implementation

The program determines the duration of a note with a function that accepts a BPM value and a measure subdivision as parameters. It then returns the result of the following calculation as a double value, rounded to 2 decimal points:

  • (60000 / BPM) / subdivision

If no subdivision option is provided in input it calculates a quarter note (one beat) by default:

  • (60000 / BPM)

For shorter notes the subdivision parameter assumes values that are multiples of 2. For half and whole notes, subdivision assumes the values 0.5 and 0.25 respectively.

Installation

gcc is required to compile the program. Navigate to the directory where you compiled it and you can use the program (type ./ms --help to view information about the available commands).

For the program to be truly more useful than simply performing the calculation yourself or searching for answers online you should add it to your PATH variable:

  1. Navigate to the directory where you compiled the binary
  2. Type echo $PATH in your terminal. Choose a folder from the results to move or copy the program to (my recommendation is /usr/local/bin)
  3. Type sudo cp ms [target directory] (copy) or sudo mv ms [target directory] (move) to add the program to your path

Now you can just bring up a terminal any time and use it like all other Linux commands (./ no longer required: ms --help will get you started).

About

Source code for a simple command line program which calculates musical note duration in milliseconds. Currently only works on Linux as it depends on the argp.h header

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages