mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 07:59:27 +02:00
sbsms Transient Sharpening shouldn't crash anymore, but it's not thoroughly tested yet.
This commit is contained in:
parent
92f28a0a1d
commit
317ed4bf17
@ -296,8 +296,8 @@ void subband :: write_(audio *inBuf, long n, real a, real ratio)
|
|||||||
long n_advance = 0;
|
long n_advance = 0;
|
||||||
for(int k=0;k<ng;k++) {
|
for(int k=0;k<ng;k++) {
|
||||||
if(nDropped < nToDrop) {
|
if(nDropped < nToDrop) {
|
||||||
n_advance++;
|
n_advance++;
|
||||||
nDropped++;
|
nDropped++;
|
||||||
} else {
|
} else {
|
||||||
if(!parent && nTrackPointsWritten%nGrainsPerFrame == 0) {
|
if(!parent && nTrackPointsWritten%nGrainsPerFrame == 0) {
|
||||||
real amod;
|
real amod;
|
||||||
@ -307,7 +307,7 @@ void subband :: write_(audio *inBuf, long n, real a, real ratio)
|
|||||||
} else {
|
} else {
|
||||||
amod = 1.0f;
|
amod = 1.0f;
|
||||||
}
|
}
|
||||||
setA(1.0f+amod*(a-1.0f));
|
setA(amod*a);
|
||||||
setAMod(amod);
|
setAMod(amod);
|
||||||
setRatio(ratio);
|
setRatio(ratio);
|
||||||
setF(1.0f/ratio);
|
setF(1.0f/ratio);
|
||||||
@ -1075,24 +1075,24 @@ long subband :: preAnalyze(audio *buf, long n, real a, real ratio)
|
|||||||
long ng_read = 0;
|
long ng_read = 0;
|
||||||
for(int k=inPre->readPos;k<inPre->writePos;k++) {
|
for(int k=inPre->readPos;k<inPre->writePos;k++) {
|
||||||
if(nDropped < nToDrop) {
|
if(nDropped < nToDrop) {
|
||||||
nDropped++;
|
nDropped++;
|
||||||
} else {
|
} else {
|
||||||
if(!parent && (nTrackPointsWritten)%nGrainsPerFrame == 0) {
|
if(!parent && (nTrackPointsWritten)%nGrainsPerFrame == 0) {
|
||||||
grain *g = inPre->read(k);
|
grain *g = inPre->read(k);
|
||||||
grain::referenced(g);
|
grain::referenced(g);
|
||||||
real o = calculateOnset(gPrev,g);
|
real o = calculateOnset(gPrev,g);
|
||||||
onset.write(o);
|
onset.write(o);
|
||||||
if(gPrev) grain::forget(gPrev);
|
if(gPrev) grain::forget(gPrev);
|
||||||
gPrev = g;
|
gPrev = g;
|
||||||
setA(a);
|
setA(a);
|
||||||
}
|
}
|
||||||
if(!parent && (nTrackPointsWritten+1)%nGrainsPerFrame == 0) {
|
if(!parent && (nTrackPointsWritten+1)%nGrainsPerFrame == 0) {
|
||||||
setAForH(a);
|
setAForH(a);
|
||||||
}
|
}
|
||||||
if((nTrackPointsWritten+1)%nGrainsPerFrame == 0) {
|
if((nTrackPointsWritten+1)%nGrainsPerFrame == 0) {
|
||||||
setH(ratio);
|
setH(ratio);
|
||||||
}
|
}
|
||||||
nTrackPointsWritten++;
|
nTrackPointsWritten++;
|
||||||
}
|
}
|
||||||
ng_read++;
|
ng_read++;
|
||||||
}
|
}
|
||||||
@ -1131,9 +1131,9 @@ void subband :: preAnalyzeComplete()
|
|||||||
|
|
||||||
for(long k=k0;k<k1;k++) {
|
for(long k=k0;k<k1;k++) {
|
||||||
bool bOnset = false;
|
bool bOnset = false;
|
||||||
if(k==k0)
|
if(k==k0) {
|
||||||
bOnset = true;
|
bOnset = true;
|
||||||
else {
|
} else {
|
||||||
real o0 = getOnset(k);
|
real o0 = getOnset(k);
|
||||||
if(o0 < 0.1f) continue;
|
if(o0 < 0.1f) continue;
|
||||||
real o1 = getOnset(k-1);
|
real o1 = getOnset(k-1);
|
||||||
@ -1141,23 +1141,25 @@ void subband :: preAnalyzeComplete()
|
|||||||
if(o0 < 0.22f) continue;
|
if(o0 < 0.22f) continue;
|
||||||
bOnset = ((o0 > 0.4f) || (o0>1.4f*o1));
|
bOnset = ((o0 > 0.4f) || (o0>1.4f*o1));
|
||||||
if(!bOnset && k>k0+1) {
|
if(!bOnset && k>k0+1) {
|
||||||
real o2 = getOnset(k-2);
|
real o2 = getOnset(k-2);
|
||||||
bOnset = ((o0 > 1.2f*o1) && (o1 > 1.2f * o2));
|
bOnset = ((o0 > 1.2f*o1) && (o1 > 1.2f * o2));
|
||||||
if(!bOnset && k>k0+2) {
|
if(!bOnset && k>k0+2) {
|
||||||
real o3 = getOnset(k-3);
|
real o3 = getOnset(k-3);
|
||||||
bOnset = ((o0 > 0.3f) && (o1 > 1.1f * o2) && (o2 > 1.1f * o3));
|
bOnset = ((o0 > 0.3f) && (o1 > 1.1f * o2) && (o2 > 1.1f * o3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(bOnset) {
|
if(bOnset) {
|
||||||
if(kend != 0) {
|
if(kend != 0) {
|
||||||
calculateA(kstart,kend);
|
calculateA(kstart,kend);
|
||||||
}
|
}
|
||||||
kstart = kend;
|
kstart = kend;
|
||||||
kend = k;
|
kend = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
calculateA(kstart,k1);
|
calculateA(kstart,k1);
|
||||||
|
aPreAnalysis.write(1.0f);
|
||||||
|
aPreAnalysis.advance(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void subband :: calculateA(long kstart, long kend)
|
void subband :: calculateA(long kstart, long kend)
|
||||||
@ -1170,6 +1172,8 @@ void subband :: calculateA(long kstart, long kend)
|
|||||||
if(o > oMax) oMax = o;
|
if(o > oMax) oMax = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oMax *= 1.3;
|
||||||
|
|
||||||
for(long k=kstart;k<kend;k++) {
|
for(long k=kstart;k<kend;k++) {
|
||||||
real o = getOnset(k);
|
real o = getOnset(k);
|
||||||
real d = oMax - o;
|
real d = oMax - o;
|
||||||
@ -1186,7 +1190,7 @@ void subband :: calculateA(long kstart, long kend)
|
|||||||
} else {
|
} else {
|
||||||
da = d/dTotal*aAllot;
|
da = d/dTotal*aAllot;
|
||||||
}
|
}
|
||||||
|
|
||||||
dTotal -= d;
|
dTotal -= d;
|
||||||
aAllot -= da;
|
aAllot -= da;
|
||||||
aPreAnalysis.write(da);
|
aPreAnalysis.write(da);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user