Skip to content

Commit

Permalink
add: end beat, loop, bpm
Browse files Browse the repository at this point in the history
  • Loading branch information
crucialfelix committed Dec 3, 2011
1 parent 7c2ad9a commit cfc00b5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
35 changes: 20 additions & 15 deletions Mx.sc
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ Mx : AbstractPlayerProxy {
var <myUnit, <inlets, <outlets;

var <>autoCable=true;

var <>endBeat,<>loop=false,<>bpm;

var allocator=0, register, unitGroups, busses;
var <master;
var removing, adding, cableEndpoints;
var <>frameRate=24, sched, ticker, <position, frameRateDevices, preFrameRateDevices;

*new { arg data;
^super.new.init(data)
*new { arg data,endBeat,loop=false,bpm;
^super.new.endBeat_(endBeat).loop_(loop).bpm_(bpm).init(data)
}
storeArgs {
^[MxLoader.saveData(this,register)];
^[MxLoader.saveData(this,register),endBeat,loop,bpm];
}
init { arg data;
var loader;
Expand All @@ -33,6 +34,7 @@ Mx : AbstractPlayerProxy {
channels = [];
inlets = [];
this.addOutput;
bpm = Tempo.bpm;
},{
loader = MxLoader(register);
loader.loadData(data);
Expand Down Expand Up @@ -332,18 +334,21 @@ Mx : AbstractPlayerProxy {
}
beatDuration {
var max;
this.allUnits.do { arg unit;
var numb;
numb = unit.beatDuration;
if(numb.notNil,{
if(max.isNil,{
max = numb
},{
max = max(max,numb)
// but if loop is on then its endless
^endBeat ?? {
this.allUnits.do { arg unit;
var numb;
numb = unit.beatDuration;
if(numb.notNil,{
if(max.isNil,{
max = numb
},{
max = max(max,numb)
})
})
})
};
^max
};
max
}
}

// API
Expand Down
8 changes: 4 additions & 4 deletions MxTimeGui.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MxTimeGui : ObjectGui {

var <from,<to,<maxTime=300,zoomCalc,playZoomCalc;
var <from,<to,<maxTime,zoomCalc,playZoomCalc;
var xScale;
var <>laneHeight=150;
var zoom,playHead,timeRuler,updater,units;
Expand Down Expand Up @@ -45,7 +45,7 @@ MxTimeGui : ObjectGui {

};

maxTime = (model.beatDuration ? 480) + 32;
maxTime = (model.endBeat ?? {model.beatDuration} ? 480);
CXLabel(layout,"MaxBeat:");
NumberEditor(maxTime,[0,10000].asSpec).action_({ arg num;
this.maxTime = num.value;
Expand Down Expand Up @@ -164,14 +164,14 @@ MxTimeGui : ObjectGui {
this.zoom(newfrom,newto);
}
maxTime_ { arg mt;
model.endBeat = mt;
maxTime = mt;
zoomCalc.modelRange = [0,maxTime];
playZoomCalc.modelRange = [0,maxTime];
timeRuler.maxTime = maxTime;
model.allUnits.do { arg unit;
unit.callHandler('setMaxTime',maxTime)
};

};
}
keyDownResponder {
var k,default;
Expand Down

0 comments on commit cfc00b5

Please sign in to comment.