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.
Pargitaru.co.cc Chord Finder is an example website using this class
Contents
- Download
- Example codes
- Examples in action
- Method list
- Possible error messages
- Latest changes
- Rate us
- Support
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
- Get supported chord names
- Get supported special chord names
- Set what modification to use
- Set what chord name to use
- Set what strings to use
- Reset all parameters
- Get errors
- Perform search
Get supported modifications
| Method name | get_modifications() |
| Description | Returns 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
| Method name | get_chords() |
| Description | Returns 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
| Method name | get_specials() |
| Description | Returns 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
| Method name | set_modification($value) |
| Description | Sets modification for which to look |
| Input parameters | string $value - one of the values from get_modifications method |
| Example input | set_modification('minor') |
Set what chord name to use
| Method name | set_chord($value, $special = false) |
| Description | Sets 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 input | set_chord('C#') |
Set what strings to use
| Method name | set_strings($arr, $special = false) |
| Description | Sets 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 input | set_strings(array(0,1,2,2,0,"x"), false) |
Reset all parameters
| Method name | reset() |
| Description | Empty all specified parameters to start searching from scratch |
Get errors
| Method name | get_errors() |
| Description | Return array with all errors. Empty array returned if no errors occured |
Perform search
| Method name | request($type = "json") |
| Description | Perform 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 text | Meaning | Solution |
| Invalid chord modification | You provided invalid chord modification | Use only modifications provided by get_modifications method |
| Invalid special chord name | You provided invalid special chord name | Use 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 used | You provided invalid value or fret | Use 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 array | You provided invalid parameter | You 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 specified | You didn't specify any search criteria or used reset method before request method | You 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
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










