iphone - Label updating during audio processing -
i'm new ios programming , i'm facing problem regarding update of labels during audio processing tasks.
i use classic recordingcallback -> processaudio method. in processaudio stop recording if level low. quite easy do. when stops, can't change text label "recording" "stopped". works great button (play/stop) not when calling back. there no error during compiling. nothing happens...
here code :
-(void)processaudio:(audiobufferlist *)bufferlist{ audiobuffer sourcebuffer = bufferlist->mbuffers[0]; // copy incoming audio data temporary buffer memcpy(tempbuffer.mdata, bufferlist->mbuffers[0].mdata, bufferlist->mbuffers[0].mdatabytesize); int16_t* samples = (int16_t*)(tempbuffer.mdata); ( int = 0; < tempbuffer.mdatabytesize / 2; ++i ) { if (samples[i]< leveltrigger) { presence++; if (presence== 2 * samplerate) { printf("nothing"); //dispatch_async(dispatch_get_main_queue(), ^{ //[self buttonpressed:nil]; //}); //[self buttonpressed:nil]; [label performselectoronmainthread:@selector(settext:) withobject:@"test" waituntildone:yes]; presence=0; break; } }
as can see, have tried use "dispatch_async" , "performselectoronmainthread" functions didn't help. buttonpressed function called correctly, nothing happens. help. jc
this did:
cloned repository provided link:
git clone https://github.com/jar-son/riograph.git
can read patch format? http://pastebin.com/sc0eb3tr (link valid 30 days on)
summary of did:- added
@class viewcontroller
audio.h - added
@property (nonatomic, assign) viewcontroller *viewcontroller;
audio.h - added
[self.viewcontroller performselectoronmainthread:@selector(setmylabel) withobject:self waituntildone:no];
-(void)processaudio:(audiobufferlist *)bufferlist
in audio.m - added
- (void)setmylabel;
viewcontroller.h - added
- (void)setmylabel { self.label.text = @"blablabla!"; }
viewcontroller.m
- added
...and worked.
ps: explains how apply patch: https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/
Comments
Post a Comment