From 7b4faf6a850cadebfac031af10efa02d5e142f61 Mon Sep 17 00:00:00 2001 From: "Mr.Blinky" <4971163+MrBlinky@users.noreply.github.com> Date: Sat, 27 Jun 2020 01:14:04 +0200 Subject: [PATCH] ATMlib minor optimisation --- board-package-source/libraries/ATMlib/src/ATMlib.cpp | 12 ++++-------- board-package-source/libraries/ATMlib/src/ATMlib.h | 12 ++++++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/board-package-source/libraries/ATMlib/src/ATMlib.cpp b/board-package-source/libraries/ATMlib/src/ATMlib.cpp index bca38fd..b91a50b 100644 --- a/board-package-source/libraries/ATMlib/src/ATMlib.cpp +++ b/board-package-source/libraries/ATMlib/src/ATMlib.cpp @@ -292,11 +292,8 @@ static inline const byte *getTrackPointer(byte track) { void ATMsynth::play(const byte *song) { - TIMSK4 = 0b00000000;// ensure interrupt is disabled + stop(); cia_count = 1; - // cleanUp stuff first - memset(channel, 0, sizeof(channel)); - ChannelActiveMute = 0b11110000; // Initializes ATMsynth // Sets sample rate and tick rate @@ -324,7 +321,7 @@ void ATMsynth::play(const byte *song) { // Store track pointer trackBase = (song += (trackCount << 1)) + 4; // Fetch starting points for each track - for (unsigned n = 0; n < 4; n++) { + for (byte n = 0; n < 4; n++) { channel[n].ptr = getTrackPointer(pgm_read_byte(song++)); } TIMSK4 = 0b00000100;// enable interrupt as last @@ -603,9 +600,8 @@ void ATM_playroutine() { } else { - memset(channel, 0, sizeof(channel)); - TIMSK4 = 0; // Disable interrupt + ATMsynth::stop(); } } } -} \ No newline at end of file +} diff --git a/board-package-source/libraries/ATMlib/src/ATMlib.h b/board-package-source/libraries/ATMlib/src/ATMlib.h index 26acc74..9339b1e 100644 --- a/board-package-source/libraries/ATMlib/src/ATMlib.h +++ b/board-package-source/libraries/ATMlib/src/ATMlib.h @@ -22,17 +22,17 @@ class ATMsynth { ATMsynth() {}; // Load and play specified song - void play(const byte *song); + static void play(const byte *song); // Play or Pause playback - void playPause(); + static void playPause(); // Stop playback (unloads song) - void stop(); + static void stop(); - void muteChannel(byte ch); + static void muteChannel(byte ch); - void unMuteChannel(byte ch); + static void unMuteChannel(byte ch); }; @@ -52,4 +52,4 @@ uint16_t read_vle(const byte **pp); static inline const byte *getTrackPointer(byte track); extern void ATM_playroutine() asm("ATM_playroutine"); -#endif \ No newline at end of file +#endif