Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

Guitar chord API class

Guitar chord API class can be used to search for guitar chords using Guitar Chord API.

It can send HTTP request to the Guitar chord API Web server to find chord variations based on given data about chord by specifying the chord name, chord modification, or/and string/fret combination.

For more information check http://pargitaru.id.lv/api/.

Pargitaru.co.cc Chord Finder is an example website using this class

Contents

Download

Example codes

<?php 

include("./chord.php");
$chord = new chords();

    $chord->set_chord("C/E", true);
    //requesting json data, json is a default data 
    //output format, so no need pass it as a parameter(here just for example)
    //to get xml data use $chord->request("xml");
    $chord_data = $chord->request();
    //getting errors
    $errors = $chord->get_errors();
    //checking if there are any error
    if(!empty($errors))
    {
        foreach($errors as $error)
        {
            echo "<p>".$error."</p>";
        }
    }
    else
    {
        echo "<pre>";
        print_r($chord_data);
        echo "</pre>";
    }
?>

Examples in action

Example scripts provided with package in action:

Method list

Get supported modifications

Back to method list

Method nameget_modifications()
DescriptionReturns array with all supported chord modifications
Example output
Array
(
    [0] => minor
    [1] => major
    [2] => aug
    [3] => dim
    [4] => sus
    [5] => add9
    [6] => m6
    [7] => m7
    [8] => m9
    [9] => maj7
    [10] => maj9
    [11] => mmaj7
    [12] => -5
    [13] => 11
    [14] => 13
    [15] => 5
    [16] => 6
    [17] => 6add9
    [18] => 7
    [19] => 7-5
    [20] => 7maj5
    [21] => 7sus4
    [22] => 9
)

Get supported chord names

Back to method list

Method nameget_chords()
DescriptionReturns array with all supported chord names
Example output
Array
(
    [0] => C
    [1] => C#
    [2] => Db
    [3] => D
    [4] => D#
    [5] => Eb
    [6] => E
    [7] => F
    [8] => F#
    [9] => Gb
    [10] => G
    [11] => G#
    [12] => Ab
    [13] => A
    [14] => A#
    [15] => Bb
    [16] => B
)

Get supported special chord names

Back to method list

Method nameget_specials()
DescriptionReturns array with all supported special chord names
Example output
Array
(
    [0] => A/C#
    [1] => A/E
    [2] => A/F
    [3] => A/G
    [4] => A/G#
    [5] => Am/C
    [6] => Am/E
    [7] => Am/F
    [8] => Am/F#
    [9] => Am/G
	...
)

Set what modification to use

Back to method list

Method nameset_modification($value)
DescriptionSets modification for which to look
Input parametersstring $value - one of the values from get_modifications method
Example inputset_modification('minor')

Set what chord name to use

Back to method list

Method nameset_chord($value, $special = false)
DescriptionSets chord name for which to look
Input parameters

string $value - one of the values from get_chords method

boolean $special - if true, will look for special chords, if false - will look for standart chords

Example inputset_chord('C#')

Set what strings to use

Back to method list

Method nameset_strings($arr, $special = false)
DescriptionSets strings and frets for which to look
Input parameters

array $arr - specify strings and frets where array elements are string from thinnest string e to thickest string E and values are frets. To specify unused string, use "x" as value. If you don't know the fret for string, specify empty element - ""

Example inputset_strings(array(0,1,2,2,0,"x"), false)

Reset all parameters

Back to method list

Method namereset()
DescriptionEmpty all specified parameters to start searching from scratch

Get errors

Back to method list

Method nameget_errors()
DescriptionReturn array with all errors. Empty array returned if no errors occured

Perform search

Back to method list

Method namerequest($type = "json")
DescriptionPerform search request by all previuously specified parameters
Input parameters

string $type - what type to return, if json then array from json structure will be returned, if xml then array from xml structure will be returned. Json is default value for type.

Possible error messages

List of all errors and meanings

Error textMeaningSolution
Invalid chord modificationYou provided invalid chord modificationUse only modifications provided by get_modifications method
Invalid special chord nameYou provided invalid special chord nameUse only special chord names provided by get_specials method
Incorrect fret value. Frets can have values from 0 - 15 and value 'x' if fret is not usedYou provided invalid value or fretUse values from 0 to 15, or x if string is unused, or empty - '' if you don't know the fret for string
set_strings first parameter must be arrayYou provided invalid parameterYou must provide array, where array elements are string from thinnest string e to thickest string E and values are frets. For more information check set_strings method
No search criterias specifiedYou didn't specify any search criteria or used reset method before request methodYou must provide array, where array elements are string from thinnest string e to thickest string E and values are frets. For more information check set_strings method

Latest changes

None for now

Rate us

Like our script? Rate it at PHP > Hot Scripts

Scripts.com
RATE ME!

Try it out and Rate on PHPclasses.org

Support

PHP classes support forum or comments below


You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus