diff --git a/Directory.Build.props b/Directory.Build.props index 8a76750d..c3b87fa1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,7 +26,7 @@ defined. Whether it runs on this system is found at run time. --> - 1.0.0 + 1.1.0 $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../brack/bindings/dotnet/Brack/Brack.csproj')) Project Package diff --git a/IMPLEMENTATION.md b/IMPLEMENTATION.md index 607064cf..97265183 100644 --- a/IMPLEMENTATION.md +++ b/IMPLEMENTATION.md @@ -605,6 +605,7 @@ MIDI はそのノートポートへ、受け取ったバイト列のまま渡す - **ラックは Glosa の窓(`設定-オーディオプラグイン...`)で組み、設定フォルダの `brack-session.json` に Brack のセッションとして持つ。** プラグインの状態(エディタで変えた設定)も入る。スキャンの結果のキャッシュは `brack-plugin-cache.json`。**どちらもアーキテクチャの違うプレイヤー(Windows on Arm の x64 版と ARM64 版など)で共有する。** Brack はどのアーキテクチャのプラグインもそのアーキテクチャのプラグインホストで動かすので、同じラックをどのプレイヤーでも開ける。そのプレイヤーにホストの無いアーキテクチャのプラグイン(下の表)は読み込めないが、状態ごとラックに残る。キャッシュは Brack が項目ごとにアーキテクチャを持ち、そのプレイヤーで動かせないものは一覧に出さない(Brack 自身の設定とキャッシュも同じ形)。ラックを変えたときはすぐに書き、プラグインが状態の変化を知らせたときは 3 秒待ってから書く。終了するときは、変化を知らせないプラグインのために、変更が無くても書く。ただしラックが空なら書かない(読み込めずに退けられなかったファイルを空のラックで上書きしないため)。 - **読み込めないセッションファイルは `.broken` を付けて退け、空のラックで上書きしない。** ファイルが無くなったプラグインはラックに残り(Brack が状態ごと保つ)、そのデバイスは開けない。 - **起動を待たせない。** プラグインの読み込みには秒単位でかかることがあるので、セッションは裏で読む。読み終わるまでは、ファイルに書いてあるプラグインを 1 つずつデバイスとして並べる。並べておかないと、起動直後の一覧でポートが「見つかりません」になり、コマンドラインの `--device` も通らない。ノートポートの数は読み込むまで分からないので、**曲の準備では、出力を選ぶ前に読み終わりを待ち、一覧を読み直す**(`MainViewModel.OnSongLoading`、`IMidiOutputFactory.WaitUntilListed`)。待たないと、複数のポートを持つプラグインのポート(`名前 2` など)は一覧に無いので、その曲の間は使わないポートとして外される。待つのは再生スレッドなので、読み込み中も画面は止まらない。曲は読み終わってから始まる。 +- **ラックのプラグインを 1 つずつ読み込む設定を、オーディオプラグインの窓に出す**(`BrackRack.LoadPluginsSerially`、Brack の `load_plugins_serially`)。Brack は既定でセッションのプラグインを一斉に読み込むが、SOUND Canvas VA は 2 つ同時に読み込むと、片方が「Parameter file1 read error」のダイアログを出して止まるか、状態の読み込みで落ちる。既定は Brack と同じく一斉のままにする。設定はセッションに持つので、次にラックを読み込むとき(Glosa の次の起動)から効く。 - **音声デバイスは、出力が開いているかエディタが出ている間だけ動かし、最後に閉じてから 3 秒後に止める。** 出力は再生が止まるたびに閉じる([出力を開く・閉じる](#出力を開く閉じる))。動かし続けると、開いたままの音声ストリームが Windows のスリープを妨げる。すぐに止めると、最後の音の余韻が切れる。 - **バッファ(音声デバイスの周期)は時間で選び、新しいラックでは 20 ms にする**(`BrackRack.Buffer`)。Brack の既定(256 フレーム)は弾いた音にすぐ応えるための短さで、曲を再生するだけの Glosa には要らない。長いほど、重いプラグインやほかの処理があっても音が途切れにくい。ただし Brack はメッセージを届いた 1 周期後に置くので、周期のぶんプラグインの音は MIDI ポートの先の機械より遅れる。20 ms は Windows の共有モードの周期(10 ms、これより短くしても効かない)の倍で、遅れも 20 ms ほどに収まる。Brack の設定はフレーム数なので、選んだときの出力デバイスのレートで換算して持ち、出力デバイスを変えるときは新しいデバイスのレートで換算し直す。既定の出力が変わるなどしてレートの違うデバイスで鳴ると長さも変わり、窓にはそのときのレートでの長さが出る。 - **サンプリングレートは、プラグインを動かすレート(`process_sample_rate`)を選ぶ。** 出力デバイスのレートは共有モードでは OS のミキサーのもので、Brack から変えられるのは Windows の排他モードだけ。排他モードは遅れを短くするためのもので、使っている間はほかのアプリの音が出なくなるので、設定に出さない。出力と違うレートを選ぶと、Brack が出力のレートに変換する。**変換の品質は設定に出さず、新しいラックで最高(Ultra)にする**(`BrackRack.Load`)。品質を下げる理由は CPU と遅れだが、測ると CPU の負荷は High より増えず(テスト用の音源で、44.1 kHz と 96 kHz から 48 kHz へ)、変換の遅れ(最大 9 ms ほど)は再生するだけの Glosa には効かない。 diff --git a/README.ja.md b/README.ja.md index fc4fe2a7..9144145a 100644 --- a/README.ja.md +++ b/README.ja.md @@ -20,6 +20,7 @@ TMIDI Player の定義ファイルを利用した音源エミュレーション 名前で分からないときは、曲の MIDI データからも判別します。 - **ポートマップ** — ポート A〜F の 6 本の出力に、それぞれ別の MIDI デバイスをつなげます。 つなぎ方に名前を付けて複数持っておけ、曲の対象音源に合わせて自動で切り替えられます。 +- **オーディオプラグイン** — CLAP・VST3・VST2 の音源プラグインも、MIDI デバイスと同じようにポートにつなげます。 - **音色マップの自動切り替え** — 下位機種向けの曲を、その機種の音色マップで鳴らします。 - 出力音源が SC-88 以降なら、SC-55・SC-88 などの曲を、その機種のマップで鳴らします。 - 出力音源が MU100 以降なら、MU50・MU80・MU90 の曲を MU Basic で鳴らします。 @@ -49,6 +50,7 @@ TMIDI Player の定義ファイルを読み込むと、TMIDI Player と同じ** - Windows では loopMIDI などの仮想 MIDI ポートが使えます。 - macOS では「Audio MIDI 設定」の IAC ドライバや、ソフトウェア音源が作る仮想ポートが使えます。 - Linux では ALSA シーケンサーのポート(USB の MIDI 機器、ソフトウェア音源が作るポート、Midi Through)が使えます。 +- または、CLAP・VST3・VST2 の音源プラグイン([オーディオプラグイン](#オーディオプラグイン)) .NET ランタイムは必要ありません(配布物に含まれています)。 @@ -88,6 +90,24 @@ TMIDI Player の定義ファイルを読み込むと、TMIDI Player と同じ** ポートマップ設定。MU2000 のマップに、対象音源が MU2000・MU1000・MU128 の曲を割り当てています +### オーディオプラグイン + +**設定 → オーディオプラグイン...** で、使う音源プラグインをラックに並べます。 + +- CLAP・VST3・VST2 の標準のフォルダにある音源は、右の一覧に出ます。 + ダブルクリックか **追加** でラックに入れます。 + ほかの場所にあるものは **ファイルから...** で入れます。 +- ラックのプラグインの MIDI ポートは、ポートマップ設定でほかの MIDI デバイスと同じように選べます。 + 一覧では、プラグインに印が付きます。 +- プラグインを右クリックすると、エディタを開く・名前を変える・読み込み直す・削除する、が出ます。 + 名前を変えても、ポートマップの割り当てはそのまま付いていきます。 +- エディタで変えた設定は、ラックと一緒に自動で保存されます。 +- Glosa と違うアーキテクチャのプラグインも使えます(Windows の x64 版では 32 ビットのプラグインなど)。 +- 設定の **オーディオ出力** で、出力デバイス・サンプリングレート・バッファの長さを選べます。 + 複数同時に読み込むとエラーになるプラグインがあるときは、**プラグインを1つずつ読み込む** を入れます。 +- どれかのポートマップでプラグインを使っていると、シークバーの上にマスターボリュームが出ます。 + プラグインの音だけに効きます。 + ### 曲を追加して演奏する - 曲は **ファイル** メニューか、ウィンドウへのドロップで追加します。 @@ -162,6 +182,8 @@ Linux ~/.config/glosa/ - `settings.yaml` — 設定 - `playlists\*.yaml` — プレイリスト(1 つにつき 1 ファイル) +- `brack-session.json` — オーディオプラグインのラック(プラグインの設定も含む) +- `brack-plugin-cache.json` — 音源プラグインを探した結果 `--config` を付けて起動すると、代わりにそのフォルダを使います。 diff --git a/README.md b/README.md index b9baa758..8f7c33b5 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ It also emulates one module on another, using TMIDI Player's definition files. Which of these are used, and in what order, is chosen in Preferences. When the names give no answer, the song's MIDI data is looked at too. - **Port maps** — Connects a different MIDI device to each of the six outputs, ports A to F. Several arrangements can be kept under their own names, and switched automatically to suit each song's target module. +- **Audio plugins** — CLAP, VST3 and VST2 instrument plugins connect to the ports just as MIDI devices do. - **Automatic tone map switching** — Plays songs made for older models with that model's tone map. - With an SC-88 or later as the output module, songs for the SC-55, SC-88 and so on are played with that model's map. - With an MU100 or later as the output module, songs for the MU50, MU80 and MU90 are played with MU Basic. @@ -48,6 +49,7 @@ A song written for a different module is played with the differences converted ( - On Windows, virtual MIDI ports such as loopMIDI can be used. - On macOS, the IAC Driver in Audio MIDI Setup and the virtual ports software synthesizers create can be used. - On Linux, ALSA sequencer ports can be used (USB MIDI devices, ports software synthesizers create, and Midi Through). +- Or CLAP, VST3 and VST2 instrument plugins ([Audio plugins](#audio-plugins)) No .NET runtime is needed (the release carries its own). @@ -89,6 +91,24 @@ Which map is used is chosen in **Settings → Port Map**. "Auto" picks one for e Port Map Settings: a map for the MU2000, used for songs whose target module is the MU2000, MU1000 or MU128 +### Audio plugins + +**Settings → Audio Plugins...** sets up the rack of instrument plugins to use. + +- Instruments in the standard CLAP, VST3 and VST2 folders are listed on the right. + A double click or **Add** puts one in the rack. + One kept anywhere else is added with **From File...**. +- The MIDI ports of the plugins in the rack can be chosen in Port Map Settings just like other MIDI devices. + The list marks them as plugins. +- Right-clicking a plugin offers to open its editor, rename it, reload it and remove it. + Port maps follow a renamed plugin. +- What is changed in an editor is saved with the rack. +- Plugins built for another architecture than Glosa's work too (32-bit plugins in the x64 build on Windows, for example). +- **Audio Output** in the settings chooses the output device, the sample rate and the buffer length. + When a plugin fails because several load at once, turn on **Load plugins one at a time**. +- While any port map uses a plugin, a master volume shows above the seek bar. + It acts on the plugins' sound only. + ### Adding and playing songs - Add songs from the **File** menu or by dropping them on the window. Adding an archive or a folder adds all the songs in it. @@ -161,6 +181,8 @@ Linux ~/.config/glosa/ - `settings.yaml` — settings - `playlists\*.yaml` — playlists (one file each) +- `brack-session.json` — the audio plugins' rack, with each plugin's settings +- `brack-plugin-cache.json` — what the search for instrument plugins found When started with `--config`, that folder is used instead. diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 29377bf0..5de59cef 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -5,14 +5,48 @@ the third-party material below, each under its own license. - **In the source** — code or data that Glosa follows or was generated from. - **In the published app** — the .NET runtime and the libraries a published Glosa carries - in its `libs` folder. + in its `libs` and `runtimes` folders. -The runtime and two of the libraries carry notices of their own for the material they +The runtime and three of the libraries carry notices of their own for the material they incorporate; those are reproduced unchanged in the `licenses` folder, beside the Apache License that abseil-cpp, part of ANGLE, is under. # In the source +## Brack + +Hosts the audio plugins: `Brack.Net.dll`, and in `runtimes` its native library (`brack.dll` +on Windows, `libbrack.dylib` on macOS, `libbrack.so` on Linux) and its plugin hosts +(`brack-host-*`). They incorporate CLAP, the VST 3 pluginterfaces, vst2sdk, r8brain-free-src, +miniaudio, nlohmann/json and Windows MIDI Services' interfaces; their notices are in +`licenses/Brack-THIRD_PARTY_NOTICES.md`, copied from the Brack the app was published with. + + + +``` +MIT License + +Copyright (c) 2026 hsshss + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + ## rcm2smf `src/Glosa.Core/Rcp/RcpConverter.cs` follows the Recomposer format as implemented by diff --git a/src/Glosa.App/Glosa.App.csproj b/src/Glosa.App/Glosa.App.csproj index e6a342e7..99474725 100644 --- a/src/Glosa.App/Glosa.App.csproj +++ b/src/Glosa.App/Glosa.App.csproj @@ -87,6 +87,16 @@ CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="true" /> + + + + <_BrackNotices Condition="'$(BrackSource)' == 'Project'">$([System.IO.Path]::GetFullPath('$(BrackProject)/../../../../THIRD_PARTY_NOTICES.md')) + <_BrackNotices Condition="'$(BrackSource)' == 'Package'">$(NuGetPackageRoot)brack.net/$(BrackVersion)/THIRD_PARTY_NOTICES.md + + + + + diff --git a/src/Glosa.App/Strings.Designer.cs b/src/Glosa.App/Strings.Designer.cs index 12f6114b..063e1af5 100644 --- a/src/Glosa.App/Strings.Designer.cs +++ b/src/Glosa.App/Strings.Designer.cs @@ -246,6 +246,24 @@ public static string AudioPluginsLoad { } } + /// + /// Looks up a localized string similar to Load plugins one at a time. + /// + public static string AudioPluginsLoadSerially { + get { + return ResourceManager.GetString("AudioPluginsLoadSerially", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to For plugins that fail when several of them load at once. When on, the rack's plugins load one after another, which takes longer. Takes effect the next time Glosa starts.. + /// + public static string AudioPluginsLoadSeriallyTip { + get { + return ResourceManager.GetString("AudioPluginsLoadSeriallyTip", resourceCulture); + } + } + /// /// Looks up a localized string similar to The share of the time the plugins take to render. Near 100%, the sound breaks up.. /// diff --git a/src/Glosa.App/Strings.ja.resx b/src/Glosa.App/Strings.ja.resx index 2b95fdff..c0691f38 100644 --- a/src/Glosa.App/Strings.ja.resx +++ b/src/Glosa.App/Strings.ja.resx @@ -84,6 +84,12 @@ CPU + + プラグインを1つずつ読み込む + + + 複数同時に読み込むとエラーになるプラグインのための設定です。チェックを入れると、ラックのプラグインを1つずつ読み込みます。読み込みは遅くなります。Glosa を次に起動したときから効きます。 + プラグインが音を作るのにかかった時間の割合です。100%に近づくと音が途切れます。 diff --git a/src/Glosa.App/Strings.resx b/src/Glosa.App/Strings.resx index 2b1c7685..b7c66bef 100644 --- a/src/Glosa.App/Strings.resx +++ b/src/Glosa.App/Strings.resx @@ -87,6 +87,12 @@ CPU + + Load plugins one at a time + + + For plugins that fail when several of them load at once. When on, the rack's plugins load one after another, which takes longer. Takes effect the next time Glosa starts. + The share of the time the plugins take to render. Near 100%, the sound breaks up. diff --git a/src/Glosa.App/ViewModels/AudioPluginsViewModel.cs b/src/Glosa.App/ViewModels/AudioPluginsViewModel.cs index 8a9015be..4facbb9a 100644 --- a/src/Glosa.App/ViewModels/AudioPluginsViewModel.cs +++ b/src/Glosa.App/ViewModels/AudioPluginsViewModel.cs @@ -172,6 +172,9 @@ private async Task ShowSettingsAsync() _sampleRate = SampleRates.First(choice => (int)choice.Value == rate); OnPropertyChanged(nameof(SampleRate)); + _loadSerially = _rack.LoadPluginsSerially; + OnPropertyChanged(nameof(LoadSerially)); + SettingsShown = true; } @@ -209,6 +212,21 @@ public Choice? BufferSize } } + private bool _loadSerially; + + /// Whether the rack's plugins load one after another, from the next start. + public bool LoadSerially + { + get => _loadSerially; + set + { + if (value == _loadSerially) return; + _loadSerially = value; + OnPropertyChanged(); + _ = Change(null, () => _rack.LoadPluginsSerially = value); + } + } + private Choice? _sampleRate; public Choice? SampleRate diff --git a/src/Glosa.App/Views/AudioPluginsWindow.axaml b/src/Glosa.App/Views/AudioPluginsWindow.axaml index 07501601..e7a5891a 100644 --- a/src/Glosa.App/Views/AudioPluginsWindow.axaml +++ b/src/Glosa.App/Views/AudioPluginsWindow.axaml @@ -123,7 +123,7 @@ narrower than its column would sit in the middle of it. The settings wait for the rack to load, before which they are Brack's defaults. --> - + @@ -175,6 +175,11 @@ ToolTip.Tip="{x:Static l:Strings.AudioPluginsBufferTip}" AutomationProperties.Name="{x:Static l:Strings.AudioPluginsBuffer}" /> + + + + diff --git a/src/Glosa.Midi.Brack/BrackRack.cs b/src/Glosa.Midi.Brack/BrackRack.cs index ea4cd1ea..663c4dc8 100644 --- a/src/Glosa.Midi.Brack/BrackRack.cs +++ b/src/Glosa.Midi.Brack/BrackRack.cs @@ -227,6 +227,20 @@ public int PluginSampleRate } } + /// + /// Whether the session's plugins load one after another rather than all at once; kept in the + /// session, so it takes effect from the next load (IMPLEMENTATION.md, "Brack バックエンド"). + /// + public bool LoadPluginsSerially + { + get => _engine.GetConfig().LoadPluginsSerially; + set + { + WaitLoaded(); + Run(() => _engine.SetConfig(_engine.GetConfig() with { LoadPluginsSerially = value })); + } + } + /// The gain on all the plugins' sound, linear (1 = 0 dB); kept in the session. /// Never blocks. Set before the session has loaded, it gives way to the session's. public float MasterGain diff --git a/tests/Glosa.Tests/BrackRackTests.cs b/tests/Glosa.Tests/BrackRackTests.cs index eb6de044..c68971f6 100644 --- a/tests/Glosa.Tests/BrackRackTests.cs +++ b/tests/Glosa.Tests/BrackRackTests.cs @@ -203,6 +203,19 @@ public void ANewRackConvertsAtTheBestAndItsBufferIsLongAndTheBufferAndThePlugins Assert.Equal((40, 96000), (Math.Round(again.Buffer.TotalMilliseconds), again.PluginSampleRate)); } + [Fact] + public void LoadingThePluginsOneAtATimeIsKept() + { + using (BrackRack rack = Rack()) + { + Assert.False(rack.LoadPluginsSerially); + rack.LoadPluginsSerially = true; + } + + using BrackRack again = Rack(); + Assert.True(again.LoadPluginsSerially); + } + [Fact] public void TheMasterGainIsKept() {