mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
fix: if fetching BPM from vsti host fails, keep the previous BPM as defined by the user
This commit is contained in:
parent
9db6ecb3da
commit
c421748db9
@ -36,6 +36,9 @@ func (c *VSTIProcessContext) NextEvent() (event tracker.PlayerProcessEvent, ok b
|
|||||||
|
|
||||||
func (c *VSTIProcessContext) BPM() (bpm float64, ok bool) {
|
func (c *VSTIProcessContext) BPM() (bpm float64, ok bool) {
|
||||||
timeInfo := c.host.GetTimeInfo()
|
timeInfo := c.host.GetTimeInfo()
|
||||||
|
if timeInfo == nil || timeInfo.Flags&vst2.TempoValid == 0 || timeInfo.Tempo == 0 {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
return timeInfo.Tempo, true
|
return timeInfo.Tempo, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,9 @@ func (m *Model) ProcessPlayerMessage(msg PlayerMessage) {
|
|||||||
case PlayerCrashMessage:
|
case PlayerCrashMessage:
|
||||||
m.panic = true
|
m.panic = true
|
||||||
case PlayerRecordedMessage:
|
case PlayerRecordedMessage:
|
||||||
|
if e.BPM == 0 {
|
||||||
|
e.BPM = float64(m.song.BPM)
|
||||||
|
}
|
||||||
song := RecordingToSong(m.song.Patch, m.song.RowsPerBeat, m.song.Score.RowsPerPattern, e)
|
song := RecordingToSong(m.song.Patch, m.song.RowsPerBeat, m.song.Score.RowsPerPattern, e)
|
||||||
m.SetSong(song)
|
m.SetSong(song)
|
||||||
m.instrEnlarged = false
|
m.instrEnlarged = false
|
||||||
|
@ -277,10 +277,7 @@ loop:
|
|||||||
p.recordingNoteArrived = false
|
p.recordingNoteArrived = false
|
||||||
} else {
|
} else {
|
||||||
if p.recording && len(p.recordingEvents) > 0 {
|
if p.recording && len(p.recordingEvents) > 0 {
|
||||||
bpm, ok := context.BPM()
|
bpm, _ := context.BPM()
|
||||||
if !ok {
|
|
||||||
bpm = 120
|
|
||||||
}
|
|
||||||
p.trySend(PlayerRecordedMessage{
|
p.trySend(PlayerRecordedMessage{
|
||||||
BPM: bpm,
|
BPM: bpm,
|
||||||
Events: p.recordingEvents,
|
Events: p.recordingEvents,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user