23class AudioClip final :
public Clip,
public ArrangerObjectOwner<AudioSourceObject>
26 Q_PROPERTY (
double sourceBpm READ sourceBpm CONSTANT)
29 stretchAlgorithm WRITE setStretchAlgorithm NOTIFY stretchAlgorithmChanged)
30 Q_PROPERTY (
float gain READ gain WRITE setGain NOTIFY gainChanged)
34 DEFINE_ARRANGER_OBJECT_OWNER_QML_PROPERTIES (
42 static constexpr int BUILTIN_FADE_FRAMES = 10;
47 QObject * parent =
nullptr)
noexcept;
59 effectiveStretchAlgorithm ()
const
64 double sourceBpm ()
const;
66 float gain ()
const {
return gain_.load (); }
67 void setGain (
float gain)
69 gain = std::clamp (gain, 0.f, 2.f);
70 if (qFuzzyCompare (gain_, gain))
73 Q_EMIT gainChanged (gain);
75 Q_SIGNAL
void gainChanged (
float gain);
77 void set_source (
const ArrangerObjectUuidReference &source);
79 juce::PositionableAudioSource &get_audio_source ()
const;
84 return "audioSources";
87 std::vector<ArrangerObjectListModel *> get_child_list_models ()
const override
89 return { ArrangerObjectOwner<AudioSourceObject>::get_model () };
92 void shift_all_children (dsp::ContentTick delta)
override;
97 friend void init_from (
99 const AudioClip &other,
102 void init_length_from_clip ();
103 void update_warp_configuration ();
105 static constexpr auto kGainKey =
"gain"sv;
106 static constexpr auto kAlgorithmKey =
"stretchAlgorithm"sv;
107 static constexpr auto kFadeRangeKey =
"fadeRange"sv;
108 friend void to_json (nlohmann::json &j,
const AudioClip &clip);
109 friend void from_json (
const nlohmann::json &j, AudioClip &clip);
111 std::atomic<float> gain_ = 1.0f;
113 dsp::StretchOptions::Algorithm::Polyphonic
117 BOOST_DESCRIBE_CLASS (AudioClip, (Clip), (), (), (gain_, algorithm_))