Skip to content

Conversation

@tobybear
Copy link
Contributor

@tobybear tobybear commented Feb 8, 2025

Also y12 struct had max_opm_voices = 1 and max_opn_voices = 0, it should probably be the other way round as y12 is an instrument format for YM2612/OPN2, right?

y12_file.c Outdated
if(bank->num_opn_voices <= pos->opn) return -1;
struct y12_file f;

strcpy(f.name, bank->opn_voices[pos->opn].name);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure strcpy is unsafe, I think you need to use strncpy or snprintf

tfi_file.c Outdated
f.alg = bank->opn_voices[pos->opn].fb_con & 0x07;
for(int i = 0; i < 4; i++) {
f.operators[i].dt = bank->opn_voices[pos->opn].operators[i].dt_mul >> 3;
f.operators[i].mul = bank->opn_voices[pos->opn].operators[i].dt_mul & 0x07;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the opn_voice_get_* functions everywhere (the opn_voice struct might change but these methods will still work the same way)

.max_opm_voices = 1,
.max_opn_voices = 0,
.max_opm_voices = 0,
.max_opn_voices = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

y12_file.c Outdated
f.fb = bank->opn_voices[pos->opn].fb_con >> 3;
f.alg = bank->opn_voices[pos->opn].fb_con & 0x07;
for(int i = 0; i < 4; i++) {
f.operators[i].mul_dt = bank->opn_voices[pos->opn].operators[i].dt_mul;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, please use the get_* methods

@tobybear
Copy link
Contributor Author

tobybear commented Feb 9, 2025

Ok, makes sense.
I added the get* functions where available (I think).
y12 format does not use 0 terminated strings, so I opted for zeroing the buffer and copying the first 15 bytes only, but I am open to any better method.

@tobybear
Copy link
Contributor Author

tobybear commented Feb 9, 2025

Wouldn't it make sense to have matching setter functions for loading as well?

tfi_file.c Outdated
buf[bc++] = f->fb;
for(int i = 0; i < 4; i++) {
buf[bc++] = f->operators[i].mul;
buf[bc++] = f->operators[i].dt;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one last thing, create a uint8_t * pointer and increment that instead of incrementing the index, *(b++) = ...

@tobybear
Copy link
Contributor Author

Done

y12_file.c Outdated
for(int i = 0; i < 4; i++) {
buf[bc++] = f->operators[i].mul_dt;
buf[bc++] = f->operators[i].tl;
buf[bc++] = f->operators[i].ar_rs;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same in this function

@vampirefrog vampirefrog merged commit da01958 into vampirefrog:master Feb 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants