Loading...
Searching...
No Matches
SoundModel.hpp
1#pragma once
2#include <Process/Dataflow/Port.hpp>
3#include <Process/MediaRange.hpp>
4#include <Process/Process.hpp>
5
6#include <Media/MediaFileHandle.hpp>
7#include <Media/Sound/SoundMetadata.hpp>
8
10#include <score/serialization/JSONVisitor.hpp>
12
13#include <ossia/dataflow/audio_stretch_mode.hpp>
14
15#include <verdigris>
16
17Q_DECLARE_METATYPE(ossia::audio_stretch_mode)
18W_REGISTER_ARGTYPE(ossia::audio_stretch_mode)
19namespace Media
20{
21namespace Sound
22{
23class ProcessModel;
24
25class SCORE_PLUGIN_MEDIA_EXPORT ProcessModel final
27 , public Nano::Observer
28{
29 SCORE_SERIALIZE_FRIENDS
30 PROCESS_METADATA_IMPL(Media::Sound::ProcessModel)
31
32 W_OBJECT(ProcessModel)
33
34public:
35 explicit ProcessModel(
36 const TimeVal& duration, const QString& data, const Id<Process::ProcessModel>& id,
37 QObject* parent);
38
39 ~ProcessModel() override;
40
41 QString prettyName() const noexcept override;
42
43 template <typename Impl>
44 explicit ProcessModel(Impl& vis, QObject* parent)
45 : Process::ProcessModel{vis, parent}
46 , m_file{std::make_shared<AudioFile>()}
47 {
48 vis.writeTo(*this);
49 init();
50 }
51
55 void setFile(const QString& file);
56 QString userFilePath() const noexcept;
57
63 void setFileForced(const QString& file, int stream = -1);
64
65 std::shared_ptr<AudioFile>& file();
66 const std::shared_ptr<AudioFile>& file() const;
67
68 int stream() const noexcept;
69 int upmixChannels() const noexcept;
70 int startChannel() const noexcept;
71 double nativeTempo() const noexcept;
72 ossia::audio_stretch_mode stretchMode() const noexcept;
73
74 void setUpmixChannels(int upmixChannels);
75 void setStartChannel(int startChannel);
76 void setStream(int stream);
77 void setNativeTempo(double);
78 void setStretchMode(ossia::audio_stretch_mode);
79
80 void on_mediaChanged();
81
82 void mapExternalFiles(Process::ExternalFileMap& map) override;
83
85 double fileTempoRatio() const noexcept;
86
88 std::optional<Process::MediaRange> usedFileRange() const noexcept;
89
90 std::unique_ptr<Process::AudioOutlet> outlet;
91
92public:
93 void fileChanged() W_SIGNAL(fileChanged);
94 void scoreTempoChanged() W_SIGNAL(scoreTempoChanged);
95 void nativeTempoChanged(double t) W_SIGNAL(nativeTempoChanged, t);
96 void streamChanged(int stream) W_SIGNAL(streamChanged, stream);
97 void upmixChannelsChanged(int upmixChannels)
98 W_SIGNAL(upmixChannelsChanged, upmixChannels);
99 void startChannelChanged(int startChannel) W_SIGNAL(startChannelChanged, startChannel);
100 void stretchModeChanged(ossia::audio_stretch_mode mode)
101 W_SIGNAL(stretchModeChanged, mode);
102
103 PROPERTY(int, stream READ stream WRITE setStream NOTIFY streamChanged, W_Final)
104 PROPERTY(
105 int,
106 startChannel READ startChannel WRITE setStartChannel NOTIFY startChannelChanged,
107 W_Final)
108 PROPERTY(
109 int,
110 upmixChannels READ upmixChannels WRITE setUpmixChannels NOTIFY
111 upmixChannelsChanged,
112 W_Final)
113 PROPERTY(
114 double,
115 nativeTempo READ nativeTempo WRITE setNativeTempo NOTIFY nativeTempoChanged,
116 W_Final)
117 PROPERTY(
118 ossia::audio_stretch_mode,
119 stretchMode READ stretchMode WRITE setStretchMode NOTIFY stretchModeChanged,
120 W_Final)
121
122private:
123 void loadFile(const QString& str, int stream = -1);
124 void reload();
125 void init();
126
127 void ancestorStartDateChanged() override;
128 void ancestorTempoChanged() override;
129
130 QString m_userFilePath{};
131 std::shared_ptr<AudioFile> m_file;
132 int m_upmixChannels{};
133 int m_startChannel{};
134 ossia::audio_stretch_mode m_mode{};
135 double m_nativeTempo{};
136 int m_stream{-1};
137};
138}
139}
Definition SoundModel.hpp:28
Collects — and in the same pass rewrites — the files a document references.
Definition ExternalFiles.hpp:80
The Process class.
Definition score-lib-process/Process/Process.hpp:75
The id_base_t class.
Definition Identifier.hpp:59
Definition TimeValue.hpp:21