|
freesound-juce
A JUCE client for accessing the Freesound API
|
The Freesound client class which is responsible for all authorization and requests to the Freesound API. More...
#include <FreesoundAPI.h>
Public Member Functions | |
| FreesoundClient () | |
| Empty construtctor. More... | |
| FreesoundClient (String secret) | |
| Constructor for token based authorization. More... | |
| FreesoundClient (String id, String secret) | |
| Constructor for OAuth2 authorization. More... | |
| void | authenticationOnBrowser (int mode=0, Callback cb=[] {}) |
| Performs the first step of the authorization on the browser. More... | |
| void | exchangeToken (String authCode, Callback cb=[] {}) |
| Exchange token is the 3rd step of the authorization proccess, where the authorization code is exchanged for an access token. More... | |
| void | refreshAccessToken (Callback cb=[] {}) |
| Function for refreshing the access token, which expires in 24h. More... | |
| SoundList | textSearch (String query, String filter=String(), String sort="score", int groupByPack=0, int page=-1, int pageSize=-1, String fields=String(), String descriptors=String(), int normalized=0) |
| This resource allows searching sounds in Freesound by matching their tags and other kinds of metadata. More... | |
| SoundList | contentSearch (String target, String descriptorsFilter=String(), int page=-1, int pageSize=-1, String fields=String(), String descriptors=String(), int normalized=0) |
| Content search. More... | |
| FSList | fetchNextPage (FSList fslist) |
| Gets the next page of a SoundList. More... | |
| FSList | fetchPreviousPage (FSList fslist) |
| Gets the previous page of a FSList. More... | |
| SoundList | fetchNextPage (SoundList fslist) |
| Gets the next page of a SoundList. More... | |
| SoundList | fetchPreviousPage (SoundList fslist) |
| Gets the previous page of a SoundList. More... | |
| FSSound | getSound (String id, String fields=String()) |
| Gets a sound instance from its id. More... | |
| var | getSoundAnalysis (String id, String descriptors=String(), int normalized=0) |
| Retrieves of analysis information (content-based descriptors) of a sound. More... | |
| SoundList | getSimilarSounds (String id, String descriptorsFilter=String(), int page=-1, int pageSize=-1, String fields=String(), String descriptors=String(), int normalized=0) |
| This resource allows the retrieval of sounds similar to the given sound target. More... | |
| URL::DownloadTask * | downloadSound (FSSound sound, const File &location, URL::DownloadTask::Listener *listener=nullptr) |
| This resource allows you to download a sound in its original format/quality. More... | |
| int | uploadSound (const File &fileToUpload, String tags, String description, String name=String(), String license="Creative Commons 0", String pack=String(), String geotag=String(), Callback cb=[] {}) |
| Uploads a sound to Freesound. More... | |
| int | describeSound (String uploadFilename, String description, String license, String name=String(), String tags=String(), String pack=String(), String geotag=String()) |
| Describe sound. More... | |
| var | pendingUploads () |
| This resource allows you to retrieve a list of audio files uploaded by the Freesound user logged in using OAuth2 that have not yet been described, processed or moderated. More... | |
| void | editSoundDescription (String id, String name=String(), String tags=String(), String description=String(), String license=String(), String pack=String(), String geotag=String(), Callback cb=[] {}) |
| Edit sound description. More... | |
| void | bookmarkSound (String id, String name=String(), String category=String(), Callback cb=[] {}) |
| This resource allows you to bookmark an existing sound. More... | |
| void | rateSound (String id, int rating, Callback cb=[] {}) |
| This resource allows you to rate an existing sound. More... | |
| void | commentSound (String id, String comment, Callback cb=[] {}) |
| This resource allows you to post a comment to an existing sound. More... | |
| FSUser | getUser (String user) |
| This resource allows the retrieval of information about a particular Freesound user. More... | |
| SoundList | getUserSounds (String username, String descriptorsFilter=String(), int page=-1, int pageSize=-1, String fields=String(), String descriptors=String(), int normalized=0) |
| This resource allows the retrieval of a list of sounds uploaded by a particular Freesound user. More... | |
| FSList | getUserBookmarkCategories (String username) |
| This resource allows the retrieval of a list of bookmark categories created by a particular Freesound user. More... | |
| FSList | getUserBookmarkCategoriesSounds (String username, String bookmarkCategory) |
| This resource allows the retrieval of a list of sounds from a bookmark category created by a particular Freesound user. More... | |
| FSList | getUserPacks (String username) |
| This resource allows the retrieval of a list of packs created by a particular Freesound user. More... | |
| FSPack | getPack (String id) |
| This resource allows the retrieval of a list of packs created by a particular Freesound user. More... | |
| SoundList | getPackSounds (String id, String descriptorsFilter=String(), int page=-1, int pageSize=-1, String fields=String(), String descriptors=String(), int normalized=0) |
| This resource allows the retrieval of information about a pack. More... | |
| URL::DownloadTask * | downloadPack (FSPack pack, const File &location, URL::DownloadTask::Listener *listener=nullptr) |
| This resource allows you to download all the sounds of a pack in a single zip file. More... | |
| FSUser | getMe () |
| Returnes a FSUser instance of the authenticated user. More... | |
| bool | isTokenNotEmpty () |
| Queries if the token is not empty. More... | |
| String | getToken () |
| Gets the authentication token. More... | |
| String | getHeader () |
| Gets the authentication header. More... | |
| String | getClientID () |
| Gets client identifier. More... | |
The Freesound client class which is responsible for all authorization and requests to the Freesound API.
| FreesoundClient::FreesoundClient | ( | ) |
Empty construtctor.
| FreesoundClient::FreesoundClient | ( | String | secret | ) |
Constructor for token based authorization.
| secret | The client secret. |
| FreesoundClient::FreesoundClient | ( | String | id, |
| String | secret | ||
| ) |
Constructor for OAuth2 authorization.
| id | The client ID. |
| secret | The client secret. |
| void FreesoundClient::authenticationOnBrowser | ( | int | mode = 0, |
| Callback | cb = [] {} |
||
| ) |
Performs the first step of the authorization on the browser.
| mode | (Optional) The login mode 0 = logout and authorize, 1 = authorize. |
| cb | (Optional) The callback function called in the end of the function. |
| void FreesoundClient::bookmarkSound | ( | String | id, |
| String | name = String(), |
||
| String | category = String(), |
||
| Callback | cb = [] {} |
||
| ) |
This resource allows you to bookmark an existing sound.
| id | The sound identifier. |
| name | (Optional) The new name that will be given to the bookmark |
| category | (Optional) The name of the category under the bookmark will be classified. |
| cb | (Optional) The callback function called in the end of the function. |
| void FreesoundClient::commentSound | ( | String | id, |
| String | comment, | ||
| Callback | cb = [] {} |
||
| ) |
This resource allows you to post a comment to an existing sound.
| id | The sound identifier. |
| comment | Comment for the sound. |
| cb | (Optional) The callback function called in the end of the function. |
| SoundList FreesoundClient::contentSearch | ( | String | target, |
| String | descriptorsFilter = String(), |
||
| int | page = -1, |
||
| int | pageSize = -1, |
||
| String | fields = String(), |
||
| String | descriptors = String(), |
||
| int | normalized = 0 |
||
| ) |
Content search.
| target | Target for the content search. |
| descriptorsFilter | (Optional) This parameter allows filtering query results by values of the content-based descriptors. |
| page | (Optional) Query results are paginated, this parameter indicates what page should be returned. |
| pageSize | (Optional) Indicates the number of sounds per page to include in the result. |
| fields | (Optional) Indicates which sound properties should be included in every sound of the response. |
| descriptors | (Optional) Indicates which sound content-based descriptors should be included in every sound of the response. |
| normalized | (Optional) Indicates whether the returned sound content-based descriptors should be normalized or not. |
| int FreesoundClient::describeSound | ( | String | uploadFilename, |
| String | description, | ||
| String | license, | ||
| String | name = String(), |
||
| String | tags = String(), |
||
| String | pack = String(), |
||
| String | geotag = String() |
||
| ) |
Describe sound.
| uploadFilename | The filename of the sound to describe. |
| description | A textual description of the sound. |
| license | The license of the sound. Must be either “Attribution”, “Attribution Noncommercial” or “Creative Commons 0”. |
| name | (Optional) The name that will be given to the sound. If not provided, filename will be used. |
| tags | (Optional) The tags that will be assigned to the sound. Separate tags with spaces and join multi-words with dashes (e.g. “tag1 tag2 tag3 cool-tag4”). |
| pack | (Optional) The name of the pack where the sound should be included. |
| geotag | (Optional) Geotag information for the sound. |
| URL::DownloadTask * FreesoundClient::downloadPack | ( | FSPack | pack, |
| const File & | location, | ||
| URL::DownloadTask::Listener * | listener = nullptr |
||
| ) |
This resource allows you to download all the sounds of a pack in a single zip file.
| pack | The desored pack. | |
| location | The location fpr the download. | |
| [in,out] | listener | (Optional) If non-null, the download task listener. |
| URL::DownloadTask * FreesoundClient::downloadSound | ( | FSSound | sound, |
| const File & | location, | ||
| URL::DownloadTask::Listener * | listener = nullptr |
||
| ) |
This resource allows you to download a sound in its original format/quality.
| sound | The sound to be downloaded. | |
| location | The location for the sound to be download. | |
| [in,out] | listener | (Optional) If non-null, the listener for the download progress. |
| void FreesoundClient::editSoundDescription | ( | String | id, |
| String | name = String(), |
||
| String | tags = String(), |
||
| String | description = String(), |
||
| String | license = String(), |
||
| String | pack = String(), |
||
| String | geotag = String(), |
||
| Callback | cb = [] {} |
||
| ) |
Edit sound description.
| id | The identifier of the sound. |
| name | (Optional) The new name that will be given to the sound. |
| tags | (Optional) The new tags that will be assigned to the sound. |
| description | (Optional) The new textual description for the sound. |
| license | (Optional) The new license of the sound. Must be either “Attribution”, “Attribution Noncommercial” or “Creative Commons 0”. |
| pack | (Optional) The new name of the pack where the sound should be included. |
| geotag | (Optional) The new geotag information for the sound. |
| cb | (Optional) The callback function called in the end of the function. |
| void FreesoundClient::exchangeToken | ( | String | authCode, |
| Callback | cb = [] {} |
||
| ) |
Exchange token is the 3rd step of the authorization proccess, where the authorization code is exchanged for an access token.
| authCode | The authentication code. |
| cb | (Optional) The callback function called in the end of the function. |
| String FreesoundClient::getClientID | ( | ) |
Gets client identifier.
| String FreesoundClient::getHeader | ( | ) |
Gets the authentication header.
| FSUser FreesoundClient::getMe | ( | ) |
| FSPack FreesoundClient::getPack | ( | String | id | ) |
This resource allows the retrieval of a list of packs created by a particular Freesound user.
| id | The username of the user. |
| SoundList FreesoundClient::getPackSounds | ( | String | id, |
| String | descriptorsFilter = String(), |
||
| int | page = -1, |
||
| int | pageSize = -1, |
||
| String | fields = String(), |
||
| String | descriptors = String(), |
||
| int | normalized = 0 |
||
| ) |
This resource allows the retrieval of information about a pack.
| id | The identifier of the pack. |
| descriptorsFilter | (Optional) This parameter allows filtering query results by values of the content-based descriptors. |
| page | (Optional) Query results are paginated, this parameter indicates what page should be returned. |
| pageSize | (Optional) Indicates the number of sounds per page to include in the result. |
| fields | (Optional) Indicates which sound properties should be included in every sound of the response. |
| descriptors | (Optional) Indicates which sound content-based descriptors should be included in every sound of the response. |
| normalized | (Optional) Indicates whether the returned sound content-based descriptors should be normalized or not. |
| SoundList FreesoundClient::getSimilarSounds | ( | String | id, |
| String | descriptorsFilter = String(), |
||
| int | page = -1, |
||
| int | pageSize = -1, |
||
| String | fields = String(), |
||
| String | descriptors = String(), |
||
| int | normalized = 0 |
||
| ) |
This resource allows the retrieval of sounds similar to the given sound target.
| id | The id of the target sound. |
| descriptorsFilter | (Optional) This parameter allows filtering query results by values of the content-based descriptors. |
| page | (Optional) Query results are paginated, this parameter indicates what page should be returned. |
| pageSize | (Optional) Indicates the number of sounds per page to include in the result. |
| fields | (Optional) Indicates which sound properties should be included in every sound of the response. |
| descriptors | (Optional) Indicates which sound content-based descriptors should be included in every sound of the response. |
| normalized | (Optional) Indicates whether the returned sound content-based descriptors should be normalized or not. |
| FSSound FreesoundClient::getSound | ( | String | id, |
| String | fields = String() |
||
| ) |
Gets a sound instance from its id.
| id | The sound’s unique identifier. |
| fields | (Optional) Indicates which sound properties should be included in every sound of the response. |
| var FreesoundClient::getSoundAnalysis | ( | String | id, |
| String | descriptors = String(), |
||
| int | normalized = 0 |
||
| ) |
Retrieves of analysis information (content-based descriptors) of a sound.
| id | The sound’s unique identifier. |
| descriptors | (Optional) Indicates which sound content-based descriptors should be included in every sound of the response. |
| normalized | (Optional) Indicates whether the returned sound content-based descriptors should be normalized or not. |
| String FreesoundClient::getToken | ( | ) |
Gets the authentication token.
| FSUser FreesoundClient::getUser | ( | String | user | ) |
This resource allows the retrieval of information about a particular Freesound user.
| user | The username of the user. |
| FSList FreesoundClient::getUserBookmarkCategories | ( | String | username | ) |
This resource allows the retrieval of a list of bookmark categories created by a particular Freesound user.
| username | The username of the user. |
| FSList FreesoundClient::getUserBookmarkCategoriesSounds | ( | String | username, |
| String | bookmarkCategory | ||
| ) |
This resource allows the retrieval of a list of sounds from a bookmark category created by a particular Freesound user.
| username | The username of the user. |
| bookmarkCategory | The desired bookmark category. |
| FSList FreesoundClient::getUserPacks | ( | String | username | ) |
This resource allows the retrieval of a list of packs created by a particular Freesound user.
| username | The username of the user. |
| SoundList FreesoundClient::getUserSounds | ( | String | username, |
| String | descriptorsFilter = String(), |
||
| int | page = -1, |
||
| int | pageSize = -1, |
||
| String | fields = String(), |
||
| String | descriptors = String(), |
||
| int | normalized = 0 |
||
| ) |
This resource allows the retrieval of a list of sounds uploaded by a particular Freesound user.
| username | The username of the user. |
| descriptorsFilter | (Optional) This parameter allows filtering query results by values of the content-based descriptors. |
| page | (Optional) Query results are paginated, this parameter indicates what page should be returned. |
| pageSize | (Optional) Indicates the number of sounds per page to include in the result. |
| fields | (Optional) Indicates which sound properties should be included in every sound of the response. |
| descriptors | (Optional) Indicates which sound content-based descriptors should be included in every sound of the response. |
| normalized | (Optional) Indicates whether the returned sound content-based descriptors should be normalized or not. |
| bool FreesoundClient::isTokenNotEmpty | ( | ) |
Queries if the token is not empty.
| var FreesoundClient::pendingUploads | ( | ) |
This resource allows you to retrieve a list of audio files uploaded by the Freesound user logged in using OAuth2 that have not yet been described, processed or moderated.
| void FreesoundClient::rateSound | ( | String | id, |
| int | rating, | ||
| Callback | cb = [] {} |
||
| ) |
This resource allows you to rate an existing sound.
| id | The sound identifier. |
| rating | Integer between 0 and 5 (both included) representing the rating for the sound. |
| cb | (Optional) The callback function called in the end of the function. |
| void FreesoundClient::refreshAccessToken | ( | Callback | cb = [] {} | ) |
Function for refreshing the access token, which expires in 24h.
| cb | (Optional) The callback function called in the end of the function. |
| SoundList FreesoundClient::textSearch | ( | String | query, |
| String | filter = String(), |
||
| String | sort = "score", |
||
| int | groupByPack = 0, |
||
| int | page = -1, |
||
| int | pageSize = -1, |
||
| String | fields = String(), |
||
| String | descriptors = String(), |
||
| int | normalized = 0 |
||
| ) |
This resource allows searching sounds in Freesound by matching their tags and other kinds of metadata.
| query | The text query. |
| filter | (Optional) Allows filtering query results. |
| sort | (Optional) Indicates how query results should be sorted. |
| groupByPack | (Optional) This parameter represents a boolean option to indicate whether to group packs in a single result |
| page | (Optional) Query results are paginated, this parameter indicates what page should be returned. |
| pageSize | (Optional) Indicates the number of sounds per page to include in the result. |
| fields | (Optional) Indicates which sound properties should be included in every sound of the response. |
| descriptors | (Optional) Indicates which sound content-based descriptors should be included in every sound of the response. |
| normalized | (Optional) Indicates whether the returned sound content-based descriptors should be normalized or not. |
| int FreesoundClient::uploadSound | ( | const File & | fileToUpload, |
| String | tags, | ||
| String | description, | ||
| String | name = String(), |
||
| String | license = "Creative Commons 0", |
||
| String | pack = String(), |
||
| String | geotag = String(), |
||
| Callback | cb = [] {} |
||
| ) |
Uploads a sound to Freesound.
| fileToUpload | The file to upload. |
| tags | The tags that will be assigned to the sound. Separate tags with spaces and join multi-words with dashes (e.g. “tag1 tag2 tag3 cool-tag4”). |
| description | A textual description of the sound. |
| name | (Optional) The name that will be given to the sound. If not provided, filename will be used. |
| license | (Optional) The license of the sound. Must be either “Attribution”, “Attribution Noncommercial” or “Creative Commons 0”. |
| pack | (Optional) The name of the pack where the sound should be included. |
| geotag | (Optional) Geotag information for the sound. |
| cb | (Optional) The callback function called in the end of the function. |
1.8.16