Skip to content

Commit f5cdbd6

Browse files
committed
Describe arguments
1 parent 44a303f commit f5cdbd6

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

index.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
/**
22
* AudioBuffer class
3-
*
4-
* @module audio-buffer/buffer
53
*/
6-
7-
class AudioBuffer {
4+
export default class AudioBuffer {
5+
/**
6+
* Create AudioBuffer instance.
7+
* @constructor
8+
* @param {Object} options - buffer init options.
9+
* @param {number} options.length - buffer length in samples.
10+
* @param {number} options.sampleRate - buffer sample rate.
11+
* @param {number} options.numberOfChannels - number of channels.
12+
*/
813
constructor(options) {
914
if (!options) throw TypeError('options argument is required')
1015
if (!options.sampleRate) throw TypeError('options.sampleRate is required')
@@ -28,8 +33,8 @@ class AudioBuffer {
2833

2934
/**
3035
* Return data associated with the channel.
31-
*
32-
* @return {Array} Array containing the data
36+
* @param {number} channel - Channel index, starting from 0.
37+
* @return {Float32Array} Array containing the data.
3338
*/
3439
getChannelData (channel) {
3540
if (channel >= this.numberOfChannels || channel < 0 || channel == null) throw Error('Cannot getChannelData: channel number (' + channel + ') exceeds number of channels (' + this.numberOfChannels + ')');
@@ -39,7 +44,10 @@ class AudioBuffer {
3944

4045

4146
/**
42-
* Place data to the destination buffer, starting from the position
47+
* Place data to the destination buffer, starting from the position.
48+
* @param {Float32Array} destination - Destination array to write data to.
49+
* @param {number} channelNumber - Channel to take data from.
50+
* @param {number} startInChannel - Data offset in channel to read from.
4351
*/
4452
copyFromChannel (destination, channelNumber, startInChannel) {
4553
if (startInChannel == null) startInChannel = 0;
@@ -51,7 +59,10 @@ class AudioBuffer {
5159

5260

5361
/**
54-
* Place data from the source to the channel, starting (in self) from the position
62+
* Place data from the source to the channel, starting (in self) from the position.
63+
* @param {FlatArray | Array} source - source array to read data from.
64+
* @param {number} channelNumber - channel index to copy data to.
65+
* @param {number} startInChannel - offset in channel to copy data to.
5566
*/
5667
copyToChannel (source, channelNumber, startInChannel) {
5768
var data = this._channelData[channelNumber]
@@ -63,5 +74,3 @@ class AudioBuffer {
6374
}
6475
}
6576
}
66-
67-
export default AudioBuffer

test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ t('copyFromChannel', function (t) {
6161

6262
t.end()
6363
});
64+

0 commit comments

Comments
 (0)