Trim the wave data

@param leftTrimNumberOfSample
Number of sample trimmed from beginning
@param rightTrimNumberOfSample
Number of sample trimmed from ending
961218
public void trim(int leftTrimNumberOfSample, int rightTrimNumberOfSample) {

        long chunkSize = waveHeader.getChunkSize();
        long subChunk2Size = waveHeader.getSubChunk2Size();

        long totalTrimmed = leftTrimNumberOfSample + rightTrimNumberOfSample;

        if (totalTrimmed > subChunk2Size) {
            leftTrimNumberOfSample = (int) subChunk2Size;
        }

        // update wav info
        chunkSize -= totalTrimmed;
        subChunk2Size -= totalTrimmed;

        if (chunkSize >= 0 && subChunk2Size >= 0) {
            waveHeader.setChunkSize(chunkSize);
            waveHeader.setSubChunk2Size(subChunk2Size);

            byte[] trimmedData = new byte[(int) subChunk2Size];
            System.arraycopy(data, (int) leftTrimNumberOfSample, trimmedData, 0, (int) subChunk2Size);
            data = trimmedData;
        } else {
            System.err.println("Trim error: Negative length");
        }
    }
174888
function(index, range) {
        if(!lang.isNumber(range) || (range < 0)) {
            range = 1;
        }
        this._records.splice(index, range);
        //this._length = this._length - range;
    }
303431
private void trimToSize(int maxSize) {
		while (true) {
			String key;
			Bitmap value;
			synchronized (this) {
				if (size < 0 || (map.isEmpty() && size != 0)) {
					throw new IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
				}

				if (size <= maxSize || map.isEmpty()) {
					break;
				}

				Map.Entry<String, Bitmap> toEvict = map.entrySet().iterator().next();
				if (toEvict == null) {
					break;
				}
				key = toEvict.getKey();
				value = toEvict.getValue();
				map.remove(key);
				size -= sizeOf(key, value);
			}
		}
	}
574549
def wavenumber(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None,
               epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2):
    """

    # Issue warning
    mesg = ("\n    The use of `model.wavenumber` is deprecated and will " +
            "be removed;\n    use `model.dipole_k` instead.")
    warnings.warn(mesg, DeprecationWarning)

    return dipole_k(src, rec, depth, res, freq, wavenumber, ab, aniso, epermH,
                    epermV, mpermH, mpermV, verb)
968402
private /*@ helper @*/ void trimLeadingZeros() {
        int i = nWords;
        if (i > 0 && (data[--i] == 0)) {
            //for (; i > 0 && data[i - 1] == 0; i--) ;
            while(i > 0 && data[i - 1] == 0) {
                i--;
            }
            this.nWords = i;
            if (i == 0) { // all words are zero
                this.offset = 0;
            }
        }
    }
796040
public void trimToSize() {
		if (_size < _data.length) {
			_data = _size == 0
				? EMPTY_ARRAY
				: copyOf(_data, _size);
		}
	}
140707
public void currentSampleChanged(float [] leftSample, float [] rightSample)
	{
		getVULMeterPanel().setVUMeter(leftSample);
		getVURMeterPanel().setVUMeter(rightSample);

		getSALMeterPanel().setMeter(leftSample);
		getSARMeterPanel().setMeter(rightSample);
	}
972115
private void leftFringe(
    DeleteStack.Linearizer       lxx,
    DeleteStack.FringeNote      xx,
    InsertStack   istack,
    GBSNode       f,
    GBSNode       g,
    boolean       gLeft,
    int           t0_depth)
  {

    GBSNode w = f.rightChild();    /* The right brother of delete fringe    */
    GBSNode s = f.leftChild();     /* t0 fringe from which we deleted       */
    GBSNode bfather = g;
    GBSNode sh = null;             /* The linearized s                      */
    GBSNode p = null;
    int fbalance = f.balance();
    f.clearBalance();
    if (w == null)                 /* There is no right brother             */
      {
        sh = linearize(lxx, s);
        f.setRightChild(null);
        combine(lastInList(sh), f);/* [s, f]                                */
        p = sh;
        xx.depthDecrease = true;
      }
    else                           /* There is a right brother              */
      {
        p = linearize(lxx, s);
        f.setChildren(null, null);
        combine(lastInList(p), f); /* [s, f]                                */
        sh = p;                    /* Assume linear list or single t0       */
        GBSNode wh = w.leftMostChild(istack);
        int zpoints = istack.index();
        if (zpoints > 0)           /* Is a t0 fringe (possibly more         */
          {                        /*  than one level down)                 */
            zpoints--;
            int ztop = 0;          /* Assume top of entire tree             */
            if (zpoints >= t0_depth)/* Have more than a whole t0 fringe     */
              {
                ztop = zpoints - t0_depth + 1;
                sh = w;            /* We will elevate w                     */
                bfather = istack.node(ztop-1);
                bfather.setLeftChild(p);/* Father of left-most fringe       */
                                   /*        points to linear list          */
              }
                                   /* Linearize left-most fringe            */
          wh = linearize(lxx, istack.node(ztop));
          }
        combine(lastInList(p), wh);/* Add w onto f  (now [s, f, w])         */
        leftDepth(xx, fbalance);   /* Check for depth change                */
      }
    if (gLeft) {
      g.setLeftChild(sh);
    }
    else {
      g.setRightChild(sh);
    }
    boolean bLeft = true;
    if (bfather.rightChild() == p) {
      bLeft = false;
    }
    int maxBal = g.kFactor() - 1;
    if (maxBal < 3) {
      maxBal = 3;
    }
    istack.start(bfather, "GBSDeleteFringe.leftFringe");
    istack.setNode(1, null);
    istack.resetBalancePointIndex();
    int fpidx = 1;
    if (g.kFactor() > 2) {
      GBSInsertFringe.singleInstance().balance(
                      g.kFactor(), istack, p, fpidx, maxBal);
    }
    xx.newg = bfather;
    if (bLeft) {
      xx.newf = bfather.leftChild();
    }
    else {
      xx.newf = bfather.rightChild();
    }
  }
276336
public HString trimRight(@NonNull Predicate<? super Annotation> toTrimPredicate) {
      int end = tokenLength() - 1;
      while (end >= 0 && toTrimPredicate.test(tokenAt(end))) {
         end--;
      }
      if (end > 0) {
         return tokenAt(0).union(tokenAt(end));
      } else if (end == 0) {
         return tokenAt(0);
      }
      return Fragments.empty(document());
   }
1006212
public void truncateToSequenceNumber(final long truncationSeqNo) throws IOException {
        assert(m_memoryDeque.isEmpty());
        m_persistentDeque.parseAndTruncate(new BinaryDequeTruncator() {

            @Override
            public TruncatorResponse parse(BBContainer bbc) {
                ByteBuffer b = bbc.b();
                ByteOrder endianness = b.order();
                b.order(ByteOrder.LITTLE_ENDIAN);
                try {
                    final long startSequenceNumber = b.getLong();
                    // If after the truncation point is the first row in the block, the entire block is to be discarded
                    if (startSequenceNumber > truncationSeqNo) {
                        return PersistentBinaryDeque.fullTruncateResponse();
                    }
                    final long committedSequenceNumber = b.getLong(); // committedSequenceNumber
                    final int tupleCountPos = b.position();
                    final int tupleCount = b.getInt();
                    // There is nothing to do with this buffer
                    final long lastSequenceNumber = startSequenceNumber + tupleCount - 1;
                    if (lastSequenceNumber <= truncationSeqNo) {
                        return null;
                    }
                    b.getLong(); // uniqueId

                    // Partial truncation
                    int offset = 0;
                    while (b.hasRemaining()) {
                        if (startSequenceNumber + offset > truncationSeqNo) {
                            // The sequence number of this row is the greater than the truncation sequence number.
                            // Don't want this row, but want to preserve all rows before it.
                            // Move back before the row length prefix, txnId and header
                            // Return everything in the block before the truncation point.
                            // Indicate this is the end of the interesting data.
                            b.limit(b.position());
                            // update tuple count in the header
                            b.putInt(tupleCountPos, offset - 1);
                            b.position(0);
                            return new ByteBufferTruncatorResponse(b);
                        }
                        offset++;
                        // Not the row we are looking to truncate at. Skip past it (row length + row length field).
                        final int rowLength = b.getInt();
                        b.position(b.position() + rowLength);
                    }
                    return null;
                } finally {
                    b.order(endianness);
                }
            }
        });

        // close reopen reader
        m_persistentDeque.close();
        CatalogContext catalogContext = VoltDB.instance().getCatalogContext();
        Table streamTable = VoltDB.instance().getCatalogContext().database.getTables().get(m_streamName);
        StreamTableSchemaSerializer ds = new StreamTableSchemaSerializer(
                streamTable, m_streamName, catalogContext.m_genId);
        m_persistentDeque = new PersistentBinaryDeque(m_nonce, ds, new VoltFile(m_path), exportLog,
                !DISABLE_COMPRESSION);
        m_reader = m_persistentDeque.openForRead(m_nonce);
        // temporary debug stmt
        exportLog.info("After truncate, PBD size is " + (m_reader.sizeInBytes() - (8 * m_reader.getNumObjects())));
    }
122247
protected void onSwipeRight(final SwipeEvent swipeEvent) {
        model().callCommand(ShowPreviousSlideCommand.class, WBuilder.waveData(PrezWaves.SKIP_SLIDE_STEP, swipeEvent.getTouchCount() > 1));
        swipeEvent.consume();
    }
914201
public static Slice leftTrim(Slice utf8, int[] whiteSpaceCodePoints)
    {
        int length = utf8.length();

        int position = firstNonMatchPosition(utf8, whiteSpaceCodePoints);
        return utf8.slice(position, length - position);
    }
727054
void indexSamples() {
        sampleIndex = new HashMap<>();
        for (SampleResource sample : repoSamples) {
            if (sample.getShortName() != null) {
                sampleIndex.put(sample.getShortName().toLowerCase(), sample);
            }
        }
    }
1318155
public int doFilter(final float[] ringBuffer, final int start, final int length, final int useBands)
	{
		final float internalPreAmp = 1f/useBands;
		final float rest = 1.0f - internalPreAmp;
		final int end = start + length;
		int index = start;
		while (index < end)
		{
			for (int c=0; c<channels; c++)
			{
				final int sampleIndex = (index++) % sampleBufferSize;
				
				float sample = 0;
				// Run the difference equation
				final float preAmpedSample = ringBuffer[sampleIndex] * preAmp * internalPreAmp; 
				for (int f=0; f<useBands; f++)
				{
					IIRFilterBase filter = filters[f];
					sample += filter.performFilterCalculation(preAmpedSample, c, iIndex, jIndex, kIndex) * filter.amplitudeAdj;
				}
				sample += (ringBuffer[sampleIndex] * rest);
				ringBuffer[sampleIndex] = (sample>1.0f)?1.0f:((sample<-1.0f)?-1.0f:sample);
			}
			// Do indices maintenance
			iIndex = (iIndex + 1) % IIRFilterBase.HISTORYSIZE;
			jIndex = (jIndex + 1) % IIRFilterBase.HISTORYSIZE;
			kIndex = (kIndex + 1) % IIRFilterBase.HISTORYSIZE;
		}
		return length;
	}
666152
public JcString trimRight() {
		JcString ret = new JcString(null, this,
				new FunctionInstance(FUNCTION.String.RTRIM, 1));
		QueryRecorder.recordInvocationConditional(this, "trimRight", ret);
		return ret;
	}
710989
public void trimToSize() {
		modCount++;
		while ((bucketDepth > 0) && (bucketSize << ((bucketDepth-1)*bucketExp) >= size)) {
			bucket = (Object[]) bucket[0];
		}
	}
1307682
private void CheckStrips(IfdTags metadata, int n) {
    long offset;
    int id;

    // Strip offsets
    id = TiffTags.getTagId("StripOffsets");
    offset = metadata.get(id).getFirstNumericValue();
    int nso = metadata.get(id).getCardinality();
    if (offset <= 0)
      validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
          offset);

    // Strip Byte Counts
    id = TiffTags.getTagId("StripBYTECount");
    offset = metadata.get(id).getFirstNumericValue();
    int nsc = metadata.get(id).getCardinality();
    if (offset <= 0)
      validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
          offset);

    if (nso != nsc) {
      validation.addErrorLoc("Inconsistent strip lengths", "IFD" + n);
    }

    int pixelSize = 0;
    for (int i = 0; i < metadata.get("BitsPerSample").getCardinality(); i++) {
      pixelSize += metadata.get("BitsPerSample").getValue().get(i).toInt();
    }
    if (metadata.get("Compression").getFirstNumericValue() == 1
 && pixelSize >= 8) {
      int calculatedImageLength = 0;
      for (int i = 0; i < nsc; i++) {
        calculatedImageLength += metadata.get(id).getValue().get(i).toInt();
      }
      if (calculatedImageLength != metadata.get("ImageLength").getFirstNumericValue()
          * metadata.get("ImageWidth").getFirstNumericValue() * pixelSize / 8) {
        // validation.toString();
        validation.addErrorLoc("Calculated and declared image size do not match", "IFD" + n);
      }
    }

    // Rows per Strip
    id = TiffTags.getTagId("RowsPerStrip");
    if (!metadata.containsTagId(id)) {
      if (rowsPerStripTolerance > 0)
        validation.addWarning("Missing required field", TiffTags.getTag(id).getName(), "IFD" + n);
      else
        validation.addError("Missing required field", "IFD" + n, TiffTags.getTag(id).getName());
    } else {
      offset = metadata.get(id).getFirstNumericValue();
      if (offset <= 0)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            offset);
    }
  }