Updated ArduboyPlaytune to 1.0.4

This commit is contained in:
Mr.Blinky 2018-09-18 19:54:09 +02:00 committed by GitHub
parent bec41ebf90
commit 8bf0c707d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View File

@ -1,6 +1,6 @@
The MIT License (MIT) 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 Based on work (C) Copyright 2011, 2015, Len Shustek
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@ -7,7 +7,7 @@
"type": "git", "type": "git",
"url": "https://github.com/Arduboy/ArduboyPlaytune.git" "url": "https://github.com/Arduboy/ArduboyPlaytune.git"
}, },
"version": "1.0.3", "version": "1.0.4",
"exclude": "extras", "exclude": "extras",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": "atmelavr" "platforms": "atmelavr"

View File

@ -1,5 +1,5 @@
name=ArduboyPlaytune name=ArduboyPlaytune
version=1.0.3 version=1.0.4
author=Len Shustek, Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen author=Len Shustek, Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen
maintainer=Scott Allen <saydisp-git@yahoo.ca> maintainer=Scott Allen <saydisp-git@yahoo.ca>
sentence=A library for playing musical scores and tones that is compatible with the Arduboy game system. sentence=A library for playing musical scores and tones that is compatible with the Arduboy game system.

View File

@ -43,6 +43,21 @@
* written by Brett Hagman, http://www.roguerobotics.com/ * 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 "ArduboyPlaytune.h"
#include <avr/power.h> #include <avr/power.h>
@ -187,12 +202,14 @@ void ArduboyPlaytune::playNote(byte chan, byte note)
if (!tone_playing) { if (!tone_playing) {
TCCR1B = (TCCR1B & 0b11111000) | prescalar_bits; TCCR1B = (TCCR1B & 0b11111000) | prescalar_bits;
OCR1A = ocr; OCR1A = ocr;
TCNT1 = 0; //LJS
bitWrite(TIMSK1, OCIE1A, 1); bitWrite(TIMSK1, OCIE1A, 1);
} }
break; break;
case 3: case 3:
TCCR3B = (TCCR3B & 0b11111000) | prescalar_bits; TCCR3B = (TCCR3B & 0b11111000) | prescalar_bits;
OCR3A = ocr; OCR3A = ocr;
TCNT3 = 0; //LJS
wait_timer_frequency2 = frequency2; // for "tune_delay" function wait_timer_frequency2 = frequency2; // for "tune_delay" function
wait_timer_playing = true; wait_timer_playing = true;
bitWrite(TIMSK3, OCIE3A, 1); bitWrite(TIMSK3, OCIE3A, 1);