Skip to content

Commit 1edf7f3

Browse files
committed
ASE: track: use properties for mute/solo/volume
Signed-off-by: Stefan Westerfeld <stefan@space.twc.de>
1 parent b703de3 commit 1edf7f3

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

ase/api.hh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,6 @@ class Track : public virtual Device {
261261
public:
262262
virtual int32 midi_channel () const = 0; ///< Midi channel assigned to this track, 0 uses internal per-track channel.
263263
virtual void midi_channel (int32 midichannel) = 0;
264-
virtual bool mute () const = 0; ///< Whether the track is muted
265-
virtual void mute (bool newmute) = 0;
266-
virtual bool solo () const = 0; ///< Whether the track is solo
267-
virtual void solo (bool newsolo) = 0;
268-
virtual double volume () const = 0; ///< Volume of the track [0..1]
269-
virtual void volume (double newvolume) = 0;
270264
virtual bool is_master () const = 0; ///< Flag set on the main output track.
271265
virtual ClipS launcher_clips () = 0; ///< Retrieve the list of clips that can be directly played.
272266
virtual DeviceP access_device () = 0; ///< Retrieve Device handle for this track.

ase/track.cc

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,30 +169,33 @@ TrackImpl::midi_channel (int32 midichannel) // TODO: implement
169169
emit_notify ("midi_channel");
170170
}
171171

172-
void
172+
bool
173173
TrackImpl::mute (bool new_mute)
174174
{
175175
mute_ = new_mute;
176176
set_chain_volumes();
177177
emit_notify ("mute");
178+
return true;
178179
}
179180

180-
void
181+
bool
181182
TrackImpl::solo (bool new_solo)
182183
{
183184
solo_ = new_solo;
184185
set_chain_volumes();
185186
emit_notify ("solo");
187+
return true;
186188
}
187189

188-
void
190+
bool
189191
TrackImpl::volume (double new_volume)
190192
{
191193
volume_ = new_volume;
192194
// TODO: display this value if track volume is changed in the UI
193195
// printf ("Track '%s' -> set volume to %f dB\n", name().c_str(), AudioChain::volume_db (new_volume));
194196
set_chain_volumes();
195197
emit_notify ("volume");
198+
return true;
196199
}
197200

198201
void
@@ -211,7 +214,10 @@ TrackImpl::set_chain_volumes()
211214

212215
bool have_solo_tracks = false;
213216
for (const auto& track : all_tracks)
214-
have_solo_tracks = have_solo_tracks || track->solo();
217+
{
218+
auto track_impl = dynamic_cast<Ase::TrackImpl*> (track.get());
219+
have_solo_tracks = have_solo_tracks || track_impl->solo();
220+
}
215221

216222
for (const auto& track : all_tracks)
217223
{
@@ -233,6 +239,25 @@ TrackImpl::set_chain_volumes()
233239
}
234240
}
235241

242+
void
243+
TrackImpl::create_properties ()
244+
{
245+
// chain to base class
246+
DeviceImpl::create_properties();
247+
// create own properties
248+
auto getvolume = [this] (Value &val) { val = volume(); };
249+
auto setvolume = [this] (const Value &val) { return volume (val.as_double()); };
250+
auto getsolo = [this] (Value &val) { val = solo(); };
251+
auto setsolo = [this] (const Value &val) { return solo (val.as_double()); };
252+
auto getmute = [this] (Value &val) { val = mute(); };
253+
auto setmute = [this] (const Value &val) { return mute (val.as_double()); };
254+
PropertyBag bag = property_bag();
255+
bag.group = _("Mix");
256+
bag += Prop (getvolume, setvolume, { "volume", _("Volume"), _("Volume"), 1., "", { 0., 2 }, STANDARD });
257+
bag += Prop (getsolo, setsolo, { "solo", _("Solo"), _("Solo"), false, "", {}, STANDARD + String (":toggle") });
258+
bag += Prop (getmute, setmute, { "mute", _("Mute"), _("Mute"), false, "", {}, STANDARD + String (":toggle") });
259+
}
260+
236261
static constexpr const uint MAX_LAUNCHER_CLIPS = 8;
237262

238263
ClipS

ase/track.hh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class TrackImpl : public DeviceImpl, public virtual Track {
2121
protected:
2222
String fallback_name () const override;
2323
void serialize (WritNode &xs) override;
24+
void create_properties () override;
25+
bool mute () const { return mute_; }
26+
bool mute (bool new_mute);
27+
bool solo () const { return solo_; }
28+
bool solo (bool new_solo);
29+
double volume () const { return volume_; }
30+
bool volume (double new_volume);
2431
public:
2532
class ClipScout;
2633
explicit TrackImpl (ProjectImpl&, bool masterflag);
@@ -34,12 +41,6 @@ public:
3441
bool is_master () const override { return MASTER_TRACK & gadget_flags(); }
3542
int32 midi_channel () const override { return midi_channel_; }
3643
void midi_channel (int32 midichannel) override;
37-
bool mute () const override { return mute_; }
38-
void mute (bool new_mute) override;
39-
bool solo () const override { return solo_; }
40-
void solo (bool new_solo) override;
41-
double volume () const override { return volume_; }
42-
void volume (double new_volume) override;
4344
ClipS launcher_clips () override;
4445
DeviceP access_device () override;
4546
MonitorP create_monitor (int32 ochannel) override;

0 commit comments

Comments
 (0)