Skip to content

Commit

Permalink
issue #6 (westlicht#373) Song Mode sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mebitek committed Jan 3, 2024
1 parent d1dd21f commit db89588
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/apps/sequencer/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,16 @@ void Engine::togglePlay(bool shift) {
void Engine::clockStart() {
_clock.masterStart();

int slotCount = _project.song().slotCount();

if (slotCount>0 && !_project.playState().songState().playing()) {
int _selectedSlot = slotCount > 0 ? clamp(1, 0, slotCount - 1) : -1;
_project.playState().playSong(_selectedSlot, PlayState::ExecuteType::Immediate);
int syncSong = _model.settings().userSettings().get<SyncSong>(SettingSyncSong)->getValue();

if (syncSong==1) {
int slotCount = _project.song().slotCount();

if (slotCount>0 && !_project.playState().songState().playing()) {
int _selectedSlot = slotCount > 0 ? clamp(1, 0, slotCount - 1) : -1;
_project.playState().playSong(_selectedSlot, PlayState::ExecuteType::Immediate);
}
}

}
Expand All @@ -259,10 +264,13 @@ void Engine::clockContinue() {

void Engine::clockReset() {
_clock.masterReset();
int syncSong = _model.settings().userSettings().get<SyncSong>(SettingSyncSong)->getValue();

if (_project.playState().songState().playing()) {
_project.playState().stopSong();
}
if (syncSong==1) {
if (_project.playState().songState().playing()) {
_project.playState().stopSong();
}
}
}

bool Engine::clockRunning() const {
Expand Down
13 changes: 13 additions & 0 deletions src/apps/sequencer/model/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define SettingLaunchpadStyle "lpstyle"
#define SettingPatternChange "patternchg"
#define SettingLaunchpadNoteStyle "lpnote"
#define SettingSyncSong "syncsong"

class BaseSetting {
public:
Expand Down Expand Up @@ -179,6 +180,17 @@ class LaunchpadNoteStyle : public Setting<int> {
) {}
};

class SyncSong : public Setting<int> {
public:
SyncSong() : Setting(
SettingSyncSong,
"Sync song",
{"yes", "no"},
{1, 0},
0
) {}
};

class UserSettings {
public:
UserSettings() {
Expand All @@ -189,6 +201,7 @@ class UserSettings {
addSetting(new LaunchpadStyleSetting());
addSetting(new PatternChange());
addSetting(new LaunchpadNoteStyle());
addSetting(new SyncSong());
}

//----------------------------------------
Expand Down

0 comments on commit db89588

Please sign in to comment.