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

Attempt to fix #646 #649

Merged
merged 3 commits into from
May 30, 2024
Merged

Attempt to fix #646 #649

merged 3 commits into from
May 30, 2024

Conversation

probonopd
Copy link
Owner

Copy link

github-actions bot commented Apr 25, 2024

Download the artifacts for this pull request:

@probonopd
Copy link
Owner Author

Thanks @diyelectromusic. It looks like my PR fixes one instance of this issue (at least the build log doesn't show one of the errors anymore); the other would need to be fixed by a similar change in Synth_Dexed.
Please do review my change and, if you have a chance, test the build. Thanks!

@diyelectromusic
Copy link
Collaborator

I think the issue is that the fixed length 10 might be correct - it is setting the voice string within the fixed DX voice structure I think...

... but I'll need to have a proper look as it is also tied up with the mess that is get/setName in Dexed (more here: #501)

Kevin

@diyelectromusic
Copy link
Collaborator

Ok, yes, looking again, we do need the fixed 10 in the strncpy as that is the size of the voice name in the voice structure for the DX7.

So I think the fix will be the following:

void CMiniDexed::SetVoiceName (std::string VoiceName, unsigned nTG)
{
	assert (nTG < CConfig::ToneGenerators);
	assert (m_pTG[nTG]);
	char Name[11];
	strncpy(Name, VoiceName.c_str(),10);
	Name[10] = '\0';
	m_pTG[nTG]->getName (Name);
}

A similar thing is probably required in Synth_Dexed/dexed.cpp but as I say that is mixed up with the problems described in #501 so that would be a breaking change in the API to fix... but it really ought to be fixed!?

It does address my comment in #501 about SetVoiceName only have a buffer of 10 though - that is wrong and does need to be 11 as shown above.

Kevin

@probonopd
Copy link
Owner Author

Why not use VoiceName.size() as suggested in my PR? That way, we don't need to hardcode any sizes. I try to never hardcode sizes, as it is a frequent source of bugs.

@diyelectromusic
Copy link
Collaborator

Why not use VoiceName.size() as suggested in my PR? That way, we don't need to hardcode any sizes. I try to never hardcode sizes, as it is a frequent source of bugs.

Because this function is about truncating whatever voice name is passed in (which could be any size) to the explicit 10 characters defined in the DX7 SysEx voice structure, so as I say, the 10 is actually correct in this case, just not really accounted for properly in how its used.

We could make the argument that GetName should do all that - and yes, I agree it ought to - but GetName/SetName is a mess as per #501 and can't be fixed without breaking the API so I doubt that will happen.

So best just to do the robust thing here. In an ideal world I agree we wouldn't have hardcoded sizes like this, but the DX7 voice structure has been fixed for over 40 years, so I don't think we need to worry about that in this case :)

Kevin

@probonopd
Copy link
Owner Author

the DX7 voice structure has been fixed for over 40 years, so I don't think we need to worry about that in this case :)

Good point 👍

@probonopd probonopd merged commit afa72d2 into main May 30, 2024
1 check passed
@probonopd probonopd deleted the probonopd-fix-646 branch May 30, 2024 16:43
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