Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic fix as score offset expansion #3544

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions SCClassLibrary/Common/Control/asScore/ScoreStreamPlayer.sc
Original file line number Diff line number Diff line change
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
43 changes: 43 additions & 0 deletions testsuite/classlibrary/TestScore.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
TestScore : UnitTest {

test_pattern_asScore_lag {
var events, score, onsetTimes;
events = [(x: 0, lag: 0.5), (x: 1, dur: 0.5), (x: 2, lag: 0.5)];
score = Pseq(events).asScore(3);
onsetTimes = score.score.drop(1).postcs.select { |x| x[2] == \default }.collect { |x| x.first };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please remove the postcs from these tests?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, using collect(_.first) at the end might make it more readable. personally i think it would be clearest to break this into two lines with an extra variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done!

this.assertEquals(onsetTimes, [0.5, 1, 2], "onsets should be correctly derived from lag and dur");
}

test_pattern_asScore_timingOffset {
var events, score, onsetTimes;
events = [(x: 0, timingOffset: 0.5), (x: 1, dur: 0.5), (x: 2, timingOffset: 0.5)];
score = Pseq(events).asScore(3);
onsetTimes = score.score.drop(1).postcs.select { |x| x[2] == \default }.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, onsetTimes;
events = [(x: 0, lag: [0.5, 1, 2])];
score = Pseq(events).asScore(3);
onsetTimes = score.score.drop(1).postcs.select { |x| x[2] == \default }.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, onsetTimes;
events = [(x: 0, timingOffset: [0.5, 1, 2])];
score = Pseq(events).asScore(3);
onsetTimes = score.score.drop(1).postcs.select { |x| x[2] == \default }.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, onsetTimes;
events = [(x: 0, timingOffset: [0.5, 1, 2], lag: [0.3, 0.7, 1])];
score = Pseq(events).asScore(4);
onsetTimes = score.score.drop(1).postcs.select { |x| x[2] == \default }.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");
}

}