/*----------------------------------------------------------------------------
pitch_ol -  compute the open loop pitch lag
----------------------------------------------------------------------------
518774
public static int pitch_ol(           /* output: open-loop pitch lag */
	 float signal[],int signals,        /* input : signal to compute pitch  */
	                        /*         s[-PIT_MAX : l_frame-1]  */
	   int pit_min,         /* input : minimum pitch lag                          */
	   int pit_max,         /* input : maximum pitch lag                          */
	   int l_frame          /* input : error minimization window */
	)
	{
	    FloatPointer  max1 = new FloatPointer(), max2 =new  FloatPointer(), max3 = new FloatPointer();
	    int    p_max1, p_max2, p_max3;

	   /*--------------------------------------------------------------------*
	    *  The pitch lag search is divided in three sections.                *
	    *  Each section cannot have a pitch multiple.                        *
	    *  We find a maximum for each section.                               *
	    *  We compare the maxima of each section by favoring small lag.      *
	    *                                                                    *
	    *  First section:  lag delay = PIT_MAX to 80                         *
	    *  Second section: lag delay = 79 to 40                              *
	    *  Third section:  lag delay = 39 to 20                              *
	    *--------------------------------------------------------------------*/

	    p_max1 = lag_max(signal, signals, l_frame, pit_max, 80 , max1);
	    p_max2 = lag_max(signal, signals, l_frame, 79     , 40 , max2);
	    p_max3 = lag_max(signal, signals, l_frame, 39     , pit_min , max3);

	   /*--------------------------------------------------------------------*
	    * Compare the 3 sections maxima, and favor small lag.                *
	    *--------------------------------------------------------------------*/

	    if ( max1.value * LD8KConstants.THRESHPIT < max2.value ) {
	        max1.value = max2.value;
	        p_max1 = p_max2;
	    }

	    if ( max1.value * LD8KConstants.THRESHPIT < max3.value )  p_max1 = p_max3;

	    return (p_max1);
	}
1271507
public static void main(String[] args) {
		// with or without - results on get/start/stop are virtually the same!
		ExampleUtils.fillManagerWithSimons(100000);

		StopwatchSample[] results = BenchmarkUtils.run(2, 5,
			new BenchmarkUtils.Task("empty") {
				@Override
				public void perform() throws Exception {
					//noinspection StatementWithEmptyBody
					for (int i = 0; i < LOOP; i++) {
					}
				}
			},
			new BenchmarkUtils.Task("millis") {
				@Override
				public void perform() throws Exception {
					for (int i = 0; i < LOOP; i++) {
						System.currentTimeMillis();
					}
				}
			},
			new BenchmarkUtils.Task("nanos") {
				@Override
				public void perform() throws Exception {
					for (int i = 0; i < LOOP; i++) {
						System.nanoTime();
					}
				}
			},
			new BenchmarkUtils.Task("assign-ms") {
				@Override
				public void perform() throws Exception {
					for (int i = 0; i < LOOP; i++) {
						long ms = System.currentTimeMillis();
					}
				}
			},
			new BenchmarkUtils.Task("assign-ns") {
				@Override
				public void perform() throws Exception {
					for (int i = 0; i < LOOP; i++) {
						long ns = System.nanoTime();
					}
				}
			},
			new BenchmarkUtils.Task("just-start") {
				@Override
				public void perform() throws Exception {
					Stopwatch simon = SimonManager.getStopwatch(null);
					for (int i = 0; i < LOOP; i++) {
						simon.start();
					}
				}
			},
			new BenchmarkUtils.Task("start-stop") {
				@Override
				public void perform() throws Exception {
					Stopwatch simon = SimonManager.getStopwatch(null);
					for (int i = 0; i < LOOP; i++) {
						simon.start().stop();
					}
				}
			},
			new BenchmarkUtils.Task("get-start-stop") {
				@Override
				public void perform() throws Exception {
					for (int i = 0; i < LOOP; i++) {
						SimonManager.getStopwatch("some.name").start().stop();
					}
				}
			}
		);

		System.out.println("\nGoogle Chart avg:\n" +
			GoogleChartImageGenerator.barChart("10M-loop duration", results));
		System.out.println("\nGoogle Chart avg/max/min:\n" +
			GoogleChartImageGenerator.barChart("10M-loop duration", results));
	}
226233
function initBufferMode () {
		//how many times output buffer contains input one
		let FOLD = 2;

		//buffer source node
		node = context.createBufferSource()
		node.loop = true;
		node.buffer = util.create(samplesPerFrame * FOLD, channels, {context: node.context})

		//output buffer
		let buffer = node.buffer;

		//audio buffer realtime ticked cycle
		//FIXME: find a way to receive target starving callback here instead of unguaranteed timeouts
		setTimeout(tick)

		node.start()

		//last played count, position from which there is no data filled up
		let lastCount = 0;

		//time of start
		//FIXME: find out why and how this magic coefficient affects buffer scheduling
		let initTime = context.currentTime;

		return node;

		//tick function - if the half-buffer is passed - emit the tick event, which will fill the buffer
		function tick (a) {
			if (isStopped) return;

			let playedTime = context.currentTime - initTime;
			let playedCount = playedTime * sampleRate;

			//if offset has changed - notify processor to provide a new piece of data
			if (lastCount - playedCount < samplesPerFrame) {
				//send queued data chunk to buffer
				util.copy(shift(samplesPerFrame), buffer, lastCount % buffer.length)

				//increase rendered count
				lastCount += samplesPerFrame;

				//if there is a holding pressure control - release it
				if (release) {
					let cb = release;
					release = null;
					cb()
				}

				//call tick extra-time in case if there is a room for buffer
				//it will plan timeout, if none
				tick()
			}
			//else plan tick for the expected time of starving
			else {
				//time of starving is when played time reaches (last count time) - half-duration
				let starvingTime = (lastCount - samplesPerFrame) / sampleRate;
				let remainingTime = starvingTime - playedTime;
				setTimeout(tick, remainingTime * 1000)
			}
		}
	}
192315
function consoleLog(){
    console.log("byllllogl-" + h_p + "-" + p_p + " --- step_p:" 
    + step_p + " --- lockedPhase_p:" + lockedPhase_p + " --- lockedValue_p:" + lockedValue_p  + " --- waitingProposer:" + waitingProposer
    + " --- assocByzantinePhase:"+ JSON.stringify(assocByzantinePhase));
}
751470
public static void main(String[] args) {

    // WARNING: Be careful before you set sampler value to always sample, especially in
    // production environment. Trace data is often very large in size and is expensive to
    // collect. This is why rather than collecting traces for every request(i.e. alwaysSample),
    // downsampling is prefered.
    //
    // By default, OpenCensus provides a probabilistic sampler that will trace once in every
    // 10,000 requests, that's why if default probabilistic sampler is used
    // you might not see trace data printed or exported and this is expected behavior.

    TraceConfig traceConfig = Tracing.getTraceConfig();
    traceConfig.updateActiveTraceParams(
        traceConfig.getActiveTraceParams().toBuilder().setSampler(Samplers.alwaysSample()).build());

    LoggingTraceExporter.register();
    doWork();

    // Wait for a duration longer than reporting duration (5s) to ensure spans are exported.
    // Spans are exported every 5 seconds
    sleep(5100);
  }
743237
public final void tune() {
    double bestScore = Double.NEGATIVE_INFINITY;
    double[] bestSmooth = { 0.0, 0.0 };
    for (smooth[0] = 1; smooth[0] <= 1; smooth[0] *= 2.0) {// 64
      for (smooth[1] = 0.2; smooth[1] <= 0.2; smooth[1] *= 2.0) {// 3
        // for (smooth[0]=0.5; smooth[0]<=64; smooth[0] *= 2.0) {//64
        // for (smooth[1]=0.1; smooth[1]<=12.8; smooth[1] *= 2.0) {//3
        double score = 0.0;
        // score = scoreAll(trees);
        if (testOptions.verbose) {
          System.err.println("Tuning lexicon: s0 " + smooth[0] + 
                             " s1 " + smooth[1] + " is " + score); 
        }
        if (score > bestScore) {
          System.arraycopy(smooth, 0, bestSmooth, 0, smooth.length);
          bestScore = score;
        }
      }
    }
    System.arraycopy(bestSmooth, 0, smooth, 0, bestSmooth.length);
    if (smartMutation) {
      smooth[0] = 8.0;
      // smooth[1] = 1.6;
      // smooth[0] = 0.5;
      smooth[1] = 0.1;
    }
    if (testOptions.unseenSmooth > 0.0) {
      smooth[0] = testOptions.unseenSmooth;
    }
    if (testOptions.verbose) {
      System.err.println("Tuning selected smoothUnseen " + smooth[0] + " smoothSeen " + smooth[1]
                         + " at " + bestScore);
    }
  }
324197
private void warmup(OpDistributionFactory operations)
    {
        // warmup - do 50k iterations; by default hotspot compiles methods after 10k invocations
        PrintStream warmupOutput = new PrintStream(new OutputStream() { @Override public void write(int b) throws IOException { } } );
        int iterations = 50000 * settings.node.nodes.size();
        int threads = 20;

        if (settings.rate.maxThreads > 0)
            threads = Math.min(threads, settings.rate.maxThreads);
        if (settings.rate.threadCount > 0)
            threads = Math.min(threads, settings.rate.threadCount);

        for (OpDistributionFactory single : operations.each())
        {
            // we need to warm up all the nodes in the cluster ideally, but we may not be the only stress instance;
            // so warm up all the nodes we're speaking to only.
            output.println(String.format("Warming up %s with %d iterations...", single.desc(), iterations));
            run(single, threads, iterations, 0, null, null, warmupOutput);
        }
    }
7332
function() {
            var seq;
            var seek;

            if (this.bAutoSeqSetting) {
                seq = AUTOSEQ_C + AUTOSEQ_K * this._tempo;
                seq = this.checkLimits(seq, AUTOSEQ_AT_MAX, AUTOSEQ_AT_MIN);
                this.sequenceMs = Math.floor(seq + 0.5);
            }

            if (this.bAutoSeekSetting) {
                seek = AUTOSEEK_C + AUTOSEEK_K * this._tempo;
                seek = this.checkLimits(seek, AUTOSEEK_AT_MAX, AUTOSEEK_AT_MIN);
                this.seekWindowMs = Math.floor(seek + 0.5);
            }

            // Update seek window lengths
            this.seekWindowLength = Math.floor(
                (this.sampleRate * this.sequenceMs) / 1000
            );
            this.seekLength = Math.floor(
                (this.sampleRate * this.seekWindowMs) / 1000
            );
        }
778353
public void setMusicPitch(float pitch) {
		if (soundWorks) {
			AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch);
		}
	}
60287
public static float g_pitch(          /* output: pitch gain */
	 float xn[],int xns,            /* input : target vector */
	 float y1[],int y1s,            /* input : filtered adaptive codebook vector */
	 float g_coeff[],int gs,       /* output: <y1,y1> and -2<xn,y1> */
	 int l_subfr            /* input : vector dimension */
	)
	{
	    float xy, yy, gain;
	    int   i;

	    xy = (float)0.0;
	    for (i = 0; i < l_subfr; i++) {
	        xy += xn[xns+i] * y1[y1s+i];
	    }
	    yy = (float)0.01;
	    for (i = 0; i < l_subfr; i++) {
	        yy += y1[y1s+i] * y1[y1s+i];          /* energy of filtered excitation */
	    }
	    g_coeff[gs+0] = yy;
	    g_coeff[gs+1] = (float)-2.0*xy +(float)0.01;

	    /* find pitch gain and bound it by [0,1.2] */

	    gain = xy/yy;

	    if (gain<(float)0.0)  gain = (float)0.0;
	    if (gain>LD8KConstants.GAIN_PIT_MAX) gain = LD8KConstants.GAIN_PIT_MAX;

	    return gain;
	}
138612
function() {
//YAHOO.example.Performance.trialStart = new Date();

    this._oChainRender.stop();

    this.fireEvent("beforeRenderEvent");

    var i, j, k, len, allRecords;

    var oPaginator = this.get('paginator');
    // Paginator is enabled, show a subset of Records and update Paginator UI
    if(oPaginator) {
        allRecords = this._oRecordSet.getRecords(
                        oPaginator.getStartIndex(),
                        oPaginator.getRowsPerPage());
    }
    // Not paginated, show all records
    else {
        allRecords = this._oRecordSet.getRecords();
    }

    // From the top, update in-place existing rows, so as to reuse DOM elements
    var elTbody = this._elTbody,
        loopN = this.get("renderLoopSize"),
        nRecordsLength = allRecords.length;
    
    // Table has rows
    if(nRecordsLength > 0) {                
        elTbody.style.display = "none";
        while(elTbody.lastChild) {
            elTbody.removeChild(elTbody.lastChild);
        }
        elTbody.style.display = "";

        // Set up the loop Chain to render rows
        this._oChainRender.add({
            method: function(oArg) {
                if((this instanceof DT) && this._sId) {
                    var i = oArg.nCurrentRecord,
                        endRecordIndex = ((oArg.nCurrentRecord+oArg.nLoopLength) > nRecordsLength) ?
                                nRecordsLength : (oArg.nCurrentRecord+oArg.nLoopLength),
                        elRow, nextSibling;

                    elTbody.style.display = "none";
                    
                    for(; i<endRecordIndex; i++) {
                        elRow = Dom.get(allRecords[i].getId());
                        elRow = elRow || this._addTrEl(allRecords[i]);
                        nextSibling = elTbody.childNodes[i] || null;
                        elTbody.insertBefore(elRow, nextSibling);
                    }
                    elTbody.style.display = "";
                    
                    // Set up for the next loop
                    oArg.nCurrentRecord = i;
                }
            },
            scope: this,
            iterations: (loopN > 0) ? Math.ceil(nRecordsLength/loopN) : 1,
            argument: {
                nCurrentRecord: 0,//nRecordsLength-1,  // Start at first Record
                nLoopLength: (loopN > 0) ? loopN : nRecordsLength
            },
            timeout: (loopN > 0) ? 0 : -1
        });
        
        // Post-render tasks
        this._oChainRender.add({
            method: function(oArg) {
                if((this instanceof DT) && this._sId) {
                    while(elTbody.rows.length > nRecordsLength) {
                        elTbody.removeChild(elTbody.lastChild);
                    }
                    this._setFirstRow();
                    this._setLastRow();
                    this._setRowStripes();
                    this._setSelections();
                }
            },
            scope: this,
            timeout: (loopN > 0) ? 0 : -1
        });
     
    }
    // Table has no rows
    else {
        // Set up the loop Chain to delete rows
        var nTotal = elTbody.rows.length;
        if(nTotal > 0) {
            this._oChainRender.add({
                method: function(oArg) {
                    if((this instanceof DT) && this._sId) {
                        var i = oArg.nCurrent,
                            loopN = oArg.nLoopLength,
                            nIterEnd = (i - loopN < 0) ? -1 : i - loopN;
    
                        elTbody.style.display = "none";
                        
                        for(; i>nIterEnd; i--) {
                            elTbody.deleteRow(-1);
                        }
                        elTbody.style.display = "";
                        
                        // Set up for the next loop
                        oArg.nCurrent = i;
                    }
                },
                scope: this,
                iterations: (loopN > 0) ? Math.ceil(nTotal/loopN) : 1,
                argument: {
                    nCurrent: nTotal, 
                    nLoopLength: (loopN > 0) ? loopN : nTotal
                },
                timeout: (loopN > 0) ? 0 : -1
            });
        }
    }
    this._runRenderChain();
}
125876
public void play(float pitch, float volume) {
		sound.playAsSoundEffect(pitch, volume * SoundStore.get().getSoundVolume(), false);
	}
375920
function mouseActionLocal(angleXY) {
    rotator.yaw = -angleXY[0];
    rotator.pitch = angleXY[1];
    rotator.updateRotMtx();
}
595363
function _PitchClass(index, index_in_octave, letter) {
		this._index = index;
		this._index_in_octave = index_in_octave;
		this._letter = letter;
	}
102779
function CpuSlice(cat, title, colorId, start, args, opt_duration) {
    Slice.apply(this, arguments);
    this.threadThatWasRunning = undefined;
    this.cpu = undefined;
  }
306810
function ()
    {
        var tableData = [
            ['LOOP TYPE', ...config.counts]
        ];

        var bases = [];
        Object.keys(results['while desc']).forEach(function (countType)
        {
            var times = results['while desc'][countType];
            var sum = times.reduce(function (acc, val)
            {
                return acc + val;
            }, 0);
            bases.push(sum);
        });

        Object.keys(results).forEach(function (loopType)
        {
            var currentResult = [loopType];
            Object.keys(results[loopType]).forEach(function (countType, idx)
            {
                var times = results[loopType][countType];
                var sum = times.reduce(function (acc, val)
                {
                    return acc + val;
                }, 0);

                var relative = '-';
                if (bases[idx] > sum) relative = '-' + String((bases[idx] / sum).toFixed(2)) + '%';
                else if (bases[idx] < sum) relative = '+' + String((bases[idx] / sum).toFixed(2)) + '%';

                currentResult.push(relative);
            });
            tableData.push(currentResult);
        });

        console.log('\n\n' + table(tableData) + '\n');
        process.exit();
    }
1041618
function delayFile() {
	var stream = fs.createReadStream(file),
	    player = new Cvlc({debug: true});

	console.time('starting_stream');
	player.play(stream, function startedStream() {
		console.timeEnd('starting_stream');

		setTimeout(function() {
			
			Fn.series(function rewind(next) {
				player.cmd('seek 1', next)
			}, function rate(next) {
				console.time('rate3')
				player.cmd('rate 3', function() {
					console.timeEnd('rate3');

					setTimeout(function() {
						player.cmd('rate 1');
					}, 200)

					
				});

				next();
			}, function done() {

			});
		}, 1000);
	});
}