示例#1
0
	def initUI(self):

		choose_label = "inputFile:"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 25
		self.filelocation.grid(row=0,column=0, sticky=W, padx=(70, 5), pady=(10,2))
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/rain.wav')

		#BUTTON TO BROWSE SOUND FILE
		open_file = Button(self.parent, text="...", command=self.browse_file) #see: def browse_file(self)
		open_file.grid(row=0, column=0, sticky=W, padx=(280, 6), pady=(10,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE
		preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		preview.grid(row=0, column=0, sticky=W, padx=(325,6), pady=(10,2))

		## STOCHASTIC TRANSFORMATIONS ANALYSIS

		#DECIMATION FACTOR
		stocf_label = "stocf:"
		Label(self.parent, text=stocf_label).grid(row=1, column=0, sticky=W, padx=(5,5), pady=(10,2))
		self.stocf = Entry(self.parent, justify=CENTER)
		self.stocf["width"] = 5
		self.stocf.grid(row=1, column=0, sticky=W, padx=(47,5), pady=(10,2))
		self.stocf.delete(0, END)
		self.stocf.insert(0, "0.1")

		#TIME SCALING FACTORS
		timeScaling_label = "Time scaling factors (time, value pairs):"
		Label(self.parent, text=timeScaling_label).grid(row=2, column=0, sticky=W, padx=5, pady=(5,2))
		self.timeScaling = Entry(self.parent, justify=CENTER)
		self.timeScaling["width"] = 35
		self.timeScaling.grid(row=3, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.timeScaling.delete(0, END)
		self.timeScaling.insert(0, "[0, 0, 1, 2]")

		#BUTTON TO DO THE SYNTHESIS
		self.compute = Button(self.parent, text="Apply Transformation", command=self.transformation_synthesis, bg="dark green", fg="white")
		self.compute.grid(row=13, column=0, padx=5, pady=(10,15), sticky=W)

		#BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
		self.transf_output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_stochasticModelTransformation.wav'), bg="gray30", fg="white")
		self.transf_output.grid(row=13, column=0, padx=(165,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
    def initUI(self):

        choose_label = "Input file (.wav, mono and 44100 sampling rate):"
        Label(self.parent, text=choose_label).grid(row=0,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(10, 2))

        #TEXTBOX TO PRINT PATH OF THE SOUND FILE
        self.filelocation = Entry(self.parent)
        self.filelocation.focus_set()
        self.filelocation["width"] = 25
        self.filelocation.grid(row=1, column=0, sticky=W, padx=10)
        self.filelocation.delete(0, END)
        self.filelocation.insert(0, '../../sounds/piano.wav')

        #BUTTON TO BROWSE SOUND FILE
        self.open_file = Button(
            self.parent, text="Browse...",
            command=self.browse_file)  #see: def browse_file(self)
        self.open_file.grid(row=1, column=0, sticky=W,
                            padx=(220,
                                  6))  #put it beside the filelocation textbox

        #BUTTON TO PREVIEW SOUND FILE
        self.preview = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay(self.filelocation.get()),
            bg="gray30",
            fg="white")
        self.preview.grid(row=1, column=0, sticky=W, padx=(306, 6))

        ## STFT

        #ANALYSIS WINDOW TYPE
        wtype_label = "Window type:"
        Label(self.parent, text=wtype_label).grid(row=2,
                                                  column=0,
                                                  sticky=W,
                                                  padx=5,
                                                  pady=(10, 2))
        self.w_type = StringVar()
        self.w_type.set("hamming")  # initial value
        window_option = OptionMenu(self.parent, self.w_type, "rectangular",
                                   "hanning", "hamming", "blackman",
                                   "blackmanharris")
        window_option.grid(row=2,
                           column=0,
                           sticky=W,
                           padx=(95, 5),
                           pady=(10, 2))

        #WINDOW SIZE
        M_label = "Window size (M):"
        Label(self.parent, text=M_label).grid(row=3,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.M = Entry(self.parent, justify=CENTER)
        self.M["width"] = 5
        self.M.grid(row=3, column=0, sticky=W, padx=(115, 5), pady=(10, 2))
        self.M.delete(0, END)
        self.M.insert(0, "1024")

        #FFT SIZE
        N_label = "FFT size (N) (power of two bigger than M):"
        Label(self.parent, text=N_label).grid(row=4,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.N = Entry(self.parent, justify=CENTER)
        self.N["width"] = 5
        self.N.grid(row=4, column=0, sticky=W, padx=(270, 5), pady=(10, 2))
        self.N.delete(0, END)
        self.N.insert(0, "1024")

        #HOP SIZE
        H_label = "Hop size (H):"
        Label(self.parent, text=H_label).grid(row=5,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.H = Entry(self.parent, justify=CENTER)
        self.H["width"] = 5
        self.H.grid(row=5, column=0, sticky=W, padx=(95, 5), pady=(10, 2))
        self.H.delete(0, END)
        self.H.insert(0, "512")

        #BUTTON TO COMPUTE EVERYTHING
        self.compute = Button(self.parent,
                              text="Compute",
                              command=self.compute_model,
                              bg="dark red",
                              fg="white")
        self.compute.grid(row=6, column=0, padx=5, pady=(10, 2), sticky=W)

        #BUTTON TO PLAY OUTPUT
        output_label = "Output:"
        Label(self.parent, text=output_label).grid(row=7,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(10, 15))
        self.output = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay('output_sounds/' + os.path.basename(
                self.filelocation.get())[:-4] + '_stft.wav'),
            bg="gray30",
            fg="white")
        self.output.grid(row=7,
                         column=0,
                         padx=(60, 5),
                         pady=(10, 15),
                         sticky=W)

        # define options for opening file
        self.file_opt = options = {}
        options['defaultextension'] = '.wav'
        options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
        options['initialdir'] = '../../sounds/'
        options[
            'title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
	def initUI(self):

		choose_label = "inputFile:"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 32
		self.filelocation.grid(row=0,column=0, sticky=W, padx=(70, 5), pady=(10,2))
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/vignesh.wav')

		#BUTTON TO BROWSE SOUND FILE
		open_file = Button(self.parent, text="...", command=self.browse_file) #see: def browse_file(self)
		open_file.grid(row=0, column=0, sticky=W, padx=(340, 6), pady=(10,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE
		preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		preview.grid(row=0, column=0, sticky=W, padx=(385,6), pady=(10,2))

		## HARMONIC TRANSFORMATIONS ANALYSIS

		#ANALYSIS WINDOW TYPE
		wtype_label = "window:"
		Label(self.parent, text=wtype_label).grid(row=1, column=0, sticky=W, padx=5, pady=(10,2))
		self.w_type = StringVar()
		self.w_type.set("blackman") # initial value
		window_option = OptionMenu(self.parent, self.w_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window_option.grid(row=1, column=0, sticky=W, padx=(65,5), pady=(10,2))

		#WINDOW SIZE
		M_label = "M:"
		Label(self.parent, text=M_label).grid(row=1, column=0, sticky=W, padx=(180, 5), pady=(10,2))
		self.M = Entry(self.parent, justify=CENTER)
		self.M["width"] = 5
		self.M.grid(row=1,column=0, sticky=W, padx=(200,5), pady=(10,2))
		self.M.delete(0, END)
		self.M.insert(0, "1201")

		#FFT SIZE
		N_label = "N:"
		Label(self.parent, text=N_label).grid(row=1, column=0, sticky=W, padx=(255, 5), pady=(10,2))
		self.N = Entry(self.parent, justify=CENTER)
		self.N["width"] = 5
		self.N.grid(row=1,column=0, sticky=W, padx=(275,5), pady=(10,2))
		self.N.delete(0, END)
		self.N.insert(0, "2048")

		#THRESHOLD MAGNITUDE
		t_label = "t:"
		Label(self.parent, text=t_label).grid(row=1, column=0, sticky=W, padx=(330,5), pady=(10,2))
		self.t = Entry(self.parent, justify=CENTER)
		self.t["width"] = 5
		self.t.grid(row=1, column=0, sticky=W, padx=(348,5), pady=(10,2))
		self.t.delete(0, END)
		self.t.insert(0, "-90")

		#MIN DURATION SINUSOIDAL TRACKS
		minSineDur_label = "minSineDur:"
		Label(self.parent, text=minSineDur_label).grid(row=2, column=0, sticky=W, padx=(5, 5), pady=(10,2))
		self.minSineDur = Entry(self.parent, justify=CENTER)
		self.minSineDur["width"] = 5
		self.minSineDur.grid(row=2, column=0, sticky=W, padx=(87,5), pady=(10,2))
		self.minSineDur.delete(0, END)
		self.minSineDur.insert(0, "0.1")

		#MAX NUMBER OF HARMONICS
		nH_label = "nH:"
		Label(self.parent, text=nH_label).grid(row=2, column=0, sticky=W, padx=(145,5), pady=(10,2))
		self.nH = Entry(self.parent, justify=CENTER)
		self.nH["width"] = 5
		self.nH.grid(row=2, column=0, sticky=W, padx=(172,5), pady=(10,2))
		self.nH.delete(0, END)
		self.nH.insert(0, "100")

		#MIN FUNDAMENTAL FREQUENCY
		minf0_label = "minf0:"
		Label(self.parent, text=minf0_label).grid(row=2, column=0, sticky=W, padx=(227,5), pady=(10,2))
		self.minf0 = Entry(self.parent, justify=CENTER)
		self.minf0["width"] = 5
		self.minf0.grid(row=2, column=0, sticky=W, padx=(275,5), pady=(10,2))
		self.minf0.delete(0, END)
		self.minf0.insert(0, "130")

		#MAX FUNDAMENTAL FREQUENCY
		maxf0_label = "maxf0:"
		Label(self.parent, text=maxf0_label).grid(row=2, column=0, sticky=W, padx=(330,5), pady=(10,2))
		self.maxf0 = Entry(self.parent, justify=CENTER)
		self.maxf0["width"] = 5
		self.maxf0.grid(row=2, column=0, sticky=W, padx=(380,5), pady=(10,2))
		self.maxf0.delete(0, END)
		self.maxf0.insert(0, "300")

		#MAX ERROR ACCEPTED
		f0et_label = "f0et:"
		Label(self.parent, text=f0et_label).grid(row=3, column=0, sticky=W, padx=5, pady=(10,2))
		self.f0et = Entry(self.parent, justify=CENTER)
		self.f0et["width"] = 3
		self.f0et.grid(row=3, column=0, sticky=W, padx=(42,5), pady=(10,2))
		self.f0et.delete(0, END)
		self.f0et.insert(0, "7")

		#ALLOWED DEVIATION OF HARMONIC TRACKS
		harmDevSlope_label = "harmDevSlope:"
		Label(self.parent, text=harmDevSlope_label).grid(row=3, column=0, sticky=W, padx=(90,5), pady=(10,2))
		self.harmDevSlope = Entry(self.parent, justify=CENTER)
		self.harmDevSlope["width"] = 5
		self.harmDevSlope.grid(row=3, column=0, sticky=W, padx=(190,5), pady=(10,2))
		self.harmDevSlope.delete(0, END)
		self.harmDevSlope.insert(0, "0.01")

		#BUTTON TO DO THE ANALYSIS OF THE SOUND
		self.compute = Button(self.parent, text="Analysis/Synthesis", command=self.analysis, bg="dark red", fg="white")
		self.compute.grid(row=4, column=0, padx=5, pady=(10,5), sticky=W)
		
		#BUTTON TO PLAY ANALYSIS/SYNTHESIS OUTPUT
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_harmonicModel.wav'), bg="gray30", fg="white")
		self.output.grid(row=4, column=0, padx=(145,5), pady=(10,5), sticky=W)

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=5, pady=5, sticky=W+E)
		###

		#FREQUENCY SCALING FACTORS
		freqScaling_label = "Frequency scaling factors (time, value pairs):"
		Label(self.parent, text=freqScaling_label).grid(row=6, column=0, sticky=W, padx=5, pady=(5,2))
		self.freqScaling = Entry(self.parent, justify=CENTER)
		self.freqScaling["width"] = 35
		self.freqScaling.grid(row=7, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.freqScaling.delete(0, END)
		self.freqScaling.insert(0, "[0, 2.0, 1, 0.3]")

		#FREQUENCY STRETCHING FACTORSharmonicModelTransformation
		freqStretching_label = "Frequency stretching factors (time, value pairs):"
		Label(self.parent, text=freqStretching_label).grid(row=8, column=0, sticky=W, padx=5, pady=(5,2))
		self.freqStretching = Entry(self.parent, justify=CENTER)
		self.freqStretching["width"] = 35
		self.freqStretching.grid(row=9, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.freqStretching.delete(0, END)
		self.freqStretching.insert(0, "[0, 1, 1, 1.5]")

		#TIMBRE PRESERVATION
		timbrePreservation_label = "Timbre preservation (1 preserves original timbre, 0 it does not):"
		Label(self.parent, text=timbrePreservation_label).grid(row=10, column=0, sticky=W, padx=5, pady=(5,2))
		self.timbrePreservation = Entry(self.parent, justify=CENTER)
		self.timbrePreservation["width"] = 2
		self.timbrePreservation.grid(row=10, column=0, sticky=W+E, padx=(395,5), pady=(5,2))
		self.timbrePreservation.delete(0, END)
		self.timbrePreservation.insert(0, "1")

		#TIME SCALING FACTORS
		timeScaling_label = "Time scaling factors (time, value pairs):"
		Label(self.parent, text=timeScaling_label).grid(row=11, column=0, sticky=W, padx=5, pady=(5,2))
		self.timeScaling = Entry(self.parent, justify=CENTER)
		self.timeScaling["width"] = 35
		self.timeScaling.grid(row=12, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.timeScaling.delete(0, END)
		self.timeScaling.insert(0, "[0, 0, 0.671, 0.671, 1.978, 1.978+1.0]")

		#BUTTON TO DO THE SYNTHESIS
		self.compute = Button(self.parent, text="Apply Transformation", command=self.transformation_synthesis, bg="dark green", fg="white")
		self.compute.grid(row=13, column=0, padx=5, pady=(10,15), sticky=W)

		#BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
		self.transf_output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_harmonicModelTransformation.wav'), bg="gray30", fg="white")
		self.transf_output.grid(row=13, column=0, padx=(165,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#4
0
	def initUI(self):

		choose_label = "Input file (.wav, mono and 44100 sampling rate):"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 25
		self.filelocation.grid(row=1,column=0, sticky=W, padx=10)
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/bendir.wav')

		#BUTTON TO BROWSE SOUND FILE
		self.open_file = Button(self.parent, text="Browse...", command=self.browse_file) #see: def browse_file(self)
		self.open_file.grid(row=1, column=0, sticky=W, padx=(220, 6)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE
		self.preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		self.preview.grid(row=1, column=0, sticky=W, padx=(306,6))

		## SINE MODEL

		#ANALYSIS WINDOW TYPE
		wtype_label = "Window type:"
		Label(self.parent, text=wtype_label).grid(row=2, column=0, sticky=W, padx=5, pady=(10,2))
		self.w_type = StringVar()
		self.w_type.set("hamming") # initial value
		window_option = OptionMenu(self.parent, self.w_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window_option.grid(row=2, column=0, sticky=W, padx=(95,5), pady=(10,2))

		#WINDOW SIZE
		M_label = "Window size (M):"
		Label(self.parent, text=M_label).grid(row=3, column=0, sticky=W, padx=5, pady=(10,2))
		self.M = Entry(self.parent, justify=CENTER)
		self.M["width"] = 5
		self.M.grid(row=3,column=0, sticky=W, padx=(115,5), pady=(10,2))
		self.M.delete(0, END)
		self.M.insert(0, "2001")

		#FFT SIZE
		N_label = "FFT size (N) (power of two bigger than M):"
		Label(self.parent, text=N_label).grid(row=4, column=0, sticky=W, padx=5, pady=(10,2))
		self.N = Entry(self.parent, justify=CENTER)
		self.N["width"] = 5
		self.N.grid(row=4,column=0, sticky=W, padx=(270,5), pady=(10,2))
		self.N.delete(0, END)
		self.N.insert(0, "2048")

		#THRESHOLD MAGNITUDE
		t_label = "Magnitude threshold (t) (in dB):"
		Label(self.parent, text=t_label).grid(row=5, column=0, sticky=W, padx=5, pady=(10,2))
		self.t = Entry(self.parent, justify=CENTER)
		self.t["width"] = 5
		self.t.grid(row=5, column=0, sticky=W, padx=(205,5), pady=(10,2))
		self.t.delete(0, END)
		self.t.insert(0, "-80")

		#MIN DURATION SINUSOIDAL TRACKS
		minSineDur_label = "Minimum duration of sinusoidal tracks:"
		Label(self.parent, text=minSineDur_label).grid(row=6, column=0, sticky=W, padx=5, pady=(10,2))
		self.minSineDur = Entry(self.parent, justify=CENTER)
		self.minSineDur["width"] = 5
		self.minSineDur.grid(row=6, column=0, sticky=W, padx=(250,5), pady=(10,2))
		self.minSineDur.delete(0, END)
		self.minSineDur.insert(0, "0.02")

		#MAX NUMBER PARALLEL SINUSOIDS
		maxnSines_label = "Maximum number of parallel sinusoids:"
		Label(self.parent, text=maxnSines_label).grid(row=7, column=0, sticky=W, padx=5, pady=(10,2))
		self.maxnSines = Entry(self.parent, justify=CENTER)
		self.maxnSines["width"] = 5
		self.maxnSines.grid(row=7, column=0, sticky=W, padx=(250,5), pady=(10,2))
		self.maxnSines.delete(0, END)
		self.maxnSines.insert(0, "150")

		#FREQUENCY DEVIATION ALLOWED
		freqDevOffset_label = "Max frequency deviation in sinusoidal tracks (at freq 0):"
		Label(self.parent, text=freqDevOffset_label).grid(row=8, column=0, sticky=W, padx=5, pady=(10,2))
		self.freqDevOffset = Entry(self.parent, justify=CENTER)
		self.freqDevOffset["width"] = 5
		self.freqDevOffset.grid(row=8, column=0, sticky=W, padx=(350,5), pady=(10,2))
		self.freqDevOffset.delete(0, END)
		self.freqDevOffset.insert(0, "10")

		#SLOPE OF THE FREQ DEVIATION
		freqDevSlope_label = "Slope of the frequency deviation (as function of freq):"
		Label(self.parent, text=freqDevSlope_label).grid(row=9, column=0, sticky=W, padx=5, pady=(10,2))
		self.freqDevSlope = Entry(self.parent, justify=CENTER)
		self.freqDevSlope["width"] = 5
		self.freqDevSlope.grid(row=9, column=0, sticky=W, padx=(340,5), pady=(10,2))
		self.freqDevSlope.delete(0, END)
		self.freqDevSlope.insert(0, "0.001")

		#BUTTON TO COMPUTE EVERYTHING
		self.compute = Button(self.parent, text="Compute", command=self.compute_model, bg="dark red", fg="white")
		self.compute.grid(row=10, column=0, padx=5, pady=(10,2), sticky=W)


		#BUTTON TO PLAY OUTPUT
		output_label = "Output:"
		Label(self.parent, text=output_label).grid(row=11, column=0, sticky=W, padx=5, pady=(10,15))
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_sineModel.wav'), bg="gray30", fg="white")
		self.output.grid(row=11, column=0, padx=(60,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#5
0
    def initUI(self):

        choose_label = "Input file (.wav, mono and 44100 sampling rate):"
        Label(self.parent, text=choose_label).grid(row=0,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(10, 2))

        #TEXTBOX TO PRINT PATH OF THE SOUND FILE
        self.filelocation = Entry(self.parent)
        self.filelocation.focus_set()
        self.filelocation["width"] = 25
        self.filelocation.grid(row=1, column=0, sticky=W, padx=10)
        self.filelocation.delete(0, END)
        self.filelocation.insert(0, '../../sounds/bendir.wav')

        #BUTTON TO BROWSE SOUND FILE
        self.open_file = Button(
            self.parent, text="Browse...",
            command=self.browse_file)  #see: def browse_file(self)
        self.open_file.grid(row=1, column=0, sticky=W,
                            padx=(220,
                                  6))  #put it beside the filelocation textbox

        #BUTTON TO PREVIEW SOUND FILE
        self.preview = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay(self.filelocation.get()),
            bg="gray30",
            fg="white")
        self.preview.grid(row=1, column=0, sticky=W, padx=(306, 6))

        ## SINE MODEL

        #ANALYSIS WINDOW TYPE
        wtype_label = "Window type:"
        Label(self.parent, text=wtype_label).grid(row=2,
                                                  column=0,
                                                  sticky=W,
                                                  padx=5,
                                                  pady=(10, 2))
        self.w_type = StringVar()
        self.w_type.set("hamming")  # initial value
        window_option = OptionMenu(self.parent, self.w_type, "rectangular",
                                   "hanning", "hamming", "blackman",
                                   "blackmanharris")
        window_option.grid(row=2,
                           column=0,
                           sticky=W,
                           padx=(95, 5),
                           pady=(10, 2))

        #WINDOW SIZE
        M_label = "Window size (M):"
        Label(self.parent, text=M_label).grid(row=3,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.M = Entry(self.parent, justify=CENTER)
        self.M["width"] = 5
        self.M.grid(row=3, column=0, sticky=W, padx=(115, 5), pady=(10, 2))
        self.M.delete(0, END)
        self.M.insert(0, "2001")

        #FFT SIZE
        N_label = "FFT size (N) (power of two bigger than M):"
        Label(self.parent, text=N_label).grid(row=4,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.N = Entry(self.parent, justify=CENTER)
        self.N["width"] = 5
        self.N.grid(row=4, column=0, sticky=W, padx=(270, 5), pady=(10, 2))
        self.N.delete(0, END)
        self.N.insert(0, "2048")

        #THRESHOLD MAGNITUDE
        t_label = "Magnitude threshold (t) (in dB):"
        Label(self.parent, text=t_label).grid(row=5,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.t = Entry(self.parent, justify=CENTER)
        self.t["width"] = 5
        self.t.grid(row=5, column=0, sticky=W, padx=(205, 5), pady=(10, 2))
        self.t.delete(0, END)
        self.t.insert(0, "-80")

        #MIN DURATION SINUSOIDAL TRACKS
        minSineDur_label = "Minimum duration of sinusoidal tracks:"
        Label(self.parent, text=minSineDur_label).grid(row=6,
                                                       column=0,
                                                       sticky=W,
                                                       padx=5,
                                                       pady=(10, 2))
        self.minSineDur = Entry(self.parent, justify=CENTER)
        self.minSineDur["width"] = 5
        self.minSineDur.grid(row=6,
                             column=0,
                             sticky=W,
                             padx=(250, 5),
                             pady=(10, 2))
        self.minSineDur.delete(0, END)
        self.minSineDur.insert(0, "0.02")

        #MAX NUMBER PARALLEL SINUSOIDS
        maxnSines_label = "Maximum number of parallel sinusoids:"
        Label(self.parent, text=maxnSines_label).grid(row=7,
                                                      column=0,
                                                      sticky=W,
                                                      padx=5,
                                                      pady=(10, 2))
        self.maxnSines = Entry(self.parent, justify=CENTER)
        self.maxnSines["width"] = 5
        self.maxnSines.grid(row=7,
                            column=0,
                            sticky=W,
                            padx=(250, 5),
                            pady=(10, 2))
        self.maxnSines.delete(0, END)
        self.maxnSines.insert(0, "150")

        #FREQUENCY DEVIATION ALLOWED
        freqDevOffset_label = "Max frequency deviation in sinusoidal tracks (at freq 0):"
        Label(self.parent, text=freqDevOffset_label).grid(row=8,
                                                          column=0,
                                                          sticky=W,
                                                          padx=5,
                                                          pady=(10, 2))
        self.freqDevOffset = Entry(self.parent, justify=CENTER)
        self.freqDevOffset["width"] = 5
        self.freqDevOffset.grid(row=8,
                                column=0,
                                sticky=W,
                                padx=(350, 5),
                                pady=(10, 2))
        self.freqDevOffset.delete(0, END)
        self.freqDevOffset.insert(0, "10")

        #SLOPE OF THE FREQ DEVIATION
        freqDevSlope_label = "Slope of the frequency deviation (as function of freq):"
        Label(self.parent, text=freqDevSlope_label).grid(row=9,
                                                         column=0,
                                                         sticky=W,
                                                         padx=5,
                                                         pady=(10, 2))
        self.freqDevSlope = Entry(self.parent, justify=CENTER)
        self.freqDevSlope["width"] = 5
        self.freqDevSlope.grid(row=9,
                               column=0,
                               sticky=W,
                               padx=(340, 5),
                               pady=(10, 2))
        self.freqDevSlope.delete(0, END)
        self.freqDevSlope.insert(0, "0.001")

        #BUTTON TO COMPUTE EVERYTHING
        self.compute = Button(self.parent,
                              text="Compute",
                              command=self.compute_model,
                              bg="dark red",
                              fg="white")
        self.compute.grid(row=10, column=0, padx=5, pady=(10, 2), sticky=W)

        #BUTTON TO PLAY OUTPUT
        output_label = "Output:"
        Label(self.parent, text=output_label).grid(row=11,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(10, 15))
        self.output = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay('output_sounds/' + os.path.basename(
                self.filelocation.get())[:-4] + '_sineModel.wav'),
            bg="gray30",
            fg="white")
        self.output.grid(row=11,
                         column=0,
                         padx=(60, 5),
                         pady=(10, 15),
                         sticky=W)

        # define options for opening file
        self.file_opt = options = {}
        options['defaultextension'] = '.wav'
        options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
        options['initialdir'] = '../../sounds/'
        options[
            'title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#6
0
	def initUI(self):

		choose_label = "inputFile:"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 32
		self.filelocation.grid(row=0,column=0, sticky=W, padx=(70, 5), pady=(10,2))
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/mridangam.wav')

		#BUTTON TO BROWSE SOUND FILE
		open_file = Button(self.parent, text="...", command=self.browse_file) #see: def browse_file(self)
		open_file.grid(row=0, column=0, sticky=W, padx=(340, 6), pady=(10,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE
		preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		preview.grid(row=0, column=0, sticky=W, padx=(385,6), pady=(10,2))

		## SINE TRANSFORMATIONS ANALYSIS

		#ANALYSIS WINDOW TYPE
		wtype_label = "window:"
		Label(self.parent, text=wtype_label).grid(row=1, column=0, sticky=W, padx=5, pady=(10,2))
		self.w_type = StringVar()
		self.w_type.set("hamming") # initial value
		window_option = OptionMenu(self.parent, self.w_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window_option.grid(row=1, column=0, sticky=W, padx=(65,5), pady=(10,2))

		#WINDOW SIZE
		M_label = "M:"
		Label(self.parent, text=M_label).grid(row=1, column=0, sticky=W, padx=(180, 5), pady=(10,2))
		self.M = Entry(self.parent, justify=CENTER)
		self.M["width"] = 5
		self.M.grid(row=1,column=0, sticky=W, padx=(200,5), pady=(10,2))
		self.M.delete(0, END)
		self.M.insert(0, "801")

		#FFT SIZE
		N_label = "N:"
		Label(self.parent, text=N_label).grid(row=1, column=0, sticky=W, padx=(255, 5), pady=(10,2))
		self.N = Entry(self.parent, justify=CENTER)
		self.N["width"] = 5
		self.N.grid(row=1,column=0, sticky=W, padx=(275,5), pady=(10,2))
		self.N.delete(0, END)
		self.N.insert(0, "2048")

		#THRESHOLD MAGNITUDE
		t_label = "t:"
		Label(self.parent, text=t_label).grid(row=1, column=0, sticky=W, padx=(330,5), pady=(10,2))
		self.t = Entry(self.parent, justify=CENTER)
		self.t["width"] = 5
		self.t.grid(row=1, column=0, sticky=W, padx=(348,5), pady=(10,2))
		self.t.delete(0, END)
		self.t.insert(0, "-90")

		#MIN DURATION SINUSOIDAL TRACKS
		minSineDur_label = "minSineDur:"
		Label(self.parent, text=minSineDur_label).grid(row=2, column=0, sticky=W, padx=(5, 5), pady=(10,2))
		self.minSineDur = Entry(self.parent, justify=CENTER)
		self.minSineDur["width"] = 5
		self.minSineDur.grid(row=2, column=0, sticky=W, padx=(87,5), pady=(10,2))
		self.minSineDur.delete(0, END)
		self.minSineDur.insert(0, "0.01")

		#MAX NUMBER OF SINES
		maxnSines_label = "maxnSines:"
		Label(self.parent, text=maxnSines_label).grid(row=2, column=0, sticky=W, padx=(145,5), pady=(10,2))
		self.maxnSines = Entry(self.parent, justify=CENTER)
		self.maxnSines["width"] = 5
		self.maxnSines.grid(row=2, column=0, sticky=W, padx=(220,5), pady=(10,2))
		self.maxnSines.delete(0, END)
		self.maxnSines.insert(0, "150")

		#FREQUENCY DEVIATION ALLOWED
		freqDevOffset_label = "freqDevOffset:"
		Label(self.parent, text=freqDevOffset_label).grid(row=2, column=0, sticky=W, padx=(280,5), pady=(10,2))
		self.freqDevOffset = Entry(self.parent, justify=CENTER)
		self.freqDevOffset["width"] = 5
		self.freqDevOffset.grid(row=2, column=0, sticky=W, padx=(372,5), pady=(10,2))
		self.freqDevOffset.delete(0, END)
		self.freqDevOffset.insert(0, "20")

		#SLOPE OF THE FREQUENCY DEVIATION
		freqDevSlope_label = "freqDevSlope:"
		Label(self.parent, text=freqDevSlope_label).grid(row=3, column=0, sticky=W, padx=(5,5), pady=(10,2))
		self.freqDevSlope = Entry(self.parent, justify=CENTER)
		self.freqDevSlope["width"] = 5
		self.freqDevSlope.grid(row=3, column=0, sticky=W, padx=(98,5), pady=(10,2))
		self.freqDevSlope.delete(0, END)
		self.freqDevSlope.insert(0, "0.02")

		#BUTTON TO DO THE ANALYSIS OF THE SOUND
		self.compute = Button(self.parent, text="Analysis/Synthesis", command=self.analysis, bg="dark red", fg="white")
		self.compute.grid(row=4, column=0, padx=5, pady=(10,5), sticky=W)
		
		#BUTTON TO PLAY ANALYSIS/SYNTHESIS OUTPUT
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_sineModel.wav'), bg="gray30", fg="white")
		self.output.grid(row=4, column=0, padx=(145,5), pady=(10,5), sticky=W)

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=5, pady=5, sticky=W+E)
		###

		#FREQUENCY SCALING FACTORS
		freqScaling_label = "Frequency scaling factors (time, value pairs):"
		Label(self.parent, text=freqScaling_label).grid(row=6, column=0, sticky=W, padx=5, pady=(5,2))
		self.freqScaling = Entry(self.parent, justify=CENTER)
		self.freqScaling["width"] = 35
		self.freqScaling.grid(row=7, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.freqScaling.delete(0, END)
		self.freqScaling.insert(0, "[0, 2.0, 1, .3]")

		#TIME SCALING FACTORS
		timeScaling_label = "Time scaling factors (in time, value pairs):"
		Label(self.parent, text=timeScaling_label).grid(row=8, column=0, sticky=W, padx=5, pady=(5,2))
		self.timeScaling = Entry(self.parent, justify=CENTER)
		self.timeScaling["width"] = 35
		self.timeScaling.grid(row=9, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.timeScaling.delete(0, END)
		self.timeScaling.insert(0, "[0, .0, .671, .671, 1.978, 1.978+1.0]")

		#BUTTON TO DO THE SYNTHESIS
		self.compute = Button(self.parent, text="Apply Transformation", command=self.transformation_synthesis, bg="dark green", fg="white")
		self.compute.grid(row=13, column=0, padx=5, pady=(10,15), sticky=W)

		#BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
		self.transf_output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_sineModelTransformation.wav'), bg="gray30", fg="white")
		self.transf_output.grid(row=13, column=0, padx=(165,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
    def initUI(self):

        ## INPUT FILE 1
        choose1_label = "inputFile1:"
        Label(self.parent, text=choose1_label).grid(row=0,
                                                    column=0,
                                                    sticky=W,
                                                    padx=5,
                                                    pady=(10, 2))

        #TEXTBOX TO PRINT PATH OF THE SOUND FILE
        self.filelocation1 = Entry(self.parent)
        self.filelocation1.focus_set()
        self.filelocation1["width"] = 30
        self.filelocation1.grid(row=0,
                                column=0,
                                sticky=W,
                                padx=(75, 5),
                                pady=(10, 2))
        self.filelocation1.delete(0, END)
        self.filelocation1.insert(0, '../../sounds/violin-B3.wav')

        #BUTTON TO BROWSE SOUND FILE 1
        open_file1 = Button(
            self.parent, text="...",
            command=self.browse_file1)  #see: def browse_file(self)
        open_file1.grid(row=0, column=0, sticky=W, padx=(330, 6),
                        pady=(10, 2))  #put it beside the filelocation textbox

        #BUTTON TO PREVIEW SOUND FILE 1
        preview1 = Button(self.parent,
                          text=">",
                          command=lambda: UF.wavplay(self.filelocation1.get()),
                          bg="gray30",
                          fg="white")
        preview1.grid(row=0, column=0, sticky=W, padx=(375, 6), pady=(10, 2))

        #ANALYSIS WINDOW TYPE SOUND 1
        wtype1_label = "window1:"
        Label(self.parent, text=wtype1_label).grid(row=1,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(4, 2))
        self.w1_type = StringVar()
        self.w1_type.set("blackman")  # initial value
        window1_option = OptionMenu(self.parent, self.w1_type, "rectangular",
                                    "hanning", "hamming", "blackman",
                                    "blackmanharris")
        window1_option.grid(row=1,
                            column=0,
                            sticky=W,
                            padx=(68, 5),
                            pady=(4, 2))

        #WINDOW SIZE SOUND 1
        M1_label = "M1:"
        Label(self.parent, text=M1_label).grid(row=1,
                                               column=0,
                                               sticky=W,
                                               padx=(180, 5),
                                               pady=(4, 2))
        self.M1 = Entry(self.parent, justify=CENTER)
        self.M1["width"] = 5
        self.M1.grid(row=1, column=0, sticky=W, padx=(208, 5), pady=(4, 2))
        self.M1.delete(0, END)
        self.M1.insert(0, "1001")

        #FFT SIZE SOUND 1
        N1_label = "N1:"
        Label(self.parent, text=N1_label).grid(row=1,
                                               column=0,
                                               sticky=W,
                                               padx=(265, 5),
                                               pady=(4, 2))
        self.N1 = Entry(self.parent, justify=CENTER)
        self.N1["width"] = 5
        self.N1.grid(row=1, column=0, sticky=W, padx=(290, 5), pady=(4, 2))
        self.N1.delete(0, END)
        self.N1.insert(0, "1024")

        #THRESHOLD MAGNITUDE SOUND 1
        t1_label = "t1:"
        Label(self.parent, text=t1_label).grid(row=1,
                                               column=0,
                                               sticky=W,
                                               padx=(343, 5),
                                               pady=(4, 2))
        self.t1 = Entry(self.parent, justify=CENTER)
        self.t1["width"] = 5
        self.t1.grid(row=1, column=0, sticky=W, padx=(370, 5), pady=(4, 2))
        self.t1.delete(0, END)
        self.t1.insert(0, "-100")

        #MIN DURATION SINUSOIDAL TRACKS SOUND 1
        minSineDur1_label = "minSineDur1:"
        Label(self.parent, text=minSineDur1_label).grid(row=2,
                                                        column=0,
                                                        sticky=W,
                                                        padx=(5, 5),
                                                        pady=(4, 2))
        self.minSineDur1 = Entry(self.parent, justify=CENTER)
        self.minSineDur1["width"] = 5
        self.minSineDur1.grid(row=2,
                              column=0,
                              sticky=W,
                              padx=(92, 5),
                              pady=(4, 2))
        self.minSineDur1.delete(0, END)
        self.minSineDur1.insert(0, "0.05")

        #MIN FUNDAMENTAL FREQUENCY SOUND 1
        minf01_label = "minf01:"
        Label(self.parent, text=minf01_label).grid(row=2,
                                                   column=0,
                                                   sticky=W,
                                                   padx=(157, 5),
                                                   pady=(4, 2))
        self.minf01 = Entry(self.parent, justify=CENTER)
        self.minf01["width"] = 5
        self.minf01.grid(row=2, column=0, sticky=W, padx=(208, 5), pady=(4, 2))
        self.minf01.delete(0, END)
        self.minf01.insert(0, "200")

        #MAX FUNDAMENTAL FREQUENCY SOUND 1
        maxf01_label = "maxf01:"
        Label(self.parent, text=maxf01_label).grid(row=2,
                                                   column=0,
                                                   sticky=W,
                                                   padx=(270, 5),
                                                   pady=(4, 2))
        self.maxf01 = Entry(self.parent, justify=CENTER)
        self.maxf01["width"] = 5
        self.maxf01.grid(row=2, column=0, sticky=W, padx=(325, 5), pady=(4, 2))
        self.maxf01.delete(0, END)
        self.maxf01.insert(0, "300")

        #MAX ERROR ACCEPTED SOUND 1
        f0et1_label = "f0et1:"
        Label(self.parent, text=f0et1_label).grid(row=3,
                                                  column=0,
                                                  sticky=W,
                                                  padx=5,
                                                  pady=(4, 2))
        self.f0et1 = Entry(self.parent, justify=CENTER)
        self.f0et1["width"] = 3
        self.f0et1.grid(row=3, column=0, sticky=W, padx=(45, 5), pady=(4, 2))
        self.f0et1.delete(0, END)
        self.f0et1.insert(0, "10")

        #ALLOWED DEVIATION OF HARMONIC TRACKS SOUND 1
        harmDevSlope1_label = "harmDevSlope1:"
        Label(self.parent, text=harmDevSlope1_label).grid(row=3,
                                                          column=0,
                                                          sticky=W,
                                                          padx=(108, 5),
                                                          pady=(4, 2))
        self.harmDevSlope1 = Entry(self.parent, justify=CENTER)
        self.harmDevSlope1["width"] = 5
        self.harmDevSlope1.grid(row=3,
                                column=0,
                                sticky=W,
                                padx=(215, 5),
                                pady=(4, 2))
        self.harmDevSlope1.delete(0, END)
        self.harmDevSlope1.insert(0, "0.01")

        ###
        #SEPARATION LINE
        Frame(self.parent, height=1, width=50, bg="black").grid(row=4,
                                                                pady=5,
                                                                sticky=W + E)
        ###

        ## INPUT FILE 2
        choose2_label = "inputFile2:"
        Label(self.parent, text=choose2_label).grid(row=5,
                                                    column=0,
                                                    sticky=W,
                                                    padx=5,
                                                    pady=(2, 2))

        #TEXTBOX TO PRINT PATH OF THE SOUND FILE
        self.filelocation2 = Entry(self.parent)
        self.filelocation2.focus_set()
        self.filelocation2["width"] = 30
        self.filelocation2.grid(row=5,
                                column=0,
                                sticky=W,
                                padx=(75, 5),
                                pady=(2, 2))
        self.filelocation2.delete(0, END)
        self.filelocation2.insert(0, '../../sounds/soprano-E4.wav')

        #BUTTON TO BROWSE SOUND FILE 2
        open_file2 = Button(
            self.parent, text="...",
            command=self.browse_file2)  #see: def browse_file(self)
        open_file2.grid(row=5, column=0, sticky=W, padx=(330, 6),
                        pady=(2, 2))  #put it beside the filelocation textbox

        #BUTTON TO PREVIEW SOUND FILE 2
        preview2 = Button(self.parent,
                          text=">",
                          command=lambda: UF.wavplay(self.filelocation2.get()),
                          bg="gray30",
                          fg="white")
        preview2.grid(row=5, column=0, sticky=W, padx=(375, 6), pady=(2, 2))

        #ANALYSIS WINDOW TYPE SOUND 2
        wtype2_label = "window2:"
        Label(self.parent, text=wtype2_label).grid(row=6,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(4, 2))
        self.w2_type = StringVar()
        self.w2_type.set("hamming")  # initial value
        window2_option = OptionMenu(self.parent, self.w2_type, "rectangular",
                                    "hanning", "hamming", "blackman",
                                    "blackmanharris")
        window2_option.grid(row=6,
                            column=0,
                            sticky=W,
                            padx=(68, 5),
                            pady=(4, 2))

        #WINDOW SIZE SOUND 2
        M2_label = "M2:"
        Label(self.parent, text=M2_label).grid(row=6,
                                               column=0,
                                               sticky=W,
                                               padx=(180, 5),
                                               pady=(4, 2))
        self.M2 = Entry(self.parent, justify=CENTER)
        self.M2["width"] = 5
        self.M2.grid(row=6, column=0, sticky=W, padx=(208, 5), pady=(4, 2))
        self.M2.delete(0, END)
        self.M2.insert(0, "901")

        #FFT SIZE SOUND 2
        N2_label = "N2:"
        Label(self.parent, text=N2_label).grid(row=6,
                                               column=0,
                                               sticky=W,
                                               padx=(265, 5),
                                               pady=(4, 2))
        self.N2 = Entry(self.parent, justify=CENTER)
        self.N2["width"] = 5
        self.N2.grid(row=6, column=0, sticky=W, padx=(290, 5), pady=(4, 2))
        self.N2.delete(0, END)
        self.N2.insert(0, "1024")

        #THRESHOLD MAGNITUDE SOUND 2
        t2_label = "t2:"
        Label(self.parent, text=t2_label).grid(row=6,
                                               column=0,
                                               sticky=W,
                                               padx=(343, 5),
                                               pady=(4, 2))
        self.t2 = Entry(self.parent, justify=CENTER)
        self.t2["width"] = 5
        self.t2.grid(row=6, column=0, sticky=W, padx=(370, 5), pady=(4, 2))
        self.t2.delete(0, END)
        self.t2.insert(0, "-100")

        #MIN DURATION SINUSOIDAL TRACKS SOUND 2
        minSineDur2_label = "minSineDur2:"
        Label(self.parent, text=minSineDur2_label).grid(row=7,
                                                        column=0,
                                                        sticky=W,
                                                        padx=(5, 5),
                                                        pady=(4, 2))
        self.minSineDur2 = Entry(self.parent, justify=CENTER)
        self.minSineDur2["width"] = 5
        self.minSineDur2.grid(row=7,
                              column=0,
                              sticky=W,
                              padx=(92, 5),
                              pady=(4, 2))
        self.minSineDur2.delete(0, END)
        self.minSineDur2.insert(0, "0.05")

        #MIN FUNDAMENTAL FREQUENCY SOUND 2
        minf02_label = "minf02:"
        Label(self.parent, text=minf02_label).grid(row=7,
                                                   column=0,
                                                   sticky=W,
                                                   padx=(157, 5),
                                                   pady=(4, 2))
        self.minf02 = Entry(self.parent, justify=CENTER)
        self.minf02["width"] = 5
        self.minf02.grid(row=7, column=0, sticky=W, padx=(208, 5), pady=(4, 2))
        self.minf02.delete(0, END)
        self.minf02.insert(0, "250")

        #MAX FUNDAMENTAL FREQUENCY SOUND 2
        maxf02_label = "maxf02:"
        Label(self.parent, text=maxf02_label).grid(row=7,
                                                   column=0,
                                                   sticky=W,
                                                   padx=(270, 5),
                                                   pady=(4, 2))
        self.maxf02 = Entry(self.parent, justify=CENTER)
        self.maxf02["width"] = 5
        self.maxf02.grid(row=7, column=0, sticky=W, padx=(325, 5), pady=(4, 2))
        self.maxf02.delete(0, END)
        self.maxf02.insert(0, "500")

        #MAX ERROR ACCEPTED SOUND 2
        f0et2_label = "f0et2:"
        Label(self.parent, text=f0et2_label).grid(row=8,
                                                  column=0,
                                                  sticky=W,
                                                  padx=5,
                                                  pady=(4, 2))
        self.f0et2 = Entry(self.parent, justify=CENTER)
        self.f0et2["width"] = 3
        self.f0et2.grid(row=8, column=0, sticky=W, padx=(45, 5), pady=(4, 2))
        self.f0et2.delete(0, END)
        self.f0et2.insert(0, "10")

        #ALLOWED DEVIATION OF HARMONIC TRACKS SOUND 2
        harmDevSlope2_label = "harmDevSlope2:"
        Label(self.parent, text=harmDevSlope2_label).grid(row=8,
                                                          column=0,
                                                          sticky=W,
                                                          padx=(108, 5),
                                                          pady=(4, 2))
        self.harmDevSlope2 = Entry(self.parent, justify=CENTER)
        self.harmDevSlope2["width"] = 5
        self.harmDevSlope2.grid(row=8,
                                column=0,
                                sticky=W,
                                padx=(215, 5),
                                pady=(4, 2))
        self.harmDevSlope2.delete(0, END)
        self.harmDevSlope2.insert(0, "0.01")

        ###
        #SEPARATION LINE
        Frame(self.parent, height=1, width=50, bg="black").grid(row=9,
                                                                pady=5,
                                                                sticky=W + E)
        ###

        #MAX NUMBER OF HARMONICS SOUND 1
        nH_label = "nH:"
        Label(self.parent, text=nH_label).grid(row=10,
                                               column=0,
                                               sticky=W,
                                               padx=(5, 5),
                                               pady=(2, 2))
        self.nH = Entry(self.parent, justify=CENTER)
        self.nH["width"] = 5
        self.nH.grid(row=10, column=0, sticky=W, padx=(35, 5), pady=(2, 2))
        self.nH.delete(0, END)
        self.nH.insert(0, "60")

        #DECIMATION FACTOR SOUND 1
        stocf_label = "stocf:"
        Label(self.parent, text=stocf_label).grid(row=10,
                                                  column=0,
                                                  sticky=W,
                                                  padx=(98, 5),
                                                  pady=(2, 2))
        self.stocf = Entry(self.parent, justify=CENTER)
        self.stocf["width"] = 5
        self.stocf.grid(row=10, column=0, sticky=W, padx=(138, 5), pady=(2, 2))
        self.stocf.delete(0, END)
        self.stocf.insert(0, "0.1")

        #BUTTON TO DO THE ANALYSIS OF THE SOUND
        self.compute = Button(self.parent,
                              text="Analysis",
                              command=self.analysis,
                              bg="dark red",
                              fg="white")
        self.compute.grid(row=10,
                          column=0,
                          padx=(210, 5),
                          pady=(2, 2),
                          sticky=W)

        ###
        #SEPARATION LINE
        Frame(self.parent, height=1, width=50, bg="black").grid(row=11,
                                                                pady=5,
                                                                sticky=W + E)
        ###

        #
        hfreqIntp_label = "harmonic frequencies interpolation factors, 0 to 1 (time,value pairs)"
        Label(self.parent, text=hfreqIntp_label).grid(row=12,
                                                      column=0,
                                                      sticky=W,
                                                      padx=5,
                                                      pady=(2, 2))
        self.hfreqIntp = Entry(self.parent, justify=CENTER)
        self.hfreqIntp["width"] = 35
        self.hfreqIntp.grid(row=13,
                            column=0,
                            sticky=W + E,
                            padx=5,
                            pady=(0, 2))
        self.hfreqIntp.delete(0, END)
        self.hfreqIntp.insert(0, "[0, 0, .1, 0, .9, 1, 1, 1]")

        #
        hmagIntp_label = "harmonic magnitudes interpolation factors, 0 to 1 (time,value pairs)"
        Label(self.parent, text=hmagIntp_label).grid(row=14,
                                                     column=0,
                                                     sticky=W,
                                                     padx=5,
                                                     pady=(5, 2))
        self.hmagIntp = Entry(self.parent, justify=CENTER)
        self.hmagIntp["width"] = 35
        self.hmagIntp.grid(row=15, column=0, sticky=W + E, padx=5, pady=(0, 2))
        self.hmagIntp.delete(0, END)
        self.hmagIntp.insert(0, "[0, 0, .1, 0, .9, 1, 1, 1]")

        #
        stocIntp_label = "stochastic component interpolation factors, 0 to 1 (time,value pairs)"
        Label(self.parent, text=stocIntp_label).grid(row=16,
                                                     column=0,
                                                     sticky=W,
                                                     padx=5,
                                                     pady=(5, 2))
        self.stocIntp = Entry(self.parent, justify=CENTER)
        self.stocIntp["width"] = 35
        self.stocIntp.grid(row=17, column=0, sticky=W + E, padx=5, pady=(0, 2))
        self.stocIntp.delete(0, END)
        self.stocIntp.insert(0, "[0, 0, .1, 0, .9, 1, 1, 1]")

        #BUTTON TO DO THE SYNTHESIS
        self.compute = Button(self.parent,
                              text="Apply Transformation",
                              command=self.transformation_synthesis,
                              bg="dark green",
                              fg="white")
        self.compute.grid(row=18, column=0, padx=5, pady=(10, 15), sticky=W)

        #BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
        self.transf_output = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay('output_sounds/' + os.path.basename(
                self.filelocation1.get())[:-4] + '_hpsMorph.wav'),
            bg="gray30",
            fg="white")
        self.transf_output.grid(row=18,
                                column=0,
                                padx=(165, 5),
                                pady=(10, 15),
                                sticky=W)

        # define options for opening file
        self.file_opt = options = {}
        options['defaultextension'] = '.wav'
        options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
        options['initialdir'] = '../../sounds/'
        options[
            'title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#8
0
    def initUI(self):

        choose_label = "inputFile:"
        Label(self.parent, text=choose_label).grid(row=0,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(10, 2))

        #TEXTBOX TO PRINT PATH OF THE SOUND FILE
        self.filelocation = Entry(self.parent)
        self.filelocation.focus_set()
        self.filelocation["width"] = 32
        self.filelocation.grid(row=0,
                               column=0,
                               sticky=W,
                               padx=(70, 5),
                               pady=(10, 2))
        self.filelocation.delete(0, END)
        self.filelocation.insert(0, '../../sounds/sax-phrase-short.wav')

        #BUTTON TO BROWSE SOUND FILE
        open_file = Button(
            self.parent, text="...",
            command=self.browse_file)  #see: def browse_file(self)
        open_file.grid(row=0, column=0, sticky=W, padx=(340, 6),
                       pady=(10, 2))  #put it beside the filelocation textbox

        #BUTTON TO PREVIEW SOUND FILE
        preview = Button(self.parent,
                         text=">",
                         command=lambda: UF.wavplay(self.filelocation.get()),
                         bg="gray30",
                         fg="white")
        preview.grid(row=0, column=0, sticky=W, padx=(385, 6), pady=(10, 2))

        ## HPS TRANSFORMATIONS ANALYSIS

        #ANALYSIS WINDOW TYPE
        wtype_label = "window:"
        Label(self.parent, text=wtype_label).grid(row=1,
                                                  column=0,
                                                  sticky=W,
                                                  padx=5,
                                                  pady=(10, 2))
        self.w_type = StringVar()
        self.w_type.set("blackman")  # initial value
        window_option = OptionMenu(self.parent, self.w_type, "rectangular",
                                   "hanning", "hamming", "blackman",
                                   "blackmanharris")
        window_option.grid(row=1,
                           column=0,
                           sticky=W,
                           padx=(65, 5),
                           pady=(10, 2))

        #WINDOW SIZE
        M_label = "M:"
        Label(self.parent, text=M_label).grid(row=1,
                                              column=0,
                                              sticky=W,
                                              padx=(180, 5),
                                              pady=(10, 2))
        self.M = Entry(self.parent, justify=CENTER)
        self.M["width"] = 5
        self.M.grid(row=1, column=0, sticky=W, padx=(200, 5), pady=(10, 2))
        self.M.delete(0, END)
        self.M.insert(0, "601")

        #FFT SIZE
        N_label = "N:"
        Label(self.parent, text=N_label).grid(row=1,
                                              column=0,
                                              sticky=W,
                                              padx=(255, 5),
                                              pady=(10, 2))
        self.N = Entry(self.parent, justify=CENTER)
        self.N["width"] = 5
        self.N.grid(row=1, column=0, sticky=W, padx=(275, 5), pady=(10, 2))
        self.N.delete(0, END)
        self.N.insert(0, "1024")

        #THRESHOLD MAGNITUDE
        t_label = "t:"
        Label(self.parent, text=t_label).grid(row=1,
                                              column=0,
                                              sticky=W,
                                              padx=(330, 5),
                                              pady=(10, 2))
        self.t = Entry(self.parent, justify=CENTER)
        self.t["width"] = 5
        self.t.grid(row=1, column=0, sticky=W, padx=(348, 5), pady=(10, 2))
        self.t.delete(0, END)
        self.t.insert(0, "-100")

        #MIN DURATION SINUSOIDAL TRACKS
        minSineDur_label = "minSineDur:"
        Label(self.parent, text=minSineDur_label).grid(row=2,
                                                       column=0,
                                                       sticky=W,
                                                       padx=(5, 5),
                                                       pady=(10, 2))
        self.minSineDur = Entry(self.parent, justify=CENTER)
        self.minSineDur["width"] = 5
        self.minSineDur.grid(row=2,
                             column=0,
                             sticky=W,
                             padx=(87, 5),
                             pady=(10, 2))
        self.minSineDur.delete(0, END)
        self.minSineDur.insert(0, "0.1")

        #MAX NUMBER OF HARMONICS
        nH_label = "nH:"
        Label(self.parent, text=nH_label).grid(row=2,
                                               column=0,
                                               sticky=W,
                                               padx=(145, 5),
                                               pady=(10, 2))
        self.nH = Entry(self.parent, justify=CENTER)
        self.nH["width"] = 5
        self.nH.grid(row=2, column=0, sticky=W, padx=(172, 5), pady=(10, 2))
        self.nH.delete(0, END)
        self.nH.insert(0, "100")

        #MIN FUNDAMENTAL FREQUENCY
        minf0_label = "minf0:"
        Label(self.parent, text=minf0_label).grid(row=2,
                                                  column=0,
                                                  sticky=W,
                                                  padx=(227, 5),
                                                  pady=(10, 2))
        self.minf0 = Entry(self.parent, justify=CENTER)
        self.minf0["width"] = 5
        self.minf0.grid(row=2, column=0, sticky=W, padx=(275, 5), pady=(10, 2))
        self.minf0.delete(0, END)
        self.minf0.insert(0, "350")

        #MAX FUNDAMENTAL FREQUENCY
        maxf0_label = "maxf0:"
        Label(self.parent, text=maxf0_label).grid(row=2,
                                                  column=0,
                                                  sticky=W,
                                                  padx=(330, 5),
                                                  pady=(10, 2))
        self.maxf0 = Entry(self.parent, justify=CENTER)
        self.maxf0["width"] = 5
        self.maxf0.grid(row=2, column=0, sticky=W, padx=(380, 5), pady=(10, 2))
        self.maxf0.delete(0, END)
        self.maxf0.insert(0, "700")

        #MAX ERROR ACCEPTED
        f0et_label = "f0et:"
        Label(self.parent, text=f0et_label).grid(row=3,
                                                 column=0,
                                                 sticky=W,
                                                 padx=5,
                                                 pady=(10, 2))
        self.f0et = Entry(self.parent, justify=CENTER)
        self.f0et["width"] = 3
        self.f0et.grid(row=3, column=0, sticky=W, padx=(42, 5), pady=(10, 2))
        self.f0et.delete(0, END)
        self.f0et.insert(0, "7")

        #ALLOWED DEVIATION OF HARMONIC TRACKS
        harmDevSlope_label = "harmDevSlope:"
        Label(self.parent, text=harmDevSlope_label).grid(row=3,
                                                         column=0,
                                                         sticky=W,
                                                         padx=(90, 5),
                                                         pady=(10, 2))
        self.harmDevSlope = Entry(self.parent, justify=CENTER)
        self.harmDevSlope["width"] = 5
        self.harmDevSlope.grid(row=3,
                               column=0,
                               sticky=W,
                               padx=(190, 5),
                               pady=(10, 2))
        self.harmDevSlope.delete(0, END)
        self.harmDevSlope.insert(0, "0.01")

        #DECIMATION FACTOR
        stocf_label = "stocf:"
        Label(self.parent, text=stocf_label).grid(row=3,
                                                  column=0,
                                                  sticky=W,
                                                  padx=(250, 5),
                                                  pady=(10, 2))
        self.stocf = Entry(self.parent, justify=CENTER)
        self.stocf["width"] = 5
        self.stocf.grid(row=3, column=0, sticky=W, padx=(290, 5), pady=(10, 2))
        self.stocf.delete(0, END)
        self.stocf.insert(0, "0.1")

        #BUTTON TO DO THE ANALYSIS OF THE SOUND
        self.compute = Button(self.parent,
                              text="Analysis/Synthesis",
                              command=self.analysis,
                              bg="dark red",
                              fg="white")
        self.compute.grid(row=4, column=0, padx=5, pady=(10, 5), sticky=W)

        #BUTTON TO PLAY ANALYSIS/SYNTHESIS OUTPUT
        self.output = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay('output_sounds/' + os.path.basename(
                self.filelocation.get())[:-4] + '_hpsModel.wav'),
            bg="gray30",
            fg="white")
        self.output.grid(row=4,
                         column=0,
                         padx=(145, 5),
                         pady=(10, 5),
                         sticky=W)

        ###
        #SEPARATION LINE
        Frame(self.parent, height=1, width=50, bg="black").grid(row=5,
                                                                pady=5,
                                                                sticky=W + E)
        ###

        #FREQUENCY SCALING FACTORS
        freqScaling_label = "Frequency scaling factors (time, value pairs):"
        Label(self.parent, text=freqScaling_label).grid(row=6,
                                                        column=0,
                                                        sticky=W,
                                                        padx=5,
                                                        pady=(5, 2))
        self.freqScaling = Entry(self.parent, justify=CENTER)
        self.freqScaling["width"] = 35
        self.freqScaling.grid(row=7,
                              column=0,
                              sticky=W + E,
                              padx=5,
                              pady=(0, 2))
        self.freqScaling.delete(0, END)
        self.freqScaling.insert(0, "[0, 1.2, 2.01, 1.2, 2.679, .7, 3.146, .7]")

        #FREQUENCY STRETCHING FACTORS
        freqStretching_label = "Frequency stretching factors (time, value pairs):"
        Label(self.parent, text=freqStretching_label).grid(row=8,
                                                           column=0,
                                                           sticky=W,
                                                           padx=5,
                                                           pady=(5, 2))
        self.freqStretching = Entry(self.parent, justify=CENTER)
        self.freqStretching["width"] = 35
        self.freqStretching.grid(row=9,
                                 column=0,
                                 sticky=W + E,
                                 padx=5,
                                 pady=(0, 2))
        self.freqStretching.delete(0, END)
        self.freqStretching.insert(0,
                                   "[0, 1, 2.01, 1, 2.679, 1.5, 3.146, 1.5]")

        #TIMBRE PRESERVATION
        timbrePreservation_label = "Timbre preservation (1 preserves original timbre, 0 it does not):"
        Label(self.parent, text=timbrePreservation_label).grid(row=10,
                                                               column=0,
                                                               sticky=W,
                                                               padx=5,
                                                               pady=(5, 2))
        self.timbrePreservation = Entry(self.parent, justify=CENTER)
        self.timbrePreservation["width"] = 2
        self.timbrePreservation.grid(row=10,
                                     column=0,
                                     sticky=W + E,
                                     padx=(395, 5),
                                     pady=(5, 2))
        self.timbrePreservation.delete(0, END)
        self.timbrePreservation.insert(0, "1")

        #TIME SCALING FACTORS
        timeScaling_label = "Time scaling factors (time, value pairs):"
        Label(self.parent, text=timeScaling_label).grid(row=11,
                                                        column=0,
                                                        sticky=W,
                                                        padx=5,
                                                        pady=(5, 2))
        self.timeScaling = Entry(self.parent, justify=CENTER)
        self.timeScaling["width"] = 35
        self.timeScaling.grid(row=12,
                              column=0,
                              sticky=W + E,
                              padx=5,
                              pady=(0, 2))
        self.timeScaling.delete(0, END)
        self.timeScaling.insert(0, "[0, 0, 2.138, 2.138-1.0, 3.146, 3.146]")

        #BUTTON TO DO THE SYNTHESIS
        self.compute = Button(self.parent,
                              text="Apply Transformation",
                              command=self.transformation_synthesis,
                              bg="dark green",
                              fg="white")
        self.compute.grid(row=13, column=0, padx=5, pady=(10, 15), sticky=W)

        #BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
        self.transf_output = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay('output_sounds/' + os.path.basename(
                self.filelocation.get())[:-4] + '_hpsModelTransformation.wav'),
            bg="gray30",
            fg="white")
        self.transf_output.grid(row=13,
                                column=0,
                                padx=(165, 5),
                                pady=(10, 15),
                                sticky=W)

        # define options for opening file
        self.file_opt = options = {}
        options['defaultextension'] = '.wav'
        options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
        options['initialdir'] = '../../sounds/'
        options[
            'title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#9
0
	def initUI(self):

		choose_label = "Input file (.wav, mono and 44100 sampling rate):"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 25
		self.filelocation.grid(row=1,column=0, sticky=W, padx=10)
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/sax-phrase-short.wav')

		#BUTTON TO BROWSE SOUND FILE
		self.open_file = Button(self.parent, text="Browse...", command=self.browse_file) #see: def browse_file(self)
		self.open_file.grid(row=1, column=0, sticky=W, padx=(220, 6)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE
		self.preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		self.preview.grid(row=1, column=0, sticky=W, padx=(306,6))

		## HARMONIC MODEL

		#ANALYSIS WINDOW TYPE
		wtype_label = "Window type:"
		Label(self.parent, text=wtype_label).grid(row=2, column=0, sticky=W, padx=5, pady=(10,2))
		self.w_type = StringVar()
		self.w_type.set("blackman") # initial value
		window_option = OptionMenu(self.parent, self.w_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window_option.grid(row=2, column=0, sticky=W, padx=(95,5), pady=(10,2))

		#WINDOW SIZE
		M_label = "Window size (M):"
		Label(self.parent, text=M_label).grid(row=3, column=0, sticky=W, padx=5, pady=(10,2))
		self.M = Entry(self.parent, justify=CENTER)
		self.M["width"] = 5
		self.M.grid(row=3,column=0, sticky=W, padx=(115,5), pady=(10,2))
		self.M.delete(0, END)
		self.M.insert(0, "601")

		#FFT SIZE
		N_label = "FFT size (N) (power of two bigger than M):"
		Label(self.parent, text=N_label).grid(row=4, column=0, sticky=W, padx=5, pady=(10,2))
		self.N = Entry(self.parent, justify=CENTER)
		self.N["width"] = 5
		self.N.grid(row=4,column=0, sticky=W, padx=(270,5), pady=(10,2))
		self.N.delete(0, END)
		self.N.insert(0, "1024")

		#THRESHOLD MAGNITUDE
		t_label = "Magnitude threshold (t) (in dB):"
		Label(self.parent, text=t_label).grid(row=5, column=0, sticky=W, padx=5, pady=(10,2))
		self.t = Entry(self.parent, justify=CENTER)
		self.t["width"] = 5
		self.t.grid(row=5, column=0, sticky=W, padx=(205,5), pady=(10,2))
		self.t.delete(0, END)
		self.t.insert(0, "-100")

		#MIN DURATION SINUSOIDAL TRACKS
		minSineDur_label = "Minimum duration of harmonic tracks:"
		Label(self.parent, text=minSineDur_label).grid(row=6, column=0, sticky=W, padx=5, pady=(10,2))
		self.minSineDur = Entry(self.parent, justify=CENTER)
		self.minSineDur["width"] = 5
		self.minSineDur.grid(row=6, column=0, sticky=W, padx=(250,5), pady=(10,2))
		self.minSineDur.delete(0, END)
		self.minSineDur.insert(0, "0.1")

		#MAX NUMBER OF HARMONICS
		nH_label = "Maximum number of harmonics:"
		Label(self.parent, text=nH_label).grid(row=7, column=0, sticky=W, padx=5, pady=(10,2))
		self.nH = Entry(self.parent, justify=CENTER)
		self.nH["width"] = 5
		self.nH.grid(row=7, column=0, sticky=W, padx=(215,5), pady=(10,2))
		self.nH.delete(0, END)
		self.nH.insert(0, "100")

		#MIN FUNDAMENTAL FREQUENCY
		minf0_label = "Minimum fundamental frequency:"
		Label(self.parent, text=minf0_label).grid(row=8, column=0, sticky=W, padx=5, pady=(10,2))
		self.minf0 = Entry(self.parent, justify=CENTER)
		self.minf0["width"] = 5
		self.minf0.grid(row=8, column=0, sticky=W, padx=(220,5), pady=(10,2))
		self.minf0.delete(0, END)
		self.minf0.insert(0, "350")

		#MAX FUNDAMENTAL FREQUENCY
		maxf0_label = "Maximum fundamental frequency:"
		Label(self.parent, text=maxf0_label).grid(row=9, column=0, sticky=W, padx=5, pady=(10,2))
		self.maxf0 = Entry(self.parent, justify=CENTER)
		self.maxf0["width"] = 5
		self.maxf0.grid(row=9, column=0, sticky=W, padx=(220,5), pady=(10,2))
		self.maxf0.delete(0, END)
		self.maxf0.insert(0, "700")

		#MAX ERROR ACCEPTED
		f0et_label = "Maximum error in f0 detection algorithm:"
		Label(self.parent, text=f0et_label).grid(row=10, column=0, sticky=W, padx=5, pady=(10,2))
		self.f0et = Entry(self.parent, justify=CENTER)
		self.f0et["width"] = 5
		self.f0et.grid(row=10, column=0, sticky=W, padx=(265,5), pady=(10,2))
		self.f0et.delete(0, END)
		self.f0et.insert(0, "5")

		#ALLOWED DEVIATION OF HARMONIC TRACKS
		harmDevSlope_label = "Max frequency deviation in harmonic tracks:"
		Label(self.parent, text=harmDevSlope_label).grid(row=11, column=0, sticky=W, padx=5, pady=(10,2))
		self.harmDevSlope = Entry(self.parent, justify=CENTER)
		self.harmDevSlope["width"] = 5
		self.harmDevSlope.grid(row=11, column=0, sticky=W, padx=(285,5), pady=(10,2))
		self.harmDevSlope.delete(0, END)
		self.harmDevSlope.insert(0, "0.01")

		#BUTTON TO COMPUTE EVERYTHING
		self.compute = Button(self.parent, text="Compute", command=self.compute_model, bg="dark red", fg="white")
		self.compute.grid(row=12, column=0, padx=5, pady=(10,2), sticky=W)

		#BUTTON TO PLAY SINE OUTPUT
		output_label = "Sinusoidal:"
		Label(self.parent, text=output_label).grid(row=13, column=0, sticky=W, padx=5, pady=(10,0))
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_hprModel_sines.wav'), bg="gray30", fg="white")
		self.output.grid(row=13, column=0, padx=(80,5), pady=(10,0), sticky=W)

		#BUTTON TO PLAY RESIDUAL OUTPUT
		output_label = "Residual:"
		Label(self.parent, text=output_label).grid(row=14, column=0, sticky=W, padx=5, pady=(5,0))
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_hprModel_residual.wav'), bg="gray30", fg="white")
		self.output.grid(row=14, column=0, padx=(80,5), pady=(5,0), sticky=W)

		#BUTTON TO PLAY OUTPUT
		output_label = "Output:"
		Label(self.parent, text=output_label).grid(row=15, column=0, sticky=W, padx=5, pady=(5,15))
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_hprModel.wav'), bg="gray30", fg="white")
		self.output.grid(row=15, column=0, padx=(80,5), pady=(5,15), sticky=W)


		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#10
0
    def initUI(self):

        choose_label = "Input file (.wav, mono and 44100 sampling rate):"
        Label(self.parent, text=choose_label).grid(row=0,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(10, 2))

        #TEXTBOX TO PRINT PATH OF THE SOUND FILE
        self.filelocation = Entry(self.parent)
        self.filelocation.focus_set()
        self.filelocation["width"] = 25
        self.filelocation.grid(row=1, column=0, sticky=W, padx=10)
        self.filelocation.delete(0, END)
        self.filelocation.insert(0, '../../sounds/ocean.wav')

        #BUTTON TO BROWSE SOUND FILE
        self.open_file = Button(
            self.parent, text="Browse...",
            command=self.browse_file)  #see: def browse_file(self)
        self.open_file.grid(row=1, column=0, sticky=W,
                            padx=(220,
                                  6))  #put it beside the filelocation textbox

        #BUTTON TO PREVIEW SOUND FILE
        self.preview = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay(self.filelocation.get()),
            bg="gray30",
            fg="white")
        self.preview.grid(row=1, column=0, sticky=W, padx=(306, 6))

        ## STOCHASTIC MODEL

        #HOP SIZE
        H_label = "Hop size (H):"
        Label(self.parent, text=H_label).grid(row=2,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.H = Entry(self.parent, justify=CENTER)
        self.H["width"] = 5
        self.H.grid(row=2, column=0, sticky=W, padx=(90, 5), pady=(10, 2))
        self.H.delete(0, END)
        self.H.insert(0, "256")

        #FFT size
        N_label = "FFT size (N):"
        Label(self.parent, text=N_label).grid(row=3,
                                              column=0,
                                              sticky=W,
                                              padx=5,
                                              pady=(10, 2))
        self.N = Entry(self.parent, justify=CENTER)
        self.N["width"] = 5
        self.N.grid(row=3, column=0, sticky=W, padx=(90, 5), pady=(10, 2))
        self.N.delete(0, END)
        self.N.insert(0, "512")

        #DECIMATION FACTOR
        stocf_label = "Decimation factor (bigger than 0, max of 1):"
        Label(self.parent, text=stocf_label).grid(row=4,
                                                  column=0,
                                                  sticky=W,
                                                  padx=5,
                                                  pady=(10, 2))
        self.stocf = Entry(self.parent, justify=CENTER)
        self.stocf["width"] = 5
        self.stocf.grid(row=4, column=0, sticky=W, padx=(285, 5), pady=(10, 2))
        self.stocf.delete(0, END)
        self.stocf.insert(0, "0.1")

        #BUTTON TO COMPUTE EVERYTHING
        self.compute = Button(self.parent,
                              text="Compute",
                              command=self.compute_model,
                              bg="dark red",
                              fg="white")
        self.compute.grid(row=5, column=0, padx=5, pady=(10, 2), sticky=W)

        #BUTTON TO PLAY OUTPUT
        output_label = "Stochastic:"
        Label(self.parent, text=output_label).grid(row=6,
                                                   column=0,
                                                   sticky=W,
                                                   padx=5,
                                                   pady=(10, 15))
        self.output = Button(
            self.parent,
            text=">",
            command=lambda: UF.wavplay('output_sounds/' + os.path.basename(
                self.filelocation.get())[:-4] + '_stochasticModel.wav'),
            bg="gray30",
            fg="white")
        self.output.grid(row=6,
                         column=0,
                         padx=(80, 5),
                         pady=(10, 15),
                         sticky=W)

        # define options for opening file
        self.file_opt = options = {}
        options['defaultextension'] = '.wav'
        options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
        options['initialdir'] = '../../sounds/'
        options[
            'title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#11
0
	def initUI(self):

		## INPUT FILE 1
		choose1_label = "inputFile1:"
		Label(self.parent, text=choose1_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation1 = Entry(self.parent)
		self.filelocation1.focus_set()
		self.filelocation1["width"] = 30
		self.filelocation1.grid(row=0,column=0, sticky=W, padx=(75, 5), pady=(10,2))
		self.filelocation1.delete(0, END)
		self.filelocation1.insert(0, '../../sounds/ocean.wav')

		#BUTTON TO BROWSE SOUND FILE 1
		open_file1 = Button(self.parent, text="...", command=self.browse_file1) #see: def browse_file(self)
		open_file1.grid(row=0, column=0, sticky=W, padx=(330, 6), pady=(10,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE 1
		preview1 = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation1.get()), bg="gray30", fg="white")
		preview1.grid(row=0, column=0, sticky=W, padx=(375,6), pady=(10,2))
		
		#ANALYSIS WINDOW TYPE SOUND 1
		wtype1_label = "window1:"
		Label(self.parent, text=wtype1_label).grid(row=1, column=0, sticky=W, padx=5, pady=(4,2))
		self.w1_type = StringVar()
		self.w1_type.set("hamming") # initial value
		window1_option = OptionMenu(self.parent, self.w1_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window1_option.grid(row=1, column=0, sticky=W, padx=(68,5), pady=(4,2))

		#WINDOW SIZE SOUND 1
		M1_label = "M1:"
		Label(self.parent, text=M1_label).grid(row=1, column=0, sticky=W, padx=(180, 5), pady=(4,2))
		self.M1 = Entry(self.parent, justify=CENTER)
		self.M1["width"] = 5
		self.M1.grid(row=1,column=0, sticky=W, padx=(208,5), pady=(4,2))
		self.M1.delete(0, END)
		self.M1.insert(0, "1024")

		#FFT SIZE SOUND 1
		N1_label = "N1:"
		Label(self.parent, text=N1_label).grid(row=1, column=0, sticky=W, padx=(265, 5), pady=(4,2))
		self.N1 = Entry(self.parent, justify=CENTER)
		self.N1["width"] = 5
		self.N1.grid(row=1,column=0, sticky=W, padx=(290,5), pady=(4,2))
		self.N1.delete(0, END)
		self.N1.insert(0, "1024")

		#HOP SIZE SOUND 1
		H1_label = "H1:"
		Label(self.parent, text=H1_label).grid(row=1, column=0, sticky=W, padx=(343,5), pady=(4,2))
		self.H1 = Entry(self.parent, justify=CENTER)
		self.H1["width"] = 5
		self.H1.grid(row=1, column=0, sticky=W, padx=(370,5), pady=(4,2))
		self.H1.delete(0, END)
		self.H1.insert(0, "256")

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=2, pady=15, sticky=W+E)
		###

		## INPUT FILE 2
		choose2_label = "inputFile2:"
		Label(self.parent, text=choose2_label).grid(row=3, column=0, sticky=W, padx=5, pady=(2,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation2 = Entry(self.parent)
		self.filelocation2.focus_set()
		self.filelocation2["width"] = 30
		self.filelocation2.grid(row=3,column=0, sticky=W, padx=(75, 5), pady=(2,2))
		self.filelocation2.delete(0, END)
		self.filelocation2.insert(0, '../../sounds/speech-male.wav')

		#BUTTON TO BROWSE SOUND FILE 2
		open_file2 = Button(self.parent, text="...", command=self.browse_file2) #see: def browse_file(self)
		open_file2.grid(row=3, column=0, sticky=W, padx=(330, 6), pady=(2,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE 2
		preview2 = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation2.get()), bg="gray30", fg="white")
		preview2.grid(row=3, column=0, sticky=W, padx=(375,6), pady=(2,2))


		#ANALYSIS WINDOW TYPE SOUND 2
		wtype2_label = "window2:"
		Label(self.parent, text=wtype2_label).grid(row=4, column=0, sticky=W, padx=5, pady=(4,2))
		self.w2_type = StringVar()
		self.w2_type.set("hamming") # initial value
		window2_option = OptionMenu(self.parent, self.w2_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window2_option.grid(row=4, column=0, sticky=W, padx=(68,5), pady=(4,2))

		#WINDOW SIZE SOUND 2
		M2_label = "M2:"
		Label(self.parent, text=M2_label).grid(row=4, column=0, sticky=W, padx=(180, 5), pady=(4,2))
		self.M2 = Entry(self.parent, justify=CENTER)
		self.M2["width"] = 5
		self.M2.grid(row=4,column=0, sticky=W, padx=(208,5), pady=(4,2))
		self.M2.delete(0, END)
		self.M2.insert(0, "1024")

		#FFT SIZE SOUND 2
		N2_label = "N2:"
		Label(self.parent, text=N2_label).grid(row=4, column=0, sticky=W, padx=(265, 5), pady=(4,2))
		self.N2 = Entry(self.parent, justify=CENTER)
		self.N2["width"] = 5
		self.N2.grid(row=4,column=0, sticky=W, padx=(290,5), pady=(4,2))
		self.N2.delete(0, END)
		self.N2.insert(0, "1024")

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=5, pady=15, sticky=W+E)
		###

		#SMOOTHING FACTOR
		smoothf_label1 = "Smooth factor of sound 2 (bigger than 0 to max of 1, where 1 is no"
		Label(self.parent, text=smoothf_label1).grid(row=6, column=0, sticky=W, padx=(5, 5), pady=(2,2))
		smoothf_label2 = "smothing):"
		Label(self.parent, text=smoothf_label2).grid(row=7, column=0, sticky=W, padx=(5, 5), pady=(0,2))
		self.smoothf = Entry(self.parent, justify=CENTER)
		self.smoothf["width"] = 5
		self.smoothf.grid(row=8, column=0, sticky=W, padx=(5,5), pady=(2,2))
		self.smoothf.delete(0, END)
		self.smoothf.insert(0, "0.5")

		#BALANCE FACTOR
		balancef_label = "Balance factor (from 0 to 1, where 0 is sound 1 and 1 is sound 2):"
		Label(self.parent, text=balancef_label).grid(row=9, column=0, sticky=W, padx=(5,5), pady=(10,2))
		self.balancef = Entry(self.parent, justify=CENTER)
		self.balancef["width"] = 5
		self.balancef.grid(row=10, column=0, sticky=W, padx=(5,5), pady=(2,2))
		self.balancef.delete(0, END)
		self.balancef.insert(0, "0.2")

		#BUTTON TO DO THE SYNTHESIS
		self.compute = Button(self.parent, text="Apply Transformation", command=self.transformation_synthesis, bg="dark green", fg="white")
		self.compute.grid(row=11, column=0, padx=5, pady=(10,15), sticky=W)

		#BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
		self.transf_output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation1.get())[:-4] + '_stftMorph.wav'), bg="gray30", fg="white")
		self.transf_output.grid(row=11, column=0, padx=(165,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
	def initUI(self):

		choose_label = "inputFile:"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 32
		self.filelocation.grid(row=0,column=0, sticky=W, padx=(70, 5), pady=(10,2))
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/mridangam.wav')

		#BUTTON TO BROWSE SOUND FILE
		open_file = Button(self.parent, text="...", command=self.browse_file) #see: def browse_file(self)
		open_file.grid(row=0, column=0, sticky=W, padx=(340, 6), pady=(10,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE
		preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		preview.grid(row=0, column=0, sticky=W, padx=(385,6), pady=(10,2))

		## SINE TRANSFORMATIONS ANALYSIS

		#ANALYSIS WINDOW TYPE
		wtype_label = "window:"
		Label(self.parent, text=wtype_label).grid(row=1, column=0, sticky=W, padx=5, pady=(10,2))
		self.w_type = StringVar()
		self.w_type.set("hamming") # initial value
		window_option = OptionMenu(self.parent, self.w_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window_option.grid(row=1, column=0, sticky=W, padx=(65,5), pady=(10,2))

		#WINDOW SIZE
		M_label = "M:"
		Label(self.parent, text=M_label).grid(row=1, column=0, sticky=W, padx=(180, 5), pady=(10,2))
		self.M = Entry(self.parent, justify=CENTER)
		self.M["width"] = 5
		self.M.grid(row=1,column=0, sticky=W, padx=(200,5), pady=(10,2))
		self.M.delete(0, END)
		self.M.insert(0, "801")

		#FFT SIZE
		N_label = "N:"
		Label(self.parent, text=N_label).grid(row=1, column=0, sticky=W, padx=(255, 5), pady=(10,2))
		self.N = Entry(self.parent, justify=CENTER)
		self.N["width"] = 5
		self.N.grid(row=1,column=0, sticky=W, padx=(275,5), pady=(10,2))
		self.N.delete(0, END)
		self.N.insert(0, "2048")

		#THRESHOLD MAGNITUDE
		t_label = "t:"
		Label(self.parent, text=t_label).grid(row=1, column=0, sticky=W, padx=(330,5), pady=(10,2))
		self.t = Entry(self.parent, justify=CENTER)
		self.t["width"] = 5
		self.t.grid(row=1, column=0, sticky=W, padx=(348,5), pady=(10,2))
		self.t.delete(0, END)
		self.t.insert(0, "-90")

		#MIN DURATION SINUSOIDAL TRACKS
		minSineDur_label = "minSineDur:"
		Label(self.parent, text=minSineDur_label).grid(row=2, column=0, sticky=W, padx=(5, 5), pady=(10,2))
		self.minSineDur = Entry(self.parent, justify=CENTER)
		self.minSineDur["width"] = 5
		self.minSineDur.grid(row=2, column=0, sticky=W, padx=(87,5), pady=(10,2))
		self.minSineDur.delete(0, END)
		self.minSineDur.insert(0, "0.01")

		#MAX NUMBER OF SINES
		maxnSines_label = "maxnSines:"
		Label(self.parent, text=maxnSines_label).grid(row=2, column=0, sticky=W, padx=(145,5), pady=(10,2))
		self.maxnSines = Entry(self.parent, justify=CENTER)
		self.maxnSines["width"] = 5
		self.maxnSines.grid(row=2, column=0, sticky=W, padx=(220,5), pady=(10,2))
		self.maxnSines.delete(0, END)
		self.maxnSines.insert(0, "150")

		#FREQUENCY DEVIATION ALLOWED
		freqDevOffset_label = "freqDevOffset:"
		Label(self.parent, text=freqDevOffset_label).grid(row=2, column=0, sticky=W, padx=(280,5), pady=(10,2))
		self.freqDevOffset = Entry(self.parent, justify=CENTER)
		self.freqDevOffset["width"] = 5
		self.freqDevOffset.grid(row=2, column=0, sticky=W, padx=(372,5), pady=(10,2))
		self.freqDevOffset.delete(0, END)
		self.freqDevOffset.insert(0, "20")

		#SLOPE OF THE FREQUENCY DEVIATION
		freqDevSlope_label = "freqDevSlope:"
		Label(self.parent, text=freqDevSlope_label).grid(row=3, column=0, sticky=W, padx=(5,5), pady=(10,2))
		self.freqDevSlope = Entry(self.parent, justify=CENTER)
		self.freqDevSlope["width"] = 5
		self.freqDevSlope.grid(row=3, column=0, sticky=W, padx=(98,5), pady=(10,2))
		self.freqDevSlope.delete(0, END)
		self.freqDevSlope.insert(0, "0.02")

		#BUTTON TO DO THE ANALYSIS OF THE SOUND
		self.compute = Button(self.parent, text="Analysis/Synthesis", command=self.analysis, bg="dark red", fg="white")
		self.compute.grid(row=4, column=0, padx=5, pady=(10,5), sticky=W)
		
		#BUTTON TO PLAY ANALYSIS/SYNTHESIS OUTPUT
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_sineModel.wav'), bg="gray30", fg="white")
		self.output.grid(row=4, column=0, padx=(145,5), pady=(10,5), sticky=W)

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=5, pady=5, sticky=W+E)
		###

		#FREQUENCY SCALING FACTORS
		freqScaling_label = "Frequency scaling factors (time, value pairs):"
		Label(self.parent, text=freqScaling_label).grid(row=6, column=0, sticky=W, padx=5, pady=(5,2))
		self.freqScaling = Entry(self.parent, justify=CENTER)
		self.freqScaling["width"] = 35
		self.freqScaling.grid(row=7, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.freqScaling.delete(0, END)
		self.freqScaling.insert(0, "[0, 2.0, 1, .3]")

		#TIME SCALING FACTORS
		timeScaling_label = "Time scaling factors (in time, value pairs):"
		Label(self.parent, text=timeScaling_label).grid(row=8, column=0, sticky=W, padx=5, pady=(5,2))
		self.timeScaling = Entry(self.parent, justify=CENTER)
		self.timeScaling["width"] = 35
		self.timeScaling.grid(row=9, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.timeScaling.delete(0, END)
		self.timeScaling.insert(0, "[0, .0, .671, .671, 1.978, 1.978+1.0]")

		#BUTTON TO DO THE SYNTHESIS
		self.compute = Button(self.parent, text="Apply Transformation", command=self.transformation_synthesis, bg="dark green", fg="white")
		self.compute.grid(row=13, column=0, padx=5, pady=(10,15), sticky=W)

		#BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
		self.transf_output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_sineModelTransformation.wav'), bg="gray30", fg="white")
		self.transf_output.grid(row=13, column=0, padx=(165,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#13
0
	def initUI(self):

		choose_label = "Input file (.wav, mono and 44100 sampling rate):"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 25
		self.filelocation.grid(row=1,column=0, sticky=W, padx=10)
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/piano.wav')

		#BUTTON TO BROWSE SOUND FILE
		self.open_file = Button(self.parent, text="Browse...", command=self.browse_file) #see: def browse_file(self)
		self.open_file.grid(row=1, column=0, sticky=W, padx=(220, 6)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE
		self.preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		self.preview.grid(row=1, column=0, sticky=W, padx=(306,6))

		## DFT MODEL

		#ANALYSIS WINDOW TYPE
		wtype_label = "Window type:"
		Label(self.parent, text=wtype_label).grid(row=2, column=0, sticky=W, padx=5, pady=(10,2))
		self.w_type = StringVar()
		self.w_type.set("blackman") # initial value
		window_option = OptionMenu(self.parent, self.w_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window_option.grid(row=2, column=0, sticky=W, padx=(95,5), pady=(10,2))

		#WINDOW SIZE
		M_label = "Window size (M):"
		Label(self.parent, text=M_label).grid(row=3, column=0, sticky=W, padx=5, pady=(10,2))
		self.M = Entry(self.parent, justify=CENTER)
		self.M["width"] = 5
		self.M.grid(row=3,column=0, sticky=W, padx=(115,5), pady=(10,2))
		self.M.delete(0, END)
		self.M.insert(0, "511")

		#FFT SIZE
		N_label = "FFT size (N) (power of two bigger than M):"
		Label(self.parent, text=N_label).grid(row=4, column=0, sticky=W, padx=5, pady=(10,2))
		self.N = Entry(self.parent, justify=CENTER)
		self.N["width"] = 5
		self.N.grid(row=4,column=0, sticky=W, padx=(270,5), pady=(10,2))
		self.N.delete(0, END)
		self.N.insert(0, "1024")

		#TIME TO START ANALYSIS
		time_label = "Time in sound (in seconds):"
		Label(self.parent, text=time_label).grid(row=5, column=0, sticky=W, padx=5, pady=(10,2))
		self.time = Entry(self.parent, justify=CENTER)
		self.time["width"] = 5
		self.time.grid(row=5, column=0, sticky=W, padx=(180,5), pady=(10,2))
		self.time.delete(0, END)
		self.time.insert(0, ".2")

		#BUTTON TO COMPUTE EVERYTHING
		self.compute = Button(self.parent, text="Compute", command=self.compute_model, bg="dark red", fg="white")
		self.compute.grid(row=6, column=0, padx=5, pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
	def initUI(self):

		choose_label = "Input file (.wav, mono and 44100 sampling rate):"
		Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))

		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation = Entry(self.parent)
		self.filelocation.focus_set()
		self.filelocation["width"] = 25
		self.filelocation.grid(row=1,column=0, sticky=W, padx=10)
		self.filelocation.delete(0, END)
		self.filelocation.insert(0, '../../sounds/ocean.wav')

		#BUTTON TO BROWSE SOUND FILE
		self.open_file = Button(self.parent, text="Browse...", command=self.browse_file) #see: def browse_file(self)
		self.open_file.grid(row=1, column=0, sticky=W, padx=(220, 6)) #put it beside the filelocation textbox

		#BUTTON TO PREVIEW SOUND FILE
		self.preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
		self.preview.grid(row=1, column=0, sticky=W, padx=(306,6))

		## STOCHASTIC MODEL

		#HOP SIZE
		H_label = "Hop size (H):"
		Label(self.parent, text=H_label).grid(row=2, column=0, sticky=W, padx=5, pady=(10,2))
		self.H = Entry(self.parent, justify=CENTER)
		self.H["width"] = 5
		self.H.grid(row=2, column=0, sticky=W, padx=(90,5), pady=(10,2))
		self.H.delete(0, END)
		self.H.insert(0, "256")

		#FFT size
		N_label = "FFT size (N):"
		Label(self.parent, text=N_label).grid(row=3, column=0, sticky=W, padx=5, pady=(10,2))
		self.N = Entry(self.parent, justify=CENTER)
		self.N["width"] = 5
		self.N.grid(row=3, column=0, sticky=W, padx=(90,5), pady=(10,2))
		self.N.delete(0, END)
		self.N.insert(0, "512")

		#DECIMATION FACTOR
		stocf_label = "Decimation factor (bigger than 0, max of 1):"
		Label(self.parent, text=stocf_label).grid(row=4, column=0, sticky=W, padx=5, pady=(10,2))
		self.stocf = Entry(self.parent, justify=CENTER)
		self.stocf["width"] = 5
		self.stocf.grid(row=4, column=0, sticky=W, padx=(285,5), pady=(10,2))
		self.stocf.delete(0, END)
		self.stocf.insert(0, "0.1")

		#BUTTON TO COMPUTE EVERYTHING
		self.compute = Button(self.parent, text="Compute", command=self.compute_model, bg="dark red", fg="white")
		self.compute.grid(row=5, column=0, padx=5, pady=(10,2), sticky=W)

		#BUTTON TO PLAY OUTPUT
		output_label = "Stochastic:"
		Label(self.parent, text=output_label).grid(row=6, column=0, sticky=W, padx=5, pady=(10,15))
		self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_stochasticModel.wav'), bg="gray30", fg="white")
		self.output.grid(row=6, column=0, padx=(80,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
示例#15
0
	def initUI(self):

		## INPUT FILE 1
		choose1_label = "inputFile1:"
		Label(self.parent, text=choose1_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation1 = Entry(self.parent)
		self.filelocation1.focus_set()
		self.filelocation1["width"] = 30
		self.filelocation1.grid(row=0,column=0, sticky=W, padx=(75, 5), pady=(10,2))
		self.filelocation1.delete(0, END)
		self.filelocation1.insert(0, '../../sounds/violin-B3.wav')

		#BUTTON TO BROWSE SOUND FILE 1
		open_file1 = Button(self.parent, text="...", command=self.browse_file1) #see: def browse_file(self)
		open_file1.grid(row=0, column=0, sticky=W, padx=(330, 6), pady=(10,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE 1
		preview1 = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation1.get()), bg="gray30", fg="white")
		preview1.grid(row=0, column=0, sticky=W, padx=(375,6), pady=(10,2))
		
		#ANALYSIS WINDOW TYPE SOUND 1
		wtype1_label = "window1:"
		Label(self.parent, text=wtype1_label).grid(row=1, column=0, sticky=W, padx=5, pady=(4,2))
		self.w1_type = StringVar()
		self.w1_type.set("blackman") # initial value
		window1_option = OptionMenu(self.parent, self.w1_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window1_option.grid(row=1, column=0, sticky=W, padx=(68,5), pady=(4,2))

		#WINDOW SIZE SOUND 1
		M1_label = "M1:"
		Label(self.parent, text=M1_label).grid(row=1, column=0, sticky=W, padx=(180, 5), pady=(4,2))
		self.M1 = Entry(self.parent, justify=CENTER)
		self.M1["width"] = 5
		self.M1.grid(row=1,column=0, sticky=W, padx=(208,5), pady=(4,2))
		self.M1.delete(0, END)
		self.M1.insert(0, "1001")

		#FFT SIZE SOUND 1
		N1_label = "N1:"
		Label(self.parent, text=N1_label).grid(row=1, column=0, sticky=W, padx=(265, 5), pady=(4,2))
		self.N1 = Entry(self.parent, justify=CENTER)
		self.N1["width"] = 5
		self.N1.grid(row=1,column=0, sticky=W, padx=(290,5), pady=(4,2))
		self.N1.delete(0, END)
		self.N1.insert(0, "1024")

		#THRESHOLD MAGNITUDE SOUND 1
		t1_label = "t1:"
		Label(self.parent, text=t1_label).grid(row=1, column=0, sticky=W, padx=(343,5), pady=(4,2))
		self.t1 = Entry(self.parent, justify=CENTER)
		self.t1["width"] = 5
		self.t1.grid(row=1, column=0, sticky=W, padx=(370,5), pady=(4,2))
		self.t1.delete(0, END)
		self.t1.insert(0, "-100")

		#MIN DURATION SINUSOIDAL TRACKS SOUND 1
		minSineDur1_label = "minSineDur1:"
		Label(self.parent, text=minSineDur1_label).grid(row=2, column=0, sticky=W, padx=(5, 5), pady=(4,2))
		self.minSineDur1 = Entry(self.parent, justify=CENTER)
		self.minSineDur1["width"] = 5
		self.minSineDur1.grid(row=2, column=0, sticky=W, padx=(92,5), pady=(4,2))
		self.minSineDur1.delete(0, END)
		self.minSineDur1.insert(0, "0.05")

		#MIN FUNDAMENTAL FREQUENCY SOUND 1
		minf01_label = "minf01:"
		Label(self.parent, text=minf01_label).grid(row=2, column=0, sticky=W, padx=(157,5), pady=(4,2))
		self.minf01 = Entry(self.parent, justify=CENTER)
		self.minf01["width"] = 5
		self.minf01.grid(row=2, column=0, sticky=W, padx=(208,5), pady=(4,2))
		self.minf01.delete(0, END)
		self.minf01.insert(0, "200")

		#MAX FUNDAMENTAL FREQUENCY SOUND 1
		maxf01_label = "maxf01:"
		Label(self.parent, text=maxf01_label).grid(row=2, column=0, sticky=W, padx=(270,5), pady=(4,2))
		self.maxf01 = Entry(self.parent, justify=CENTER)
		self.maxf01["width"] = 5
		self.maxf01.grid(row=2, column=0, sticky=W, padx=(325,5), pady=(4,2))
		self.maxf01.delete(0, END)
		self.maxf01.insert(0, "300")

		#MAX ERROR ACCEPTED SOUND 1
		f0et1_label = "f0et1:"
		Label(self.parent, text=f0et1_label).grid(row=3, column=0, sticky=W, padx=5, pady=(4,2))
		self.f0et1 = Entry(self.parent, justify=CENTER)
		self.f0et1["width"] = 3
		self.f0et1.grid(row=3, column=0, sticky=W, padx=(45,5), pady=(4,2))
		self.f0et1.delete(0, END)
		self.f0et1.insert(0, "10")

		#ALLOWED DEVIATION OF HARMONIC TRACKS SOUND 1
		harmDevSlope1_label = "harmDevSlope1:"
		Label(self.parent, text=harmDevSlope1_label).grid(row=3, column=0, sticky=W, padx=(108,5), pady=(4,2))
		self.harmDevSlope1 = Entry(self.parent, justify=CENTER)
		self.harmDevSlope1["width"] = 5
		self.harmDevSlope1.grid(row=3, column=0, sticky=W, padx=(215,5), pady=(4,2))
		self.harmDevSlope1.delete(0, END)
		self.harmDevSlope1.insert(0, "0.01")

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=4, pady=5, sticky=W+E)
		###

		## INPUT FILE 2
		choose2_label = "inputFile2:"
		Label(self.parent, text=choose2_label).grid(row=5, column=0, sticky=W, padx=5, pady=(2,2))
 
		#TEXTBOX TO PRINT PATH OF THE SOUND FILE
		self.filelocation2 = Entry(self.parent)
		self.filelocation2.focus_set()
		self.filelocation2["width"] = 30
		self.filelocation2.grid(row=5,column=0, sticky=W, padx=(75, 5), pady=(2,2))
		self.filelocation2.delete(0, END)
		self.filelocation2.insert(0, '../../sounds/soprano-E4.wav')

		#BUTTON TO BROWSE SOUND FILE 2
		open_file2 = Button(self.parent, text="...", command=self.browse_file2) #see: def browse_file(self)
		open_file2.grid(row=5, column=0, sticky=W, padx=(330, 6), pady=(2,2)) #put it beside the filelocation textbox
 
		#BUTTON TO PREVIEW SOUND FILE 2
		preview2 = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation2.get()), bg="gray30", fg="white")
		preview2.grid(row=5, column=0, sticky=W, padx=(375,6), pady=(2,2))


		#ANALYSIS WINDOW TYPE SOUND 2
		wtype2_label = "window2:"
		Label(self.parent, text=wtype2_label).grid(row=6, column=0, sticky=W, padx=5, pady=(4,2))
		self.w2_type = StringVar()
		self.w2_type.set("hamming") # initial value
		window2_option = OptionMenu(self.parent, self.w2_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
		window2_option.grid(row=6, column=0, sticky=W, padx=(68,5), pady=(4,2))

		#WINDOW SIZE SOUND 2
		M2_label = "M2:"
		Label(self.parent, text=M2_label).grid(row=6, column=0, sticky=W, padx=(180, 5), pady=(4,2))
		self.M2 = Entry(self.parent, justify=CENTER)
		self.M2["width"] = 5
		self.M2.grid(row=6,column=0, sticky=W, padx=(208,5), pady=(4,2))
		self.M2.delete(0, END)
		self.M2.insert(0, "901")

		#FFT SIZE SOUND 2
		N2_label = "N2:"
		Label(self.parent, text=N2_label).grid(row=6, column=0, sticky=W, padx=(265, 5), pady=(4,2))
		self.N2 = Entry(self.parent, justify=CENTER)
		self.N2["width"] = 5
		self.N2.grid(row=6,column=0, sticky=W, padx=(290,5), pady=(4,2))
		self.N2.delete(0, END)
		self.N2.insert(0, "1024")

		#THRESHOLD MAGNITUDE SOUND 2
		t2_label = "t2:"
		Label(self.parent, text=t2_label).grid(row=6, column=0, sticky=W, padx=(343,5), pady=(4,2))
		self.t2 = Entry(self.parent, justify=CENTER)
		self.t2["width"] = 5
		self.t2.grid(row=6, column=0, sticky=W, padx=(370,5), pady=(4,2))
		self.t2.delete(0, END)
		self.t2.insert(0, "-100")

		#MIN DURATION SINUSOIDAL TRACKS SOUND 2
		minSineDur2_label = "minSineDur2:"
		Label(self.parent, text=minSineDur2_label).grid(row=7, column=0, sticky=W, padx=(5, 5), pady=(4,2))
		self.minSineDur2 = Entry(self.parent, justify=CENTER)
		self.minSineDur2["width"] = 5
		self.minSineDur2.grid(row=7, column=0, sticky=W, padx=(92,5), pady=(4,2))
		self.minSineDur2.delete(0, END)
		self.minSineDur2.insert(0, "0.05")

		#MIN FUNDAMENTAL FREQUENCY SOUND 2
		minf02_label = "minf02:"
		Label(self.parent, text=minf02_label).grid(row=7, column=0, sticky=W, padx=(157,5), pady=(4,2))
		self.minf02 = Entry(self.parent, justify=CENTER)
		self.minf02["width"] = 5
		self.minf02.grid(row=7, column=0, sticky=W, padx=(208,5), pady=(4,2))
		self.minf02.delete(0, END)
		self.minf02.insert(0, "250")

		#MAX FUNDAMENTAL FREQUENCY SOUND 2
		maxf02_label = "maxf02:"
		Label(self.parent, text=maxf02_label).grid(row=7, column=0, sticky=W, padx=(270,5), pady=(4,2))
		self.maxf02 = Entry(self.parent, justify=CENTER)
		self.maxf02["width"] = 5
		self.maxf02.grid(row=7, column=0, sticky=W, padx=(325,5), pady=(4,2))
		self.maxf02.delete(0, END)
		self.maxf02.insert(0, "500")

		#MAX ERROR ACCEPTED SOUND 2
		f0et2_label = "f0et2:"
		Label(self.parent, text=f0et2_label).grid(row=8, column=0, sticky=W, padx=5, pady=(4,2))
		self.f0et2 = Entry(self.parent, justify=CENTER)
		self.f0et2["width"] = 3
		self.f0et2.grid(row=8, column=0, sticky=W, padx=(45,5), pady=(4,2))
		self.f0et2.delete(0, END)
		self.f0et2.insert(0, "10")

		#ALLOWED DEVIATION OF HARMONIC TRACKS SOUND 2
		harmDevSlope2_label = "harmDevSlope2:"
		Label(self.parent, text=harmDevSlope2_label).grid(row=8, column=0, sticky=W, padx=(108,5), pady=(4,2))
		self.harmDevSlope2 = Entry(self.parent, justify=CENTER)
		self.harmDevSlope2["width"] = 5
		self.harmDevSlope2.grid(row=8, column=0, sticky=W, padx=(215,5), pady=(4,2))
		self.harmDevSlope2.delete(0, END)
		self.harmDevSlope2.insert(0, "0.01")

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=9, pady=5, sticky=W+E)
		###

		#MAX NUMBER OF HARMONICS SOUND 1
		nH_label = "nH:"
		Label(self.parent, text=nH_label).grid(row=10, column=0, sticky=W, padx=(5,5), pady=(2,2))
		self.nH = Entry(self.parent, justify=CENTER)
		self.nH["width"] = 5
		self.nH.grid(row=10, column=0, sticky=W, padx=(35,5), pady=(2,2))
		self.nH.delete(0, END)
		self.nH.insert(0, "60")

		#DECIMATION FACTOR SOUND 1
		stocf_label = "stocf:"
		Label(self.parent, text=stocf_label).grid(row=10, column=0, sticky=W, padx=(98,5), pady=(2,2))
		self.stocf = Entry(self.parent, justify=CENTER)
		self.stocf["width"] = 5
		self.stocf.grid(row=10, column=0, sticky=W, padx=(138,5), pady=(2,2))
		self.stocf.delete(0, END)
		self.stocf.insert(0, "0.1")

		#BUTTON TO DO THE ANALYSIS OF THE SOUND
		self.compute = Button(self.parent, text="Analysis", command=self.analysis, bg="dark red", fg="white")
		self.compute.grid(row=10, column=0, padx=(210, 5), pady=(2,2), sticky=W)

		###
		#SEPARATION LINE
		Frame(self.parent,height=1,width=50,bg="black").grid(row=11, pady=5, sticky=W+E)
		###

		#
		hfreqIntp_label = "harmonic frequencies interpolation factors, 0 to 1 (time,value pairs)"
		Label(self.parent, text=hfreqIntp_label).grid(row=12, column=0, sticky=W, padx=5, pady=(2,2))
		self.hfreqIntp = Entry(self.parent, justify=CENTER)
		self.hfreqIntp["width"] = 35
		self.hfreqIntp.grid(row=13, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.hfreqIntp.delete(0, END)
		self.hfreqIntp.insert(0, "[0, 0, .1, 0, .9, 1, 1, 1]")

		#
		hmagIntp_label = "harmonic magnitudes interpolation factors, 0 to 1 (time,value pairs)"
		Label(self.parent, text=hmagIntp_label).grid(row=14, column=0, sticky=W, padx=5, pady=(5,2))
		self.hmagIntp = Entry(self.parent, justify=CENTER)
		self.hmagIntp["width"] = 35
		self.hmagIntp.grid(row=15, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.hmagIntp.delete(0, END)
		self.hmagIntp.insert(0, "[0, 0, .1, 0, .9, 1, 1, 1]")

		#
		stocIntp_label = "stochastic component interpolation factors, 0 to 1 (time,value pairs)"
		Label(self.parent, text=stocIntp_label).grid(row=16, column=0, sticky=W, padx=5, pady=(5,2))
		self.stocIntp = Entry(self.parent, justify=CENTER)
		self.stocIntp["width"] = 35
		self.stocIntp.grid(row=17, column=0, sticky=W+E, padx=5, pady=(0,2))
		self.stocIntp.delete(0, END)
		self.stocIntp.insert(0, "[0, 0, .1, 0, .9, 1, 1, 1]")


		#BUTTON TO DO THE SYNTHESIS
		self.compute = Button(self.parent, text="Apply Transformation", command=self.transformation_synthesis, bg="dark green", fg="white")
		self.compute.grid(row=18, column=0, padx=5, pady=(10,15), sticky=W)

		#BUTTON TO PLAY TRANSFORMATION SYNTHESIS OUTPUT
		self.transf_output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation1.get())[:-4] + '_hpsMorph.wav'), bg="gray30", fg="white")
		self.transf_output.grid(row=18, column=0, padx=(165,5), pady=(10,15), sticky=W)

		# define options for opening file
		self.file_opt = options = {}
		options['defaultextension'] = '.wav'
		options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
		options['initialdir'] = '../../sounds/'
		options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'