2012-02-01 2 views
1

오디오를 처리하는이 응용 프로그램을 작성 중이며 사운드 카드로 보낼 모든 데이터가 포함 된 버퍼가 있습니다. VU 미터로 이것을 표시하는 가장 좋은 방법에 대한 제안이 있다면 궁금합니다. 차이가 있다면 Java를 사용하고 있습니다. 필자가 보았던 대부분의 예는 물리적 인 VU 미터에 대한 것입니다.오디오 버퍼에서 VU 미터 만들기

편집 : 나는 어떤 특정 지점 내 대답은 매우 약 버퍼의 절대 값의 새는 통합을 계산한다 무엇

답변

1

에서 오디오 버퍼의 볼륨을 얻을 방법을 알아낼 필요가있다. 일반적으로 디지털 오디오가 음압과 음압을 모두 재생해야하므로 50 % 값은 "꺼짐"입니다. 디지털 오디오에 대한 위키 백과 문서를 참조하십시오.

실제 VU 고기는 신호 진폭의 새는 적분기입니다. (검류계 또는 전자식 VU 미터 칩의 입력 저항이 충분히 높으면 간단한 버퍼와 커패시터로 충분할 수 있음)

16 비트 샘플의 경우 코드는 다음과 비슷할 수 있습니다.)

//set up 
long total=0; 
const long half = 32768; //2^(n-1) 
const long decayInMilliseconds=30; // 30ms for the needle to fall back to zero. 
// leak rate is enough to get the reported signal to decay to zero decayMilliseconds after 
// the actual amplitude goes to zero. 
int leakRate = (sample_rate*1000 /decayInMilliseconds) * half; 


// goes in a loop to do the work 
// can be executed on buffer-loads of data at less than the sampling rate, but the net number of calls to it persecond needs to equal the sampling rate. 

int amplitude = buffer[i]-half; 
total = total + abs(amplitude); 
total = total - leakRate; 
if(total > half) { 
    total = half; 
} 
//total is the current "vu level". 

일반적으로 합계 값은 로그 눈금으로 표시됩니다.