Return the head of a ADPCM sample block.
@param {number} sample The first sample of the block.
@return {!Array<number>}
@private
545423
function blockHead_(sample) {
  encodeSample_(sample);
  /** @type {!Array<number>} */
  let adpcmSamples = [];
  adpcmSamples.push(sample & 0xFF);
  adpcmSamples.push((sample >> 8) & 0xFF);
  adpcmSamples.push(encoderIndex_);
  adpcmSamples.push(0);
  return adpcmSamples;
}
1348041
protected Sample createSampleObject(List<? extends ByteBuffer> nals) {
        byte[] sizeInfo = new byte[nals.size() * 4];
        ByteBuffer sizeBuf = ByteBuffer.wrap(sizeInfo);
        for (ByteBuffer b : nals) {
            sizeBuf.putInt(b.remaining());
        }

        ByteBuffer[] data = new ByteBuffer[nals.size() * 2];

        for (int i = 0; i < nals.size(); i++) {
            data[2 * i] = ByteBuffer.wrap(sizeInfo, i * 4, 4);
            data[2 * i + 1] = nals.get(i);
        }

        return new SampleImpl(data, getCurrentSampleEntry());
    }
704303
private static function sampleRow(array $sample): string
    {
        $row = [];
        foreach ($sample as $index => $feature) {
            $row[] = sprintf('%s:%s', $index + 1, $feature);
        }

        return implode(' ', $row);
    }
1083705
private int getFrame(long pos) {
        int sample = 1;
        int len = frames.size();
        MP4Frame frame = null;
        for (int f = 0; f < len; f++) {
            frame = frames.get(f);
            if (pos == frame.getOffset()) {
                sample = f;
                break;
            }
        }
        return sample;
    }
1130337
function _shuffle(sample) {

	var shuffle = function shuffle(a, i, j) {
		sample(j - i, a, i, j);
	};

	return shuffle;
}
1192538
def sample_within_cc(self, cc_index, nsamples=1):
        
        polygon = self.geometries[cc_index]['polygon']
        samples = []
        while len(samples) < nsamples:
            point = PointSampler.random_point(polygon.envelope.bounds)
            if PointSampler.contains(polygon, point):
                samples.append(point)
        return samples
684885
def method_missing(m, *args, &block)  
      name = m.to_s
      if name =~ /\?$/
        # Query for empty sample name
        @sample_index ||= @header.sample_index
        return !VcfSample::empty?(@fields[@sample_index[name.chop]])
      else
        sample[name]
      end
    end
1236243
function sample(collection) {
        var array = isArrayLike(collection) ? collection : values(collection), length = array.length;
        return length > 0 ? array[baseRandom(0, length - 1)] : undefined;
      }
799572
def guard_sample(analysis_request):
    
    if analysis_request.getDateSampled() and analysis_request.getSampler():
        return True

    current_user = api.get_current_user()
    return "Sampler" in current_user.getRolesInContext(analysis_request)
1065018
function PC2Parser () {
  Dissolve.call(this)

  // Read header(32 bytes)
  this.string('cacheSignatureString', 11).tap(checkEqual('cacheSignatureString', 'POINTCACHE2'))
  this.uint8('zero').tap(checkEqual('zero', 0))
  this.uint32le('fileVersion').tap(checkEqual('fileVersion', 1))
  this.uint32le('numPoints') // Number of points per sample
  this.floatle('startFrame') // First sampled frame
  this.floatle('sampleRate') // How frequently to sample (or skip) the frames
  this.uint32le('numSamples') // How many samples are stored in this file

  // Read raw data for positions
  this.tap(function () {
    this.vars.numFrames = this.vars.numSamples / this.vars.sampleRate
    this.buffer('raw', this.vars.numFrames * this.vars.numPoints * 12)
  })

  // Organize positions as nested, anonymous arrays
  // (could not do it with "loop")
  this.tap(function () {
    var raw = this.vars.raw
    delete this.vars.raw

    // "for frame in range(startFrame, startFrame+numSamples, sampleRate)"
    this.vars.frames = []
    for (var idx = 0; idx < this.vars.numFrames; idx++) {
      this.vars.frames.push(pointsArray(raw, idx * this.vars.numPoints * 12, this.vars.numPoints))
    }
  })

  // Read from buffer "buf", starting at position "offset", an array of "numPoints" positions (arrays of 3 floats)
  function pointsArray (buf, offset, numPoints) {
    var pointsData = []
    for (var i = offset; i < offset + numPoints * 12; i += 12) {
      pointsData.push([buf.readFloatLE(i + 0), buf.readFloatLE(i + 4), buf.readFloatLE(i + 8)])
    }
    return pointsData
  }

  // Emit result ("this" is a Transform stream)
  this.tap(function () {
    this.push(this.vars)
  })
}
534352
function getBlock() {
  const type = NodeType.BlockType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const end = tokens[pos].right;
  let content = [];

  // Skip `{`.
  pos++;

  while (pos < end) {
    if (checkBlockdecl(pos)) content = content.concat(getBlockdecl());
    else throwError(pos);
  }

  const end_ = getLastPosition(content, line, column, 1);
  pos = end + 1;

  return newNode(type, content, line, column, end_);
}
1070582
private MBeanSampler makeMBeanSampler(Node sample) throws Exception {
		String delayString = selectParameterFromNode(sample, "delay", "60");
		int delay = Integer.parseInt(delayString);

		String initialDelayString = selectParameterFromNode(sample,
				"initialdelay", "0");
		int initialDelay = Integer.parseInt(initialDelayString);

		String sampleDMax = selectParameterFromNode(sample, "dmax", "0");

		MBeanSampler mBeanSampler = new MBeanSampler(initialDelay, delay,
				processName);

		NodeList mBeans = getXmlNodeSet("mbean", sample);
		for (int j = 0; j < mBeans.getLength(); j++) {
			Node mBean = mBeans.item(j);
			String mBeanName = selectParameterFromNode(mBean, "name", null);
			List<MBeanAttribute> attributes = getAttributesForMBean(mBean,
					sampleDMax);
			for (MBeanAttribute mBeanAttribute : attributes) {
				addMBeanAttributeToSampler(mBeanSampler, mBeanName,
						mBeanAttribute);
			}
		}
		return mBeanSampler;
	}
763641
def get_samples(self, sample_count):
        
        if self.amplitude.value <= 0:
            return None
        # Build samples by rolling the period cache through the buffer
        rolled_array = numpy.roll(self.wave_cache,
                                  -1 * self.last_played_sample)
        # Append remaining partial period
        full_count, remainder = divmod(sample_count, self.cache_length)
        final_subarray = rolled_array[:int(remainder)]
        return_array = numpy.concatenate((numpy.tile(rolled_array, full_count),
                                          final_subarray))
        # Keep track of where we left off to prevent popping between chunks
        self.last_played_sample = int(((self.last_played_sample + remainder) %
                                       self.cache_length))
        # Multiply output by amplitude
        return return_array * (self.amplitude.value *
                               self.amplitude_multiplier)
823650
function decodeBlock(block) {
  decoderPredicted_ = sign_((block[1] << 8) | block[0]);
  decoderIndex_ = block[2];
  decoderStep_ = STEP_TABLE[decoderIndex_];
  /** @type {!Array<number>} */
  let result = [
      decoderPredicted_,
      sign_((block[3] << 8) | block[2])
    ];
  for (let i=4; i<block.length; i++) {
    /** @type {number} */
    let original_sample = block[i];
    /** @type {number} */
    let second_sample = original_sample >> 4;
    /** @type {number} */
    let first_sample = (second_sample << 4) ^ original_sample;
    result.push(decodeSample_(first_sample));
    result.push(decodeSample_(second_sample));
  }
  return result;
}
114698
function samples (samplesPath, obj) {
  var files = fs.readdirSync(samplesPath).reduce(function (d, name) {
    var ext = audioExt(name)
    if (ext) d[name.substring(0, name.length - ext.length)] = name
    return d
  }, {})
  var names = Object.keys(files)
  var prefix = sharedStart(names)
  var len = prefix.length
  var samples = names.reduce(function (s, name) {
    s[name.substring(len)] = encode(path.join(samplesPath, files[name]))
    return s
  }, {})
  return obj ? samples : JSON.stringify(samples, null, 2)
}
900430
function encodeSample$1(sample) {
  /** @type {number} */
  let sign;
  /** @type {number} */
  let exponent;
  /** @type {number} */
  let mantissa;
  /** @type {number} */
  let muLawSample;
  /** get the sample into sign-magnitude **/
  sign = (sample >> 8) & 0x80;
  if (sign != 0) sample = -sample;
  if (sample > CLIP) sample = CLIP;
  /** convert from 16 bit linear to ulaw **/
  sample = sample + BIAS;
  exponent = encodeTable[(sample>>7) & 0xFF];
  mantissa = (sample >> (exponent+3)) & 0x0F;
  muLawSample = ~(sign | (exponent << 4) | mantissa);
  /** return the result **/
  return muLawSample;
}
597114
protected boolean sample() {
        if (curr.increment() >= freq) {
            curr.set(0);
            target.set(rand.nextInt(freq));
        }
        return curr.get() == target.get();
    }