Reintroduce JSON export from 0cc#199
Reintroduce JSON export from 0cc#199Gumball2415 merged 5 commits intoDn-Programming-Core-Management:mainfrom
Conversation
|
Oh yeah, there are also a couple mysteries I encountered.
|
|
This PR addresses #200. |
|
for .chm manual entries, feel free to submit a corresponding PR at https://github.com/Dn-Programming-Core-Management/Dn-help |
the MIDI note helper functions use equations that are off-by-one, perhaps Hertz fixed this in later versions, with all other code using these functions following suit? |
FamiTracker has always supported 4 effect columns, all the way to 0CC, and today in Dn. it seems that for (const auto &[fx, param] : note.Effects)
if (fx != effect_t::none)
j["effects"].push_back(json {
{"column", fx}, // fx is treated as a column value, when it's really an index into EFF_CHAR[]
{"name", std::string {EFF_CHAR[value_cast(fx)]}}, // as shown here
{"param", param},
});as for chip, channel, and note structuring, it seems that Hertz has overhauled/refactored everything, so i sadly wouldn't expect 100% compatibility |
|
can you try this fix for // hack to get the equivalent 0CC-exclusive channel subindex
// TODO: implement whatever 0CC's doing for better compatibility
auto chip_type = ch->GetChip();
uint8_t subindex = ch->GetID();
switch (chip_type) {
case SNDCHIP_VRC6: subindex -= 5; break;
case SNDCHIP_VRC7: subindex -= 20; break;
case SNDCHIP_FDS: subindex -= 19; break;
case SNDCHIP_MMC5: subindex -= 8; break;
case SNDCHIP_S5B: subindex -= 26; break;
default: break;
}
channels.push_back({
{ "chip", GetChannelChipName(chip_type)},
{ "subindex", subindex},
}); |
It's possible. My only concern is that 0CC iterates through 96 values, and my code only iterates through 95, but I'm not sure what note I'm missing exactly.
I feel like the JSON export is already like 95% of the way there, so even if the internals are different, I think we can get 100% compatibility (except maybe for the bookmarks field, unless I'm missing something).
I really appreciate the detailed response. I will try this out when I have access to a windows computer again, which could be a while. |
judging purely by the code shown, i think you're missing note "95". 0CC indexes through values 0 until 95, while the code so far indexes through 0 until 94 if the for loop is offset by +1, and the MIDI note helper functions are offset by -1, wouldn't they cancel each other out? for (int n = 0; n < NOTE_COUNT; ++n)
{
int oct = GET_OCTAVE(n);
int note = GET_NOTE(n);
if (auto d_index = inst.GetSampleIndex(oct, note); d_index != 0)
{
j["dpcm_map"].push_back(json{
{"dpcm_index", d_index},
{"pitch", inst.GetSamplePitch(oct, note) & 0x0Fu},
{"loop", inst.GetSampleLoop(oct, note)},
{"delta", inst.GetSampleDeltaValue(oct, note)},
{"note", n},
});
}
}edit: looking deeper into the perhaps a fix might look like this instead: for (int n = 0; n < NOTE_COUNT; ++n)
{
int oct = GET_OCTAVE(n);
int note = GET_NOTE(n);
if (auto d_index = (inst.GetSampleIndex(oct, note) - 1); d_index > 0) // offset d_index by -1
{
j["dpcm_map"].push_back(json{
{"dpcm_index", d_index},
{"pitch", inst.GetSamplePitch(oct, note) & 0x0Fu},
{"loop", inst.GetSampleLoop(oct, note)},
{"delta", inst.GetSampleDeltaValue(oct, note)},
{"note", n},
});
}
} |
|
apologies if i can't test this code out myself, i'm not sure what to look for in terms of output |
|
Oh it's okay, it's my responsibility to test it out! If you want to test it, you could compare the output with the output from 0CC-famitracker's JSON export for a simple module with just a couple notes. |
|
i hope you don't mind if i relegate this PR for version 0.5.0.2 (next next release) |
|
rebased to main |
|
initial observations:
|
- Fix DPCM map note indexing - Add bookmarks field - Fix effects column key
|
for info not present in the 0CC json export (such as device mixing, OPLL hardware patches, etc.), i think following the text export formatting would help |
- Add module and JSON export version numbers - Fix APU2 device mix offset bug
|
@nstbayless i've added the missing Dn-FT data blocks from v0.5.0.0+, please check if i've missed anything with regards to 0CC's data format |
|
Thank you! That's amazing. It looks complete to me so far. |
- Export external OPLL options when VRC7 is enabled
|
as far as i can tell, this PR looks complete. i will merge it soon. |
This pull request reintroduces JSON export (#197), which is a handy feature in 0CC-Famitracker that makes it easy to read famitracker data from scripts (say, for exporting to a custom engine).
The feature works and is basically identical to 0CC's. However, here are some missing features:
Subindexis no longer a field channels have, and I'm not sure how to get this data. I could use some advice. (Line.)"bookmarks"field. This probably isn't a very important thing for scripts to have though.