Polyphase Game Engine
Loading...
Searching...
No Matches
SoundWaveImportFixupModal.h
Go to the documentation of this file.
1#pragma once
2
3#include "Engine.h"
4
5#if EDITOR
6
7#include "AssetRef.h"
9
10#include <cstdint>
11#include <string>
12#include <vector>
13
14// Post-import prompt for WAVs whose sample rate isn't 44.1 kHz (or 22.05 kHz,
15// which the runtime already upsamples). Desktop backends play any rate, but
16// Android relabels everything as 44.1 kHz without resampling and the console
17// cook paths assume 44.1 kHz, so the user picks Resample / Keep / Cancel per
18// row or in bulk. Unlike TextureImportFixupModal the asset is already fully
19// valid when enqueued; the modal only defers the auto-save so the .oct is
20// written once with the final PCM.
21class SoundWaveImportFixupModal
22{
23public:
24
25 static constexpr uint32_t kTargetSampleRate = 44100;
26
27 enum class FixChoice
28 {
29 None,
30 Resampled,
31 Kept,
33 };
34
35 struct PendingRow
36 {
37 AssetRef mSound; // imported asset (auto-cleared on unload)
38 std::string mAssetName; // captured at enqueue so the row still labels after teardown
39 std::string mSourcePath;
40 uint32_t mSrcSampleRate = 0;
41 uint32_t mNumChannels = 0;
42 uint32_t mBitsPerSample = 0;
43 FixChoice mResolved = FixChoice::None;
44 };
45
46 static SoundWaveImportFixupModal* Get();
47
48 // Called from SoundWave::Import when the parsed sample rate is non-standard.
49 void Enqueue(SoundWave* wave, const std::string& sourcePath);
50
51 bool HasPending() const { return !mRows.empty(); }
52
53 // True while `asset` is enqueued and unresolved. ActionManager skips the
54 // import auto-save while this is true; the modal saves after resolving.
55 bool IsAwaitingFixup(const Asset* asset) const;
56
57 void Reset();
58
59 // Call from EditorImguiDraw every frame.
60 void Draw();
61
62private:
63
64 SoundWaveImportFixupModal() = default;
65
66 void ApplyResample(PendingRow& row);
67 void ApplyKeep(PendingRow& row);
68 void ApplyCancel(PendingRow& row);
69 void SaveRow(const PendingRow& row);
70
71 std::vector<PendingRow> mRows;
72 bool mModalRequested = false;
73};
74
75#endif // EDITOR
Definition AssetRef.h:18
Definition Asset.h:125
Definition SoundWave.h:6