diff --git a/board-package-source/libraries/ArduboyPlaytune/LICENSE.txt b/board-package-source/libraries/ArduboyPlaytune/LICENSE.txt index ac2a60e..4811408 100644 --- a/board-package-source/libraries/ArduboyPlaytune/LICENSE.txt +++ b/board-package-source/libraries/ArduboyPlaytune/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -(C) Copyright 2016-2017, Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen +(C) Copyright 2016-2018, Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen Based on work (C) Copyright 2011, 2015, Len Shustek Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/board-package-source/libraries/ArduboyPlaytune/library.json b/board-package-source/libraries/ArduboyPlaytune/library.json index 317b7ea..c7ecba6 100644 --- a/board-package-source/libraries/ArduboyPlaytune/library.json +++ b/board-package-source/libraries/ArduboyPlaytune/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/Arduboy/ArduboyPlaytune.git" }, - "version": "1.0.3", + "version": "1.0.4", "exclude": "extras", "frameworks": "arduino", "platforms": "atmelavr" diff --git a/board-package-source/libraries/ArduboyPlaytune/library.properties b/board-package-source/libraries/ArduboyPlaytune/library.properties index 27e86fa..f9eb7af 100644 --- a/board-package-source/libraries/ArduboyPlaytune/library.properties +++ b/board-package-source/libraries/ArduboyPlaytune/library.properties @@ -1,5 +1,5 @@ name=ArduboyPlaytune -version=1.0.3 +version=1.0.4 author=Len Shustek, Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen maintainer=Scott Allen sentence=A library for playing musical scores and tones that is compatible with the Arduboy game system. diff --git a/board-package-source/libraries/ArduboyPlaytune/src/ArduboyPlaytune.cpp b/board-package-source/libraries/ArduboyPlaytune/src/ArduboyPlaytune.cpp index 107ed9e..dda1bca 100644 --- a/board-package-source/libraries/ArduboyPlaytune/src/ArduboyPlaytune.cpp +++ b/board-package-source/libraries/ArduboyPlaytune/src/ArduboyPlaytune.cpp @@ -43,6 +43,21 @@ * written by Brett Hagman, http://www.roguerobotics.com/ * *****************************************************************************/ +/* 27 March 2018, L. Shustek +This was adapted from my Playtune library, but it was missing this fix that +prevents a "stuttering" playback because of timing errors: + 15 August 2016, L. Shustek, + - Fixed a timing error: T Wasiluk's change to using a 16-bit timer instead + of an 8-bit timer for score waits exposed a old bug that was in the original + Brett Hagman code: when writing the timer OCR value, we need to clear the + timer counter, or else (the manual says) "the counter [might] miss the compare + match...and will have to count to its maximum value (0xFFFF) and wrap around + starting at 0 before the compare match can occur". This caused an error that + was small and not noticeable for the 8-bit timer, but could be hundreds of + milliseconds for the 16-bit counter. Thanks go to Joey Babcock for pushing me + to figure out why his music sounded weird, and for discovering that it worked + ok with the 2013 version that used the 8-bit timer for score waits. +*/ #include "ArduboyPlaytune.h" #include @@ -187,12 +202,14 @@ void ArduboyPlaytune::playNote(byte chan, byte note) if (!tone_playing) { TCCR1B = (TCCR1B & 0b11111000) | prescalar_bits; OCR1A = ocr; + TCNT1 = 0; //LJS bitWrite(TIMSK1, OCIE1A, 1); } break; case 3: TCCR3B = (TCCR3B & 0b11111000) | prescalar_bits; OCR3A = ocr; + TCNT3 = 0; //LJS wait_timer_frequency2 = frequency2; // for "tune_delay" function wait_timer_playing = true; bitWrite(TIMSK3, OCIE3A, 1);