나는 녹음 응용 프로그램을위한 에뮬레이트 된 아날로그 VU 미터를 만들었고 모든 것이 제대로 연결되고 한 가지 측면을 제외하고는 기대했던대로 작동합니다. VU 미터가 작동중인 watch this 13-second video이라면 바늘이 모든 곳에서 튀어 나와 실제 VU 미터에서 실제로 발생하지는 않습니다. 내가 찾고있는 예를 보려면 Apple의 "음성 메모"앱을 사용해보십시오.현실적인 아날로그 VU 미터의 오디오 레벨 미터링을 부드럽게 할 수 있습니까?
내 논리는 지금까지 쉽게 : 기본적으로
#define VU_METER_FREQUENCY 1.0/5.0
- (void)someMethod {
_updateTimer = [NSTimer
scheduledTimerWithTimeInterval:VU_METER_FREQUENCY
target:self
selector:@selector(_refresh)
userInfo:nil
repeats:YES];
}
- (void)_refresh {
// if we have no queue, but still have levels, gradually bring them down
if (_delegate == nil) {
CFAbsoluteTime thisFire = CFAbsoluteTimeGetCurrent();
// calculate how much time passed since the last draw
CFAbsoluteTime timePassed = thisFire - _peakFalloffLastFire;
needleValue = needleValue - timePassed * VU_METER_LEVEL_FALL_OFF_PER_SECOND;
if (needleValue < VU_METER_MIN_DB) {
needleValue = VU_METER_MIN_DB;
TT_INVALIDATE_TIMER(_updateTimer);
}
_peakFalloffLastFire = thisFire;
} else {
prevNeedleValue = needleValue;
needleValue = [_delegate currentDB];
}
[self updateNeedle];
}
- (void)updateNeedle {
[UIView beginAnimations:nil context:NULL]; // arguments are optional
[UIView setAnimationDuration:VU_METER_FREQUENCY];
[UIView setAnimationCurve:(needleValue > prevNeedleValue ? UIViewAnimationCurveEaseOut : UIViewAnimationCurveEaseIn)];
CGFloat radAngle = [self radianAngleForValue:needleValue];
self.needle.transform = CGAffineTransformMakeRotation(radAngle);
[UIView commitAnimations];
}
, 내가 설치가 VU_METER_FREQUENCY
에서 실행하고 그 바늘이 높은 유지하기 위해 우선적 인 완화와 UIView의 애니메이션을 사용하여 바늘의 회전을 업데이트하는 타이머. 나는 벤치 마크가 Apple의 아날로그 VU 미터에 최대한 가깝도록 부드럽게 바늘을 제공하기 위해이를 어떻게 든 조정할 방법을 찾고 있습니다. needleValue
을 얻으려면 AudioQueue
의 mAveragePower
을 사용하고 있으며 currentDB
이 호출 될 때마다 쿼리합니다. 어떻게 이것을 부드럽게 할 수 있습니까?
radianAngleForValue : needleValue : method를 나와 공유 하시길 바랍니다. VU 미터를 작동 시키려고하는데, 작동하지 않습니다. –
각도는 고객님의 구현에 따라 매우 다양합니다. 바늘 길이와 눈금에 따라 달라 지므로 값을 표시하기 위해 만든 이미지로 결정됩니다. 필자는 여러 가지 방정식을 풀고 설정에서이 함수에 필요한 값을 검색하기 위해 종이로 작업하는 데 시간이 걸렸다. 이 링크는 스스로 설정하는 방법을 결정하는 데 유용했습니다. http://neolit123.blogspot.com/2009/03/designing-analog-vu-meter-in-dsp.html#hcon – coneybeare
감사합니다. 내가 알아낼 수있게 도와 줘. 잠들지 않는 주말, 여기와! 지금 당장은 바늘이 옆으로 움직이는 VU 미터를 엉뚱한 방법으로 구현 했습니다만, 나는 그런 것처럼 보이지만 실제로 VU 미터가 필요합니다. –