Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
project.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2#ifndef __ASE_PROJECT_HH__
3#define __ASE_PROJECT_HH__
4
5#include <ase/device.hh>
6#include <ase/track.hh>
7#include <ase/member.hh>
8#include <ase/transport.hh>
9
10namespace Ase {
11
12class UndoScope {
13 ProjectImplP projectp_;
14 friend class ProjectImpl;
15 explicit UndoScope (ProjectImplP projectp);
16public:
17 /*copy*/ UndoScope (const UndoScope&);
18 /*dtor*/ ~UndoScope ();
19 void operator+= (const VoidF &func);
20};
21
22class ProjectImpl final : public DeviceImpl, public virtual Project {
25 TickSignature tick_sig_;
26 MusicalTuning musical_tuning_ = MusicalTuning::OD_12_TET;
27 uint autoplay_timer_ = 0;
28 uint undo_scopes_open_ = 0;
29 uint undo_groups_open_ = 0;
30 String undo_group_name_;
31 struct UndoFunc { VoidF func; String name; };
32 std::vector<UndoFunc> undostack_, redostack_;
33 struct PStorage;
34 PStorage *storage_ = nullptr;
35 String saved_filename_;
36 bool discarded_ = false;
37 friend class UndoScope;
38 UndoScope add_undo_scope (const String &scopename);
39protected:
40 explicit ProjectImpl ();
41 virtual ~ProjectImpl ();
42 void set_bpm (double bpm) override;
43 double get_bpm () const override;
44 void set_numerator (double num) override;
45 double get_numerator () const override;
46 void set_denominator (double den) override;
47 double get_denominator () const override;
48 void serialize (WritNode &xs) override;
49 void update_tempo ();
50 Error snapshot_project (String &json);
51 String match_serialized (const String &regex, int group) override;
52public:
53 void _activate () override;
54 void _deactivate () override;
55 const TickSignature& signature () const { return tick_sig_; }
56 void discard () override;
57 AudioProcessorP _audio_processor () const override;
58 void _set_event_source (AudioProcessorP esource) override;
59 DeviceInfo device_info () override;
60 UndoScope undo_scope (const String &scopename);
61 void push_undo (const VoidF &func);
62 void undo () override;
63 bool can_undo () override;
64 void redo () override;
65 bool can_redo () override;
66 void group_undo (const String &undoname) override;
67 void ungroup_undo () override;
68 void clear_undo ();
69 size_t undo_size_guess () const;
70 void start_playback (double autostop);
71 void start_playback () override { start_playback (D64MAX); }
72 void stop_playback () override;
73 bool is_playing () override;
74 TrackP create_track () override;
75 bool remove_track (Track &child) override;
76 TrackS all_tracks () override;
77 TrackP master_track () override;
78 Error load_project (const String &utf8filename) override;
79 StreamReaderP load_blob (const String &fspath);
80 String loader_resolve (const String &hexhash);
81 Error save_project (const String &utf8filename, bool collect) override;
82 String saved_filename () override; // returns utf8filename
83 String writer_file_name (const String &fspath) const;
84 Error writer_add_file (const String &fspath);
85 Error writer_collect (const String &fspath, String *hexhashp);
86 TelemetryFieldS telemetry () const override;
87 AudioProcessorP master_processor () const;
88 ssize_t track_index (const Track &child) const;
89 static ProjectImplP create (const String &projectname);
90 static size_t undo_mem_counter;
91};
92using ProjectImplP = std::shared_ptr<ProjectImpl>;
93
94} // Ase
95
96#endif // __ASE_PROJECT_HH__
bool remove_track(Track &child) override
Remove a track owned by this Project.
Definition project.cc:827
void group_undo(const String &undoname) override
Merge upcoming undo steps.
Definition project.cc:604
void _deactivate() override
Stop processing the corresponding AudioProcessor.
Definition project.cc:129
void redo() override
Redo the last undo modification.
Definition project.cc:572
bool can_redo() override
Check if any redo steps have been recorded.
Definition project.cc:598
TrackP master_track() override
Retrieve the master track.
Definition project.cc:860
bool is_playing() override
Check whether a project is currently playing (song sequencing).
Definition project.cc:806
void undo() override
Undo the last project modification.
Definition project.cc:538
String match_serialized(const String &regex, int group) override
Match regex against the serialized project state.
Definition project.cc:472
bool can_undo() override
Check if any undo steps have been recorded.
Definition project.cc:566
void serialize(WritNode &xs) override
Serialize members and childern.
Definition project.cc:439
TelemetryFieldS telemetry() const override
Retrieve project telemetry locations.
Definition project.cc:650
TrackS all_tracks() override
List all tracks of the project.
Definition project.cc:843
void ungroup_undo() override
Stop merging undo steps.
Definition project.cc:619
String saved_filename() override
Retrieve UTF-8 filename for save or from load.
Definition project.cc:362
TrackP create_track() override
Create and append a new Track.
Definition project.cc:814
AudioProcessorP _audio_processor() const override
Retrieve the corresponding AudioProcessor.
Definition project.cc:873
Error save_project(const String &utf8filename, bool collect) override
Store Project and collect external files.
Definition project.cc:160
void _activate() override
Add AudioProcessor to the Engine and start processing.
Definition project.cc:120
String loader_resolve(const String &hexhash)
Find file from hash code, returns fspath.
Definition project.cc:428
void start_playback() override
Start playback of a project, requires active sound engine.
Definition project.hh:71
DeviceInfo device_info() override
Describe this Device type.
Definition project.cc:867
void discard() override
Discard project and associated resources.
Definition project.cc:109
Error load_project(const String &utf8filename) override
Load project from file filename.
Definition project.cc:368
void stop_playback() override
Stop project playback.
Definition project.cc:783
Projects support loading, saving, playback and act as containers for all other sound objects.
Definition api.hh:317
Container for Clip objects and sequencing information.
Definition api.hh:285
One entry in a Writ serialization document.
Definition serialize.hh:24
#define ASE_DEFINE_MAKE_SHARED(CLASS)
Definition cxxaux.hh:269
The Anklang C++ API namespace.
Definition api.hh:9
Error
Enum representing Error states.
Definition api.hh:22
uint32_t uint
Provide 'uint' as convenience type.
Definition cxxaux.hh:18
MusicalTuning
Musical tunings, see: http://en.wikipedia.org/wiki/Musical_tuning.
Definition api.hh:83
Info for device types.
Definition api.hh:203
Musical time signature and tick conversions.
Definition transport.hh:61
typedef ssize_t