Skip to content

Calculates stop lengths, frequencies, intervals, harmonics, etc.

License

Notifications You must be signed in to change notification settings

extended-strings/strings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

strings

Build Status Scrutinizer Code Quality

Calculates string lengths, frequencies, intervals, harmonics, etc.

Example

<?php

require_once 'vendor/autoload.php';

use ExtendedStrings\Strings\HarmonicCalculator;
use ExtendedStrings\Strings\Instrument;
use ExtendedStrings\Strings\Note;

// Find all the possible harmonics on a violin for the sounding pitch D5.
$harmonics = (new HarmonicCalculator())
    ->findHarmonics(Note::fromName('D5'), Instrument::fromPreset('violin'));

foreach ($harmonics as $harmonic) {
    $string = $harmonic->getString();
    $stringNote = Note::fromFrequency($string->getFrequency());
    $baseNote = Note::fromFrequency($harmonic->getBaseStop()->getFrequency($string));
    $harmonicNote = Note::fromFrequency($harmonic->getHalfStop()->getFrequency($string));
    $soundingNote = Note::fromFrequency($harmonic->getSoundingFrequency());

    echo "String: $stringNote\n";
    if ($harmonic->isNatural()) {
        echo "  Harmonic pressure on: $harmonicNote\n";
    } else {
        echo "  Artificial harmonic: $baseNote : $harmonicNote\n";
    }
    echo "  Sounding pitch: $soundingNote\n";
    echo "\n";
}

Result:

String: D4
  Harmonic pressure on: D5
  Sounding pitch: D5

String: G3
  Harmonic pressure on: D5 +2c
  Sounding pitch: D5 +2c

String: G3
  Harmonic pressure on: D4 +2c
  Sounding pitch: D5 +2c

String: G3
  Artificial harmonic: D4 : D5
  Sounding pitch: D5

About

Calculates stop lengths, frequencies, intervals, harmonics, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages