-
-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added feature of manually setting "BUFFERSIZE" in amplitude analysis #419
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,10 +47,10 @@ define(function (require) { | |
* | ||
* </code></div> | ||
*/ | ||
p5.Amplitude = function(smoothing) { | ||
p5.Amplitude = function(smoothing, bufferSize = 2048) { | ||
|
||
// Set to 2048 for now. In future iterations, this should be inherited or parsed from p5sound's default | ||
this.bufferSize = safeBufferSize(2048); | ||
this.bufferSize = safeBufferSize(bufferSize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the comment above this line should be deleted or updated. I'm curious if you considered the other options mentioned in the comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @therewasaguy |
||
|
||
// set audio context | ||
this.audiocontext = p5sound.audiocontext; | ||
|
@@ -290,6 +290,21 @@ define(function (require) { | |
} | ||
}; | ||
|
||
/** | ||
* bufferSize of Amplitude | ||
* @method setBufferSize | ||
* @for p5.Amplitude | ||
* @param {Number} set bufferSize to any value multiple of 2 | ||
*/ | ||
|
||
p5.Amplitude.prototype.setBufferSize = function(s) { | ||
if (s%2==0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a good practice to use triple equals so that we check for type as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually i have modified it in my local repo , i will be pushing it with your recommendations keeping in mind 😃 |
||
this._workletNode.port.postMessage({ name: 'bufferSize', bufferSize: s }); | ||
} else { | ||
console.log('Error: bufferSize must be multiple of 2'); | ||
endurance21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}; | ||
|
||
p5.Amplitude.prototype.dispose = function() { | ||
// remove reference from soundArray | ||
var index = p5sound.soundArray.indexOf(this); | ||
|
@@ -309,3 +324,5 @@ define(function (require) { | |
}; | ||
|
||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this comment should be updated to read "power of 2"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya ofcourse !!