Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Song::loop_right, Song::tick_pointer #68

Merged
merged 4 commits into from Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion bse/bseapi.idl
Expand Up @@ -546,6 +546,7 @@ Const MIN_BPM = 1;
Const MAX_BPM = 1024;
Const MIN_TRANSPOSE = -72;
Const MAX_TRANSPOSE = +72;
Const READWRITE = "r:w:";
Const GUI = "r:w:G";
Const STORAGE = "r:w:S";
Const STANDARD = STORAGE ":G";
Expand Down Expand Up @@ -1019,7 +1020,6 @@ interface Song : SNet {
// group _("MIDI Instrument") {
// CSynth pnet = Object ("Postprocessor", "Synthesis network to be used as postprocessor", STANDARD);
// };
// int32 tick_pointer = Range ("Tick Pointer", "", STORAGE, -1, MAXINT31, 384, -1);
group _("Timing") {
float64 bpm = Range (_("BPM"), _("Beats per minute"), STANDARD ":scale", MIN_BPM, MAX_BPM, 10, 120);
};
Expand All @@ -1035,6 +1035,7 @@ interface Song : SNet {
bool loop_enabled = Bool (_("Loop Enabled"), "", STORAGE SKIP_DEFAULT SKIP_UNDO, false);
int32 loop_left = Range (_("Loop Left"), "", STORAGE SKIP_DEFAULT SKIP_UNDO, -1, MAXINT31, 384, -1);
int32 loop_right = Range (_("Loop Right"), "", STORAGE SKIP_DEFAULT SKIP_UNDO, -1, MAXINT31, 384, -1);
int32 tick_pointer = Range (_("Tick Pointer"), "", READWRITE SKIP_UNDO, -1, MAXINT31, 384, -1);
};
};

Expand Down
56 changes: 31 additions & 25 deletions bse/bsesong.cc
Expand Up @@ -24,7 +24,6 @@ enum
PROP_NUMERATOR,
PROP_DENOMINATOR,
PROP_PNET,
PROP_TICK_POINTER,
};


Expand Down Expand Up @@ -142,7 +141,6 @@ bse_song_set_property (GObject *object,
switch (param_id)
{
SfiInt vint;
SfiRing *ring;
case PROP_PNET:
if (!self->postprocess || !BSE_SOURCE_PREPARED (self->postprocess))
{
Expand Down Expand Up @@ -177,20 +175,6 @@ bse_song_set_property (GObject *object,
self->tpqn = sfi_value_get_int (value);
bse_song_update_tpsi_SL (self);
break;
case PROP_TICK_POINTER:
vint = sfi_value_get_int (value);
if (uint (vint) != self->tick_SL)
{
BSE_SEQUENCER_LOCK ();
self->tick_SL = vint;
for (ring = self->tracks_SL; ring; ring = sfi_ring_walk (ring, self->tracks_SL))
{
BseTrack *track = (BseTrack*) ring->data;
track->track_done_SL = FALSE; /* let sequencer recheck if playing */
}
BSE_SEQUENCER_UNLOCK ();
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
Expand Down Expand Up @@ -218,9 +202,6 @@ bse_song_get_property (GObject *object,
case PROP_TPQN:
sfi_value_set_int (value, self->tpqn);
break;
case PROP_TICK_POINTER:
sfi_value_set_int (value, self->tick_SL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
Expand Down Expand Up @@ -451,7 +432,7 @@ bse_song_reset (BseSource *source)
self->position_handler = 0;
}
bse_object_unlock (BSE_OBJECT (self));
g_object_notify ((GObject*) self, "tick-pointer");
self->as<Bse::SongImpl*>()->notify ("tick_pointer");
}
BseSource*
bse_song_create_summation (BseSong *self)
Expand Down Expand Up @@ -666,11 +647,6 @@ bse_song_class_init (BseSongClass *klass)
PROP_PNET,
bse_param_spec_object ("pnet", _("Postprocessor"), _("Synthesis network to be used as postprocessor"),
BSE_TYPE_CSYNTH, SFI_PARAM_STANDARD ":unprepared"));
bse_object_class_add_param (object_class, _("Looping"),
PROP_TICK_POINTER,
sfi_pspec_int ("tick_pointer", NULL, NULL,
-1, -1, G_MAXINT, 384,
SFI_PARAM_READWRITE ":skip-undo"));

signal_pointer_changed = bse_object_class_add_signal (object_class, "pointer-changed",
G_TYPE_NONE, 1, SFI_TYPE_INT);
Expand Down Expand Up @@ -991,6 +967,36 @@ SongImpl::loop_right (int tick)
}
}

int
SongImpl::tick_pointer() const
{
BseSong *self = const_cast<SongImpl*> (this)->as<BseSong*>();

return self->tick_SL;
}

void
SongImpl::tick_pointer (int tick)
{
BseSong *self = as<BseSong*>();

if (uint (tick) != self->tick_SL)
{
// this property has no undo

BSE_SEQUENCER_LOCK ();
self->tick_SL = tick;
for (SfiRing *ring = self->tracks_SL; ring; ring = sfi_ring_walk (ring, self->tracks_SL))
{
BseTrack *track = (BseTrack*) ring->data;
track->track_done_SL = FALSE; /* let sequencer recheck if playing */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, the C macros TRUE and FALSE should be converted to C++'s true and false.

}
BSE_SEQUENCER_UNLOCK ();

notify ("tick_pointer");
}
}

BusIfaceP
SongImpl::ensure_master_bus ()
{
Expand Down
2 changes: 2 additions & 0 deletions bse/bsesong.hh
Expand Up @@ -82,6 +82,8 @@ public:
virtual void loop_left (int tick) override;
virtual int loop_right () const override;
virtual void loop_right (int tick) override;
virtual int tick_pointer () const override;
virtual void tick_pointer (int tick) override;
virtual SongTiming get_timing (int tick);
virtual TrackIfaceP find_any_track_for_part (PartIface &part) override;
virtual BusIfaceP create_bus () override;
Expand Down