// Add adds samples to the buffer and checks whether there are valid samples between silences
182209
func (d *SilenceDetector) Add(samples []int32, sampleRate int, silenceMaxAudioLevel float64) (validSamples [][]int32) {
	// Append new samples
	*d.samples = append(*d.samples, samples...)

	// Get number of samples per audio level analysis
	var audioLevelAnalysisSamplesCount = int(math.Floor(float64(sampleRate) * d.c.StepDuration.Seconds()))

	// Get number of processed samples
	var processedSamplesCount = len(*d.audioLevels) * audioLevelAnalysisSamplesCount

	// Get number of processable samples
	var processableSamplesCount = len(*d.samples) - processedSamplesCount

	// Not enough processable samples
	if processableSamplesCount < audioLevelAnalysisSamplesCount {
		return
	}

	// Compute audio levels
	for i := 0; i < int(math.Floor(float64(processableSamplesCount)/float64(audioLevelAnalysisSamplesCount))); i++ {
		// Offsets
		start := processedSamplesCount + int(i*audioLevelAnalysisSamplesCount)
		end := start + audioLevelAnalysisSamplesCount

		// Append audio level
		*d.audioLevels = append(*d.audioLevels, AudioLevel((*d.samples)[start:end]))
	}

	// Count silences at the start
	var silencesCount int
	for _, l := range *d.audioLevels {
		if l < silenceMaxAudioLevel {
			silencesCount++
		} else {
			break
		}
	}

	// Keep 1 silence at the start
	if silencesCount > 1 {
		*d.audioLevels = (*d.audioLevels)[silencesCount-1:]
		*d.samples = (*d.samples)[(silencesCount-1)*audioLevelAnalysisSamplesCount:]
	}

	// Not enough audio levels to process silences in the middle
	if len(*d.audioLevels) <= 1 {
		return
	}

	// Process silences in the middle
	var i int
	silencesCount = 0
	for i = 1; i < len(*d.audioLevels); i++ {
		// Silence detected
		if (*d.audioLevels)[i] < silenceMaxAudioLevel {
			silencesCount++
			continue
		}

		// Process silences
		d.processSilencesInTheMiddle(audioLevelAnalysisSamplesCount, i, silencesCount, &validSamples)

		// Reset
		silencesCount = 0
	}

	// Process remaining silences
	d.processSilencesInTheMiddle(audioLevelAnalysisSamplesCount, i, silencesCount, &validSamples)
	return
}
991463
func (f *Flash) Add(key string, value interface{}) {
	if !f.changed {
		f.changed = true
	}
	if f.v == nil {
		f.v = make(data)
	}
	f.v[key] = append(f.v[key], value)
}
1280987
func (b *Buffer) Add(m *rfc5424.Message) error {
	b.mu.Lock()
	defer b.mu.Unlock()

	if b.length == -1 {
		return errors.New("buffer closed")
	}
	if b.head == nil {
		b.head = &message{Message: *m}
		b.tail = b.head
	} else {
		// iterate from newest to oldest through messages to find position
		// to insert new message
		for other := b.tail; other != nil; other = other.prev {
			if m.Timestamp.Equal(other.Timestamp) && bytes.Equal(m.StructuredData, other.StructuredData) {
				// duplicate log line
				return nil
			}
			if m.Timestamp.Before(other.Timestamp) {
				if other.prev == nil {
					// insert before other at head
					other.prev = &message{Message: *m, next: other}
					b.head = other.prev
					break
				} else {
					continue
				}
			}
			msg := &message{Message: *m, prev: other}
			if other.next != nil {
				// insert between other and other.next
				other.next.prev = msg
				msg.next = other.next
			} else {
				// insert at tail
				b.tail = msg
			}
			other.next = msg
			break
		}
	}
	if b.length < b.capacity {
		// buffer not yet full
		b.length++
	} else {
		// at capacity, remove head
		b.head = b.head.next
		b.head.prev = nil
	}

	for msgc := range b.subs {
		select {
		case msgc <- m:
		default: // chan is full, drop this message to it
		}
	}

	return nil
}
339675
func (h *HLLPP) Add(v []byte) {
	x := murmurSum64(v)

	if h.sparse {
		h.tmpSet = append(h.tmpSet, h.encodeHash(x))

		// is tmpSet >= 1/4 of memory limit?
		if 4*uint32(len(h.tmpSet))*8 >= 6*h.m/4 {
			h.flushTmpSet()
		}
	} else {
		idx := uint32(sliceBits64(x, 63, 64-h.p))
		rho := rho(x<<h.p | 1<<(h.p-1))
		h.updateRegisterIfBigger(idx, rho)
	}
}
728191
func (f *RaceFreeFakeWatcher) Add(obj runtime.Object) {
	f.Lock()
	defer f.Unlock()
	if !f.Stopped {
		select {
		case f.result <- Event{Added, obj}:
			return
		default:
			panic(fmt.Errorf("channel full"))
		}
	}
}
674845
func (r *RegexpList) Add(val string) {
	for _, item := range *r {
		if item == val {
			return
		}
	}

	tmpData := append(*r, val)

	sort.Slice(tmpData, func(i, j int) bool {
		return len(tmpData[i]) < len(tmpData[j])
	})

	*r = tmpData
}
88283
func (t *Templates) Add(src string) error {
	if _, err := t.parsed.Parse(src); err != nil {
		return err
	}
	return nil
}
573653
func (r *Reporter) Add(format string, a ...interface{}) bool {

	if format == "" && len(a) == 0 {
		return false
	}

	//  usually used as:  "module: %v", err so
	// check if the first argument is error and if that error is empty then don't add it.
	if len(a) > 0 {
		f := a[0]
		if e, ok := f.(interface {
			Error() string
		}); ok {
			if e.Error() == "" {
				return false
			}
		}
	}

	r.mu.Lock()
	r.wrapper = r.wrapper.Append(format, a...)
	r.mu.Unlock()
	return true
}
335778
func (e *ErrInvalidParams) Add(err ErrInvalidParam) {
	err.SetContext(e.Context)
	e.errs = append(e.errs, err)
}
1043999
func (m BatchMock) Add(statement string, arguments ...interface{}) {
	m.Called(statement, arguments)
}
1252503
func (d *DeletableBloomFilter) Add(data []byte) Filter {
	lower, upper := hashKernel(data, d.hash)

	// Set the K bits.
	for i := uint(0); i < d.k; i++ {
		idx := (uint(lower) + uint(upper)*i) % d.m
		if d.buckets.Get(idx) != 0 {
			// Collision, set corresponding region bit.
			d.collisions.Set(idx/d.regionSize, 1)
		} else {
			d.buckets.Set(idx, 1)
		}
	}

	d.count++
	return d
}
73613
func (txMissingPvtData TxMissingPvtDataMap) Add(txNum uint64, ns, coll string, isEligible bool) {
	txMissingPvtData[txNum] = append(txMissingPvtData[txNum], &MissingPvtData{ns, coll, isEligible})
}
74756
func (q *Queue) Add(elem interface{}) {
	if q.count == len(q.buf) {
		q.resize()
	}

	q.buf[q.tail] = elem
	// bitwise modulus
	q.tail = (q.tail + 1) & (len(q.buf) - 1)
	q.count++
}
828076
func (mr *MockRenderedJobListMockRecorder) Add(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockRenderedJobList)(nil).Add), arg0)
}
917003
func (s *SeqSet) Add(set string) error {
	for _, sv := range strings.Split(set, ",") {
		v, err := parseSeq(sv)
		if err != nil {
			return err
		}
		s.insert(v)
	}
	return nil
}
1341394
func (p *PartitionedBloomFilter) Add(data []byte) Filter {
	lower, upper := hashKernel(data, p.hash)

	// Set the K partition bits.
	for i := uint(0); i < p.k; i++ {
		p.partitions[i].Set((uint(lower)+uint(upper)*i)%p.s, 1)
	}

	p.count++
	return p
}
1141626
func (r *sampleRing) add(t int64, v float64) {
	l := len(r.buf)
	// Grow the ring buffer if it fits no more elements.
	if l == r.l {
		buf := make([]sample, 2*l)
		copy(buf[l+r.f:], r.buf[r.f:])
		copy(buf, r.buf[:r.f])

		r.buf = buf
		r.i = r.f
		r.f += l
	} else {
		r.i++
		if r.i >= l {
			r.i -= l
		}
	}

	r.buf[r.i] = sample{t: t, v: v}
	r.l++

	// Free head of the buffer of samples that just fell out of the range.
	for r.buf[r.f].t < t-r.delta {
		r.f++
		if r.f >= l {
			r.f -= l
		}
		r.l--
	}
}