9#ifndef __AUDIO_REGION_H__
10#define __AUDIO_REGION_H__
20#include <glib/gi18n.h>
36#define REGION_SCHEMA_VERSION 1
38#define REGION_MAGIC 93075327
39#define IS_REGION(x) (((ZRegion *) x)->magic == REGION_MAGIC)
40#define IS_REGION_AND_NONNULL(x) (x && IS_REGION (x))
42#define REGION_PRINTF_FILENAME "%s_%s.mid"
44#define region_is_selected(r) \
45 arranger_object_is_selected ((ArrangerObject *) r)
62static const cyaml_strval_t region_musical_mode_strings[] = {
114 size_t midi_notes_size;
131 int num_unended_notes;
194 int num_split_points;
195 size_t split_points_size;
222 int num_chord_objects;
223 size_t chord_objects_size;
261 GdkRectangle last_main_full_rect;
267 GdkRectangle last_lane_full_rect;
288static const cyaml_schema_field_t region_fields_schema[] = {
289 YAML_FIELD_INT (
ZRegion, schema_version),
293 arranger_object_fields_schema),
297 region_identifier_fields_schema),
298 YAML_FIELD_STRING_PTR (
ZRegion, name),
299 YAML_FIELD_INT (
ZRegion, pool_id),
300 YAML_FIELD_FLOAT (
ZRegion, gain),
304 gdk_rgba_fields_schema),
305 YAML_FIELD_INT (
ZRegion, use_color),
306 CYAML_FIELD_SEQUENCE_COUNT (
308 CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
315 CYAML_FIELD_SEQUENCE_COUNT (
317 CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
321 &automation_point_schema,
324 CYAML_FIELD_SEQUENCE_COUNT (
326 CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
330 &chord_object_schema,
336 region_musical_mode_strings),
341static const cyaml_schema_value_t region_schema = {
348#define region_type_can_fade(rtype) \
349 (rtype == REGION_TYPE_AUDIO)
359 unsigned int track_name_hash,
361 int idx_inside_lane);
371region_set_track_name_hash (
373 unsigned int name_hash)
375 self->
id.track_name_hash = name_hash;
383 const size_t buf_size);
421 bool update_identifier);
424region_has_link_group (
ZRegion * region);
458 const bool normalize);
498 const char * base_name,
514NONNULL WARN_UNUSED_RESULT
bool
556 int lane_or_at_index,
567 return type == REGION_TYPE_MIDI || type == REGION_TYPE_AUDIO;
613 const bool inclusive);
628 const bool end_inclusive);
656region_get_type_as_string (
RegionType type,
char * buf);
684region_add_arranger_object (
690region_create_link_group_if_none (
ZRegion * region);
716region_is_looped (const
ZRegion * const self);
725region_get_arranger_selections (
ZRegion * self);
733region_get_arranger_for_children (
ZRegion * self);
748 double frames_per_tick);
Macros for arranger object backends.
Chord object in the TimelineArranger.
API for MIDI notes in the PianoRoll.
RegionLinkGroup * region_get_link_group(ZRegion *self)
Returns the region's link group.
PURE ZRegion * region_at_position(const Track *track, const AutomationTrack *at, const Position *pos)
Returns the region at the given position in the given Track.
NONNULL void region_update_link_group(ZRegion *self)
Updates all other regions in the region link group, if any.
NONNULL HOT signed_frame_t region_timeline_frames_to_local(const ZRegion *const self, const signed_frame_t timeline_frames, const bool normalize)
Converts frames on the timeline (global) to local frames (in the clip).
void region_copy_children(ZRegion *dest, ZRegion *src)
Clones and copies all children from src to dest.
NONNULL void region_print(const ZRegion *region)
Print region info for debugging.
NONNULL PURE int region_is_hit(const ZRegion *region, const signed_frame_t gframes, const bool inclusive)
Returns if the position is inside the region or not.
NONNULL WARN_UNUSED_RESULT bool region_stretch(ZRegion *self, double ratio, GError **error)
Stretch the region's contents.
void region_init(ZRegion *region, const Position *start_pos, const Position *end_pos, unsigned int track_name_hash, int lane_pos, int idx_inside_lane)
Only to be used by implementing structs.
int region_is_hit_by_range(const ZRegion *region, const signed_frame_t gframes_start, const signed_frame_t gframes_end, const bool end_inclusive)
Returns if any part of the ZRegion is inside the given range, inclusive.
NONNULL void region_get_frames_till_next_loop_or_end(const ZRegion *const self, const signed_frame_t timeline_frames, signed_frame_t *ret_frames, bool *is_loop)
Returns the number of frames until the next loop end point or the end of the region.
MidiNote * region_find_midi_note(ZRegion *r, MidiNote *_mn)
Returns the MidiNote matching the properties of the given MidiNote.
AutomationTrack * region_get_automation_track(const ZRegion *const region)
Gets the AutomationTrack using the saved index.
NONNULL void region_set_lane(ZRegion *self, const TrackLane *const lane)
Sets the track lane.
RegionMusicalMode
Musical mode setting for audio regions.
RegionType
Type of Region.
void region_move_to_track(ZRegion *region, Track *track, int lane_or_at_index, int index)
Moves the ZRegion to the given Track, maintaining the selection status of the ZRegion.
TrackLane * region_get_lane(const ZRegion *region)
Get lane.
NONNULL void region_update_identifier(ZRegion *self)
To be called every time the identifier changes to update the region's children.
void region_gen_name(ZRegion *region, const char *base_name, AutomationTrack *at, Track *track)
Generates a name for the ZRegion, either using the given AutomationTrack or Track,...
void region_copy(ZRegion *src, ZRegion *dest)
Copies the data from src to dest.
HOT NONNULL ZRegion * region_find(const RegionIdentifier *const id)
Looks for the ZRegion matching the identifier.
void region_set_automation_track(ZRegion *region, AutomationTrack *at)
Sets the automation track.
COLD NONNULL_ARGS(1) void automation_track_init_loaded(AutomationTrack *self
Inits a loaded AutomationTracklist.
void region_set_link_group(ZRegion *region, int group_idx, bool update_identifier)
Sets the link group to the region.
@ REGION_MUSICAL_MODE_ON
Musical mode on - auto-stretch when BPM changes.
@ REGION_MUSICAL_MODE_OFF
Musical mode off - don't auto-stretch when BPM changes.
@ REGION_MUSICAL_MODE_INHERIT
Inherit from global musical mode setting.
#define YAML_FIELD_MAPPING_EMBEDDED(owner, member, schema)
Mapping embedded inside the struct.
int_fast64_t signed_frame_t
Signed type for frame index.
float sample_t
The sample type.
#define YAML_VALUE_PTR_NULLABLE(cc, fields_schema)
Schema to be used as a pointer that can be NULL.
Base struct for arranger objects.
Audio clips for the pool.
An automation point inside an AutomationTrack.
A Channel is part of a Track (excluding Tracks that don't have Channels) and contains information rel...
A ChordObject to be shown in the TimelineArrangerWidget.
A MIDI note inside a ZRegion shown in the piano roll.
A Position is made up of bars.beats.sixteenths.ticks.
Index/identifier for a Region, so we can get Region objects quickly with it without searching by name...
A group of linked regions.
A TrackLane belongs to a Track (can have many TrackLanes in a Track) and contains Regions.
Track to be inserted into the Project's Tracklist.
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
AutomationPoint * last_recorded_ap
Last recorded automation point.
RegionIdentifier id
Unique ID.
char * escaped_name
Escaped name for drawing.
GdkRectangle last_main_draw_rect
Last main draw rect.
int bounce
Set to ON during bouncing if this region should be included.
ChordObject ** chord_objects
ChordObject's in this Region.
gint64 last_clip_change
Last timestamp the audio clip or its contents changed.
bool stretching
Whether currently running the stretching algorithm.
MidiNote * unended_notes[12000]
Unended notes started in recording with MIDI NOTE ON signal but haven't received a NOTE OFF yet.
AutomationPoint ** aps
The automation points this region contains.
GdkRGBA color
Region color independent of track.
ArrangerObject last_positions_obj
Last known marker positions (only positions are used).
char * name
Name to be shown on the widget.
PangoLayout * layout
Cache layout for drawing the name.
GdkRectangle last_lane_draw_rect
Last lane draw rect.
AudioClip * clip
Clip to read frames from, if not from the pool.
int pool_id
Audio pool ID of the associated audio file, mostly used during serialization.
double before_length
The length before stretching, in ticks.
RegionMusicalMode musical_mode
Musical mode setting.
float gain
Gain to apply to the audio (amplitude 0.0-2.0).
Position * split_points
Array of split points.
bool read_from_pool
Whether to read the clip from the pool (used in most cases).
ArrangerObject base
Base struct.
double stretch_ratio
Used during arranger UI overlay actions.
gint64 last_cache_time
Last timestamp the region was cached.
MidiNote ** midi_notes
MIDI notes.
PangoLayout * chords_layout
Cache layout for drawing the chord names inside the region.
bool use_color
Whether to use the custom color.