Skip to content

Commit 0d6e340

Browse files
committed
added a wall-clock to UI
1 parent 69bd8f8 commit 0d6e340

File tree

5 files changed

+124
-50
lines changed

5 files changed

+124
-50
lines changed

classes/rc_clock.sc

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
RcClock {
2+
classvar <>instance;
3+
4+
var <>txtClock;
5+
var <>startTime;
6+
7+
*new { |mainWindow|
8+
if ( instance.notNil, { ^instance }, {
9+
instance = super.new.init(mainWindow);
10+
^instance;
11+
})
12+
}
13+
14+
*reset {
15+
instance.reset();
16+
}
17+
18+
*hrsMinsSecs { |startSeconds, endSeconds|
19+
var rVal = [0,0,0];
20+
var diffSecs = endSeconds - startSeconds;
21+
22+
rVal[2] = diffSecs.mod(60).asInteger;
23+
rVal[1] = ((diffSecs - rVal[2]).mod(3600) / 60).asInteger;
24+
rVal[0] = (diffSecs / 3600).asInteger;
25+
26+
^rVal;
27+
}
28+
29+
*clkString { |startSeconds, endSeconds|
30+
var clk = RcClock.hrsMinsSecs(startSeconds, endSeconds);
31+
32+
^format("%:%:%",
33+
clk[0].asString.padLeft(2,"0"),
34+
clk[1].asString.padLeft(2,"0"),
35+
clk[2].asString.padLeft(2,"0"))
36+
}
37+
38+
init { |mainWindow|
39+
txtClock = RcHelpers.buttonBW("00:00:00",mainWindow,
40+
Rect( 253, 10, 100, 25 ), { RcClock.reset });
41+
42+
this.reset();
43+
this.loop_();
44+
}
45+
46+
reset {
47+
startTime = Date.localtime.rawSeconds.asInteger;
48+
}
49+
50+
loop_ {
51+
SystemClock.sched(0.0, {
52+
AppClock.sched(0, {
53+
txtClock.states = [
54+
[ RcClock.clkString(
55+
this.startTime,
56+
Date.localtime.rawSeconds.asInteger
57+
), Color.black, Color.white ]
58+
];
59+
});
60+
1
61+
});
62+
}
63+
64+
}

classes/rc_config.sc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RcConfig {
1919
}
2020

2121
setupGui { |mainWindow|
22-
var view = FlowView(mainWindow, Rect(10,10,270,29));
22+
var view = FlowView(mainWindow, Rect(10,10,235,29));
2323
view.background = Color.grey;
2424

2525
RcHelpers.addStaticText(view, "Scape:", 60@25);
@@ -44,6 +44,7 @@ RcConfig {
4444

4545
loadWithDialog {
4646
Dialog.openPanel( { |path|
47+
RcClock.reset;
4748
s.volume.volume = guiMgr.loadConfigFromFile(path, addSample);
4849
}, path: optsDir);
4950
}

classes/rc_pendulums.sc

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ RcPendulumBase {
4747
\FadeOut, { RcPendulumFadeOut.newEmpty; },
4848
\FadeIn, { RcPendulumFadeIn.newEmpty; },
4949
\FadeInOneTime, { RcPendulumFadeInOneTime.newEmpty; },
50-
\RecordAll, { RcPendulumRecordAll.newEmpty; }
50+
\RecordAll, { RcPendulumRecordAll.newEmpty; },
51+
\Delete, { RcPendulumRemove.newEmpty; }
5152
).initFromYamlData(yamlData);
5253

5354
obj.startDelay = yamlData.atFail("startDelay", { 0 }).asFloat;
@@ -501,10 +502,12 @@ RcPendulumTimer : RcPendulumBase {
501502

502503
SystemClock.sched(startDelay, {
503504
if ( this.stopNow, { nil }, {
504-
{ this.dial.value = this.startValue; }.defer;
505-
506505
stepFactor = if ( startValue > endValue, {-1}, {1} );
507506

507+
// Starting at the endValue because the assumption is made
508+
// that a dial was moved from startValue to endValue so it's
509+
// currently at endValue, so the dial is moved back to the
510+
// startValue, from there back to endValue, and so on.
508511
this.values = Interval.new( endValue, startValue,
509512
0-stepFactor ).asArray ++ Interval.new( startValue,
510513
endValue, stepFactor ).asArray;
@@ -808,7 +811,25 @@ RcPendulumRemove : RcPendulumBase {
808811
}
809812

810813
go {
811-
pendulums[dial].do { |a| a.stop(true) };
812-
pendulums[dial] = [];
814+
pendulums[this.dial].do { |a| a.stop(true) };
815+
pendulums[this.dial] = [];
816+
}
817+
818+
asYaml { |pendId|
819+
^format("pend%:\n" ++
820+
" type: Delete\n" ++
821+
" startDelay: %\n" ++
822+
" argnum: %\n",
823+
pendId,
824+
startDelay.asFloat,
825+
argNum);
826+
}
827+
828+
startFromYamlLoad {
829+
SystemClock.sched( startDelay, {
830+
this.go();
831+
this.stop(true);
832+
});
833+
^this;
813834
}
814835
}

classes/rc_recorder.sc

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,21 @@ RcRecorder {
2929
}
3030

3131
loop_ {
32-
SystemClock.sched(0.0, {
33-
var ldate = Date.localtime;
34-
var mins, secs, hrs;
35-
36-
37-
secs = (ldate.rawSeconds - this.startTime.rawSeconds).mod(60);
38-
mins = (ldate.rawSeconds - this.startTime.rawSeconds) / 60;
39-
hrs = (ldate.rawSeconds - this.startTime.rawSeconds) / 3600;
32+
this.startTime = Date.localtime.rawSeconds.asInteger;
4033

34+
SystemClock.sched(0.0, {
4135
AppClock.sched(0, {
4236
guiButton.states = [
4337
btnStates[0],
44-
[format("Stop %:%:%",
45-
hrs.asInteger.asString.padLeft(2,"0"),
46-
mins.asInteger.asString.padLeft(2,"0"),
47-
secs.asInteger.asString.padLeft(2,"0")),
38+
[format("Stop %",
39+
RcClock.clkString( this.startTime,
40+
Date.localtime.rawSeconds.asInteger)),
4841
Color.white, Color.red]
4942
];
5043
guiButton.value = 1;
5144
});
5245

53-
if ( this.server.isRecording, {
54-
1.0
55-
}, {
46+
if ( this.server.isRecording, { 1.0 }, {
5647
AppClock.sched(0, {
5748
guiButton.states = btnStates;
5849
guiButton.value = 0;
@@ -87,15 +78,15 @@ RcRecorder {
8778

8879
this.currPath = server.recorder.path;
8980
this.sendOsc( ["/recFilename", this.currPath.basename] );
90-
this.configMgr.saveWithoutDialog(this.currPath.basename.replace(".aiff").replace("SC_","RC_"));
81+
this.configMgr.saveWithoutDialog(
82+
this.currPath.basename.replace(".aiff").replace("SC_","RC_")
83+
);
9184
});
9285
this.go;
9386
});
9487
}
9588

9689
go {
97-
this.startTime = Date.localtime;
98-
9990
SystemClock.sched(0.0, {
10091
if ( server.isRecording, {
10192
this.loop_();

gui.scd

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -514,15 +514,6 @@ cfgMgr.addSample = ~addSample;
514514

515515
var meterView = ServerMeterView.new(s, mainWindow, 1250@10, 2, 2);
516516

517-
var openAllSamplesButton = Button(mainWindow, Rect(450, 10, 120, 25));
518-
openAllSamplesButton.states = [
519-
["Open All Samples", Color.black, Color.white]
520-
];
521-
openAllSamplesButton.action = {
522-
gui.pads.collect { |a| a.filename }.reject { |a| a.isNil }.asSet.do { |a|
523-
format( "open -a Audacity \"%\"", a ).unixCmd
524-
};
525-
};
526517

527518
meterView.view.fixedHeight = 500;
528519

@@ -536,8 +527,7 @@ cfgMgr.addSample = ~addSample;
536527

537528
// buttons and samples being played
538529
{
539-
var view, exitButton, loadButton;
540-
var outDevSelector, inDevSelector, sampleRateButton, serverWinButton;
530+
var view, exitButton, outDevSelector, inDevSelector, sampleRateButton;
541531

542532
rcRecorder = RcRecorder.new(s,
543533
Button(mainWindow, Rect(1650, 10, 120, 25)),
@@ -581,17 +571,27 @@ cfgMgr.addSample = ~addSample;
581571
sampleRateButton.action = { "open -a 'Audio MIDI Setup'".unixCmd; };
582572
});
583573

584-
serverWinButton = RcHelpers.buttonBW("Server Window", mainWindow,
585-
Rect(640, 10, 120, 25), {
586-
s.makeWindow;
587-
});
574+
view = FlowView(mainWindow, Rect(360, 10, 420, 30));
575+
576+
RcHelpers.buttonBW("Load Sample", view, 120@25, {
577+
FileDialog({ |paths|
578+
paths.do { |path| ~addSample.value(path); }
579+
}, {}, fileMode: 3, stripResult: false);
580+
});
581+
582+
RcHelpers.buttonBW("Server Window", view, 120@25, {
583+
s.makeWindow;
584+
});
588585

589-
loadButton = RcHelpers.buttonBW("Load Sample", mainWindow,
590-
Rect(290, 10, 120, 25), {
591-
FileDialog({ |paths|
592-
paths.do { |path| ~addSample.value(path); }
593-
}, {}, fileMode: 3, stripResult: false);
586+
Platform.case( \osx, {
587+
RcHelpers.buttonBW("Samples --> Audacity", view, 150@25, {
588+
gui.pads.collect { |a| a.filename }.reject { |a| a.isNil }.asSet.do { |a|
589+
format( "open -a Audacity \"%\"", a ).unixCmd
590+
};
594591
});
592+
});
593+
594+
RcClock.new( mainWindow );
595595

596596
view = FlowView(mainWindow, Rect(777, 40, 450, 67), margin: 3@5);
597597
view.background = Color.grey;
@@ -700,18 +700,15 @@ cfgMgr.addSample = ~addSample;
700700
// midi linking controls
701701
var view = nil;
702702

703-
FlowView( view2, Rect(10,10, 450,30));
703+
FlowView( view2, Rect(10,10, 580,30));
704704
view = FlowView(view2, Rect(10, 200, 300, 30), margin: 3@3);
705-
view.background = Color.grey;
706-
707-
RcHelpers.addStaticText(view,"Link Midi Dials. All/None & Toggle:");
708705

709-
CheckBox.new( view, 15@15, "").action = { |cbx|
706+
CheckBox.new( view, 15@25, "").action = { |cbx|
710707
gui.pads.do { |paddef|
711708
RcHelpers.setValueIfEnabled(paddef.linkMidi,cbx);
712709
};
713710
};
714-
CheckBox.new( view, 15@15, "").action = { |cbx|
711+
CheckBox.new( view, 15@25, "").action = { |cbx|
715712
gui.pads.do { |paddef|
716713
RcHelpers.toggleValueIfEnabled(paddef.linkMidi);
717714
};

0 commit comments

Comments
 (0)