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