[beast: 21/26] BSE: move SongTiming into bseapi.idl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 21/26] BSE: move SongTiming into bseapi.idl
- Date: Mon, 13 Jul 2015 02:28:13 +0000 (UTC)
commit acbb452346ec3c8d809a408d2f2248eccc4be1aa
Author: Tim Janik <timj gnu org>
Date: Fri Jul 3 01:17:24 2015 +0200
BSE: move SongTiming into bseapi.idl
beast-gtk/bstpianorollctrl.cc | 10 +++++-----
beast-gtk/bsttrackrollctrl.cc | 12 ++++++------
bse/bseapi.idl | 28 +++++++++++++++++++++-------
bse/bsebasics.idl | 15 ---------------
bse/bsepart.cc | 13 +++++++++++++
bse/bsepart.hh | 1 +
bse/bsepart.proc | 32 --------------------------------
bse/bsesong.cc | 19 +++++++++++++------
bse/bsesong.hh | 22 ++++++++++------------
bse/bsesong.proc | 27 ---------------------------
bse/bsetrack.cc | 17 +++++++++++++++--
bse/bsetrack.hh | 1 +
bse/bsetrack.proc | 32 --------------------------------
13 files changed, 85 insertions(+), 144 deletions(-)
---
diff --git a/beast-gtk/bstpianorollctrl.cc b/beast-gtk/bstpianorollctrl.cc
index db283eb..25655dd 100644
--- a/beast-gtk/bstpianorollctrl.cc
+++ b/beast-gtk/bstpianorollctrl.cc
@@ -454,20 +454,20 @@ bst_piano_roll_controller_quantize (BstPianoRollController *self,
g_return_val_if_fail (self != NULL, fine_tick);
Bse::PartH part = self->proll->part;
- BseSongTiming *timing = bse_part_get_timing (part.proxy_id(), fine_tick);
+ Bse::SongTiming timing = part.get_timing (fine_tick);
uint quant, tick, qtick;
if (QUANTIZATION (self) == BST_QUANTIZE_NONE)
quant = 1;
else if (QUANTIZATION (self) == BST_QUANTIZE_TACT)
- quant = timing->tpt;
+ quant = timing.tpt;
else
- quant = timing->tpqn * 4 / QUANTIZATION (self);
- tick = fine_tick - timing->tick;
+ quant = timing.tpqn * 4 / QUANTIZATION (self);
+ tick = fine_tick - timing.tick;
qtick = tick / quant;
qtick *= quant;
if (tick - qtick > quant / 2)
qtick += quant;
- tick = timing->tick + qtick;
+ tick = timing.tick + qtick;
return tick;
}
diff --git a/beast-gtk/bsttrackrollctrl.cc b/beast-gtk/bsttrackrollctrl.cc
index 1ff04f3..27032cf 100644
--- a/beast-gtk/bsttrackrollctrl.cc
+++ b/beast-gtk/bsttrackrollctrl.cc
@@ -300,24 +300,24 @@ guint
bst_track_roll_controller_quantize (BstTrackRollController *self,
guint fine_tick)
{
- BseSongTiming *timing;
guint quant, tick, qtick;
g_return_val_if_fail (self != NULL, fine_tick);
- timing = bse_song_get_timing (self->song, fine_tick);
+ Bse::SongH song = Bse::SongH::down_cast (bse_server.from_proxy (self->song));
+ Bse::SongTiming timing = song.get_timing (fine_tick);
if (QUANTIZATION (self) == BST_QUANTIZE_NONE)
quant = 1;
else if (QUANTIZATION (self) == BST_QUANTIZE_TACT)
- quant = timing->tpt;
+ quant = timing.tpt;
else
- quant = timing->tpqn * 4 / QUANTIZATION (self);
- tick = fine_tick - timing->tick;
+ quant = timing.tpqn * 4 / QUANTIZATION (self);
+ tick = fine_tick - timing.tick;
qtick = tick / quant;
qtick *= quant;
if (tick - qtick > quant / 2)
qtick += quant;
- tick = timing->tick + qtick;
+ tick = timing.tick + qtick;
return tick;
}
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 830bb26..3c6eb7d 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -318,6 +318,20 @@ record UserMessage {
String label; ///< Message class label, used to enable/disable this type of message.
};
+/// Song timing configuration.
+record SongTiming {
+ int32 tick = Range ("Current tick", "Song position timing applies to", STANDARD, 0, MAXINT31,
384, 0);
+ float64 bpm = Range ("BPM", "Beats per minute", STANDARD, MIN_BPM, MAX_BPM, 10, 120);
+ // Signature
+ int32 numerator = Range ("Numerator", "Number of notes per measure", STANDARD, 1, 256, 2, 4);
+ int32 denominator = Range ("Denominator", "Type of notes counted per measure", STANDARD, 1, 256, 2, 4);
+ // Sequencer Timing
+ int32 tpqn = Range ("TPQN", "Ticks per quarter note", STANDARD, 1, MAXINT31, 12, 384);
+ int32 tpt = Range ("TPT", "Ticks per tact", STANDARD, 1, MAXINT31, 12, 384);
+ // Playback Timing
+ float64 stamp_ticks = Range ("Tick Increment", "Ticks per stamp increment (useful only during playback)",
STANDARD, 1, MAXINT31, 12, 384);
+};
+
/// Fundamental base type for all BSE objects.
interface Object {
String debug_name (); ///< Object name useful for debugging output.
@@ -367,8 +381,9 @@ interface Part : Item {
PartControlSeq list_controls (int32 tick, int32 duration, MidiSignalType control_type); ///<
List all control events within a tick range.
PartControlSeq get_channel_controls (int32 channel, int32 tick, int32 duration, MidiSignalType
control_type); ///< Retrieve all control events of a specific type within range of a channel.
PartControlSeq get_controls (int32 tick, MidiSignalType control_type); ///< Retrieve all
control events of a specific type at specified tick.
- int32 get_max_note (); ///< Retrieve the maximum note supported in this part.
- int32 get_min_note (); ///< Retrieve the minimum note supported in this part.
+ SongTiming get_timing (int32 tick); ///< Retrieve song timing information at a specific
tick.
+ int32 get_max_note (); ///< Retrieve the maximum note supported in this
part.
+ int32 get_min_note (); ///< Retrieve the minimum note supported in this
part.
ErrorType change_control (int32 id, int32 tick, MidiSignalType control_type, float64
value); ///< Change an existing control event within a part.
ErrorType change_note (int32 id, int32 tick, int32 duration, int32 note, int32
fine_tune, float64 velocity); ///< Change an existing note within a part.
ErrorType delete_event (int32 id); ///< Delete an existing event from a part.
@@ -392,7 +407,6 @@ interface Part : Item {
PartNoteSeq check_overlap (int32 tick, int32 duration, int32 note); ///< Check whether a note would
overlap with neighbours.
PartNoteSeq get_notes (int32 tick, int32 note); ///< Retrieve all notes at a specific frequency
or crossing a tick.
- // SongTiming get_timing (int32 tick); ///< Retrieve song timing information at a
specific tick.
// signal void range_changed (int32 a, int32 b, int32 c, int32 d);
// signal void links_changed ();
// property int32 n_channels;
@@ -449,8 +463,9 @@ interface SubSynth : Source {
/// Interface for sequencing information and links to Part objects.
interface Track : ContextMerger {
- int32 insert_part (int32 tick, Part part); ///< Insert Part into Track at @a tick, returns the
corresponding link id.
- void remove_tick (int32 tick); ///< Remove Part at specified @a tick from a track.
+ SongTiming get_timing (int32 tick); ///< Retrieve song timing information at a specific tick.
+ int32 insert_part (int32 tick, Part part); ///< Insert Part into Track at @a tick, returns the
corresponding link id.
+ void remove_tick (int32 tick); ///< Remove Part at specified @a tick from a track.
// ItemSeq list_parts_uniq (); ///< List all parts contained in a track.
// TrackPartSeq list_parts (); ///< List parts scheduled in a track, sorted by tick.
@@ -462,7 +477,6 @@ interface Track : ContextMerger {
/// The output of this module is the merged result from all polyphonic voices and has all track specific
alterations applied.
Source get_output_source ();
- // SongTimingHandle get_timing (int32 tick); ///< Retrieve song timing information at a specific tick.
// property bool muted; ///< _("Mute this track by ignoring it in the sequencer.")
// property CSynth snet; ///< _("Synthesis network to be used as instrument.")
// property Wave wave; ///< _("Wave to be used as instrument.")
@@ -492,6 +506,7 @@ interface Bus : SubSynth {
/// Interface for Track and Part objects, as well as meta data for sequencing.
interface Song : SNet {
+ SongTiming get_timing (int32 tick); ///< Retrieve song timing information at a specific tick.
Track find_any_track_for_part (Part part); ///< Find the first track that contains part, suitable
to check for orphan parts.
Bus create_bus (); ///< Create a new mixer bus for a Song.
void remove_bus (Bus bus); ///< Delete a mixer bus from a Song.
@@ -503,7 +518,6 @@ interface Song : SNet {
// void ensure_track_links (); ///< Ensure that each part in a song is inserted into
at least one track.
// Track find_track_for_part (Part part); ///< Find a track suitable for playing notes of a
given part.
// Bus get_master_bus (); ///< Retrieve master output bus of a song if it
exists.
- // SongTiming get_timing (int32 tick); ///< Retrieve song timing information at a specific
tick.
// void synthesize_note (Track track, int32 duration, int32 note, int32 fine_tune, float64 velocity); ///<
Synthesize a note on a song of an active project.
// signal void pointer_changed (int32 a);
// group _("Tuning") {
diff --git a/bse/bsebasics.idl b/bse/bsebasics.idl
index d0658b2..d09b4fe 100644
--- a/bse/bsebasics.idl
+++ b/bse/bsebasics.idl
@@ -412,21 +412,6 @@ record TrackPart {
sequence TrackPartSeq {
TrackPart tparts;
};
-/* BSE Song timing structure */
-record SongTiming {
- /* song position timing applies to */
- Int tick = SfiInt ("Current tick", "", 0, 0, G_MAXINT, 384, STANDARD);
- /* tempo */
- Real bpm = SfiReal ("Beats per minute", "", 120, BSE_MIN_BPM, BSE_MAX_BPM, 10, STANDARD);
- /* signature */
- Int numerator = SfiInt ("Numerator", "Number of notes per measure", 4, 1, 256, 2, STANDARD);
- Int denominator = SfiInt ("Denominator", "Type of notes counted per measure", 4, 1, 256, 2, STANDARD);
- /* sequencer timing */
- Int tpqn = SfiInt ("Ticks per quarter note", "", 384, 1, G_MAXINT, 12, STANDARD);
- Int tpt = SfiInt ("Ticks per tact", "", 384, 1, G_MAXINT, 12, STANDARD);
- /* playback timing */
- Real stamp_ticks = SfiReal ("Ticks per stamp increment (valid only during playback)", "", 384, 1,
G_MAXINT, 12, STANDARD);
-};
record SampleFileInfo {
SfiString file = SfiString ("Filename", "", "", STANDARD);
Int size = SfiInt ("File Size", "", 0, 0, G_MAXINT, 0, STANDARD);
diff --git a/bse/bsepart.cc b/bse/bsepart.cc
index cf1d1df..79919eb 100644
--- a/bse/bsepart.cc
+++ b/bse/bsepart.cc
@@ -2146,6 +2146,19 @@ PartImpl::get_channel_controls (int channel, int tick, int duration, MidiSignalT
return bse_part_list_controls (self, channel, tick, duration, control_type);
}
+SongTiming
+PartImpl::get_timing (int tick)
+{
+ BsePart *self = as<BsePart*>();
+ SongTiming timing;
+ BseItem *parent = BSE_ITEM (self)->parent;
+ if (BSE_IS_SONG (parent))
+ bse_song_get_timing (BSE_SONG (parent), tick, &timing);
+ else
+ bse_song_timing_get_default (&timing);
+ return timing;
+}
+
int
PartImpl::get_max_note ()
{
diff --git a/bse/bsepart.hh b/bse/bsepart.hh
index 737dac0..9839d76 100644
--- a/bse/bsepart.hh
+++ b/bse/bsepart.hh
@@ -282,6 +282,7 @@ public:
virtual PartControlSeq list_controls (int tick, int duration, MidiSignalType control_type)
override;
virtual PartControlSeq get_channel_controls (int channel, int tick, int duration, MidiSignalType
control_type) override;
virtual PartControlSeq get_controls (int tick, MidiSignalType control_type) override;
+ virtual SongTiming get_timing (int tick) override;
virtual int get_max_note () override;
virtual int get_min_note () override;
virtual ErrorType change_control (int id, int tick, MidiSignalType control_type, double
value) override;
diff --git a/bse/bsepart.proc b/bse/bsepart.proc
index bd8155b..4e49b23 100644
--- a/bse/bsepart.proc
+++ b/bse/bsepart.proc
@@ -10,38 +10,6 @@ AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-METHOD (BsePart, get-timing) {
- HELP = "Retrieve song timing information at a specific tick.";
- IN = bse_param_spec_object ("part", "Part", NULL, BSE_TYPE_PART, SFI_PARAM_STANDARD);
- IN = sfi_pspec_int ("tick", "Tick", "Tick to retrieve timing info about", 0, 0, G_MAXINT, 384,
SFI_PARAM_STANDARD);
- OUT = bse_param_spec_boxed ("timing", "Timing", "Song Timing", BSE_TYPE_SONG_TIMING, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BsePart *self = (BsePart*) bse_value_get_object (in_values++);
- SfiInt tick = sfi_value_get_int (in_values++);
- BseItem *parent;
- BseSongTiming timing = { 0, };
-
- /* check parameters */
- if (!BSE_IS_PART (self))
- return Bse::ERROR_PROC_PARAM_INVAL;
-
- /* action */
- parent = BSE_ITEM (self)->parent;
- if (BSE_IS_SONG (parent))
- bse_song_get_timing (BSE_SONG (parent), tick, &timing);
- else
- bse_song_timing_get_default (&timing);
-
- /* set output parameters */
- bse_value_set_boxed (out_values++, &timing);
-
- return Bse::ERROR_NONE;
-}
-
METHOD (BsePart, list-links) {
HELP = "List all places where parts are used (linked) from tracks, sorted by tick.";
IN = bse_param_spec_object ("part", "Part", NULL, BSE_TYPE_PART, SFI_PARAM_STANDARD);
diff --git a/bse/bsesong.cc b/bse/bsesong.cc
index 906281a..540b174 100644
--- a/bse/bsesong.cc
+++ b/bse/bsesong.cc
@@ -70,7 +70,7 @@ BSE_BUILTIN_TYPE (BseSong)
}
void
-bse_song_timing_get_default (BseSongTiming *timing)
+bse_song_timing_get_default (Bse::SongTiming *timing)
{
g_return_if_fail (timing != NULL);
@@ -305,9 +305,7 @@ bse_song_get_property (GObject *object,
}
void
-bse_song_get_timing (BseSong *self,
- guint tick,
- BseSongTiming *timing)
+bse_song_get_timing (BseSong *self, uint tick, Bse::SongTiming *timing)
{
g_return_if_fail (BSE_IS_SONG (self));
g_return_if_fail (timing != NULL);
@@ -573,7 +571,7 @@ static void
bse_song_init (BseSong *self)
{
BseSNet *snet = BSE_SNET (self);
- BseSongTiming timing;
+ Bse::SongTiming timing;
bse_song_timing_get_default (&timing);
@@ -716,7 +714,7 @@ bse_song_class_init (BseSongClass *klass)
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
BseContainerClass *container_class = BSE_CONTAINER_CLASS (klass);
BseSuperClass *super_class = BSE_SUPER_CLASS (klass);
- BseSongTiming timing;
+ Bse::SongTiming timing;
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
@@ -951,4 +949,13 @@ SongImpl::remove_track (TrackIface &track_iface)
bse_item_undo_close (ustack);
}
+SongTiming
+SongImpl::get_timing (int tick)
+{
+ BseSong *self = as<BseSong*>();
+ SongTiming timing;
+ bse_song_get_timing (self, tick, &timing);
+ return timing;
+}
+
} // Bse
diff --git a/bse/bsesong.hh b/bse/bsesong.hh
index 48a71b9..afe61ae 100644
--- a/bse/bsesong.hh
+++ b/bse/bsesong.hh
@@ -56,18 +56,15 @@ struct BseSong : BseSNet {
struct BseSongClass : BseSNetClass
{};
-BseSong* bse_song_lookup (BseProject *project,
- const gchar *name);
-void bse_song_stop_sequencing_SL (BseSong *self);
-void bse_song_get_timing (BseSong *self,
- guint tick,
- BseSongTiming *timing);
-void bse_song_timing_get_default (BseSongTiming *timing);
-BseSource* bse_song_create_summation (BseSong *self);
-BseBus* bse_song_find_master (BseSong *self);
-BseSource* bse_song_ensure_master (BseSong *self);
-void bse_song_set_solo_bus (BseSong *self, BseBus *bus);
-BseTrack* bse_song_find_first_track (BseSong *self, BsePart *part);
+BseSong* bse_song_lookup (BseProject *project, const char *name);
+void bse_song_stop_sequencing_SL (BseSong *self);
+void bse_song_get_timing (BseSong *self, uint tick, Bse::SongTiming *timing);
+void bse_song_timing_get_default (Bse::SongTiming *timing);
+BseSource* bse_song_create_summation (BseSong *self);
+BseBus* bse_song_find_master (BseSong *self);
+BseSource* bse_song_ensure_master (BseSong *self);
+void bse_song_set_solo_bus (BseSong *self, BseBus *bus);
+BseTrack* bse_song_find_first_track (BseSong *self, BsePart *part);
G_END_DECLS
@@ -78,6 +75,7 @@ protected:
virtual ~SongImpl ();
public:
explicit SongImpl (BseObject*);
+ SongTiming get_timing (int tick);
TrackIfaceP find_any_track_for_part (PartIface &part) override;
BusIfaceP create_bus () override;
void remove_bus (BusIface &bus) override;
diff --git a/bse/bsesong.proc b/bse/bsesong.proc
index 1d54c51..d0ae4d0 100644
--- a/bse/bsesong.proc
+++ b/bse/bsesong.proc
@@ -222,30 +222,3 @@ METHOD (BseSong, synthesize-note) {
return Bse::ERROR_NONE;
}
-
-METHOD (BseSong, get-timing) {
- HELP = _("Retrieve song timing information at a specific tick.");
- IN = bse_param_spec_object ("song", "Song", NULL, BSE_TYPE_SONG, SFI_PARAM_STANDARD);
- IN = sfi_pspec_int ("tick", "Tick", "Tick to retrieve timing info about", 0, 0, G_MAXINT, 384,
SFI_PARAM_STANDARD);
- OUT = bse_param_spec_boxed ("timing", "Timing", "Song Timing", BSE_TYPE_SONG_TIMING, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseSong *self = (BseSong*) bse_value_get_object (in_values++);
- SfiInt tick = sfi_value_get_int (in_values++);
- BseSongTiming timing = { 0, };
-
- /* check parameters */
- if (!BSE_IS_SONG (self))
- return Bse::ERROR_PROC_PARAM_INVAL;
-
- /* action */
- bse_song_get_timing (self, tick, &timing);
-
- /* set output parameters */
- bse_value_set_boxed (out_values++, &timing);
-
- return Bse::ERROR_NONE;
-}
diff --git a/bse/bsetrack.cc b/bse/bsetrack.cc
index 4bef00e..cf93a3d 100644
--- a/bse/bsetrack.cc
+++ b/bse/bsetrack.cc
@@ -622,7 +622,7 @@ bse_track_list_parts_intern (BseTrack *self,
BseSong *song = NULL;
if (BSE_IS_SONG (item->parent))
song = BSE_SONG (item->parent);
- BseSongTiming timing;
+ Bse::SongTiming timing;
bse_song_timing_get_default (&timing);
BseTrackPartSeq *tps = bse_track_part_seq_new ();
gint i;
@@ -832,7 +832,7 @@ bse_track_get_last_tick (BseTrack *self)
if (part)
{
BseItem *item = BSE_ITEM (self);
- BseSongTiming timing;
+ Bse::SongTiming timing;
g_object_get (part, "last-tick", &last_tick, NULL);
if (BSE_IS_SONG (item->parent))
bse_song_get_timing (BSE_SONG (item->parent), offset, &timing);
@@ -1067,6 +1067,19 @@ TrackImpl::TrackImpl (BseObject *bobj) :
TrackImpl::~TrackImpl ()
{}
+SongTiming
+TrackImpl::get_timing (int tick)
+{
+ BseTrack *self = as<BseTrack*>();
+ SongTiming timing;
+ BseItem *parent = BSE_ITEM (self)->parent;
+ if (BSE_IS_SONG (parent))
+ bse_song_get_timing (BSE_SONG (parent), tick, &timing);
+ else
+ bse_song_timing_get_default (&timing);
+ return timing;
+}
+
int
TrackImpl::insert_part (int tick, PartIface &parti)
{
diff --git a/bse/bsetrack.hh b/bse/bsetrack.hh
index 158da47..60fac20 100644
--- a/bse/bsetrack.hh
+++ b/bse/bsetrack.hh
@@ -86,6 +86,7 @@ protected:
virtual ~TrackImpl ();
public:
explicit TrackImpl (BseObject*);
+ virtual SongTiming get_timing (int tick) override;
virtual int insert_part (int tick, PartIface &part) override;
virtual void remove_tick (int tick) override;
virtual PartIfaceP get_part (int tick) override;
diff --git a/bse/bsetrack.proc b/bse/bsetrack.proc
index 739b09b..85e15bd 100644
--- a/bse/bsetrack.proc
+++ b/bse/bsetrack.proc
@@ -99,35 +99,3 @@ BODY (BseProcedureClass *proc,
return Bse::ERROR_NONE;
}
-
-METHOD (BseTrack, get-timing) {
- HELP = "Retrieve song timing information at a specific tick.";
- IN = bse_param_spec_object ("track", "Track", NULL, BSE_TYPE_TRACK, SFI_PARAM_STANDARD);
- IN = sfi_pspec_int ("tick", "Tick", "Tick to retrieve timing info about", 0, 0, G_MAXINT, 384,
SFI_PARAM_STANDARD);
- OUT = bse_param_spec_boxed ("timing", "Timing", "Song Timing", BSE_TYPE_SONG_TIMING, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
- SfiInt tick = sfi_value_get_int (in_values++);
- BseItem *parent;
- BseSongTiming timing = { 0, };
-
- /* check parameters */
- if (!BSE_IS_TRACK (self))
- return Bse::ERROR_PROC_PARAM_INVAL;
-
- /* action */
- parent = BSE_ITEM (self)->parent;
- if (BSE_IS_SONG (parent))
- bse_song_get_timing (BSE_SONG (parent), tick, &timing);
- else
- bse_song_timing_get_default (&timing);
-
- /* set output parameters */
- bse_value_set_boxed (out_values++, &timing);
-
- return Bse::ERROR_NONE;
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]