mirror of
https://github.com/yokemura/Magical8bitPlug2.git
synced 2025-07-17 11:04:16 -04:00
Added code
This commit is contained in:
71
Source/FrameSequence.h
Normal file
71
Source/FrameSequence.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
FrameSequence.h
|
||||
Created: 11 Dec 2019 11:37:27am
|
||||
Author: 除村 武志
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
struct FrameSequence
|
||||
{
|
||||
std::vector<int> sequence;
|
||||
bool isLooped = false;
|
||||
bool hasRelease = false;
|
||||
int loopStartIndex = 0;
|
||||
int releaseSequenceStartIndex = 0;
|
||||
static const int SHOULD_RETIRE = 65535;
|
||||
|
||||
int valueAt (int index)
|
||||
{
|
||||
if (index < 0 || index >= sequence.size())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sequence[index];
|
||||
}
|
||||
|
||||
int nextIndexOf (int current)
|
||||
{
|
||||
if (current < releaseSequenceStartIndex) // Hold
|
||||
{
|
||||
if (current == releaseSequenceStartIndex - 1) // Reached to the end
|
||||
{
|
||||
if (isLooped)
|
||||
{
|
||||
return loopStartIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
return current; // Hold the last value
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return current + 1;
|
||||
}
|
||||
|
||||
// No reach here
|
||||
}
|
||||
else // Released
|
||||
{
|
||||
if (current >= sequence.size() - 1) // Reached to the end
|
||||
{
|
||||
return SHOULD_RETIRE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return current + 1;
|
||||
}
|
||||
|
||||
// No reach here
|
||||
}
|
||||
|
||||
// No reach here
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user