图形均衡器

时间:2017-04-15 18:25:11

标签: user-interface audio signal-processing real-time

我正在尝试在python中创建一个图形均衡器。一切进展顺利,但我无法实时运行音频。我设计了5个滑块,代表每个频段(总共5个频段)。每次我操纵这些滑块时,scikits音频播放都会重新计算。这是我的代码,所以你可以看到我更详细的信息

均衡器功能:

from Tkinter import *
import tkFileDialog
import threading
from Equalizer import processAudio

# GUI assosiated Functions
filepath = ''

def choosefile():
    try:
        global filepath
        filepath = tkFileDialog.askopenfilename(filetypes=[('Audio Files', '*.wav')])
        filenamelabel.config(text=filepath)
    except ValueError:
        pass


def getSliderValues():
    sliderVector = []
    sliderVector.append(Value45hz.get())
    sliderVector.append(Value700hz.get())
    sliderVector.append(Value2khz.get())
    sliderVector.append(Value8khz.get())
    sliderVector.append(Value15khz.get())
    if filepath:
        audioThread = threading.Thread(target=processAudio, args=(filepath, sliderVector[0], sliderVector[1], sliderVector[2], sliderVector[3], sliderVector[4]))
        audioThread.start()
    test45hzslider.after(500, getSliderValues)

root = Tk()
root.title("Graphic Equalizer")
# Initiation of Frames
sliderframes = Frame(root)
sliderframes.pack(side=TOP)
slider1frame = Frame(sliderframes)
slider1frame.pack(side=LEFT)
slider2frame = Frame(sliderframes)
slider2frame.pack(side=LEFT)
slider3frame = Frame(sliderframes)
slider3frame.pack(side=LEFT)
slider4frame = Frame(sliderframes)
slider4frame.pack(side=LEFT)
slider5frame = Frame(sliderframes)
slider5frame.pack(side=LEFT)

importframe = Frame(root)
importframe.pack(side=BOTTOM)

# Variable creation
## En estas variables es que se guarda el valor del slider cuando le des al boton o hagan refresh con el timer
Value45hz = DoubleVar()
Value700hz = DoubleVar()
Value2khz = DoubleVar()
Value8khz = DoubleVar()
Value15khz = DoubleVar()

# All sliderframes widgets

# Slider 1
w = Scale(slider1frame, from_=12, to=-12, variable=Value45hz) ### slider label =45hz
w.set(0)
w.pack(side=TOP)
# Label for slider 1
label45hz = Label(slider1frame, text='45Hz')
label45hz.pack(side=TOP)

# Slider 2
w2 = Scale(slider2frame, from_=12, to=-12, variable=Value700hz)  #slider label = 700hz
w2.set(0)
w2.pack(side=TOP)
# Label for slider 2
label700hz = Label(slider2frame, text='700Hz')
label700hz.pack(side=TOP)

# Slider 3
w3 = Scale(slider3frame, from_=12, to=-12, variable=Value2khz)  # slider label = 2khz
w3.set(0)
w3.pack(side=TOP)
# Label for slider 3
label2khz = Label(slider3frame, text='2kHz')
label2khz.pack(side=TOP)

# Slider 4
w4 = Scale(slider4frame, from_=12, to=-12, variable=Value8khz)  # slider label = 8k
w4.set(0)
w4.pack(side=TOP)
# Label for slider 4
label8khz = Label(slider4frame, text='8kHz')
label8khz.pack(side=TOP)

# Slider 5
w5 = Scale(slider5frame, from_=12, to=-12, variable=Value15khz) ### slider label= 15khz
w5.set(0)
w5.pack(side=TOP)
# Label for slider 5
label15khz = Label(slider5frame, text='15kHz')
label15khz.pack(side=TOP)

# Audio Import Button
audiobutton = Button(importframe, text='Import Audio...', command=choosefile)
audiobutton.pack(side=LEFT)
filenamelabel = Label(importframe, text='No File Chosen.')
filenamelabel.pack(side=LEFT)
test45hzslider = Label(importframe, text='No Value')
test45hzslider.pack(side=LEFT)

#

getSliderValues()
mainloop()

## dale run a ver si el gas pela

###45Hz, 700Hz, 2KHz 8k, 15KHz

GUI功能

{{1}}

0 个答案:

没有答案