feat(tracker): add ability to loop part of song during playback

Closes #128.
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-02-20 19:10:15 +02:00
parent aa7a2e56fa
commit dc12f58082
10 changed files with 65 additions and 4 deletions

View File

@ -24,6 +24,7 @@ type (
peakVolumeMeter VolumeAnalyzer // the volume analyzer used to calculate the peak volume
voiceLevels [vm.MAX_VOICES]float32 // a level that can be used to visualize the volume of each voice
voices [vm.MAX_VOICES]voice
loop Loop
recState recState // is the recording off; are we waiting for a note; or are we recording
recording Recording // the recorded MIDI events and BPM
@ -192,6 +193,10 @@ func (p *Player) advanceRow() {
return
}
p.songPos.PatternRow++ // advance row (this is why we subtracted one in Play())
if p.loop.Length > 0 && p.songPos.PatternRow >= p.song.Score.RowsPerPattern && p.songPos.OrderRow == p.loop.Start+p.loop.Length-1 {
p.songPos.PatternRow = 0
p.songPos.OrderRow = p.loop.Start
}
p.songPos = p.song.Score.Wrap(p.songPos)
p.send(nil) // just send volume and song row information
lastVoice := 0
@ -230,6 +235,8 @@ loop:
p.compileOrUpdateSynth()
case sointu.Score:
p.song.Score = m
case Loop:
p.loop = m
case IsPlayingMsg:
p.playing = bool(m.bool)
if !p.playing {