Exemplo n.º 1
0
def skipHelper(n1, n2, s):
    s.push()
    s.add(
        isSkip(ConstPitch(n1.semitoneDistance),
               ConstPitch(n2.semitoneDistance)))
    res = s.check()
    s.pop()
    return res
def test_SimFailure(workingCF):
    cf = workingCF
    s1 = workingCF.copy()
    s1[1] = s1[1] + 11 #seventh
    assert checkS1(cf, s1).reasons[0].split(':')[0].split('.')[1] == "SIMULTANEITY"
    symCF = [ConstPitch(x) for x in cf]
    symS1 = [ConstPitch(x) for x in s1]
    sm = makeSimMap([makeTemporalisedLine(symCF, NoteLength.WHOLE)],
                    makeTemporalisedLine(symS1, NoteLength.WHOLE))
    x = smartRepairLine(symS1, firstSpeciesSpec(symCF, 20, ''), checkS1(cf, s1), 13, sm)
    assert x is not None
    assert checkS1(cf,x).isValid()
 def createNew(self):
     try:
         pitches = self.foundry.extractPitches(self.spec.line)
     except Exception:
         return []
     self.foundry.apply(distinctFromExample(self.spec.line, [ConstPitch(x) for x in pitches]))
     return pitches
def test_gamutFailure(workingCF, cantus, cantusGamut):
    workingCF[2] = 1
    assert checkCF(workingCF).reasons[0].split(':')[0].split('.')[1] == "GAMUT"
    symCF = [ConstPitch(x) for x in workingCF]
    sm = makeSimMap([makeTemporalisedLine(symCF, NoteLength.WHOLE)],
                    makeTemporalisedLine(symCF, NoteLength.WHOLE))
    x = smartRepairLine(symCF, cantus, checkCF(workingCF), cantusGamut, sm)
    assert x is not None
    assert checkCF(x).isValid()
Exemplo n.º 5
0
    def createNew(self, species, length, gamutLength, cf):
        if species == cf:
            cf = ()
        cf = tuple(cf)

        key = (species, length, gamutLength, cf)
        if key in self.generators:
            return self.generators[key].createNew()
        else:
            if species == 'cf':
                g = Generator(cantusSpec(length, gamutLength, 'cf'))
            elif species == 's1':
                g = Generator(firstSpeciesSpec([ConstPitch(x) for x in cf], gamutLength, 's1'))
            elif species == 's2':
                g = Generator(secondSpeciesSpec([ConstPitch(x) for x in cf], gamutLength, 's2'))
            else:
                g = Generator(thirdSpeciesSpec([ConstPitch(x) for x in cf], gamutLength, 's3'))

            self.generators[key] = g
            return g.createNew()
Exemplo n.º 6
0
def s1GoodCF(goodCF, highSpeciesGamut):
    return firstSpeciesSpec([ConstPitch(x) for x in goodCF], highSpeciesGamut,
                            '')
Exemplo n.º 7
0
def s3BadCF(badCF, highSpeciesGamut):
    return thirdSpeciesSpec([ConstPitch(x) for x in badCF], highSpeciesGamut,
                            '')
Exemplo n.º 8
0
def s3GoodCF(goodCF, highSpeciesGamut):
    return thirdSpeciesSpec([ConstPitch(x) for x in goodCF], highSpeciesGamut,
                            '')
def testExtractPitches(foundry):
    l = Line(1, '')
    p0 = l[0]
    p1 = ConstPitch(4)
    foundry.apply(Constraint(p0 == p1, ConstraintType.MISC, "bla"))
    assert foundry.extractPitches(l) == [p1.flattened()]
Exemplo n.º 10
0
def isDissonantHelper(n1, n2, s):
    s.push()
    s.add(isDissonant(ConstPitch(n1), ConstPitch(n2)))
    res = s.check()
    s.pop()
    return res
Exemplo n.º 11
0
def triadicHelper(n1, n2, n3, s):
    s.push()
    s.add(isTriadic(ConstPitch(n1), ConstPitch(n2), ConstPitch(n3)))
    res = s.check()
    s.pop()
    return res
def test_oneArgConstructorWorks_NegativeOctave():
    p = ConstPitch(-3)
    assert p.letter == 9
    assert p.octave == -1
def test_oneArgConstructorWorks_PositiveOctave():
    p = ConstPitch(27)
    assert p.letter == 3
    assert p.octave == 2
def example():
    return [ConstPitch(1), ConstPitch(2), ConstPitch(3)]
Exemplo n.º 15
0
def isTriadic(n1, n2, n3):
    tonicIndex = ConstPitch(0, 0)
    return And(isConsonant(tonicIndex, n1), isConsonant(tonicIndex, n2),
               isConsonant(tonicIndex, n3))
Exemplo n.º 16
0
def s1BadCF(badCF, highSpeciesGamut):
    return firstSpeciesSpec([ConstPitch(x) for x in badCF], highSpeciesGamut,
                            '')
def test_twoArgConstructorWorks():
    p = ConstPitch(1, 2)
    assert p.letter == 1
    assert p.octave == 2
def test_oneArgConstructorWorks_zerothOctave():
    p = ConstPitch(1)
    assert p.letter == 1
    assert p.octave == 0
Exemplo n.º 19
0
def stepHelper(n1, n2, s):
    s.push()
    s.add(isStep(ConstPitch(n1), ConstPitch(n2)))
    res = s.check()
    s.pop()
    return res
Exemplo n.º 20
0
def s2GoodCF(goodCF, highSpeciesGamut):
    return secondSpeciesSpec([ConstPitch(x) for x in goodCF], highSpeciesGamut,
                             '')
Exemplo n.º 21
0
def smallerHelper(n, n1, n2, s):
    s.push()
    s.add(isIntervalOrSmaller(n, ConstPitch(n1), ConstPitch(n2)))
    res = s.check()
    s.pop()
    return res
Exemplo n.º 22
0
def s2BadCF(badCF, highSpeciesGamut):
    return secondSpeciesSpec([ConstPitch(x) for x in badCF], highSpeciesGamut,
                             '')
Exemplo n.º 23
0
def run2(function, arg1, arg2):
    s = Solver()
    s.add(function(ConstPitch(arg1), ConstPitch(arg2)))
    return s
def testExtractPitch(foundry):
    p0 = VarPitch('x')
    p1 = ConstPitch(4)
    foundry.apply(Constraint(p0 == p1, ConstraintType.MISC, "bla"))
    foundry.check()
    assert foundry.extractPitch(p0) == p1.flattened()