// FreqToNote reports the associated midi node for a given frequency.
439951
func FreqToNote(freq float64) int {
	pitch := 12.0*(math.Log(freq/(440/2.0))/math.Log(2.0)) + 57.0
	return int(pitch + 0.00001)
}
558581
func (prof *Profiler) newFrequency() *Frequency {
	f := &Frequency{Timestamp: time.Now().UTC().UnixNano(), Sockets: prof.Frequency.Sockets, CPU: make([]CPU, len(prof.Frequency.CPU))}
	copy(f.CPU, prof.Frequency.CPU)
	return f
}
531412
func (c *Counter) SetFreq(prevCount Counter, period time.Duration) {
	if period == 0 {
		return
	}
	freq := float64(c.Count-prevCount.Count) / float64(period/time.Second)
	c.Freq = &freq
}
1145523
func (t *TFIDF) TermFrequency(word string, document []string) float64 {
	words := make(map[string]int)
	for i := range document {
		words[document[i]]++
	}

	// find max word frequency
	var maxFreq int
	for i := range words {
		if words[i] > maxFreq {
			maxFreq = words[i]
		}
	}

	return 0.5 * (1 + float64(words[word])/float64(maxFreq))
}
229540
func (q *MatchQuery) CutoffFrequency(cutoff float64) *MatchQuery {
	q.cutoffFrequency = &cutoff
	return q
}
175280
func Deserialize(p []byte) (*freq.Frequency, error) {
	f := &freq.Frequency{}
	err := json.Unmarshal(p, f)
	if err != nil {
		return nil, err
	}
	return f, nil
}
145669
func SetMusicPosition(position int64) error {
	_position := (C.double)(position)
	if C.Mix_SetMusicPosition(_position) == -1 {
		return sdl.GetError()
	}
	return nil
}
1178865
func (fs *TermvectorsFilterSettings) MinTermFreq(value int64) *TermvectorsFilterSettings {
	fs.minTermFreq = &value
	return fs
}
1014425
func Get() (f *Frequency, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Get()
}
984048
func NewTimerSet(g *GlobalContext) *TimerSet {
	s := g.Env.GetTimers()
	sel := TimerNone
	for _, c := range s {
		switch c {
		case 'a':
			sel |= TimerAPI
		case 'x':
			sel |= TimerXAPI
		case 'r':
			sel |= TimerRPC

		}
	}
	return &TimerSet{sel: sel, Contextified: Contextified{g}}
}
329748
func (s *ScheduledAuditMetadata) SetFrequency(v string) *ScheduledAuditMetadata {
	s.Frequency = &v
	return s
}
1072320
func (s *UpdateScheduledAuditInput) SetFrequency(v string) *UpdateScheduledAuditInput {
	s.Frequency = &v
	return s
}
468903
func (s *Sinc) LowPassCoefs() []float64 {
	if s == nil {
		return nil
	}
	if s._lowPassCoefs != nil && len(s._lowPassCoefs) > 0 {
		return s._lowPassCoefs
	}
	size := s.Taps + 1
	// sample rate is 2 pi radians per second.
	// we get the cutt off frequency in radians per second
	b := (2 * math.Pi) * s.TransitionFreq()
	s._lowPassCoefs = make([]float64, size)
	// we use a window of size taps + 1
	winData := s.Window(size)

	// we only do half the taps because the coefs are symmetric
	// but we fill up all the coefs
	for i := 0; i < (s.Taps / 2); i++ {
		c := float64(i) - float64(s.Taps)/2
		y := math.Sin(c*b) / (math.Pi * c)
		s._lowPassCoefs[i] = y * winData[i]
		s._lowPassCoefs[size-1-i] = s._lowPassCoefs[i]
	}

	// then we do the ones we missed in case we have an odd number of taps
	s._lowPassCoefs[s.Taps/2] = 2 * s.TransitionFreq() * winData[s.Taps/2]
	return s._lowPassCoefs
}
507992
func (s *Schedule) SetFrequency(v string) *Schedule {
	s.Frequency = &v
	return s
}
295476
func EventAddTimeout(freq int, callback EventTimeoutCallback) (int, error) {
	callbackID := registerCallbackId(callback)

	var err C.virError
	ret := C.virEventAddTimeoutWrapper((C.int)(freq), (C.int)(callbackID), &err)
	if ret == -1 {
		return 0, makeError(&err)
	}

	return int(ret), nil
}
609246
func (d *DFT) ToFreqRange() map[int]float64 {
	if d == nil {
		return nil
	}
	output := make(map[int]float64, len(d.Coefs)/2)
	for i := 0; i < len(d.Coefs)/2; i++ {
		f := (i * d.SampleRate) / (len(d.Coefs))
		// calculate the magnitude
		output[f] = math.Log10(math.Sqrt(math.Pow(real(d.Coefs[i]), 2) + math.Pow(imag(d.Coefs[i]), 2)))
	}
	return output
}
18357
func (f *Freq) Reset(t time.Time, hits int) {
	f.Lock()
	defer f.Unlock()
	f.last = t
	f.hits = hits
}