ios - What technology to use to build Apple Watch's Siri Waveform -


i'm building music player ios. want have visualizer, similar waveform of siri on apple watch.

i've found open source project on github looks promising. uses core graphics drawing , quite simple understand. uses ~50% of cpu on iphone 6 , high amplitudes can't achieve 60 fps. there way achieve effect using uikit or spritekit improved performance (notice blending effect - it's important)? also, author of project says fft (in todos). spent day understand fft, i'm still not sure how can in case achieve effect (or maybe become more performant). ideas?

you can use siriwaveview. download github.

then can make instance of like,

 siriwaveview = [[scsiriwaveformview alloc]initwithframe:cgrectmake(20, (self.view.frame.size.height/2) - 160 + 120, self.view.frame.size.width - 40, 80)]; //you can set desired frame     siriwaveview.backgroundcolor = appgraycolor; 

then can set properties like,

    [siriwaveview setwavecolor:mycolor]; //desired color     [siriwaveview setprimarywavelinewidth:3.0f];     [siriwaveview setsecondarywavelinewidth:1.0]; 

implement methods,

  - (void)updatemeters {   if (audioplayer.playing) {       cgfloat normalizedvalue;     [audioplayer updatemeters];     normalizedvalue = [self _normalizedpowerlevelfromdecibels:[audioplayer averagepowerforchannel:0]];     [siriwaveview updatewithlevel:normalizedvalue];     //  nslog(@"update meter called");  }    }   - (cgfloat)_normalizedpowerlevelfromdecibels:(cgfloat)decibels { if (decibels < -60.0f || decibels == 0.0f) {     return 0.0f; }  return powf((powf(10.0f, 0.05f * decibels) - powf(10.0f, 0.05f * -60.0f)) * (1.0f / (1.0f - powf(10.0f, 0.05f * -60.0f))), 1.0f / 2.0f); } 

when play audio or music call like,

   displaylink = [cadisplaylink displaylinkwithtarget:self selector:@selector(updatemeters)];     [displaylink addtorunloop:[nsrunloop currentrunloop] formode:nsrunloopcommonmodes]; 

you can refer demo project link better understanding.

hope :)


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -