Loading...
Searching...
No Matches
PatternGrid.hpp
1#pragma once
2#include <Process/TimeValue.hpp>
3#include <Process/ZoomHelper.hpp>
4
5#include <ossia/editor/scenario/time_signature.hpp>
6
7#include <Patternist/PatternModel.hpp>
8
9#include <score_plugin_midi_export.h>
10
11#include <utility>
12#include <vector>
13
14namespace Patternist
15{
20{
27 std::vector<std::pair<TimeVal, ossia::time_signature>> signatures;
28
29 bool operator==(const TimeGrid&) const noexcept = default;
30};
31
34{
35 double x0{};
36 double x1{};
37 int step{};
39 bool repeat{};
40 bool barStart{};
41 bool beatStart{};
43 int beat{};
46 int64_t index{};
49 int shade{};
50};
51
55SCORE_PLUGIN_MIDI_EXPORT
56std::vector<StepSlot> timelineSlots(
57 int length, int division, const TimeGrid& grid, ZoomRatio zoom, double width,
58 std::size_t maxSlots = 100000);
59
60inline std::vector<StepSlot> timelineSlots(
61 const Pattern& p, const TimeGrid& grid, ZoomRatio zoom, double width,
62 std::size_t maxSlots = 100000)
63{
64 return timelineSlots(p.length, p.division, grid, zoom, width, maxSlots);
65}
66
68SCORE_PLUGIN_MIDI_EXPORT
69ossia::time_signature signatureAt(const TimeGrid& grid, TimeVal date) noexcept;
70
73SCORE_PLUGIN_MIDI_EXPORT
74std::vector<StepSlot>
75fitSlots(const Pattern& p, ossia::time_signature sig, double x0, double x1);
76
78SCORE_PLUGIN_MIDI_EXPORT double longestLoop(const Pattern& p) noexcept;
79
83SCORE_PLUGIN_MIDI_EXPORT
84std::vector<StepSlot> fitLaneSlots(
85 int length, int division, ossia::time_signature sig, double span, double x0,
86 double x1);
87
90{
91 std::vector<std::vector<StepSlot>> lanes;
93 double span{};
94};
95
98SCORE_PLUGIN_MIDI_EXPORT
99FitLayout fitLayout(
100 const Pattern& p, ossia::time_signature sig, double x0, double x1, double minStep);
101
105SCORE_PLUGIN_MIDI_EXPORT
106int playingSlot(
107 const std::vector<StepSlot>& slots, int64_t played, int length, int division,
108 double span) noexcept;
109
111SCORE_PLUGIN_MIDI_EXPORT
112int slotWithIndex(const std::vector<StepSlot>& slots, int64_t index) noexcept;
113}
Every lane of a pattern over [x0; x1[.
Definition PatternGrid.hpp:90
double span
Quarters across the width when the lanes line up, 0 otherwise.
Definition PatternGrid.hpp:93
One step as it falls on the timeline.
Definition PatternGrid.hpp:34
int64_t index
Definition PatternGrid.hpp:46
bool repeat
Past the first pass through the pattern, or before the process starts.
Definition PatternGrid.hpp:39
int shade
Definition PatternGrid.hpp:49
int beat
Index of the beat the step falls in, counted from its bar line.
Definition PatternGrid.hpp:43
Definition PatternGrid.hpp:20
TimeVal playStart
Definition PatternGrid.hpp:25
TimeVal origin
Date of the layer's left edge.
Definition PatternGrid.hpp:22
std::vector< std::pair< TimeVal, ossia::time_signature > > signatures
Sorted by date. Empty, or before the first entry, is 4/4 from 0.
Definition PatternGrid.hpp:27
Definition TimeValue.hpp:21