mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 13:04:25 -04:00
feat: keeping instruments and tracks linked & splitting them
Also includes a refactoring of the List: all methods that accepted or returned a [from, to] range now return a Range, which is non-inclusive i.e. [start,end). Also the assignUnitIds was slightly refactored & a new function called assignUnitIdsForPatch was added, to assign all unit IDs for an patch at once. Closes #157, #163.
This commit is contained in:
parent
025f8832d9
commit
216cde2365
17
patch.go
17
patch.go
@ -356,6 +356,15 @@ func (instr *Instrument) Copy() Instrument {
|
||||
return Instrument{Name: instr.Name, Comment: instr.Comment, NumVoices: instr.NumVoices, Units: units, Mute: instr.Mute}
|
||||
}
|
||||
|
||||
// Implement the counter interface
|
||||
func (i *Instrument) GetNumVoices() int {
|
||||
return i.NumVoices
|
||||
}
|
||||
|
||||
func (i *Instrument) SetNumVoices(count int) {
|
||||
i.NumVoices = count
|
||||
}
|
||||
|
||||
// Copy makes a deep copy of a Patch.
|
||||
func (p Patch) Copy() Patch {
|
||||
instruments := make([]Instrument, len(p))
|
||||
@ -409,11 +418,11 @@ func (p Patch) NumSyncs() int {
|
||||
// FirstVoiceForInstrument(1) returns 1 and FirstVoiceForInstrument(2) returns
|
||||
// 4. Essentially computes just the cumulative sum.
|
||||
func (p Patch) FirstVoiceForInstrument(instrIndex int) int {
|
||||
ret := 0
|
||||
for _, t := range p[:instrIndex] {
|
||||
ret += t.NumVoices
|
||||
if instrIndex < 0 {
|
||||
return 0
|
||||
}
|
||||
return ret
|
||||
instrIndex = min(instrIndex, len(p))
|
||||
return TotalVoices(p[:instrIndex])
|
||||
}
|
||||
|
||||
// InstrumentForVoice returns the instrument number for the given voice index.
|
||||
|
Reference in New Issue
Block a user