Skip to content
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

Debug module #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions console/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ auto ParseArgs(std::vector<std::string>& args, InputOutput& io) -> OperationType
io.output_file = "";
io.output_type = ModuleType::kNone;

const size_t arg_count = args.size();
const std::size_t arg_count = args.size();

if (arg_count == 1)
{
Expand Down Expand Up @@ -205,7 +205,7 @@ auto ParseArgs(std::vector<std::string>& args, InputOutput& io) -> OperationType
io.output_type = Utils::GetTypeFromCommandName(args[1]);
if (io.output_type != ModuleType::kNone)
{
const size_t dot_pos = io.input_file.rfind('.');
const std::size_t dot_pos = io.input_file.rfind('.');
if (dot_pos == 0 || dot_pos + 1 >= io.input_file.size())
{
std::cerr << "ERROR: The input file is invalid.\n";
Expand Down
2 changes: 1 addition & 1 deletion include/core/conversion_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ConversionOptionsBase : public OptionCollection, public EnableReflection<C
* Cast ConversionOptionsPtr to std::shared_ptr<T> where T is the derived ConversionOptions class
*/
template<class T, std::enable_if_t<std::is_base_of_v<ConversionOptionsBase, T>, bool> = true>
[[nodiscard]] auto Cast() const -> std::shared_ptr<const T>
auto Cast() const -> std::shared_ptr<const T>
{
return std::static_pointer_cast<const T>(shared_from_this());
}
Expand Down
100 changes: 50 additions & 50 deletions include/core/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

namespace d2m {

using OrderIndex = uint16_t;
using PatternIndex = uint16_t;
using ChannelIndex = uint8_t;
using RowIndex = uint16_t;
using OrderIndex = std::uint16_t;
using PatternIndex = std::uint16_t;
using ChannelIndex = std::uint8_t;
using RowIndex = std::uint16_t;

enum class DataStorageType
{
Expand Down Expand Up @@ -100,9 +100,9 @@ namespace detail {
{
public:
virtual ~ModuleDataStorageBase() = default;
[[nodiscard]] inline auto GetNumChannels() const -> ChannelIndex { return num_channels_; }
[[nodiscard]] inline auto GetNumOrders() const -> OrderIndex { return num_orders_; }
[[nodiscard]] inline auto GetNumRows() const -> RowIndex { return num_rows_; }
auto GetNumChannels() const -> ChannelIndex { return num_channels_; }
auto GetNumOrders() const -> OrderIndex { return num_orders_; }
auto GetNumRows() const -> RowIndex { return num_rows_; }
protected:
virtual void CleanUpData() = 0;
virtual void SetPatternMatrix(ChannelIndex channels, OrderIndex orders, RowIndex rows) = 0;
Expand Down Expand Up @@ -134,20 +134,20 @@ namespace detail {
using PatternMetadataType = PatternMetadata<ModuleClass>;
using PatternMetadataStorageType = std::vector<std::vector<PatternMetadataType>>; // [channel][pattern id]

[[nodiscard]] inline auto GetPatternId(ChannelIndex channel, OrderIndex order) const -> PatternIndex { return pattern_matrix_[channel][order]; }
inline void SetPatternId(ChannelIndex channel, OrderIndex order, PatternIndex pattern_id) { pattern_matrix_[channel][order] = pattern_id; }
[[nodiscard]] inline auto GetNumPatterns(ChannelIndex channel) const -> PatternIndex { return num_patterns_[channel]; }
inline void SetNumPatterns(ChannelIndex channel, PatternIndex num_patterns) { num_patterns_[channel] = num_patterns; }
[[nodiscard]] inline auto GetPattern(ChannelIndex channel, OrderIndex order) const -> PatternType { return patterns_[channel][GetPatternId(channel, order)]; }
inline void SetPattern(ChannelIndex channel, OrderIndex order, PatternType&& pattern) { patterns_[channel][GetPatternId(channel, order)] = std::move(pattern); } // TODO: Deep copy?
[[nodiscard]] inline auto GetPatternById(ChannelIndex channel, PatternIndex pattern_id) const -> PatternType { return patterns_[channel][pattern_id]; }
inline void SetPatternById(ChannelIndex channel, PatternIndex pattern_id, PatternType&& pattern) { patterns_[channel][pattern_id] = std::move(pattern); } // TODO: Deep copy?
[[nodiscard]] inline auto GetRow(ChannelIndex channel, OrderIndex order, RowIndex row) const -> const RowType& { return GetPattern(channel, order)[row]; }
inline void SetRow(ChannelIndex channel, OrderIndex order, RowIndex row, const RowType& row_value) { GetPattern(channel, order)[row] = row_value; }
[[nodiscard]] inline auto GetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row) const -> const RowType& { return GetPatternById(channel, pattern_id)[row]; }
inline void SetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row, const RowType& row_value) { GetPatternById(channel, pattern_id)[row] = row_value; }
[[nodiscard]] inline auto GetPatternMetadata(ChannelIndex channel, PatternIndex pattern_id) const -> const PatternMetadataType& { return pattern_metadata_[channel][pattern_id]; }
inline void SetPatternMetadata(ChannelIndex channel, PatternIndex pattern_id, const PatternMetadataType& pattern_metadata) { pattern_metadata_[channel][pattern_id] = pattern_metadata; }
auto GetPatternId(ChannelIndex channel, OrderIndex order) const -> PatternIndex { return pattern_matrix_[channel][order]; }
void SetPatternId(ChannelIndex channel, OrderIndex order, PatternIndex pattern_id) { pattern_matrix_[channel][order] = pattern_id; }
auto GetNumPatterns(ChannelIndex channel) const -> PatternIndex { return num_patterns_[channel]; }
void SetNumPatterns(ChannelIndex channel, PatternIndex num_patterns) { num_patterns_[channel] = num_patterns; }
auto GetPattern(ChannelIndex channel, OrderIndex order) const -> PatternType { return patterns_[channel][GetPatternId(channel, order)]; }
void SetPattern(ChannelIndex channel, OrderIndex order, PatternType&& pattern) { patterns_[channel][GetPatternId(channel, order)] = std::move(pattern); } // TODO: Deep copy?
auto GetPatternById(ChannelIndex channel, PatternIndex pattern_id) const -> PatternType { return patterns_[channel][pattern_id]; }
void SetPatternById(ChannelIndex channel, PatternIndex pattern_id, PatternType&& pattern) { patterns_[channel][pattern_id] = std::move(pattern); } // TODO: Deep copy?
auto GetRow(ChannelIndex channel, OrderIndex order, RowIndex row) const -> const RowType& { return GetPattern(channel, order)[row]; }
void SetRow(ChannelIndex channel, OrderIndex order, RowIndex row, const RowType& row_value) { GetPattern(channel, order)[row] = row_value; }
auto GetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row) const -> const RowType& { return GetPatternById(channel, pattern_id)[row]; }
void SetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row, const RowType& row_value) { GetPatternById(channel, pattern_id)[row] = row_value; }
auto GetPatternMetadata(ChannelIndex channel, PatternIndex pattern_id) const -> const PatternMetadataType& { return pattern_metadata_[channel][pattern_id]; }
void SetPatternMetadata(ChannelIndex channel, PatternIndex pattern_id, const PatternMetadataType& pattern_metadata) { pattern_metadata_[channel][pattern_id] = pattern_metadata; }

protected:
ModuleDataStorage() = default;
Expand Down Expand Up @@ -250,20 +250,20 @@ namespace detail {
using PatternMetadataType = PatternMetadata<ModuleClass>;
using PatternMetadataStorageType = std::vector<PatternMetadataType>; // [pattern id] (No per-channel patterns)

[[nodiscard]] inline auto GetPatternId(OrderIndex order) const -> PatternIndex { return pattern_matrix_[order]; }
inline void SetPatternId(OrderIndex order, PatternIndex pattern_id) { pattern_matrix_[order] = pattern_id; }
[[nodiscard]] inline auto GetNumPatterns() const -> PatternIndex { return num_patterns_; }
inline void SetNumPatterns(PatternIndex num_patterns) { num_patterns_ = num_patterns; }
[[nodiscard]] inline auto GetPattern(OrderIndex order) const -> PatternType { return patterns_[GetPatternId(order)]; }
inline void SetPattern(OrderIndex order, PatternType&& pattern) { patterns_[GetPatternId(order)] = std::move(pattern); } // TODO: Deep copy?
[[nodiscard]] inline auto GetPatternById(PatternIndex pattern_id) const -> PatternType { return patterns_[pattern_id]; }
inline void SetPatternById(PatternIndex pattern_id, PatternType&& pattern) { patterns_[pattern_id] = std::move(pattern); } // TODO: Deep copy?
[[nodiscard]] inline auto GetRow(ChannelIndex channel, OrderIndex order, RowIndex row) const -> const RowType& { return GetPattern(order)[row][channel]; }
inline void SetRow(ChannelIndex channel, OrderIndex order, RowIndex row, const RowType& row_value) { GetPattern(order)[row][channel] = row_value; }
[[nodiscard]] inline auto GetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row) const -> const RowType& { return GetPatternById(pattern_id)[row][channel]; }
inline void SetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row, const RowType& row_value) { GetPatternById(pattern_id)[row][channel] = row_value; }
[[nodiscard]] inline auto GetPatternMetadata(PatternIndex pattern_id) const -> const PatternMetadataType& { return pattern_metadata_[pattern_id]; }
inline void SetPatternMetadata(PatternIndex pattern_id, const PatternMetadataType& pattern_metadata) { pattern_metadata_[pattern_id] = pattern_metadata; }
auto GetPatternId(OrderIndex order) const -> PatternIndex { return pattern_matrix_[order]; }
void SetPatternId(OrderIndex order, PatternIndex pattern_id) { pattern_matrix_[order] = pattern_id; }
auto GetNumPatterns() const -> PatternIndex { return num_patterns_; }
void SetNumPatterns(PatternIndex num_patterns) { num_patterns_ = num_patterns; }
auto GetPattern(OrderIndex order) const -> PatternType { return patterns_[GetPatternId(order)]; }
void SetPattern(OrderIndex order, PatternType&& pattern) { patterns_[GetPatternId(order)] = std::move(pattern); } // TODO: Deep copy?
auto GetPatternById(PatternIndex pattern_id) const -> PatternType { return patterns_[pattern_id]; }
void SetPatternById(PatternIndex pattern_id, PatternType&& pattern) { patterns_[pattern_id] = std::move(pattern); } // TODO: Deep copy?
auto GetRow(ChannelIndex channel, OrderIndex order, RowIndex row) const -> const RowType& { return GetPattern(order)[row][channel]; }
void SetRow(ChannelIndex channel, OrderIndex order, RowIndex row, const RowType& row_value) { GetPattern(order)[row][channel] = row_value; }
auto GetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row) const -> const RowType& { return GetPatternById(pattern_id)[row][channel]; }
void SetRowById(ChannelIndex channel, PatternIndex pattern_id, RowIndex row, const RowType& row_value) { GetPatternById(pattern_id)[row][channel] = row_value; }
auto GetPatternMetadata(PatternIndex pattern_id) const -> const PatternMetadataType& { return pattern_metadata_[pattern_id]; }
void SetPatternMetadata(PatternIndex pattern_id, const PatternMetadataType& pattern_metadata) { pattern_metadata_[pattern_id] = pattern_metadata; }

protected:
ModuleDataStorage() = default;
Expand Down Expand Up @@ -381,30 +381,30 @@ class ModuleData final : public detail::ModuleDataStorage<ModuleGlobalData<Modul

/////// DIRECT ACCESS GETTERS ///////

inline auto PatternMatrixRef() const -> const typename Storage::PatternMatrixType& { return Storage::pattern_matrix_; }
inline auto PatternMatrixRef() -> typename Storage::PatternMatrixType& { return Storage::pattern_matrix_; }
auto PatternMatrixRef() const -> const typename Storage::PatternMatrixType& { return Storage::pattern_matrix_; }
auto PatternMatrixRef() -> typename Storage::PatternMatrixType& { return Storage::pattern_matrix_; }

inline auto NumPatternsRef() const -> const typename Storage::NumPatternsType& { return Storage::num_patterns_; }
inline auto NumPatternsRef() -> typename Storage::NumPatternsType& { return Storage::num_patterns_; }
auto NumPatternsRef() const -> const typename Storage::NumPatternsType& { return Storage::num_patterns_; }
auto NumPatternsRef() -> typename Storage::NumPatternsType& { return Storage::num_patterns_; }

inline auto PatternsRef() const -> const typename Storage::PatternStorageType& { return Storage::patterns_; }
inline auto PatternsRef() -> typename Storage::PatternStorageType& { return Storage::patterns_; }
auto PatternsRef() const -> const typename Storage::PatternStorageType& { return Storage::patterns_; }
auto PatternsRef() -> typename Storage::PatternStorageType& { return Storage::patterns_; }

inline auto PatternMetadataRef() const -> const typename Storage::PatternMetadataStorageType& { return Storage::pattern_metadata_; }
inline auto PatternMetadataRef() -> typename Storage::PatternMetadataStorageType& { return Storage::pattern_metadata_; }
auto PatternMetadataRef() const -> const typename Storage::PatternMetadataStorageType& { return Storage::pattern_metadata_; }
auto PatternMetadataRef() -> typename Storage::PatternMetadataStorageType& { return Storage::pattern_metadata_; }

inline auto ChannelMetadataRef() const -> const std::vector<ChannelMetadataType>& { return channel_metadata_; }
inline auto ChannelMetadataRef() -> std::vector<ChannelMetadataType>& { return channel_metadata_; }
auto ChannelMetadataRef() const -> const std::vector<ChannelMetadataType>& { return channel_metadata_; }
auto ChannelMetadataRef() -> std::vector<ChannelMetadataType>& { return channel_metadata_; }

inline auto GlobalData() const -> const GlobalDataType& { return global_data_; }
inline auto GlobalData() -> GlobalDataType& { return global_data_; }
auto GlobalData() const -> const GlobalDataType& { return global_data_; }
auto GlobalData() -> GlobalDataType& { return global_data_; }

/////// GETTERS / SETTERS ///////

inline auto GetChannelMetadata(ChannelIndex channel) const -> const ChannelMetadataType& { return channel_metadata_[channel]; }
inline void SetChannelMetadata(ChannelIndex channel, const ChannelMetadataType& channelMetadata) { channel_metadata_[channel] = channelMetadata; }
auto GetChannelMetadata(ChannelIndex channel) const -> const ChannelMetadataType& { return channel_metadata_[channel]; }
void SetChannelMetadata(ChannelIndex channel, const ChannelMetadataType& channelMetadata) { channel_metadata_[channel] = channelMetadata; }

static inline constexpr auto GetStorageType() -> DataStorageType { return storage_type; }
static constexpr auto GetStorageType() -> DataStorageType { return storage_type; }

/////// Other

Expand Down
42 changes: 21 additions & 21 deletions include/core/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace d2m {

using EffectCode = int8_t;
using EffectValue = int16_t;
using EffectCode = std::int8_t;
using EffectValue = std::int16_t;

struct Effect
{
Expand All @@ -31,25 +31,25 @@ namespace Effects
enum
{
// All common effects are less than 0
kNoEffect =0,
kArp =-1,
kPortUp =-2,
kPortDown =-3,
kPort2Note =-4,
kVibrato =-5,
kPort2NoteVolSlide =-6,
kVibratoVolSlide =-7,
kTremolo =-8,
kPanning =-9,
kSpeedA =-10,
kVolSlide =-11,
kPosJump =-12,
kRetrigger =-13,
kPatBreak =-14,
kNoteCut =-15,
kNoteDelay =-16,
kTempo =-17,
kSpeedB =-18,
kNoEffect = 0,
kArp = -1,
kPortUp = -2,
kPortDown = -3,
kPort2Note = -4,
kVibrato = -5,
kPort2NoteVolSlide = -6,
kVibratoVolSlide = -7,
kTremolo = -8,
kPanning = -9,
kSpeedA = -10,
kVolSlide = -11,
kPosJump = -12,
kRetrigger = -13,
kPatBreak = -14,
kNoteCut = -15,
kNoteDelay = -16,
kTempo = -17,
kSpeedB = -18,
};
// Modules should implement effects specific to them using positive values starting with 1.
}
Expand Down
8 changes: 4 additions & 4 deletions include/core/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ template<class Base> bool Factory<Base>::initialized_ = false;
template<class Base>
struct EnableReflection : public detail::EnableReflectionBase
{
[[nodiscard]] virtual auto GetType() const -> ModuleType = 0;
[[nodiscard]] virtual auto GetInfo() const -> const Info<Base>* = 0;
virtual auto GetType() const -> ModuleType = 0;
virtual auto GetInfo() const -> const Info<Base>* = 0;
};


Expand All @@ -242,13 +242,13 @@ struct EnableReflection : public detail::EnableReflectionBase
template<class Derived, class Base>
struct ReflectionImpl : public Base
{
[[nodiscard]] auto GetType() const -> ModuleType final
auto GetType() const -> ModuleType final
{
static const ModuleType module_type = Factory<Base>::template GetEnumFromType<Derived>();
return module_type;
}

[[nodiscard]] auto GetInfo() const -> const Info<Base>* final
auto GetInfo() const -> const Info<Base>* final
{
return Factory<Base>::GetInfo(GetType());
}
Expand Down
Loading
Loading