Loading...
Searching...
No Matches
SoundView.hpp
1#pragma once
2#include <optional>
3#include <Process/LayerView.hpp>
4#include <Process/TimeValue.hpp>
5#include <Process/ZoomHelper.hpp>
6#include <score_plugin_media_export.h>
7
8#include <Media/AudioArray.hpp>
9#include <Media/MediaFileHandle.hpp>
10#include <Media/Sound/WaveformComputer.hpp>
11
12#include <score/graphics/GraphicsItem.hpp>
13
14#include <ossia/detail/pod_vector.hpp>
15
16#include <verdigris>
17namespace Media
18{
19namespace Sound
20{
21class ProcessModel;
22class SCORE_PLUGIN_MEDIA_EXPORT LayerView final
23 : public Process::LayerView
24 , public Nano::Observer
25{
26public:
27 explicit LayerView(const ProcessModel& model, QGraphicsItem* parent);
28 ~LayerView();
29
30 void setData(const std::shared_ptr<AudioFile>& data);
31
33 QRectF renderedSpan() const noexcept;
34 void setFrontColors(bool);
35 void setTempoRatio(double);
36 void recompute(ZoomRatio ratio);
37 void recompute() const;
38
39 void on_finishedDecoding();
40
41private:
42 void paint_impl(QPainter*) const override;
43 void mousePressEvent(QGraphicsSceneMouseEvent*) override;
44 void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
45 void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
46 void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
47 void dropEvent(QGraphicsSceneDragDropEvent* event) override;
48
49 void heightChanged(qreal) override;
50 void widthChanged(qreal) override;
51
52 void scrollValueChanged(int);
53
54 void on_newData();
55
56 std::shared_ptr<AudioFile> m_data;
57 int m_numChan{};
58 int m_sampleRate{};
59
60 ZoomRatio m_zoom{};
61 double m_tempoRatio{1.};
62
63 QVector<QImage*> m_images;
64 WaveformComputer* m_cpt{};
65
66 ComputedWaveform m_wf{};
67 const ProcessModel& m_model;
68
69 void requestIfUncovered(double coveredX0, double coveredXf) const;
70
71 bool m_frontColors{true};
72 mutable bool m_recomputed{false};
73
75 mutable std::optional<WaveformRequest> m_lastRequest;
76};
77}
78}
Definition SoundView.hpp:25
Definition SoundModel.hpp:28
Definition LayerView.hpp:21
Definition WaveformComputer.hpp:47
Definition WaveformComputer.hpp:65