-
Notifications
You must be signed in to change notification settings - Fork 106
Add AutomationEventList #267
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dcb873b
Add Automation Event List
RobLoach d0b9e01
Update include/AutomationEventList.hpp
RobLoach 39d5a3a
Apply suggestions from code review
RobLoach a2aac0c
Update include/AutomationEventList.hpp
RobLoach 59e7276
Fix playautomatedevent
RobLoach 1cbb8a4
Update lib
RobLoach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| #ifndef RAYLIB_CPP_INCLUDE_AUTOMATIONEVENTLIST_HPP_ | ||
| #define RAYLIB_CPP_INCLUDE_AUTOMATIONEVENTLIST_HPP_ | ||
|
|
||
| #include "./raylib.hpp" | ||
| #include "./raylib-cpp-utils.hpp" | ||
| #include "./RaylibException.hpp" | ||
|
|
||
| namespace raylib { | ||
| /** | ||
| * AutomationEventList management functions | ||
| */ | ||
| class AutomationEventList : public ::AutomationEventList { | ||
| public: | ||
| AutomationEventList(const ::AutomationEventList& automationEventList) { | ||
| set(automationEventList); | ||
| } | ||
|
|
||
| AutomationEventList(unsigned int capacity = 16384, | ||
| unsigned int count = 0, | ||
| AutomationEvent *events = nullptr) : ::AutomationEventList{capacity, count, events} { | ||
| // Nothing. | ||
| } | ||
|
|
||
| AutomationEventList(const char* fileName) { | ||
| Load(fileName); | ||
| } | ||
|
|
||
| AutomationEventList(const AutomationEventList&) = delete; | ||
|
|
||
| AutomationEventList(AutomationEventList&& other) { | ||
| set(other); | ||
|
|
||
| other.capacity = 0; | ||
| other.count = 0; | ||
| other.events = nullptr; | ||
| } | ||
|
|
||
| ~AutomationEventList() { | ||
| Unload(); | ||
| } | ||
|
|
||
| GETTERSETTER(unsigned int, Capacity, capacity) | ||
| GETTERSETTER(unsigned int, Count, count) | ||
| GETTERSETTER(AutomationEvent*, Events, events) | ||
|
|
||
| AutomationEventList& operator=(const ::AutomationEventList& other) { | ||
| set(other); | ||
| return *this; | ||
| } | ||
|
|
||
| AutomationEventList& operator=(const AutomationEventList&) = delete; | ||
|
|
||
| AutomationEventList& operator=(AutomationEventList&& other) noexcept { | ||
| if (this == &other) { | ||
| return *this; | ||
| } | ||
|
|
||
| Unload(); | ||
| set(other); | ||
|
|
||
| other.capacity = 0; | ||
| other.count = 0; | ||
| other.events = nullptr; | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| /** | ||
| * Load audio stream (to stream raw audio pcm data) | ||
| * | ||
| * @throws raylib::RaylibException Throws if the AutomationEventList failed to load. | ||
| */ | ||
| void Load(const char* fileName) { | ||
| Unload(); | ||
| set(::LoadAutomationEventList(fileName)); | ||
| if (!IsReady()) { | ||
| throw RaylibException("Failed to load automation event list"); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Update audio stream buffers with data | ||
| */ | ||
| inline AutomationEventList& Unload() { | ||
| ::UnloadAutomationEventList(this); | ||
| return *this; | ||
| } | ||
|
|
||
| inline bool IsReady() { | ||
| return events != nullptr; | ||
| } | ||
|
|
||
| inline bool Export(const char* fileName) { | ||
| return ::ExportAutomationEventList(*this, fileName); | ||
| } | ||
|
|
||
| inline void Set() { | ||
| ::SetAutomationEventList(this); | ||
| } | ||
|
|
||
| inline void SetBaseFrame(int frame) { | ||
| ::SetAutomationEventBaseFrame(frame); | ||
| } | ||
|
|
||
| inline void StartRecording() { | ||
| Set(); | ||
| ::StartAutomationEventRecording(); | ||
| } | ||
|
|
||
| inline void StopRecording() { | ||
| ::StopAutomationEventRecording(); | ||
RobLoach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| inline void Play() { | ||
| ::StopAutomationEventRecording(); | ||
RobLoach marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| protected: | ||
| void set(const ::AutomationEventList& other) { | ||
| capacity = other.capacity; | ||
| count = other.count; | ||
| events = other.events; | ||
| } | ||
| }; | ||
| } // namespace raylib | ||
|
|
||
| using RAutomationEventList = raylib::AutomationEventList; | ||
|
|
||
| #endif // RAYLIB_CPP_INCLUDE_AUTOMATIONEVENTLIST_HPP_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.