示例#1
0
文件: HW7.py 项目: rootulp/school
def louder():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    maxL = left[:]
    maxR = right[:]
    bigL = left[0]
    bigR = right[0]
    for i in range(len(left)):
        if abs(left[i]) > abs(bigL):
            bigL = left[i]
    for i in range(len(right)):
        if abs(right[i]) > abs(bigR):
            bigR = right[i]
    for i in range(len(left)):
        maxL[i] = left[i]/bigL
    for i in range(len(right)):
        maxR[i] = right[i]/bigR
    left[:] = maxL[:]
    right[:] = maxR[:]
    for i in range(len(left)):
        if left[i] > 0:
            left[i] = left[i] ** .8
        else:
            left[i] = -1*((left[i]*-1)**.8)
    for i in range(len(right)):
        if right[i] > 0:
            right[i] = right[i] ** .8
        else:
            right[i] = -1*((right[i]*-1)**.8)       
    BCAudio.play()
示例#2
0
文件: HW7.py 项目: rootulp/school
def swap():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    newRight = left[:]
    newLeft = right[:]
    left[:] = newLeft[:]
    right[:] = newRight[:]
    BCAudio.play()
示例#3
0
文件: HW7.py 项目: rootulp/school
def mono():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    mono = left[:]
    for i in range(len(left)):
        mono[i] = (left[i] + right[i])/ 2.0
    left[:] = mono[:]
    right[:] = mono[:]
    BCAudio.play()
示例#4
0
文件: HW7.py 项目: rootulp/school
def quiet():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    quietL = left[:]
    quietR = right[:]
    for i in range(len(left)):
        quietL[i] = left[i]/2.0
        quietR[i] = right[i]/2.0
    left[:] = quietL[:]
    right[:] = quietR[:]
    BCAudio.play()
示例#5
0
文件: HW7.py 项目: rootulp/school
def faster():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    leftFaster = []
    rightFaster = []
    for i in range(0,len(left),2):
        leftFaster.append(left[i])
    for i in range (0,len(right),2):
        rightFaster.append(right[i])
    left[:] = leftFaster[:]
    right[:] = rightFaster[:]
    BCAudio.play()
示例#6
0
文件: HW7.py 项目: rootulp/school
def reverse():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    reverseL = []
    reverseR = []
    for i in reversed(right):
        reverseR.append(i)
    for i in reversed(left):
        reverseL.append(i)
    left[:] = reverseL[:]
    right[:] = reverseR[:]
    BCAudio.play()
示例#7
0
文件: HW7.py 项目: rootulp/school
def slower():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    leftSlow = []
    rightSlow = []
    for i in range (len(left)):
        leftSlow.append(left[i])
        leftSlow.append(left[i])
    for i in range (len(right)):
        rightSlow.append(right[i])
        rightSlow.append(right[i])
    left[:] = leftSlow[:]
    right[:] = rightSlow[:]
    BCAudio.play()
示例#8
0
文件: HW7.py 项目: rootulp/school
def maximize():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    maxL = left[:]
    maxR = right[:]
    bigL = left[0]
    bigR = right[0]
    for i in range(len(left)):
        if abs(left[i]) > abs(bigL):
            bigL = left[i]
    for i in range(len(right)):
        if abs(right[i]) > abs(bigR):
            bigR = right[i]
    for i in range(len(left)):
        maxL[i] = left[i]/bigL
    for i in range(len(right)):
        maxR[i] = right[i]/bigR
    left[:] = maxL[:]
    right[:] = maxR[:]
    BCAudio.play()
示例#9
0
文件: HW7.py 项目: rootulp/school
def echo():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    leftEcho = []
    rightEcho = []
    leftTemp = []
    rightTemp = []
    delta = int(44100//8)
    for i in range (0, 44100//8):
        leftTemp.append(left[i])
        rightTemp.append(right[i])
    for i in range (44100//8,len(left)):
        leftEcho.append(.25*left[i] + .75*left[i-delta])
    for i in range (44100//8,len(right)):
        rightEcho.append(.25*right[i] + .75*right[i-delta])
    leftTemp.extend(leftEcho)
    rightTemp.extend(rightEcho)
    left[:] = leftTemp[:]
    right[:] = rightTemp[:]
    BCAudio.play()
示例#10
0
文件: HW7.py 项目: rootulp/school
def distort():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    leftDistort = left[:]
    rightDistort = right[:]
    for i in range (len(left)):
        if left[i] >= .2:
            leftDistort[i] = .2
        elif left[i] <= -.2:
            leftDistort[i] = -.2
        else:
            leftDistort[i] = left[i]
    for i in range (len(right)):
        if right[i] >= .2:
            rightDistort[i] = .2
        elif right[i] <= -.2:
            rightDistort[i] = -.2
        else:
            rightDistort[i] = right[i]
    left[:] = leftDistort[:]
    right[:] = rightDistort[:]
    BCAudio.play()
示例#11
0
文件: HW7.py 项目: rootulp/school
def play():
    left = BCAudio.getLeft()
    right = BCAudio.getRight()
    BCAudio.play()