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:

  1. cloned repository provided link: git clone https://github.com/jar-son/riograph.git

  2. 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
  3. ...and worked.

ps: explains how apply patch: https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -