forked from einfachfelixverdammt/Maschine-Jam-for-Bitwig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StepMode.js
129 lines (104 loc) · 3.73 KB
/
StepMode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* @classdesc Step Sequencer Mode
* @class
* @augments JamMode
*
* @param {NoteView} noteView
* @param {DrumPadView} drumPadView
* @param {TrackViewContainer} trackView reference to Clip Mode object
* @param {TrackHandler} trackHandler
* @param {Clip} clip the cursor Clip
*
*/
function StepMode(noteView, drumPadView, trackView, trackHandler, clip, cursorDevice, sceneView) {
var stepView = new StepView(clip, noteView);
var stepLenView = new StepPositionView();
var drumBank = null;
var hasDrumPads = false;
JamMode.call(this, drumPadView, trackView, stepLenView);
var handleEvent = this.handleEvent;
drumPadView.setStepLenView(stepLenView);
stepView.setStepLenView(stepLenView);
stepLenView.setOffsetListener(this);
/**
* @param {function} callback callback that exits the Step Mode
*/
this.setExitHandler = function (callback) {
stepView.setExitHandler(callback);
drumPadView.setExitHandler(callback);
};
this.handleEvent = function (sender, row, col, value, notenr) {
handleEvent.call(this,sender, row, col, value, notenr);
var note = 0;
if (this.isInDrumMode()) {
note = ((7 - row) * 4) + 36 + (col - 4);
cursorDevice.selectParent();
cursorDevice.selectFirstInKeyPad(note);
cursorDevice.selectInEditor();
}
};
this.receiveNote = function (on, note, velocity) {
this.mainView.receiveNote(on, note, velocity);
};
this.notifyModifier = function (modifierState) {
this.mainView.notifyModifier(modifierState);
};
this.setOffset = function (selPos, mOffset) {
this.mainView.setOffset(selPos, mOffset);
};
this.notifyShift = function (shift) {
stepLenView.notifyShift(shift);
};
this.setToDrumMode = function () {
stepLenView.setSteps(stepView.gridMap().nrOfSteps() * 4);
drumPadView.setStepMode(true);
if (this.mainView !== drumPadView) {
this.mainView.exit();
this.mainView = drumPadView;
}
};
this.setToPianoMode = function () {
stepLenView.setSteps(stepView.gridMap().nrOfSteps());
if (this.mainView !== stepView) {
this.mainView.exit();
this.mainView = stepView;
}
};
this.isInDrumMode = function () {
return this.mainView === drumPadView;
};
this.isInPianoMode = function () {
return this.mainView === stepView;
};
this.setHasDrumPads = function (hasDrumPads) {
this.hasDrumPads = hasDrumPads;
};
this.navigate = function (direction) {
if (modifiers.isSelectDown() && (direction === DirectionPad.TOP || direction === DirectionPad.DOWN)) {
trackHandler.selectSlotInDirection(direction === DirectionPad.TOP ? -1 : 1);
} else {
this.mainView.navigate(direction);
}
};
this.notifyClear = function (clearDown) {
if (clearDown)
clip.clearSteps();
};
this.modifyGrid = function (incValue, pressedModifier) {
this.mainView.modifyGrid(incValue, pressedModifier);
};
this.pushAction = function (value) {
this.mainView.pushAction(value);
};
this.update = function () {
this.mainView.update();
stepLenView.update();
};
this.postEnter = function () {
modifiers.setLockButtonState(stepView.inMonoMode());
modifiers.setLockButtonHandler(stepView.handleLockButton);
};
this.setDrumPadBank = function (drumPadBank) {
this.drumBank = drumPadBank;
};
}