Skip to content

Commit

Permalink
Resolved overflow when loading more than 8 soundfonts
Browse files Browse the repository at this point in the history
  • Loading branch information
rhansenne committed Apr 14, 2024
1 parent d275ead commit a6f0ed6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ extern cRGB color;
extern cRGB currentColor;
#endif
extern void HumRelaunch();
extern void SinglePlay_Sound(uint8_t track);
extern void LoopPlay_Sound(uint8_t track);
extern void SinglePlay_Sound(uint16_t track);
extern void LoopPlay_Sound(uint16_t track);
extern void Pause_Sound();
extern void Resume_Sound();
extern void Set_Loop_Playback();
Expand Down
4 changes: 2 additions & 2 deletions ConfigMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ extern cRGB currentColor;
extern cRGB color;
#endif
extern void HumRelaunch();
extern void SinglePlay_Sound(uint8_t track);
extern void LoopPlay_Sound(uint8_t track);
extern void SinglePlay_Sound(uint16_t track);
extern void LoopPlay_Sound(uint16_t track);
extern void Pause_Sound();
extern void Resume_Sound();
extern void Set_Loop_Playback();
Expand Down
4 changes: 2 additions & 2 deletions FX-SaberOS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1393,14 +1393,14 @@ void HumRelaunch() {
hum_playing = true;
}

void SinglePlay_Sound(uint8_t track) {
void SinglePlay_Sound(uint16_t track) {
dfplayer.playPhysicalTrack(track);
#ifdef DFPLAYER_CLONE
dfplayer.setSingleLoop(false); // fixes incorrect looping of certain sounds on clone chips
#endif
}

void LoopPlay_Sound(uint8_t track) {
void LoopPlay_Sound(uint16_t track) {
dfplayer.playSingleLoop(track);
}

Expand Down
23 changes: 12 additions & 11 deletions Soundfont.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SoundFont {
}
;
void setID(uint16_t id) {
/*
uint16_t boot[2];
uint16_t powerOn[2];
uint16_t powerOff[2];
Expand All @@ -63,7 +64,7 @@ void setID(uint16_t id) {
uint16_t lockup[2];
uint16_t blaster[2];
uint16_t menu[2];

*/
this->ID = id;

switch (id) {
Expand Down Expand Up @@ -93,7 +94,7 @@ void setID(uint16_t id) {
// soundFont directory 05 :
this->powerOnTime = 700;
this->powerOffTime = 1500;
break;
break;
#else if DIYINO_STARDUST_V2
default:
case 0:
Expand Down Expand Up @@ -164,39 +165,39 @@ void setID(uint16_t id) {

}

const uint8_t getBlaster(uint8_t offset = 0) {
const uint16_t getBlaster(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_BLASTER_OFFSET + random(0,SF_BLASTER_NR);
}

const uint8_t getBoot(uint8_t offset = 0) {
const uint16_t getBoot(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_BOOT_OFFSET;
}

const uint8_t getClash(uint8_t offset = 0) {
const uint16_t getClash(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_CLASH_OFFSET + random(0,SF_CLASH_NR);
}

const uint8_t getHum(uint8_t offset = 0) {
const uint16_t getHum(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_HUM_OFFSET + random(0,SF_HUM_NR);
}

const uint8_t getLockup(uint8_t offset = 0) {
const uint16_t getLockup(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_LOCKUP_OFFSET + random(0,SF_LOCKUP_NR);
}

const uint8_t getPowerOff(uint8_t offset = 0) {
const uint16_t getPowerOff(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_POWEROFF_OFFSET + random(0,SF_POWEROFF_NR);
}

const uint8_t getPowerOn(uint8_t offset = 0) {
const uint16_t getPowerOn(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_POWERON_OFFSET + random(0,SF_POWERON_NR);
}

const uint8_t getSwing(uint8_t offset = 0) {
const uint16_t getSwing(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_SWING_OFFSET + random(0,SF_SWING_NR);
}

const uint8_t getMenu(uint8_t offset = 0) {
const uint16_t getMenu(uint16_t offset = 0) {
return NR_CONFIGFOLDERFILES + NR_JUKEBOXSONGS + offset + SF_MENU_OFFSET;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/DFPlayer/DFPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class DFPlayer {
send();
}

inline void playSingleLoop(uint8_t track, uint8_t folder = 0) {
inline void playSingleLoop(uint16_t track, uint8_t folder = 0) {
setSendBuffer(PLAY_REPEAT, track, folder);
send();
}
Expand Down

0 comments on commit a6f0ed6

Please sign in to comment.