GUI: optimize calcChanOsc()
This commit is contained in:
parent
e06fc9c480
commit
a4698dc911
|
|
@ -96,16 +96,16 @@ void FurnaceGUI::calcChanOsc() {
|
||||||
// 30ms should be enough
|
// 30ms should be enough
|
||||||
int displaySize=(float)(buf->rate)*0.03f;
|
int displaySize=(float)(buf->rate)*0.03f;
|
||||||
if (e->isRunning()) {
|
if (e->isRunning()) {
|
||||||
float minLevel=1.0f;
|
short minLevel=32767;
|
||||||
float maxLevel=-1.0f;
|
short maxLevel=-32768;
|
||||||
unsigned short needlePos=buf->needle;
|
unsigned short needlePos=buf->needle;
|
||||||
needlePos-=displaySize;
|
needlePos-=displaySize;
|
||||||
for (unsigned short i=0; i<512; i++) {
|
for (unsigned short i=0; i<512; i++) {
|
||||||
float y=(float)buf->data[(unsigned short)(needlePos+(i*displaySize/512))]/32768.0f;
|
short y=buf->data[(unsigned short)(needlePos+(i*displaySize/512))];
|
||||||
if (minLevel>y) minLevel=y;
|
if (minLevel>y) minLevel=y;
|
||||||
if (maxLevel<y) maxLevel=y;
|
if (maxLevel<y) maxLevel=y;
|
||||||
}
|
}
|
||||||
float estimate=pow(maxLevel-minLevel,0.5f);
|
float estimate=pow((float)(maxLevel-minLevel)/32768.0f,0.5f);
|
||||||
if (estimate>1.0f) estimate=1.0f;
|
if (estimate>1.0f) estimate=1.0f;
|
||||||
chanOscVol[i]=MAX(chanOscVol[i]*0.87f,estimate);
|
chanOscVol[i]=MAX(chanOscVol[i]*0.87f,estimate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue