Music::Harmonics - Calculate harmonics for stringed instruments
Version 0.01
use Music::Harmonics; my $h = Music::Harmonics->new(); foreach (2..5) { my %harm = $h->GetStringHarmonic(name => 'E2', harmonic => $_); printf("Grab fret %i to play the harmonic #%i. It'll be a %s.\n", $harm{frets}->[0], $_, uc $harm{name}); }
This module calculates the note names and positions of harmonics and overtones. So far, it is limited to stringed instruments.
Note that the first harmonic is the foundational pitch, the second harmonic is the first overtone, and so on.
The pitch names used in this module are the sames as used by MIDI::Pitch.
my $h = Music::Harmonics->new(frets_per_octave => 12);
Creates a new Music::Harmonics object. The frets_per_octave parameter is optional and defaults to 12.
Music::Harmonics
frets_per_octave
my $f = $h->GetFret($position);
Given a position on the fingerboard between 0 and 1 (0 being directly at the nut, 1 being at the other end of the string at the bridge), returns the fret number as a float (assuming even intonation). For example, 0.5 refers to the middle of the string, so that GetFret(0.5) on an instrument with 12 frets per octave returns 12.
0.5
GetFret(0.5)
%harm = $h->GetStringHarmonic(name => 'E2', harmonic => 2, minfret => 0, maxfret => 12);
Returns the positions where a certain harmonic can be played. minfret and maxfret are optional, their default values are 0 and 12 respectively.
minfret
maxfret
The result is a hash. name gives the name of the harmonic, frequency the frequency and frets is a list of fret positions.
name
frequency
frets
$h->GetStringHarmonics(name => 'E2', minharmonic => 2, maxharmonic => 6);
Retrieves a list of harmonics from minharmonic to maxharmonic.
minharmonic
maxharmonic
MIDI::Pitch
Christian Renz, <crenz @ web42.com>
Please report any bugs or feature requests to bug-music-harmonics@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Music-Harmonics. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-music-harmonics@rt.cpan.org
Copyright 2005 Christian Renz <crenz @ web42.com>, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Music::Harmonics, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Music::Harmonics
CPAN shell
perl -MCPAN -e shell install Music::Harmonics
For more information on module installation, please visit the detailed CPAN module installation guide.