Skip to content

Commit

Permalink
Merge pull request #23 from mebitek/featurs_46
Browse files Browse the repository at this point in the history
Featurs 46
  • Loading branch information
mebitek authored Jan 4, 2024
2 parents 173ce84 + 890d51b commit 0a899ec
Show file tree
Hide file tree
Showing 19 changed files with 294 additions and 51 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Changelog

## v 0.1.46 (4 January 2024)

- UI note edit page reaggment
- song sync with clock
- fix reverse shape feature
- add new shapes
- add new repeat modes
- encoder to change tempo on Performer page

## v0.1.45 (31 December 2023)

#### Improvements

- various bugfixes
- improve solo perform
- launchpad follow mode
- launchpad improve slide visulazation
- launchpad improve slide visualization
- launchpad color theme
- launchpad circuit dtyle note editor

## v0.1.44 (29 December 2023)

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To find out more about improvements changes, check the table below.
| import Metro like seq PR | [link](https://github.com/westlicht/performer/pull/259) | done |
| import trigger negative offset PR | [link](https://github.com/westlicht/performer/pull/234) | done |
| extend probability steps | turning the encoder results in more steps (min is 6.3%) | done |
| add various curves | add curve half and double curves| done |
| add various curves | add curve half and double curves and missing reverse curves| done |
| double click to toggle gates| double click on step to toggle a gate when editing layer other than gate| done |
| cv outs on stop clock| cv outs remain to the last value when clock is stopped | done |
| random seed | each time we enter the random generator page a random seed is picked | done |
Expand All @@ -27,6 +27,10 @@ To find out more about improvements changes, check the table below.
| launchpad color theme | in user settings there is an option to chose between classic and blue launchapd color schema | done |
| launchpad circuit note editor | novation circuit style note editor. on user setting you can choose it or leave the classic one | done |
| step edit ui enhancements | on track and curve step edit pages, turning the encoder cycles through available layers of the selected tab | done |
| Improve Note edit page layout | thanks to @aclangor: use the encoder to switch between layouts. layouts rearrangment | done |
| Sync Song | sync song play with starting clock | done |
| Perform Page | encoder to change tempo on Performer page | done
| Metro like seq | add new repeat modes | done |

[WIKI page ](https://github.com/mebitek/performer/wiki)

Expand Down
2 changes: 1 addition & 1 deletion src/apps/sequencer/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define CONFIG_VERSION_NAME "PER|FORMER SEQUENCER"
#define CONFIG_VERSION_MAJOR 0
#define CONFIG_VERSION_MINOR 1
#define CONFIG_VERSION_REVISION 45
#define CONFIG_VERSION_REVISION 46

// Task priorities
#define CONFIG_DRIVER_TASK_PRIORITY 5
Expand Down
35 changes: 35 additions & 0 deletions src/apps/sequencer/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ void Engine::togglePlay(bool shift) {

void Engine::clockStart() {
_clock.masterStart();

startSong();

}

void Engine::clockStop() {
Expand All @@ -251,12 +254,37 @@ void Engine::clockContinue() {

void Engine::clockReset() {
_clock.masterReset();
stopSong();
}

bool Engine::clockRunning() const {
return _state.running();
}


void Engine::startSong() {
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);
}
}
}

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

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

void Engine::toggleRecording() {
_state.setRecording(!_state.recording());
}
Expand Down Expand Up @@ -780,6 +808,7 @@ void Engine::initClock() {
// start clock on first clock pulse if reset is not hold and clock is not running
if (clockSetup.clockInputMode() == ClockSetup::ClockInputMode::Reset && !_clock.isRunning() && !_dio.resetInput.get()) {
_clock.slaveStart(ClockSourceExternal);
startSong();
}
if (value) {
_clock.slaveTick(ClockSourceExternal);
Expand All @@ -793,23 +822,29 @@ void Engine::initClock() {
case ClockSetup::ClockInputMode::Reset:
if (value) {
_clock.slaveReset(ClockSourceExternal);
stopSong();
} else {
_clock.slaveStart(ClockSourceExternal);
startSong();
}
break;
case ClockSetup::ClockInputMode::Run:
if (value) {
_clock.slaveContinue(ClockSourceExternal);
startSong();
} else {
_clock.slaveStop(ClockSourceExternal);
stopSong();
}
break;
case ClockSetup::ClockInputMode::StartStop:
if (value) {
_clock.slaveStart(ClockSourceExternal);
startSong();
} else {
_clock.slaveStop(ClockSourceExternal);
_clock.slaveReset(ClockSourceExternal);
stopSong();
}
break;
case ClockSetup::ClockInputMode::Last:
Expand Down
4 changes: 4 additions & 0 deletions src/apps/sequencer/engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class Engine : private Clock::Listener {
void clockReset();
bool clockRunning() const;

// song control
void startSong();
void stopSong();

// recording
void toggleRecording();
void setRecording(bool recording);
Expand Down
42 changes: 40 additions & 2 deletions src/apps/sequencer/engine/NoteTrackEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ui/MatrixMap.h"
#include <climits>
#include <iostream>
#include <ctime>

static Random rng;

Expand Down Expand Up @@ -164,9 +165,9 @@ TrackEngine::TickResult NoteTrackEngine::tick(uint32_t tick) {

recordStep(tick, divisor);
const auto &step = sequence.step(_sequenceState.step());
bool isLastStageStep = ((int) step.stageRepeats() - (int) _currentStageRepeat) <= 0;
bool isLastStageStep = ((int) (step.stageRepeats()+1) - (int) _currentStageRepeat) <= 0;

triggerStep(tick, divisor);
triggerStep(tick+divisor, divisor);

if (isLastStageStep) {
_currentStageRepeat = 1;
Expand Down Expand Up @@ -357,11 +358,48 @@ void NoteTrackEngine::triggerStep(uint32_t tick, uint32_t divisor, bool forNextS
case NoteSequence::StageRepeatMode::First:
stepGate = stepGate && _currentStageRepeat == 1;
break;
case NoteSequence::StageRepeatMode::Last:
stepGate = stepGate && _currentStageRepeat == step.stageRepeats()+1;
break;
case NoteSequence::StageRepeatMode::Middle:
stepGate = stepGate && _currentStageRepeat == (step.stageRepeats()+1)/2;
break;
case NoteSequence::StageRepeatMode::Odd:
stepGate = stepGate && _currentStageRepeat % 2 != 0;
break;
case NoteSequence::StageRepeatMode::Even:
stepGate = stepGate && _currentStageRepeat % 2 == 0;
break;
case NoteSequence::StageRepeatMode::Triplets:
stepGate = stepGate && (_currentStageRepeat - 1) % 3 == 0;
break;
case NoteSequence::StageRepeatMode::Random:
srand((unsigned int)time(NULL));
int rndMode = 0 + ( std::rand() % ( 6 - 0 + 1 ) );
switch (rndMode) {
case 0:
break;
case 1:
stepGate = stepGate && _currentStageRepeat == 1;
break;
case 2:
stepGate = stepGate && _currentStageRepeat == step.stageRepeats()+1;
break;
case 3:
stepGate = stepGate && _currentStageRepeat % ((step.stageRepeats()+1)/2)+1 == 0;
break;
case 4:
stepGate = stepGate && _currentStageRepeat % 2 != 0;
break;
case 5:
stepGate = stepGate && _currentStageRepeat % 2 == 0;
break;
case 6:
stepGate = stepGate && (_currentStageRepeat - 1) % 3 == 0;
break;

}
break;
}

if (stepGate) {
Expand Down
3 changes: 2 additions & 1 deletion src/apps/sequencer/engine/generators/RandomGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "RandomGenerator.h"

#include "core/utils/Random.h"
#include <ctime>


RandomGenerator::RandomGenerator(SequenceBuilder &builder, Params &params) :
Expand Down Expand Up @@ -48,7 +49,7 @@ void RandomGenerator::init() {
}

void RandomGenerator::randomizeSeed() {

srand((unsigned int)time(NULL));
_params.seed = 0 + ( std::rand() % ( 999 - 0 + 1 ) );
}

Expand Down
25 changes: 25 additions & 0 deletions src/apps/sequencer/model/Curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,18 @@ static float triangle(float x) {
return (x < 0.5f ? x : 1.f - x) * 2.f;
}

static float revTriangle(float x) {
return 1.f+(-triangle(x));
}

static float bell(float x) {
return 0.5f - 0.5f * std::cos(x * TwoPi);
}

static float revBell(float x) {
return 1.f+-bell(x);
}

static float stepUp(float x) {
return x < 0.5f ? 0.f : 1.f;
}
Expand All @@ -107,6 +115,18 @@ static float expDown4x(float x) {
return x < 1.f ? expDown(std::fmod(x * 4.f, 1.f)) : 0.f;
}

static float expUp2x(float x) {
return x < 1.f ? expUp(std::fmod(x * 2.f, 1.f)) : 0.f;
}

static float expUp3x(float x) {
return x < 1.f ? expUp(std::fmod(x * 3.f, 1.f)) : 0.f;
}

static float expUp4x(float x) {
return x < 1.f ? expUp(std::fmod(x * 4.f, 1.f)) : 0.f;
}

static float doubleRampUpHalf(float x) {
return x < 0.5f ? rampUp(std::fmod(x * 2.f, 1.f)) : rampUp(std::fmod(x * 2.f, 1.f));
}
Expand Down Expand Up @@ -169,10 +189,15 @@ static Curve::Function functions[] = {
&doubleSmoothUpHalf,
&doubleSmoothDownHalf,
&triangle,
&revTriangle,
&bell,
&revBell,
&expDown2x,
&expUp2x,
&expDown3x,
&expUp3x,
&expDown4x,
&expUp4x
};

Curve::Function Curve::function(Type type) {
Expand Down
14 changes: 14 additions & 0 deletions src/apps/sequencer/model/Curve.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <map>
class Curve {
public:
typedef float (*Function)(float x);
Expand Down Expand Up @@ -32,16 +33,29 @@ class Curve {
doubleSmoothUpHalf,
doubleSmoothDownHalf,
Triangle,
RevTriangle,
Bell,
RevBell,
StepUp,
StepDown,
ExpDown2x,
ExpUp2x,
ExpDown3x,
ExpUp3x,
ExpDown4x,
ExpUp4x,
Last,
};



static Function function(Type type);

static float eval(Type type, float x);




};


2 changes: 1 addition & 1 deletion src/apps/sequencer/model/NoteSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void NoteSequence::Step::clear() {
setNoteVariationRange(0);
setNoteVariationProbability(NoteVariationProbability::Max);
setCondition(Types::Condition::Off);
setStageRepeats(1);
setStageRepeats(0);
setStageRepeatsMode(StageRepeatMode::Each);
}

Expand Down
Loading

0 comments on commit 0a899ec

Please sign in to comment.