-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feat/audio buffer #105
Feat/audio buffer #105
Conversation
This reverts commit 8d7500a.
val pan = pan.getValueAtTime(context.getCurrentTime()) | ||
val x = (pan + 1) / 2; | ||
val x = (pan + 1) / 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.
val x = (pan + 1) / 2 | |
val x = (if (pan <= 0) pan + 1 else pan) * PI / 2 |
playbackParameters.leftPan *= gainL | ||
playbackParameters.rightPan *= gainR |
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.
playbackParameters.leftPan *= gainL | |
playbackParameters.rightPan *= gainR | |
// TODO: This assumes both channels play the same sound (buffer) | |
// but it should mix the channels. F.e. pan < 0: leftChannel = leftChannel + leftGain * rightChannel | |
if (pan <= 0) { | |
playbackParameters.leftPan *= (1+gainL) | |
playbackParameters.rightPan *= gainR | |
} else { | |
playbackParameters.leftPan *= gainL | |
playbackParameters.rightPan *= (1+gainR) | |
} |
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.
Can't find any better source that ppl arguing on online forums, but it seems that:
- doing a "gain change" on single channel aka
left = left * gainL
is calledbalancing
- doing a "gain change" when mixing the other(s?) channels is called panning
https://www.kvraudio.com/forum/viewtopic.php?t=148865
https://www.reddit.com/r/synthesizers/comments/14fqq4t/whats_the_difference_between_pan_and_balance/
|
||
for (int frame = 0; frame < frameCount; frame++) { | ||
double input = bufferL[frame]; | ||
// double output = _b0 * input + _b1 * _x1 + _b2 * _x2 - _a1 * _y1 - _a2 * _y2; |
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.
// double output = _b0 * input + _b1 * _x1 + _b2 * _x2 - _a1 * _y1 - _a2 * _y2; |
float *bufferL = (float *)bufferList->mBuffers[0].mData; | ||
float *bufferR = (float *)bufferList->mBuffers[1].mData; | ||
|
||
for (int frame = 0; frame < frameCount; frame += 1) { | ||
double pan = [_panParam getValueAtTime:[self.context getCurrentTime]]; | ||
double x = (pan + 1) / 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.
double x = (pan + 1) / 2; | |
double x = ((pan <= 0) ? pan + 1 : pan) * M_PI / 2; |
bufferL[frame] *= cos(x * M_PI / 2); | ||
bufferR[frame] *= sin(x * M_PI / 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.
bufferL[frame] *= cos(x * M_PI / 2); | |
bufferR[frame] *= sin(x * M_PI / 2); | |
double gainL = cos(x); | |
double gainR = sin(x); | |
if (pan <= 0) { | |
bufferL[frame] += bufferR[frame] * gainL; | |
bufferR[frame] *= gainR; | |
} else { | |
bufferL[frame] *= gainL; | |
bufferR[frame] += bufferL * gainR; | |
} |
Closes #101
Closes #97
Closes #89