/** Translation durchfuehren */ public void process() { int i, j, k; int ch, len; float f1; double d1, d2, d3, d4, d5; long progOff, progLen, lo; // io AudioFile reInF = null; AudioFile imInF = null; AudioFile reOutF = null; AudioFile imOutF = null; AudioFileDescr reInStream = null; AudioFileDescr imInStream = null; AudioFileDescr reOutStream = null; AudioFileDescr imOutStream = null; FloatFile reFloatF[] = null; FloatFile imFloatF[] = null; File reTempFile[] = null; File imTempFile[] = null; int outChanNum; float[][] reInBuf; // [ch][i] float[][] imInBuf; // [ch][i] float[][] reOutBuf = null; // [ch][i] float[][] imOutBuf = null; // [ch][i] float[] convBuf1, convBuf2; boolean complex; PathField ggOutput; // Synthesize Param ampRef = new Param(1.0, Param.ABS_AMP); // transform-Referenz float gain; // gain abs amp float dryGain, wetGain; float inGain; float maxAmp = 0.0f; Param peakGain; int inLength, inOff; int pre; int post; int length; int framesRead, framesWritten, outLength; boolean polarIn, polarOut; // phase unwrapping double[] phi; int[] wrap; double[] carry; Param lenRef; topLevel: try { complex = pr.bool[PR_HASIMINPUT] || pr.bool[PR_HASIMOUTPUT]; polarIn = pr.intg[PR_OPERATOR] == OP_POLAR2RECT; polarOut = pr.intg[PR_OPERATOR] == OP_RECT2POLAR; if ((polarIn || polarOut) && !complex) throw new IOException(ERR_NOTCOMPLEX); // ---- open input ---- reInF = AudioFile.openAsRead(new File(pr.text[PR_REINPUTFILE])); reInStream = reInF.getDescr(); inLength = (int) reInStream.length; reInBuf = new float[reInStream.channels][8192]; imInBuf = new float[reInStream.channels][8192]; if (pr.bool[PR_HASIMINPUT]) { imInF = AudioFile.openAsRead(new File(pr.text[PR_IMINPUTFILE])); imInStream = imInF.getDescr(); if (imInStream.channels != reInStream.channels) throw new IOException(ERR_COMPLEX); inLength = (int) Math.min(inLength, imInStream.length); } lenRef = new Param(AudioFileDescr.samplesToMillis(reInStream, inLength), Param.ABS_MS); d1 = AudioFileDescr.millisToSamples( reInStream, (Param.transform(pr.para[PR_OFFSET], Param.ABS_MS, lenRef, null).value)); j = (int) (d1 >= 0.0 ? (d1 + 0.5) : (d1 - 0.5)); // correct rounding for negative values! length = (int) (AudioFileDescr.millisToSamples( reInStream, (Param.transform(pr.para[PR_LENGTH], Param.ABS_MS, lenRef, null)).value) + 0.5); // System.err.println( "offset = "+j ); if (j >= 0) { inOff = Math.min(j, inLength); if (!pr.bool[PR_REVERSE]) { reInF.seekFrame(inOff); if (pr.bool[PR_HASIMINPUT]) { imInF.seekFrame(inOff); } } inLength -= inOff; pre = 0; } else { inOff = 0; pre = Math.min(-j, length); } inLength = Math.min(inLength, length - pre); post = length - pre - inLength; if (pr.bool[PR_REVERSE]) { i = pre; pre = post; post = i; inOff += inLength; } // .... check running .... if (!threadRunning) break topLevel; // for( op = 0; op < 2; op++ ) { // System.out.println( op +": pre "+pre[op]+" / len "+inLength[op]+" / post "+post[op] ); // } // System.out.println( "tot "+length[0]); outLength = length; outChanNum = reInStream.channels; // ---- open output ---- ggOutput = (PathField) gui.getItemObj(GG_REOUTPUTFILE); if (ggOutput == null) throw new IOException(ERR_MISSINGPROP); reOutStream = new AudioFileDescr(reInStream); ggOutput.fillStream(reOutStream); reOutStream.channels = outChanNum; // well, more sophisticated code would // move and truncate the markers... if ((pre == 0) /* && (post == 0) */) { reInF.readMarkers(); reOutStream.setProperty( AudioFileDescr.KEY_MARKERS, reInStream.getProperty(AudioFileDescr.KEY_MARKERS)); } reOutF = AudioFile.openAsWrite(reOutStream); reOutBuf = new float[outChanNum][8192]; imOutBuf = new float[outChanNum][8192]; if (pr.bool[PR_HASIMOUTPUT]) { imOutStream = new AudioFileDescr(reInStream); ggOutput.fillStream(imOutStream); imOutStream.channels = outChanNum; imOutStream.file = new File(pr.text[PR_IMOUTPUTFILE]); imOutF = AudioFile.openAsWrite(imOutStream); } // .... check running .... if (!threadRunning) break topLevel; // ---- Further inits ---- phi = new double[outChanNum]; wrap = new int[outChanNum]; carry = new double[outChanNum]; for (ch = 0; ch < outChanNum; ch++) { phi[ch] = 0.0; wrap[ch] = 0; carry[ch] = Double.NEGATIVE_INFINITY; } progOff = 0; // read, transform, write progLen = (long) outLength * 3; wetGain = (float) (Param.transform(pr.para[PR_WETMIX], Param.ABS_AMP, ampRef, null)).value; dryGain = (float) (Param.transform(pr.para[PR_DRYMIX], Param.ABS_AMP, ampRef, null)).value; if (pr.bool[PR_DRYINVERT]) { dryGain = -dryGain; } inGain = (float) (Param.transform(pr.para[PR_INPUTGAIN], Param.ABS_AMP, ampRef, null)).value; if (pr.bool[PR_INVERT]) { inGain = -inGain; } // normalization requires temp files if (pr.intg[PR_GAINTYPE] == GAIN_UNITY) { reTempFile = new File[outChanNum]; reFloatF = new FloatFile[outChanNum]; for (ch = 0; ch < outChanNum; ch++) { // first zero them because an exception might be thrown reTempFile[ch] = null; reFloatF[ch] = null; } for (ch = 0; ch < outChanNum; ch++) { reTempFile[ch] = IOUtil.createTempFile(); reFloatF[ch] = new FloatFile(reTempFile[ch], GenericFile.MODE_OUTPUT); } if (pr.bool[PR_HASIMOUTPUT]) { imTempFile = new File[outChanNum]; imFloatF = new FloatFile[outChanNum]; for (ch = 0; ch < outChanNum; ch++) { // first zero them because an exception might be thrown imTempFile[ch] = null; imFloatF[ch] = null; } for (ch = 0; ch < outChanNum; ch++) { imTempFile[ch] = IOUtil.createTempFile(); imFloatF[ch] = new FloatFile(imTempFile[ch], GenericFile.MODE_OUTPUT); } } progLen += outLength; } else { gain = (float) (Param.transform(pr.para[PR_GAIN], Param.ABS_AMP, ampRef, null)).value; wetGain *= gain; dryGain *= gain; } // .... check running .... if (!threadRunning) break topLevel; // ----==================== the real stuff ====================---- framesRead = 0; framesWritten = 0; while (threadRunning && (framesWritten < outLength)) { // ---- choose chunk len ---- len = Math.min(8192, outLength - framesWritten); if (pre > 0) { len = Math.min(len, pre); } else if (inLength > 0) { len = Math.min(len, inLength); } else { len = Math.min(len, post); } // ---- read input chunks ---- if (pre > 0) { Util.clear(reInBuf); if (complex) { Util.clear(imInBuf); } pre -= len; } else if (inLength > 0) { if (pr.bool[PR_REVERSE]) { // ---- read reversed ---- reInF.seekFrame(inOff - framesRead - len); reInF.readFrames(reInBuf, 0, len); for (ch = 0; ch < reInStream.channels; ch++) { convBuf1 = reInBuf[ch]; for (i = 0, j = len - 1; i < j; i++, j--) { f1 = convBuf1[j]; convBuf1[j] = convBuf1[i]; convBuf1[i] = f1; } } if (pr.bool[PR_HASIMINPUT]) { imInF.seekFrame(inOff - framesRead - len); imInF.readFrames(imInBuf, 0, len); for (ch = 0; ch < imInStream.channels; ch++) { convBuf1 = imInBuf[ch]; for (i = 0, j = len - 1; i < j; i++, j--) { f1 = convBuf1[j]; convBuf1[j] = convBuf1[i]; convBuf1[i] = f1; } } } else if (complex) { Util.clear(imInBuf); } } else { // ---- read normal ---- reInF.readFrames(reInBuf, 0, len); if (pr.bool[PR_HASIMINPUT]) { imInF.readFrames(imInBuf, 0, len); } else if (complex) { Util.clear(imInBuf); } } inLength -= len; framesRead += len; } else { Util.clear(reInBuf); if (complex) { Util.clear(imInBuf); } post -= len; } progOff += len; // .... progress .... setProgression((float) progOff / (float) progLen); // .... check running .... if (!threadRunning) break topLevel; // ---- save dry signal ---- for (ch = 0; ch < outChanNum; ch++) { convBuf1 = reInBuf[ch]; convBuf2 = reOutBuf[ch]; for (i = 0; i < len; i++) { convBuf2[i] = convBuf1[i] * dryGain; } if (complex) { convBuf1 = imInBuf[ch]; convBuf2 = imOutBuf[ch]; for (i = 0; i < len; i++) { convBuf2[i] = convBuf1[i] * dryGain; } } } // ---- rectify + apply input gain ---- for (ch = 0; ch < reInStream.channels; ch++) { convBuf1 = reInBuf[ch]; convBuf2 = imInBuf[ch]; // ---- rectify ---- if (pr.bool[PR_RECTIFY]) { if (complex) { if (polarIn) { for (i = 0; i < len; i++) { convBuf2[i] = 0.0f; } } else { for (i = 0; i < len; i++) { d1 = convBuf1[i]; d2 = convBuf2[i]; convBuf1[i] = (float) Math.sqrt(d1 * d1 + d2 * d2); convBuf2[i] = 0.0f; } } } else { for (i = 0; i < len; i++) { convBuf1[i] = Math.abs(convBuf1[i]); } } } // ---- apply input gain ---- Util.mult(convBuf1, 0, len, inGain); if (complex & !polarIn) { Util.mult(convBuf2, 0, len, inGain); } } // ---- heart of the dragon ---- for (ch = 0; ch < outChanNum; ch++) { convBuf1 = reInBuf[ch]; convBuf2 = imInBuf[ch]; switch (pr.intg[PR_OPERATOR]) { case OP_NONE: // ================ None ================ for (i = 0; i < len; i++) { reOutBuf[ch][i] += wetGain * convBuf1[i]; } if (complex) { for (i = 0; i < len; i++) { imOutBuf[ch][i] += wetGain * convBuf2[i]; } } break; case OP_SIN: // ================ Cosinus ================ if (complex) { for (i = 0; i < len; i++) { reOutBuf[ch][i] += wetGain * (float) Math.sin(convBuf1[i] * Math.PI); imOutBuf[ch][i] += wetGain * (float) Math.sin(convBuf2[i] * Math.PI); } } else { for (i = 0; i < len; i++) { reOutBuf[ch][i] += wetGain * (float) Math.sin(convBuf1[i] * Math.PI); } } break; case OP_SQR: // ================ Square ================ if (complex) { for (i = 0; i < len; i++) { reOutBuf[ch][i] += wetGain * (convBuf1[i] * convBuf1[i] - convBuf2[i] * convBuf2[i]); imOutBuf[ch][i] -= wetGain * (convBuf1[i] * convBuf2[i] * 2); } } else { for (i = 0; i < len; i++) { reOutBuf[ch][i] += wetGain * (convBuf1[i] * convBuf1[i]); } } break; case OP_SQRT: // ================ Square root ================ if (complex) { d3 = phi[ch]; k = wrap[ch]; d4 = k * Constants.PI2; for (i = 0; i < len; i++) { d1 = wetGain * Math.pow(convBuf1[i] * convBuf1[i] + convBuf2[i] * convBuf2[i], 0.25); d2 = Math.atan2(convBuf2[i], convBuf1[i]); if (d2 - d3 > Math.PI) { k--; d4 = k * Constants.PI2; } else if (d3 - d2 > Math.PI) { k++; d4 = k * Constants.PI2; } d2 += d4; d3 = d2; d2 /= 2; reOutBuf[ch][i] += (float) (d1 * Math.cos(d2)); imOutBuf[ch][i] += (float) (d1 * Math.sin(d2)); } phi[ch] = d3; wrap[ch] = k; } else { for (i = 0; i < len; i++) { f1 = convBuf1[i]; if (f1 > 0) { reOutBuf[ch][i] += wetGain * (float) Math.sqrt(f1); } // else undefiniert } } break; case OP_RECT2POLARW: // ================ Rect->Polar (wrapped) ================ for (i = 0; i < len; i++) { d1 = wetGain * Math.sqrt(convBuf1[i] * convBuf1[i] + convBuf2[i] * convBuf2[i]); d2 = Math.atan2(convBuf2[i], convBuf1[i]); reOutBuf[ch][i] += (float) d1; imOutBuf[ch][i] += (float) d2; } break; case OP_RECT2POLAR: // ================ Rect->Polar ================ d3 = phi[ch]; k = wrap[ch]; d4 = k * Constants.PI2; for (i = 0; i < len; i++) { d1 = wetGain * Math.sqrt(convBuf1[i] * convBuf1[i] + convBuf2[i] * convBuf2[i]); d2 = Math.atan2(convBuf2[i], convBuf1[i]); if (d2 - d3 > Math.PI) { k--; d4 = k * Constants.PI2; } else if (d3 - d2 > Math.PI) { k++; d4 = k * Constants.PI2; } d2 += d4; reOutBuf[ch][i] += (float) d1; imOutBuf[ch][i] += (float) d2; d3 = d2; } phi[ch] = d3; wrap[ch] = k; break; case OP_POLAR2RECT: // ================ Polar->Rect ================ for (i = 0; i < len; i++) { f1 = wetGain * convBuf1[i]; reOutBuf[ch][i] += f1 * (float) Math.cos(convBuf2[i]); imOutBuf[ch][i] += f1 * (float) Math.sin(convBuf2[i]); } break; case OP_LOG: // ================ Log ================ if (complex) { d3 = phi[ch]; k = wrap[ch]; d4 = k * Constants.PI2; d5 = carry[ch]; for (i = 0; i < len; i++) { d1 = Math.sqrt(convBuf1[i] * convBuf1[i] + convBuf2[i] * convBuf2[i]); d2 = Math.atan2(convBuf2[i], convBuf1[i]); if (d2 - d3 > Math.PI) { k--; d4 = k * Constants.PI2; } else if (d3 - d2 > Math.PI) { k++; d4 = k * Constants.PI2; } if (d1 > 0.0) { d5 = Math.log(d1); } d2 += d4; reOutBuf[ch][i] += (float) d5; imOutBuf[ch][i] += (float) d2; d3 = d2; } phi[ch] = d3; wrap[ch] = k; carry[ch] = d5; } else { for (i = 0; i < len; i++) { f1 = convBuf1[i]; if (f1 > 0) { reOutBuf[ch][i] += wetGain * (float) Math.log(f1); } // else undefiniert } } break; case OP_EXP: // ================ Exp ================ if (complex) { for (i = 0; i < len; i++) { d1 = wetGain * Math.exp(convBuf1[i]); reOutBuf[ch][i] += (float) (d1 * Math.cos(convBuf2[i])); imOutBuf[ch][i] += (float) (d1 * Math.sin(convBuf2[i])); } } else { for (i = 0; i < len; i++) { reOutBuf[ch][i] += wetGain * (float) Math.exp(convBuf1[i]); } } break; case OP_NOT: // ================ NOT ================ for (i = 0; i < len; i++) { lo = ~((long) (convBuf1[i] * 2147483647.0)); reOutBuf[ch][i] += wetGain * (float) ((lo & 0xFFFFFFFFL) / 2147483647.0); } if (complex) { for (i = 0; i < len; i++) { lo = ~((long) (convBuf2[i] * 2147483647.0)); imOutBuf[ch][i] += wetGain * (float) ((lo & 0xFFFFFFFFL) / 2147483647.0); } } break; } } // for outChan progOff += len; // .... progress .... setProgression((float) progOff / (float) progLen); // .... check running .... if (!threadRunning) break topLevel; // ---- write output chunk ---- if (reFloatF != null) { for (ch = 0; ch < outChanNum; ch++) { reFloatF[ch].writeFloats(reOutBuf[ch], 0, len); if (pr.bool[PR_HASIMOUTPUT]) { imFloatF[ch].writeFloats(imOutBuf[ch], 0, len); } } } else { reOutF.writeFrames(reOutBuf, 0, len); if (pr.bool[PR_HASIMOUTPUT]) { imOutF.writeFrames(imOutBuf, 0, len); } } // check max amp for (ch = 0; ch < outChanNum; ch++) { convBuf1 = reOutBuf[ch]; for (i = 0; i < len; i++) { f1 = Math.abs(convBuf1[i]); if (f1 > maxAmp) { maxAmp = f1; } } if (pr.bool[PR_HASIMOUTPUT]) { convBuf1 = imOutBuf[ch]; for (i = 0; i < len; i++) { f1 = Math.abs(convBuf1[i]); if (f1 > maxAmp) { maxAmp = f1; } } } } progOff += len; framesWritten += len; // .... progress .... setProgression((float) progOff / (float) progLen); } // while not framesWritten // ----==================== normalize output ====================---- if (pr.intg[PR_GAINTYPE] == GAIN_UNITY) { peakGain = new Param(maxAmp, Param.ABS_AMP); gain = (float) (Param.transform( pr.para[PR_GAIN], Param.ABS_AMP, new Param(1.0 / peakGain.value, peakGain.unit), null)) .value; f1 = pr.bool[PR_HASIMOUTPUT] ? ((1.0f + getProgression()) / 2) : 1.0f; normalizeAudioFile(reFloatF, reOutF, reOutBuf, gain, f1); if (pr.bool[PR_HASIMOUTPUT]) { normalizeAudioFile(imFloatF, imOutF, imOutBuf, gain, 1.0f); } maxAmp *= gain; for (ch = 0; ch < outChanNum; ch++) { reFloatF[ch].cleanUp(); reFloatF[ch] = null; reTempFile[ch].delete(); reTempFile[ch] = null; if (pr.bool[PR_HASIMOUTPUT]) { imFloatF[ch].cleanUp(); imFloatF[ch] = null; imTempFile[ch].delete(); imTempFile[ch] = null; } } } // .... check running .... if (!threadRunning) break topLevel; // ---- Finish ---- reOutF.close(); reOutF = null; reOutStream = null; if (imOutF != null) { imOutF.close(); imOutF = null; imOutStream = null; } reInF.close(); reInF = null; reInStream = null; if (pr.bool[PR_HASIMINPUT]) { imInF.close(); imInF = null; imInStream = null; } reOutBuf = null; imOutBuf = null; reInBuf = null; imInBuf = null; // inform about clipping/ low level handleClipping(maxAmp); } catch (IOException e1) { setError(e1); } catch (OutOfMemoryError e2) { reOutBuf = null; imOutBuf = null; reInBuf = null; imInBuf = null; convBuf1 = null; convBuf2 = null; System.gc(); setError(new Exception(ERR_MEMORY)); } // ---- cleanup (topLevel) ---- convBuf1 = null; convBuf2 = null; if (reInF != null) { reInF.cleanUp(); reInF = null; } if (imInF != null) { imInF.cleanUp(); imInF = null; } if (reOutF != null) { reOutF.cleanUp(); reOutF = null; } if (imOutF != null) { imOutF.cleanUp(); imOutF = null; } if (reFloatF != null) { for (ch = 0; ch < reFloatF.length; ch++) { if (reFloatF[ch] != null) { reFloatF[ch].cleanUp(); reFloatF[ch] = null; } if (reTempFile[ch] != null) { reTempFile[ch].delete(); reTempFile[ch] = null; } } } if (imFloatF != null) { for (ch = 0; ch < imFloatF.length; ch++) { if (imFloatF[ch] != null) { imFloatF[ch].cleanUp(); imFloatF[ch] = null; } if (imTempFile[ch] != null) { imTempFile[ch].delete(); imTempFile[ch] = null; } } } } // process()
protected void process() { long progOff; final long progLen; AudioFile inF = null; final AudioFileDescr inDescr; final int inChanNum; final long inLength; // final Param ampRef = new Param( 1.0, Param.ABS_AMP ); // transform-Referenz final PathField ggOutput; int chunkLen; final ConstQ constQ; final float boost = 1f; // 1000f; final double minFreq = pr.para[PR_MINFREQ].value; final double maxFreq = pr.para[PR_MAXFREQ].value; final double timeRes = pr.para[PR_TIMERES].value; final int bandsPerOct = (int) pr.para[PR_BANDSPEROCT].value; final int maxFFTSize = 256 << pr.intg[PR_MAXFFTSIZE]; final boolean color = false; final int bitsPerSmp; ImageFile outF = null; final ImageStream imgStream; final byte[] row; final int overlapSize; final int width, height; final int inBufSize; final float[][] inBuf; final int fftSize; final int stepSize; final int numKernels; final float[] kernel; // final float[] hsb = new float[ 3 ]; final double signalCeil = pr.para[PR_SIGNALCEIL] .value; // (Param.transform( pr.para[ PR_SIGNALCEIL ], Param.ABS_AMP, ampRef, null // )).value; final double noiseFloor = pr.para[PR_NOISEFLOOR] .value; // (Param.transform( pr.para[ PR_NOISEFLOOR ], Param.ABS_AMP, ampRef, null // )).value; final double dynamic = signalCeil - noiseFloor; int rgb; int winSize, inOff; long framesRead; // float brightness; topLevel: try { // ---- open input, output; init ---- // ptrn input inF = AudioFile.openAsRead(new File(pr.text[PR_INPUTFILE])); inDescr = inF.getDescr(); inChanNum = inDescr.channels; inLength = inDescr.length; // this helps to prevent errors from empty files! if ((inLength < 1) || (inChanNum < 1)) throw new EOFException(ERR_EMPTY); if (inChanNum != 1) throw new EOFException(ERR_MONO); // .... check running .... if (!threadRunning) break topLevel; // if( inChanNum > 1 ) { // System.out.println( "WARNING: Multichannel input. Using mono mix for mosaic // correlation!" ); // } // ---- further inits ---- constQ = new ConstQ(); constQ.setSampleRate(inDescr.rate); constQ.setMinFreq((float) minFreq); constQ.setMaxFreq((float) maxFreq); constQ.setBandsPerOct(bandsPerOct); constQ.setMaxFFTSize(maxFFTSize); constQ.setMaxTimeRes((float) timeRes); constQ.createKernels(); fftSize = constQ.getFFTSize(); numKernels = constQ.getNumKernels(); winSize = fftSize; // << 1; stepSize = (int) (AudioFileDescr.millisToSamples(inDescr, timeRes) + 0.5); overlapSize = fftSize - stepSize; height = (int) ((inLength + stepSize - 1) / stepSize); width = numKernels; // System.out.println( "w " + width + "; h " + height + "; winSize " + winSize + "; inLength " // + inLength ); ggOutput = (PathField) gui.getItemObj(GG_OUTPUTFILE); if (ggOutput == null) throw new IOException(ERR_MISSINGPROP); outF = new ImageFile(pr.text[PR_OUTPUTFILE], GenericFile.MODE_OUTPUT | ggOutput.getType()); imgStream = new ImageStream(); imgStream.bitsPerSmp = 8; // ??? fillStream might not work correctly? ggOutput.fillStream(imgStream); imgStream.width = width; imgStream.height = height; imgStream.smpPerPixel = /* color ? 3 :*/ 1; bitsPerSmp = imgStream.bitsPerSmp; outF.initWriter(imgStream); row = outF.allocRow(); inBufSize = Math.max(8192, fftSize); inBuf = new float[inChanNum][inBufSize]; kernel = new float[numKernels]; progLen = height; progOff = 0; // ----==================== processing loop ====================---- framesRead = 0; inOff = 0; // final java.util.Random rnd = new java.util.Random(); for (int y = 0; y < height; y++) { if (inOff < 0) { inF.seekFrame(Math.min(inF.getFrameNum(), inF.getFramePosition() - inOff)); inOff = 0; } // read chunkLen = (int) Math.min(inLength - framesRead, winSize - inOff); // System.out.println( "readFrames " + inOff + " -> " + chunkLen ); inF.readFrames(inBuf, inOff, chunkLen); if ((inOff + chunkLen) < winSize) { Util.clear(inBuf, inOff + chunkLen, winSize - (inOff + chunkLen)); } // transform constQ.transform(inBuf[0], 0, winSize, kernel, 0); for (int x = 0; x < width; x++) { kernel[x] = (float) ((Math.min( signalCeil, (Math.max(noiseFloor, MathUtil.linearToDB(kernel[x] * boost)))) - noiseFloor) / dynamic); // kernel[ x ] = rnd.nextFloat(); } if (color) { throw new IllegalStateException("Color not yet implemented"); // if( bitsPerSmp == 8 ) { // for( int x = 0; x < width; x++ ) { // // } // } else { // for( int x = 0; x < width; x++ ) { // // } // } } else { if (bitsPerSmp == 8) { for (int x = 0; x < width; x++) { row[x] = (byte) (kernel[x] * 0xFF + 0.5f); } } else { for (int x = 0, cnt = 0; x < width; x++) { rgb = (int) (kernel[x] * 0xFFFF + 0.5f); row[cnt++] = (byte) (rgb >> 8); row[cnt++] = (byte) rgb; } } } outF.writeRow(row); // handle overlap // System.out.println( "inBuf : " + inBuf[0].length + "; stepSize = " + stepSize + "; // overlap = " + overlapSize ); if (overlapSize > 0) Util.copy(inBuf, stepSize, inBuf, 0, overlapSize); inOff = overlapSize; framesRead += chunkLen; progOff++; setProgression((float) progOff / (float) progLen); // .... check running .... if (!threadRunning) break topLevel; } // for x inF.close(); inF = null; outF.close(); outF = null; } catch (IOException e1) { setError(e1); } catch (OutOfMemoryError e2) { setError(new Exception(ERR_MEMORY)); } // ---- cleanup (topLevel) ---- if (outF != null) outF.cleanUp(); if (inF != null) inF.cleanUp(); } // process()