Audacity 3.2.0
WideClip.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 WideClip.cpp
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#include "WideClip.h"
12
14 std::shared_ptr<ClipInterface> left, std::shared_ptr<ClipInterface> right)
15 : mChannels { std::move(left), std::move(right) }
16{
17}
18
20 size_t ii, sampleCount start, size_t len, bool mayThrow) const
21{
22 return mChannels[ii]->GetSampleView(0u, start, len, mayThrow);
23}
24
26{
27 return mChannels[0u]->GetVisibleSampleCount();
28}
29
30size_t WideClip::GetWidth() const
31{
32 return mChannels[1u] == nullptr ? 1u : 2u;
33}
34
36{
37 return mChannels[0u]->GetRate();
38}
39
41{
42 return mChannels[0u]->GetPlayStartTime();
43}
44
46{
47 return mChannels[0u]->GetPlayEndTime();
48}
49
51{
52 return mChannels[0u]->TimeToSamples(time);
53}
54
56{
57 return mChannels[0u]->GetStretchRatio();
58}
59
61{
62 return mChannels[0u]->GetCentShift();
63}
64
66{
67 return mChannels[0u]->GetPitchAndSpeedPreset();
68}
69
71WideClip::SubscribeToCentShiftChange(std::function<void(int)> cb)
72{
73 // On purpose set the publisher on the left channel only. This is not a clip
74 // property that is saved to disk, and else we'll get two callbacks for the
75 // same event.
76 return mChannels[0u]->SubscribeToCentShiftChange(std::move(cb));
77}
78
81{
82 // On purpose set the publisher on the left channel only. This is not a clip
83 // property that is saved to disk, and else we'll get two callbacks for the
84 // same event.
85 return mChannels[0u]->SubscribeToPitchAndSpeedPresetChange(std::move(cb));
86}
PitchAndSpeedPreset
Definition: ClipInterface.h:40
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
int GetCentShift() const override
Definition: WideClip.cpp:60
sampleCount GetVisibleSampleCount() const override
Definition: WideClip.cpp:25
double GetPlayStartTime() const override
Definition: WideClip.cpp:40
double GetPlayEndTime() const override
Definition: WideClip.cpp:45
Observer::Subscription SubscribeToCentShiftChange(std::function< void(int)> cb) override
Definition: WideClip.cpp:71
WideClip(std::shared_ptr< ClipInterface > left, std::shared_ptr< ClipInterface > right)
Definition: WideClip.cpp:13
const std::array< std::shared_ptr< ClipInterface >, 2 > mChannels
Definition: WideClip.h:60
int GetRate() const override
Definition: WideClip.cpp:35
AudioSegmentSampleView GetSampleView(size_t ii, sampleCount start, size_t len, bool mayThrow) const override
Definition: WideClip.cpp:19
size_t GetWidth() const override
Definition: WideClip.cpp:30
double GetStretchRatio() const override
Definition: WideClip.cpp:55
PitchAndSpeedPreset GetPitchAndSpeedPreset() const override
Definition: WideClip.cpp:65
Observer::Subscription SubscribeToPitchAndSpeedPresetChange(std::function< void(PitchAndSpeedPreset)> cb) override
Definition: WideClip.cpp:80
sampleCount TimeToSamples(double time) const override
Definition: WideClip.cpp:50
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
STL namespace.