开发者

PCMU fade out effect

开发者 https://www.devze.com 2023-03-23 11:20 出处:网络
I want to achieve PCMU fade out effect of the a开发者_开发问答udio. Lets say I have two pieces of 160 bytes of audio which correspond to 20ms audio duration each and I want to insert some silence betw

I want to achieve PCMU fade out effect of the a开发者_开发问答udio. Lets say I have two pieces of 160 bytes of audio which correspond to 20ms audio duration each and I want to insert some silence between them but I want smooth transition from the first piece to silence and then from silence to the second piece.

How do I achieve this?


You would probably need to convert the PCMU samples within the transition to linear values, scale them according to your transition function, then convert them back to PCMU.

There may be a way of doing this while remaining in the µ-Law domain, since scaling becomes addition/subtraction, but it will be fiddly to get right and probably not worth the loss of portability/simplicity unless you are really pushing the performance envelope.


you can lower volume down to complete silence and then start another piece raising its volume from 0

volume modification is pretty simple. if your audio is 2 bytes samples so just take a sample as 16bit integer and treat it as a volume level. E.g. you need to lower volume from current level to 0 smoothly during 5 seconds. Take last 5 seconds of your first piece and modify it, e.g. for each 2 bytes sample calculate new volume level (according of its timestamp to provide smooth volume change effect) as a fraction of 1 and multiply by sample value.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号