2
我正在使用Superpowered SDK来播放声音。 它有一个函数返回名为peakWaveForm的无符号字符**。 我写了一个自定义的uiview,并试图绘制这个值,我的视图没有很好看。我的问题是,如何绘制我的波形值? 和什么样的变量。数组?。波形的正常大小应该是多少? SDK返回一个无符号字符**我该如何继续?如何绘制波形?
- (void)drawRect:(CGRect)updateRect
{
unsigned i, maxIndex;
maxIndex = floor(CGRectGetMaxX(updateRect));
i = floor(CGRectGetMinX(updateRect));
float firstPoint = (float)mPeakWaveForm[0][i];
UIBezierPath *path = [UIBezierPath bezierPath];
path.lineWidth = 2;
[[UIColor blackColor] setFill];
[path moveToPoint:CGPointMake(i,firstPoint)];
for(i; i <= maxIndex; i++)
{
float nextPoint = (float)mPeakWaveForm[0][i];
[path addLineToPoint:CGPointMake(i, nextPoint)];
}
[path fill];
}