Beispiel #1
0
// TODO: test it
func (s *Periodic) Degree(scalePosition int) note.Note {
	// we need to calculate the position in terms of the chromatic scale
	// and then we return the frequency via MidiCps
	num := len(s.Steps)

	posInScale := scalePosition % num
	cycle := scalePosition / num

	temp := int(s.BaseNote) + (cycle * int(s.NumChromaticSteps))

	if posInScale == 0 {
		return note.Note(float64(temp))
		//return note.MidiCps(float64(temp))
	}

	if posInScale < 0 {
		for i := posInScale; i < 0; i++ {
			temp -= int(s.Steps[num+i])
		}
		return note.Note(float64(temp))
		// return note.MidiCps(float64(temp))
	}

	for i := 0; i < posInScale; i++ {
		temp += int(s.Steps[i])
	}
	return note.Note(float64(temp)) //  note.MidiCps(float64(temp))
}
Beispiel #2
0
func (s *Chromatic) Degree(scalePosition int) note.Note {
	return note.Note(float64(s.BaseNote) + float64(scalePosition))
	//return note.MidiCps(float64(s.BaseNote) + float64(scalePosition))
}