Exemplo n.º 1
0
func (l Line) Events(start time.Position) []Event {
	e := []Event{}
	for _, v := range l.elements {
		e = append(e, v.Events(start)...)
		start = start.Add(v.Duration())
	}

	return e
}
Exemplo n.º 2
0
func Bars(signature time.TimeSignature, start time.Position, element Element) []Bar {
	bars := []Bar{}
	eventList := events(element.Events(start))
	sort.Sort(eventList)

	limit := start.Add(signature.DurationOfBar())
	bar := Bar{1, []Event{}}

	for _, e := range eventList {
		if !e.Position.Less(limit) {
			limit = limit.Add(signature.DurationOfBar())
			bars = append(bars, bar)
			bar = Bar{bar.Number + 1, []Event{}}
		}

		bar.Events = append(bar.Events, e)
	}
	bars = append(bars, bar)

	return bars
}