ofxMidi
ofxMidi copied to clipboard
explicit conversion : Just to get rid of warnings
not sure if its the best way
What is the warning?
Implicit conversion loses integer precision: 'unsigned long' to 'unsigned int'
it can be supressed by #pragma GCC diagnostic ignored "-Wshorten-64-to-32"
In general, suppression is a bad idea, better to fix the issue.
The issue is that the ticks member variable is an unsigned long
while the functions work with unsigned int
. I probably used the larger type to ensure there would be plenty of space for very long songs. However when I wrote the rest of the API, I changed to unsigned ints which now clips this upper limit.
Two approaches:
- Change ticks to
unsigned int
. This will lower the max number of ticks which can be stored internally but wouldn't introduce warnings to existing projects. - Change the beat functions to use
unsigned long
. This would fix the clipping of the max number of beats, but could introduce warnings in people's projects.
UPDATE: Since no one has brought up the issue of not having enough ticks, I'd say 1 would work for now. We can implement 2 if/when that becomes an issue.