Skip to content

Commit

Permalink
Remove debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Jun 18, 2024
1 parent 5f68521 commit 249b166
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 41 deletions.
4 changes: 2 additions & 2 deletions firmware/src/console/pr_dbg.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ inline constexpr bool PRINT_WARN = true;
inline constexpr bool PRINT_INFO = true;

// Debug: temporary messges used for debugging
inline constexpr bool PRINT_DEBUG = true;
inline constexpr bool PRINT_DEBUG = false;

// Trace: detailed log of execution
inline constexpr bool PRINT_TRACE = true;
inline constexpr bool PRINT_TRACE = false;

// Dump: large amounts of verbose data
inline constexpr bool PRINT_DUMP = false;
Expand Down
2 changes: 0 additions & 2 deletions firmware/src/patch_file/open_patch_manager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public:
if (view_patch_)
return &view_patch_->patch;
else {
pr_err("Tried to get_view_patch when viewpatch is null.\n");
return nullptr;
}
}
Expand Down Expand Up @@ -121,7 +120,6 @@ public:
if (view_patch_)
return view_patch_->loc.vol;
else {
pr_err("Tried to get_view_patch_vol() for null view_patch\n");
return Volume::MaxVolumes;
}
}
Expand Down
39 changes: 31 additions & 8 deletions firmware/src/patch_file/open_patches.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct OpenPatchList {
return nullptr;

if (auto it = std::ranges::find(list, hash, &OpenPatch::loc_hash); it != list.end()) {
pr_dbg("range found\n");
return &(*it);
}
return nullptr;
Expand All @@ -49,19 +48,16 @@ struct OpenPatchList {

OpenPatch *emplace_back(PatchLocation const &loc) {
auto &openpatch = list.emplace_back(loc);
dump();
return &openpatch;
}

bool remove(PatchLocHash hash) {
auto num_erased = std::erase_if(list, [=](auto &e) { return e.loc_hash == hash; });
dump();
return num_erased > 0;
}

void remove(std::list<OpenPatch>::iterator item) {
list.erase(item);
dump();
}

void remove_last() {
Expand All @@ -85,13 +81,12 @@ struct OpenPatchList {
}

private:
void dump() {
void dump_open_patches() {
unsigned i = 0;
size_t total_size = 0;

pr_dbg("________\n");
for (auto &p : list) {
auto sz = p.patch.patch_size();
auto sz = patch_size(p.patch);
total_size += sz;
pr_dbg("[%d] %d:%s: %s #%d [%zu B]\n",
i++,
Expand All @@ -102,7 +97,35 @@ private:
sz);
}
pr_dbg("TOTAL: %zu\n", total_size);
pr_dbg("________\n");
}

static size_t patch_size(PatchData const &p) {
auto sz = sizeof(PatchData);
sz += p.module_slugs.size() * sizeof(BrandModuleSlug);

sz += p.int_cables.size() * sizeof(InternalCable);
for (auto const &cable : p.int_cables)
sz += cable.ins.size() * sizeof(Jack);

sz += p.mapped_ins.size() * sizeof(MappedInputJack);
for (auto const &in : p.mapped_ins)
sz += in.ins.size() * sizeof(Jack);

sz += p.mapped_outs.size() * sizeof(MappedOutputJack);

sz += p.static_knobs.size() * sizeof(StaticParam);

sz += p.knob_sets.size() * sizeof(MappedKnobSet);
for (auto const &knob_set : p.knob_sets)
sz += knob_set.set.size() * sizeof(MappedKnob);

sz += p.module_states.size() * sizeof(ModuleInitState);
for (auto const &state : p.module_states)
sz += state.state_data.size() * sizeof(char);

sz += p.midi_maps.set.size() * sizeof(MappedKnob);

return sz;
}

private:
Expand Down
29 changes: 0 additions & 29 deletions shared/patch/patch_data.hh
Original file line number Diff line number Diff line change
Expand Up @@ -331,35 +331,6 @@ struct PatchData {
return module_id;
}

size_t patch_size() {
auto sz = sizeof(PatchData);
sz += module_slugs.size() * sizeof(BrandModuleSlug);

sz += int_cables.size() * sizeof(InternalCable);
for (auto const &cable : int_cables)
sz += cable.ins.size() * sizeof(Jack);

sz += mapped_ins.size() * sizeof(MappedInputJack);
for (auto const &in : mapped_ins)
sz += in.ins.size() * sizeof(Jack);

sz += mapped_outs.size() * sizeof(MappedOutputJack);

sz += static_knobs.size() * sizeof(StaticParam);

sz += knob_sets.size() * sizeof(MappedKnobSet);
for (auto const &knob_set : knob_sets)
sz += knob_set.set.size() * sizeof(MappedKnob);

sz += module_states.size() * sizeof(ModuleInitState);
for (auto const &state : module_states)
sz += state.state_data.size() * sizeof(char);

sz += midi_maps.set.size() * sizeof(MappedKnob);

return sz;
}

private:
//non-const version for private use only
MappedKnob *_get_mapped_knob(uint32_t set_id, uint32_t module_id, uint32_t param_id) {
Expand Down

0 comments on commit 249b166

Please sign in to comment.