Constructor
new SimpleFreesound(apiKey, storeSoundsInfoopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
apiKey |
String | Your api key, as generated from your freesound developer account when creating a new application. |
||
storeSoundsInfo |
Boolean |
<optional> |
false | Store all sounds detailed informations, including preview urls, to optimize the number of queries to the API (can be memory consuming). |
- Source:
Example
<script type="text/javascript" src="simple-freesound.min.js"></script>
<script type="text/javascript">
var apiKey = "your_freesound_api_key_goes_here";
var sf = new simpleFreesound.SimpleFreesound(apiKey);
sf.query({
search: [ 'drum', 'bass' ],
duration: [ 0.01, 1 ]
});
</script>
Members
soundsInfo
An object containing every detailed information obtained since
instantiation or last call to
.clear()
Properties:
Name | Type | Description |
---|---|---|
soundsInfo |
Object |
- Source:
currentSoundsInfo
An object containing the detailed information obtained from the last call to
,
query()
,
queryFromIds()
or
download()
.queryAndDownload()
Properties:
Name | Type | Description |
---|---|---|
currentSoundsInfo |
Object |
- Source:
buffers
Array of the buffers stored internally on download success, after call to
or
download()
.queryAndDownload()
Properties:
Name | Type | Description |
---|---|---|
buffers |
Array.AudioBuffer |
- Source:
Methods
query(queryParams) → {Promise}
Get a list of sound ids with detailed information, that correspond to a set of query parameters.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
queryParams |
Object | The parameters used to build the query. Properties
|
- Source:
Throws:
-
An error if a problem occurs during the query.
- Type
- Error
Returns:
A Promise object that resolves with the list of new sound ids if the query goes well.
- Type
- Promise
queryFromIds(ids) → {Promise}
Get detailed information of sounds from their ids.
Parameters:
Name | Type | Description |
---|---|---|
ids |
Array.Number | The ids of the sounds we want to get the detailed info of. |
- Source:
Throws:
-
An error if a problem occurs during the query.
- Type
- Error
Returns:
A promise that will resolve with an array of the sound ids the detailed info of which needed to be queried.
- Type
- Promise
download(idsopt) → {Promise}
Download hq mp3 previews from their sound ids.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ids |
Array.Number |
<optional> |
null | The ids of the sounds to download.
If |
- Source:
Throws:
-
An error if a problem occurs during the downloads.
- Type
- Error
Returns:
A promise that will resolve if the downloads go well.
- Type
- Promise
queryAndDownload(queryParams, destinationopt) → {Promise}
Download sounds hq mp3 previews from queried sound information.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
queryParams |
Object | The parameters used to build the query. Properties
|
||||||||||||||||||
destination |
String |
<optional> |
'.' | The folder in which to save the downloaded files. |
- Source:
Throws:
-
An error if a problem occurs during the downloads.
- Type
- Error
Returns:
A Promise object that resolves with an array of the
downloaded AndioBufferif
s the downloading go well.
- Type
- Promise
clear()
Clear the internal sound information lists.
- Source: