Skip to content

byte doesn't allow for negative#9

Open
douweh wants to merge 1 commit into
adafruit:masterfrom
douweh:master
Open

byte doesn't allow for negative#9
douweh wants to merge 1 commit into
adafruit:masterfrom
douweh:master

Conversation

@douweh
Copy link
Copy Markdown

@douweh douweh commented Sep 16, 2020

The definition of addNote has a (byte typed) step param (with a default value of -1); therefore the following code (lines 369-372):

if(step == -1)
    position = _quantizedPosition();
  else
    position = step;

should result in position being equal to _quantizedPosition() when you omit the step from the addNote call.

However a byte doesn't allow for a negative value (and -1 gets silently casted to 255: see https://www.arduino.cc/reference/en/language/variables/data-types/byte/). Therefore when omitting the step (or setting it to -1) the actual value will be 255 and consequently the position will also result in 255... and not what we expect.

Typing the step param as byte solves this.

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.

1 participant