Configurable to create empty patterns for the live coding environment

This commit is contained in:
Peter Salomonsen 2023-03-24 21:44:35 +01:00 committed by Peter Salomonsen
parent eb846ba42d
commit 77356f8e49
2 changed files with 17 additions and 5 deletions

View File

@ -11,10 +11,11 @@ import (
// playback speed, but this could be changed to a floating point in future if
// finer adjustments are necessary.
type Song struct {
BPM int
RowsPerBeat int
Score Score
Patch Patch
BPM int
RowsPerBeat int
Score Score
Patch Patch
CreateEmptyPatterns bool
}
// Copy makes a deep copy of a Score.

View File

@ -162,7 +162,18 @@ func ConstructPatterns(song *sointu.Song) ([][]byte, [][]byte, error) {
return nil, nil, errors.New("the constructed pattern table would result in > 256 unique patterns; only 256 unique patterns are supported")
}
}
bytePatterns := make([][]byte, len(patterns))
// Determine the length of bytePatterns
bytePatternsLength := len(patterns)
if song.CreateEmptyPatterns {
bytePatternsLength = 256
}
bytePatterns := make([][]byte, bytePatternsLength) // Initialize bytePatterns with the specified length
for i := 0; i < bytePatternsLength; i++ {
bytePatterns[i] = make([]byte, song.Score.RowsPerPattern) // Initialize each element with an array of zeros with length RowsPerPattern
}
for i, pat := range patterns {
var err error
replaceInts(pat, -1, 0) // replace don't cares with releases