how to generate amplitude modulated sine wave in iphone sdk?
I need to get开发者_运维技巧 the amplitude while recording. From that i've to construct a sine wave which is amplitude modulated one. How to get the amplitude of the sound? Please give me suggestions.
Just generating sine wave is easier. Well, I implemented sine wave into the UIView drawrect method as follows :
float x=75;
float yc=50;
float w=0;
while (w<=rect.frame.size.width) {
CGPathMoveToPoint(path, nil, w,y/2);
CGPathAddQuadCurveToPoint(path, nil, w+x/4, -yc,w+ x/2, y/2);
CGPathMoveToPoint(path, nil, w+x/2,y/2);
CGPathAddQuadCurveToPoint(path, nil, w+3*x/4, y+yc, w+x, y/2);
CGContextAddPath(context, path);
CGContextDrawPath(context, kCGPathStroke);
w+=x;
}
Here x would be the width of each sine wave, while y is the height of the frame. This would draw number of sine waves to fit in the whole UIViewFrame. It would produce crisp looking sine wave and yc being control handle. Try it you might like it.
If the width ie. x is similar to the width of the frame then a single sine wave will be produced.
Number of complete sine wave = (width of frame) / ('x' width of each sine wave) Now, try to adjust the amplitude and frequency of the wave with respect to the power of audio.
精彩评论