Skip to content

Commit

Permalink
Loudness dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
oshibka404 committed Jul 13, 2020
1 parent b4f10a6 commit 4a8d704
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/arpeggiator/player_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PlayerAction {
PlayerAction withModulation(double newModulation) => _isStop
? this
: PlayerAction(
modulation: newModulation,
modulation: newModulation ?? this.modulation,
velocity: velocity,
stepOffset: stepOffset,
);
Expand All @@ -45,13 +45,13 @@ class PlayerAction {
: PlayerAction(
modulation: modulation,
velocity: velocity,
stepOffset: stepOffset != null ? newOffset + stepOffset : null,
stepOffset: newOffset != null ? newOffset + stepOffset : stepOffset,
);

PlayerAction withVelocity(double newVelocity) => _isStop
? this
: PlayerAction(
velocity: newVelocity,
velocity: newVelocity ?? this.velocity,
modulation: modulation,
stepOffset: stepOffset,
);
Expand Down
6 changes: 1 addition & 5 deletions lib/controller/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,11 @@ class _ControllerState extends State<Controller> {
setState(() {
_loopViews[id] = _loopViews[id].assign(isPlaying: false);
});
print("Stopped $id");
} else {
looper.start(loop);
setState(() {
_loopViews[id] = _loopViews[id].assign(isPlaying: true);
});
print("Play $id!");
}
}

Expand Down Expand Up @@ -249,9 +247,7 @@ class _ControllerState extends State<Controller> {
}
if (sample.pressure > 0) {
_arpeggiators[sample.pointerId].play(sample.modulation,
baseStep: sample.stepOffset,
modulation: sample.modulation,
velocity: sample.pressure);
baseStep: sample.stepOffset, modulation: sample.pressure);
} else {
_arpeggiators[sample.pointerId].stop();
_arpeggiators.remove(sample.pointerId);
Expand Down
10 changes: 2 additions & 8 deletions lib/looper/loop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,12 @@ class Loop {
_isPlaying = true;
var iterator = _actions.iterator;
var playbackStartTime = DateTime.now();
print("Play $startTime! 0");
while (iterator.moveNext() && _isPlaying) {
var action = iterator.current;
if (action.pressure > 0) {
if (_pressedPointers.add(action.pointerId)) {
print("+1 $startTime = ${_pressedPointers.length}");
}
_pressedPointers.add(action.pointerId);
} else {
if (_pressedPointers.remove(action.pointerId)) {
print("-1 $startTime = ${_pressedPointers.length}");
}
_pressedPointers.remove(action.pointerId);
}
var timeFromPlaybackStart =
DateTime.now().difference(playbackStartTime);
Expand All @@ -85,7 +80,6 @@ class Loop {
for (var i = 0; i < _pressedPointers.length; i++) {
yield Sample.from(KeyboardAction.release(pointersToRelease[i]));
}
print("delete remaining ${pointersToRelease.length} from $startTime");
_pressedPointers.clear();
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: perfect_first_synth
description: A project with ambitions of becoming the perfect first synthesizer

publish_to: 'none'
version: 1.0
version: 1.1.0

repository: https://github.com/oshibka404/perfect-first-synth
issue_tracker: https://github.com/oshibka404/perfect-first-synth/issues
Expand Down

0 comments on commit 4a8d704

Please sign in to comment.