Skip to content

Commit

Permalink
Merge pull request #3544 from telephon/topic-fix-asScore-offset-expan…
Browse files Browse the repository at this point in the history
…sion

Topic fix as score offset expansion
  • Loading branch information
mossheim committed Mar 4, 2018
2 parents 93ed40f + 4f01c21 commit bce4abd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
8 changes: 4 additions & 4 deletions SCClassLibrary/Common/Control/asScore/ScoreStreamPlayer.sc
Expand Up @@ -42,10 +42,10 @@ ScoreStreamPlayer : Server {
prepareEvent { | event |
event = event.copy;
event.use({
~schedBundle = { | lag, offset, server ...bundle |
~schedBundle = flop { | lag, offset, server ... bundle |
this.add(offset * tempo + lag + beats, bundle)
};
~schedBundleArray = { | lag, offset, server, bundle |
~schedBundleArray = flop { | lag, offset, server, bundle |
this.add(offset * tempo + lag + beats, bundle)
};
});
Expand All @@ -57,10 +57,10 @@ ScoreStreamPlayer : Server {
proto = (
server: this,

schedBundle: { | lag, offset, server ...bundle |
schedBundle: flop { | lag, offset, server ...bundle |
this.add(offset * tempo + lag + beats, bundle)
},
schedBundleArray: { | lag, offset, server, bundle |
schedBundleArray: flop { | lag, offset, server, bundle |
this.add(offset * tempo + lag + beats, bundle)
}
);
Expand Down
48 changes: 48 additions & 0 deletions testsuite/classlibrary/TestScore.sc
@@ -0,0 +1,48 @@
TestScore : UnitTest {

test_pattern_asScore_lag {
var events, score, s_new_messages, onsetTimes;
events = [(x: 0, lag: 0.5), (x: 1, dur: 0.5), (x: 2, lag: 0.5)];
score = Pseq(events).asScore(3);
s_new_messages = score.score.drop(1).select { |x| x[2] == \default };
onsetTimes = s_new_messages.collect { |x| x.first };
this.assertEquals(onsetTimes, [0.5, 1, 2], "onsets should be correctly derived from lag and dur");
}

test_pattern_asScore_timingOffset {
var events, score, s_new_messages, onsetTimes;
events = [(x: 0, timingOffset: 0.5), (x: 1, dur: 0.5), (x: 2, timingOffset: 0.5)];
score = Pseq(events).asScore(3);
s_new_messages = score.score.drop(1).select { |x| x[2] == \default };
onsetTimes = s_new_messages.collect { |x| x.first };
this.assertEquals(onsetTimes, [0.5, 1, 2], "onsets should be correctly derived from timingOffset and dur");
}

test_pattern_asScore_lag_multichannel {
var events, score, s_new_messages, onsetTimes;
events = [(x: 0, lag: [0.5, 1, 2])];
score = Pseq(events).asScore(3);
s_new_messages = score.score.drop(1).select { |x| x[2] == \default };
onsetTimes = s_new_messages.collect { |x| x.first };
this.assertEquals(onsetTimes, [0.5, 1, 2], "onsets should be correctly derived from lag in multichannel expanding");
}

test_pattern_asScore_timingOffset_multichannel {
var events, score, s_new_messages, onsetTimes;
events = [(x: 0, timingOffset: [0.5, 1, 2])];
score = Pseq(events).asScore(3);
s_new_messages = score.score.drop(1).select { |x| x[2] == \default };
onsetTimes = s_new_messages.collect { |x| x.first };
this.assertEquals(onsetTimes, [0.5, 1, 2], "onsets should be correctly derived from timingOffset in multichannel expanding");
}

test_pattern_asScore_timingValues_multichannel {
var events, score, s_new_messages, onsetTimes;
events = [(x: 0, timingOffset: [0.5, 1, 2], lag: [0.3, 0.7, 1])];
score = Pseq(events).asScore(4);
s_new_messages = score.score.drop(1).select { |x| x[2] == \default };
onsetTimes = s_new_messages.collect { |x| x.first };
this.assertEquals(onsetTimes, [0.5, 1, 2] + [0.3, 0.7, 1], "onsets should be correctly derived from lag and timingOffset in multichannel expanding");
}

}

0 comments on commit bce4abd

Please sign in to comment.