magspoof icon indicating copy to clipboard operation
magspoof copied to clipboard

Plays Track1+2, then ONLY Track 2 every other "press"

Open cheeseandcereal opened this issue 7 years ago • 3 comments

With the current implementation of the code, the first time you press the button, it will call playTrack(1), then next time you press the button, it will call playTrack(2) (because of how it keeps track and increments curTrack)

This doesn't make a lot of sense, because when calling playTrack(1), it will actually play BOTH tracks because of this if statement within the method:

  if (track == 0)
  {
    // if track 1, also play track 2 in reverse
    // zeros in between
    for (int i = 0; i < BETWEEN_ZERO; i++)
      playBit(0);

    // send second track in reverse
    reverseTrack(2);
  }

Then after playing both tracks, next time you press the button it will call playTrack(2) which will ONLY play the 2nd track because that if statement isn't satisfied.

Essentially this means that every other time you press the button, the magspoof will ONLY play track 2. All other times it will play both tracks.

This doesn't make a lot of sense, and it should probably be changed by either:

  1. Getting rid of curTrack entirely, and simply replace the line playTrack(1 + (curTrack++ % 2)); with playTrack(1)

OR

  1. Remove the reverse track implementation entirely, then simply call playTrack(1) and playTrack(2) sequentially.

cheeseandcereal avatar Apr 30 '17 00:04 cheeseandcereal