ios - AVMutableAudioMixInputParameters setVolume atTime not working only with kCMTimeZero -


im developing ios app in xcode. still new programming. trying set volume of audiotrack while playing avplayer. working great if set time @ kcmtimezero want set volume 1 second after button pressed.

not working

- (ibaction)maxvolbuttonpressed:(id)sender {     [audioinputparams1 setvolume:1 attime:time1];     [self applyaudiomix]; } 

working

- (ibaction)minvolbuttonpressed:(id)sender {     [audioinputparams1 setvolume:0 attime:kcmtimezero];     [self applyaudiomix]; } 

what should write after attime if want 1 second delay?

answer: ok figured out. have add time current item @ moment. use setvolumerampfromstartvolume little time interval instead of setvolume. setvolume fades given volume reason haven't figured out why. works me this:

cmtime time1 = cmtimemake(1000, 1000); //2s cmtime time2 = cmtimemake(1001, 1000); //3s cmtime timecurrent = [player currenttime]; cmtime time1added = cmtimeadd(timecurrent, time1); cmtime time2added = cmtimeadd(timecurrent, time2); cmtimerange fadeintimerange = cmtimerangefromtimetotime(time1added, time2added); [audioinputparams1 setvolumerampfromstartvolume:0 toendvolume:1 timerange:fadeintimerange]; [self applyaudiomix]; 

you should this:

- (ibaction)maxvolbuttonpressed:(id)sender {     [nstimer scheduledtimerwithtimeinterval:1 target:self selector:@selector(setvolume:) userinfo:nil repeats:no]; }  - (void)setvolume:(id)sender{     [audioinputparams1 setvolume:1 attime:kcmtimezero];     [self applyaudiomix]; } 

in first method saying: wait 1 second , call method setvolume:.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -