Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3544 from telephon/topic-fix-asScore-offset-expan…
…sion Topic fix as score offset expansion
- Loading branch information
Showing
2 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
|
||
} |