Re: Can anyone help me in Fade In...?
Re: Can anyone help me in Fade In...?
- Subject: Re: Can anyone help me in Fade In...?
- From: Howard Moon <email@hidden>
- Date: Fri, 17 Jul 2009 09:19:40 -0700
On Jul 17, 2009, at 8:59 AM, Richard Dobson wrote:
Ansh wrote:
I have reduce my algorithm to
- (void)applyFadeInEffectForBuffer:(float *)buffer
ofLength:(int)length {
* **length = length / sizeof(float);*
* **for (int i = 0; i < length; i ++) {*
* **float factor = (float)( i/(float) length); *
What was wrong with simply casting i? That makes the whole
expression a float.
* **buffer[i] = (float)(buffer[i]) * factor;*
* **}*
}
where length is in number of bytes. But still there is a noise in
fade in.
You will need to specify the noise in a little more detail. Note
that a plain linear ramp is less than ideal for an audio fade-in -
gets loud too soon. Try a log or quasi-log (rising exp) curve. A
simple one would be to change:
buffer[i] = (float)(buffer[i]) * factor;
to:
buffer[i] = (float)((buffer[i]) * (factor * factor));
A sine-curve-shaped fade-in (offset by -pi/2 horizontally and by 1
vertically, and scaled in both axes appropriately) would also work
well, wouldn't it? That would give you a (relative) slope of zero at
both ends, which would smooth out the transitions nicely.
-Howard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden