コード例 #1
0
    def analyze_cont(self):

        self.average, self.entropy, self.kurtosis, self.max_v, self.median, self.min_v, self.skewness, self.standart_dev = Features.check_statistics(self)
        self.wavelet_type, self.sampling_per, self.min_scale, self.max_scale, self.scale_step = Features.cont_check_wavelet(self)
        if (self.load_check and (
                self.average or self.entropy or self.kurtosis or self.max_v or self.median or self.min_v or self.skewness or self.standart_dev)):  # işlenecek müzik olması durumu
            self.scaling = np.arange(int(self.min_scale), int(self.max_scale), int(self.scale_step))

            self.analyze_check = True
            self.wavelet_level = len(self.scaling) - 1
            col, self.header, self.db_header = Features.init_table(self, len(self.all_signals))
            self.db_matrix = np.zeros((len(self.all_signals), 8 * (self.wavelet_level + 1)), dtype=complex)

            for iter in range(0, len(self.all_signals)):
                print(self.all_signals[iter])
                self.signals.clear()
                self.audio, self.sample = librosa.load(self.all_signals[iter])
                self.signals.append(self.audio)
                self.time = np.arange(0, len(self.audio)) / self.sample
                coef, freqs = pywt.cwt(self.audio, self.scaling, self.wavelet_type, int(self.sampling_per))
                for i in range(0, self.wavelet_level + 1):
                    self.signals.append(coef[i])  # adding signals array to coeffs
                if (iter == 0):  # plotting first signal  only
                    self.plot_original_signal()
                    firstau = self.audio
                    time = self.time
                self.db_matrix[iter] = Features.insertTableComplex(self, iter, col)
            self.plot_wavelet(firstau,time)
        else:
            if not self.load_check:
                Features.message("You have to load at least 1 signal !", QMessageBox.Warning)
            else:
                Features.message("You have to pick at least 1 statistic function !", QMessageBox.Warning)
コード例 #2
0
    def run(self):
        wave_types = pywt.wavelist(kind='discrete')
        levels = [1, 2, 3]
        signals = []
        self.average, self.entropy, self.kurtosis, self.max_v, self.median, self.min_v, self.skewness, self.standart_dev = Features.check_statistics(
            self)
        table_names = Database.get_table_names(Database.database_name)

        for wave_func in wave_types:
            if wave_func.find("sym") == -1:
                for level in levels:
                    self.wavelet_level = level
                    self.wavelet_type = wave_func
                    col, self.header, self.db_header = Features.init_table(
                        self, len(self.all_signals))
                    self.db_matrix = np.zeros(
                        (len(self.all_signals), 8 * (self.wavelet_level + 1)))

                    if not any("Db_GTZAN_function_" + str(wave_func) +
                               "_Degree_" + str(level) in s
                               for s in table_names):

                        for iter in range(0, len(self.all_signals)):
                            self.signals.clear()
                            self.audio, self.sample = librosa.load(
                                self.all_signals[iter])
                            self.signals.append(self.audio)
                            self.time = np.arange(0, len(
                                self.audio)) / self.sample

                            coeffs = pywt.wavedec(
                                self.audio,
                                self.wavelet_type,
                                level=self.wavelet_level)  # wavelet analyze

                            for i in range(0, self.wavelet_level + 1):
                                self.signals.append(
                                    coeffs[i]
                                )  # adding signals array to coeffs

                            self.db_matrix[iter] = Features.insertTable(
                                self, iter, col
                            )  # level = 3 ise signals içinde  5 (4 analiz edilmiş + 1 kaynak)

                        w_name = str(wave_func)
                        table_name = "Db_GTZAN_function_" + w_name + "_Degree_" + str(
                            level)
                        Database.create_table(Database.database_name,
                                              table_name, self.db_header, "")

                        for index in range(0, len(self.all_signals)):
                            name = self.all_signals[index].split(
                                sep='/')  # name of signal
                            Database.delete_row(Database.database_name,
                                                table_name, name[-1], "")
                            Database.add_values_to_table(
                                Database.database_name, table_name, name[-1],
                                self.db_header, self.db_matrix[index],
                                "")  # adding db to values
                        print(table_name)
                    else:
                        print("Db_GTZAN_function_" + str(wave_func) +
                              "_Degree_" + str(level) + ' passed')
            else:
                print(wave_func + " passed")
コード例 #3
0
    def run(self):

        self.average, self.entropy, self.kurtosis, self.max_v, self.median, self.min_v, self.skewness, self.standart_dev = Features.check_statistics(self)
        #self.wavelet_type, self.sampling_per, self.min_scale, self.max_scale, self.scale_step = Features.cont_check_wavelet(self)
        self.sampling_per = 1
        self.min_scale = 1
        self.max_scale = 8
        self.scale_step = 1
        wave_types = pywt.wavelist(kind='continuous')
        self.scaling = np.arange(self.min_scale, self.max_scale, self.scale_step)
        for wave_func in wave_types:
            self.wavelet_type = wave_func
            self.wavelet_level = len(self.scaling) - 1
            col, self.header, self.db_header = Features.init_table(self, len(self.all_signals))
            self.db_matrix = np.zeros((len(self.all_signals), 8 * (self.wavelet_level + 1)), dtype=complex)
            for iter in range(0, len(self.all_signals)):
                #print(self.all_signals[iter])

                self.signals.clear()
                self.audio, self.sample = librosa.load(self.all_signals[iter])
                self.signals.append(self.audio)
                self.time = np.arange(0, len(self.audio)) / self.sample
                coef, freqs = pywt.cwt(self.audio, self.scaling, self.wavelet_type, int(self.sampling_per))
                for i in range(0, self.wavelet_level + 1):
                    self.signals.append(coef[i])                                        # adding signals array to coeffs
                self.db_matrix[iter] = Features.insertTableComplex(self, iter, col)

            w_name = str(self.wavelet_type)
            table_name = "Db_GTZAN_function_" + w_name + "_Scale_1_to_8_Period_1"

            Database.create_table(Database.database_name, table_name, self.db_header,"")  # creating new table with statistic function
            Database.create_table(Database.database_name, table_name, self.db_header, "Comp_")

            for index in range(0, len(self.all_signals)):
                name = self.all_signals[index].split(sep='/')
                Database.add_values_to_table(Database.database_name, table_name, name[-1], self.db_header,self.db_matrix[index], "")
                Database.add_values_to_table(Database.database_name, table_name, name[-1], self.db_header,self.db_matrix[index], "Comp_")

            print(table_name)
コード例 #4
0
    def analyze_signal(self):  #Veriyi Analiz Etme
        self.average, self.entropy, self.kurtosis, self.max_v, self.median, self.min_v, self.skewness, self.standart_dev = Features.check_statistics(
            self)
        self.wavelet_type, self.wavelet_level = Features.discrete_check_wavelet(
            self)
        if (self.load_check and
            (self.average or self.entropy or self.kurtosis or self.max_v
             or self.median or self.min_v or self.skewness
             or self.standart_dev)):  #işlenecek müzik olması durumu

            self.analyze_check = True
            col, self.header, self.db_header = Features.init_table(
                self, len(self.all_signals))
            self.db_matrix = np.zeros(
                (len(self.all_signals), 8 * (self.wavelet_level + 1)))

            for iter in range(0, len(self.all_signals)):
                print(self.all_signals[iter])
                self.signals.clear()
                self.audio, self.sample = librosa.load(self.all_signals[iter])
                self.signals.append(self.audio)
                self.time = np.arange(0, len(self.audio)) / self.sample

                coeffs = pywt.wavedec(
                    self.audio, self.wavelet_type,
                    level=self.wavelet_level)  #Wavelet Analiz

                for i in range(0, self.wavelet_level + 1):
                    self.signals.append(coeffs[i])  #Sinyalleri Coef içine atma

                if (iter == 0
                        and self.wavelet_level < 8):  #İlk sinyali yazdırma
                    Features.discrete_plot_signal(self)
                self.db_matrix[iter] = Features.insertTable(self, iter, col)

                self.progressBar.setValue(
                    ((iter + 1) / len(self.all_signals)) * 100)
                #level = 3 ise signals içinde  5 (4 analiz edilmiş + 1 source)
        else:
            if not self.load_check:
                Features.message("You have to load at least 1 signal",
                                 QMessageBox.Warning)
            else:
                Features.message(
                    "You have to pick at least 1 statistic function",
                    QMessageBox.Warning)