Centralize FixMath dependency for better portability and stricter build systems #321
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This set of changes addresses build issues encountered when using Mozzi with Arduino CLI and strictly structured 3rd party cores (specifically for the CH32 architecture).
The Problem:
In the original codebase, files like 'Oscil.h' and 'Line.h' included both 'mozzi_fixmath.h' (Mozzi's math abstraction) and 'FixMath.h' (the external library) explicitly. On some platforms/build systems, if the include paths are not resolved in a specific order, or if a user includes a Mozzi header that relies on FixMath types without including FixMath.h themselves, compilation fails with "unknown type" errors.
The Solution:
Moved the
#include <FixMath.h>directive insidemozzi_fixmath.h.Consequently, removed the explicit
#include <FixMath.h>from:Why this is safe and better:
mozzi_fixmath.hacts as the interface for fixed-point math in Mozzi. It effectively "owns" the relationship with the underlyingFixMathlibrary. Consuming files shouldn't need to manually import the backend library.mozzi_fixmath.his now guaranteed to have the necessaryFixMathtypes defined, preventing subtle ordering bugs.FixMath.huses standard include guards, this change does not negatively impact existing platforms (AVR, ESP, STM32, etc.), but it fixes the build path issues on newer/stricter platforms.