Code covered by the BSD License
-
music.freq2cent(f1,f2)
MUSIC.FREQ2CENT Returns the number of cents between two frequencies.
-
music.freq2interval(f,key)
MUSIC.FREQ2INTERVAL Returns the interval and octave of a frequency.
-
music.freq2note(f)
MUSIC.FREQ2NOTE converts a frequency to a note string.
-
music.freq2tone(f)
MUSIC.FREQ2TONE converts a frequency to a musical semitone.
-
music.interval2freq(I,O,key)
MUSIC.INTERVAL2FREQ returns the frequency of a musical interval.
-
music.interval2note(I,O,key,a...
MUSIC.INTERVAL2NOTE returns a note string in scientific pitch notation.
-
music.interval2tone(I,O,key)
MUSIC.INTERVAL2TONE returns the absolute musical semitone of an interval.
-
music.note2cent(N1,N2)
MUSIC.NOTE2CENT Returns the number of cents between notes.
-
music.note2freq(N)
MUSIC.NOTE2FREQ Converts a scientific pitch note to a frequency.
-
music.note2interval(N,key)
MUSIC.NOTE2INTERVAL Converts a note string to a semitone interval and octave.
-
music.note2tone(N)
MUSIC.NOTE2TONE Converts a scientific pitch note to a tone relative to C4.
-
music.tone2cent(t1,t2)
MUSIC.TONE2CENT Returns the number of cents between two semitones.
-
music.tone2freq(T)
MUSIC.TONE2FREQ converts a musical semitone to a frequency.
-
music.tone2interval(T,key)
MUSIC.TONE2INTERVAL Returns the interval and octave of notes in a key.
-
music.tone2note(T,accsym)
MUSIC.TONE2NOTE Converts a musical semitone to a character note.
-
examples.m
-
Music function examples
-
View all files
from
Musical Notes
by Eric Johnson
Collection of functions for working with musical notes, intervals, frequencies, and cents.
|
| examples.m |
%% Music function examples
% The MUSIC package directory contains a collection of utility functions for
% converting between different musical measures. You can convert between
% frequencies, tones, and character notes. There are also functions for
% calculating the number of cents between two notes.
% Copyright 2010 The MathWorks, Inc.
%% Scientific Pitch Notation
% Scientific pitch notation is a character-based method of specifying a note.
% There are two parts: the note and the octave. For example, middle C on the
% piano 'C4' and the low E string on a guitar is 'E2'.
notes = {'C3', 'A3', 'A4', 'Bb6'}
%% Semitones
% A semitone is equal to one half-step. For example, A# is one semitone above A.
% Semitones can also specify an absolute note. In this package, the term
% 'semitone' means the number of half-steps above or below C4. C4 is 'middle C'
% on a piano and is a common musical reference datum.
tones = music.note2tone(notes)
%% Frequency
% The frequency of a note doubles every octave. For example A3 is 220 Hz and
% A4 is 440 Hz.
freqs = music.note2freq(notes)
%% Musical Interval
% The formats above are ways of specifying absolute pitches. In music theory
% however the most important characteristic of a note is its position in a key.
% C3 and C4 are different frequencies but they can be substituted for each
% other in a musical phrase. The passage will still sound correct and pleasing
% to the ear (assuming it was pleasing to begin with!).
%
% In this representation we derive the interval of a note within a given key, as
% well as the absolute octave it occurs in.
[intervalsC,octavesC] = music.note2interval(notes,'C') % key of 'C'
[intervalsG,octavesG] = music.note2interval(notes,'G') % key of 'G'
%% Centitones
% A cent is a logarithmic measure of note spacing. A semitone is equal to 100
% cents and there are 1200 cents in an octave. They are frequently used when
% tuning instruments as a measure of how close a pitch is to the correct
% frequency. For example, a guitar string can be considered tuned if it is
% within +/- 10 cents of the correct pitch.
cents = music.note2cent('C4',notes)
|
|
Contact us at files@mathworks.com