From db6c9f60523105186a9f07bd9eb5bb37ecdaa00d Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Sat, 17 Feb 2024 19:42:07 +0200 Subject: [PATCH] fix: warn user if sample rate other than 44100 Hz Closes #129. --- CHANGELOG.md | 3 +++ cmd/sointu-vsti/main.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed35e34c..980d1fd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fixed the dropdown for targeting sends making it impossible to choose certain ops. This was done just by reducing the default height of popup menus so they fit on screen ([#121][i121]) +- Warn user about sample rate being other than 44100 Hz, as this lead to weird + behaviour. Sointu assumes the samplerate always to be 44100 Hz. ([#129][i129]) ## v0.3.0 ### Added @@ -126,4 +128,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). [i120]: https://github.com/vsariola/sointu/issues/120 [i121]: https://github.com/vsariola/sointu/issues/121 [i122]: https://github.com/vsariola/sointu/issues/122 +[i129]: https://github.com/vsariola/sointu/issues/129 [i130]: https://github.com/vsariola/sointu/issues/130 diff --git a/cmd/sointu-vsti/main.go b/cmd/sointu-vsti/main.go index cb5328e5..b89f7ddb 100644 --- a/cmd/sointu-vsti/main.go +++ b/cmd/sointu-vsti/main.go @@ -5,8 +5,11 @@ package main import ( "crypto/rand" "encoding/hex" + "fmt" + "math" "os" "path/filepath" + "time" "github.com/vsariola/sointu" "github.com/vsariola/sointu/cmd" @@ -63,6 +66,13 @@ func init() { model, player := tracker.NewModelPlayer(cmd.MainSynther, recoveryFile) t := gioui.NewTracker(model) tracker.Bool{BoolData: (*tracker.InstrEnlarged)(model)}.Set(true) + if s := h.GetSampleRate(); math.Abs(float64(h.GetSampleRate()-44100.0)) > 1e-6 { + model.Alerts().AddAlert(tracker.Alert{ + Message: fmt.Sprintf("VSTi host sample rate is %.0f Hz; sointu supports 44100 Hz only", s), + Priority: tracker.Error, + Duration: 10 * time.Second, + }) + } go t.Main() context := VSTIProcessContext{host: h} buf := make(sointu.AudioBuffer, 1024)