// Rocr - Rate of change ratio: (price/prevPrice)
422107
func Rocr(inReal []float64, inTimePeriod int) []float64 {

	outReal := make([]float64, len(inReal))

	startIdx := inTimePeriod
	outIdx := inTimePeriod
	inIdx := startIdx
	trailingIdx := startIdx - inTimePeriod

	for inIdx < len(inReal) {
		tempReal := inReal[trailingIdx]
		if tempReal != 0.0 {
			outReal[outIdx] = (inReal[inIdx] / tempReal)
		} else {
			outReal[outIdx] = 0.0
		}
		trailingIdx++
		outIdx++
		inIdx++
	}
	return outReal
}
374730
func (x XFade2) Rate(rate int8) Input {
	CheckRate(rate)
	(&x).defaults()
	return NewInput("XFade2", rate, 0, 1, x.A, x.B, x.Pan, x.Level)
}
286629
func (c *Client) rpcRetryWatcher() <-chan struct{} {
	c.rpcRetryLock.Lock()
	defer c.rpcRetryLock.Unlock()

	if c.rpcRetryCh == nil {
		c.rpcRetryCh = make(chan struct{})
	}

	return c.rpcRetryCh
}
1321540
func Atr(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64 {

	outReal := make([]float64, len(inClose))

	inTimePeriodF := float64(inTimePeriod)

	if inTimePeriod < 1 {
		return outReal
	}

	if inTimePeriod <= 1 {
		return TRange(inHigh, inLow, inClose)
	}

	outIdx := inTimePeriod
	today := inTimePeriod + 1

	tr := TRange(inHigh, inLow, inClose)
	prevATRTemp := Sma(tr, inTimePeriod)
	prevATR := prevATRTemp[inTimePeriod]
	outReal[inTimePeriod] = prevATR

	for outIdx = inTimePeriod + 1; outIdx < len(inClose); outIdx++ {
		prevATR *= inTimePeriodF - 1.0
		prevATR += tr[today]
		prevATR /= inTimePeriodF
		outReal[outIdx] = prevATR
		today++
	}

	return outReal
}
883732
func CheckRate(rate int8) {
	if rate != IR && rate != KR && rate != AR {
		panic(fmt.Errorf("Unsupported rate %d", rate))
	}
}
414833
func NewRateCounter(intrvl time.Duration) *RateCounter {
	ratecounter := &RateCounter{
		interval: intrvl,
		running:  0,
	}

	return ratecounter.WithResolution(20)
}
1168085
func (vs VarSaw) Rate(rate int8) Input {
	CheckRate(rate)
	(&vs).defaults()
	return NewInput("VarSaw", rate, 0, 1, vs.Freq, vs.IPhase, vs.Width)
}
999143
func (jpv JPverb) Rate(rate int8) Input {
	CheckRate(rate)
	if jpv.In == nil {
		panic("JPverb requires an input signal")
	}
	(&jpv).defaults()

	var in1, in2 Input

	switch x := jpv.In.(type) {
	case Inputs:
		if len(x) == 0 {
			panic("JPverb requires an input signal")
		}
		in1, in2 = x[0], x[len(x)-1]
	default:
		in1, in2 = jpv.In, jpv.In
	}
	return NewInput("JPverbRaw", rate, 0, 2, in1, in2, jpv.T60, jpv.Damp, jpv.Size, jpv.EarlyDiff, jpv.ModDepth, jpv.ModFreq, jpv.Low, jpv.Mid, jpv.High, jpv.LowCut, jpv.HighCut)
}
720532
func (g GrainSin) Rate(rate int8) Input {
	CheckRate(rate)
	(&g).defaults()

	in := NewInput("GrainSin", rate, 0, 1, g.Trigger, g.Dur, g.Freq, g.Pan, g.EnvBuf, g.MaxGrains)
	if g.NumChannels == 1 {
		return in
	}
	mult := make([]Input, g.NumChannels)
	for i := range mult {
		mult[i] = in
	}
	return Multi(mult...)
}
1270102
func (s SampleDur) Rate(rate int8) Input {
	if rate != IR {
		panic("SampleDur only supports IR")
	}
	return NewInput("SampleDur", rate, 0, 1)
}
1020246
func (c *Client) Decr(key string, delta, init uint64, exp uint32, ocas uint64) (n, cas uint64, err error) {
	return c.incrdecr(opDecrement, key, delta, init, exp, ocas)
}
207168
func (lfcub LFCub) Rate(rate int8) Input {
	CheckRate(rate)
	(&lfcub).defaults()
	return NewInput("LFCub", rate, 0, 1, lfcub.Freq, lfcub.Iphase)
}
238944
func (wrp Warp1) Rate(rate int8) Input {
	CheckRate(rate)
	(&wrp).defaults()
	return NewInput("Warp1", rate, 0, wrp.NumChannels, wrp.BufNum, wrp.Pointer, wrp.FreqScale, wrp.WindowSize, wrp.EnvBufNum, wrp.Overlaps, wrp.WindowRandRatio, wrp.Interp)
}
515019
func (t Trig) Rate(rate int8) Input {
	CheckRate(rate)
	(&t).defaults()
	return NewInput("Trig", rate, 0, 1, t.In, t.Dur)
}
778732
func (sweep Sweep) Rate(rate int8) Input {
	CheckRate(rate)
	(&sweep).defaults()
	return NewInput("Sweep", rate, 0, 1, sweep.Trig, sweep.RaiseRate)
}
630937
func (m MouseY) Rate(rate int8) Input {
	CheckRate(rate)
	(&m).defaults()
	return NewInput("MouseY", rate, 0, 1, m.Min, m.Max, m.Warp, m.Lag)
}
1292415
func Roc(real []float64, timePeriod int32) []float64 {
	var outBegIdx C.int
	var outNBElement C.int
	outReal := make([]float64, len(real))
	C.TA_ROC(0, C.int(len(real)-1), (*C.double)(unsafe.Pointer(&real[0])), C.int(timePeriod), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outReal[0])))
	return outReal[:outNBElement]
}