Eigentlich müsste jetzt alles so programmiert sein, wie Herr Zwanger es nach dem 11ten Meeting wollte. IIR Filter 5ter Ordnung und der Speichrvorgang ist wesentlich schnellermaster
@@ -7,6 +7,7 @@ | |||
<w>beide</w> | |||
<w>beiden</w> | |||
<w>definieren</w> | |||
<w>filterordnung</w> | |||
<w>fontcolor</w> | |||
<w>frequenz</w> | |||
<w>kommentar</w> | |||
@@ -21,6 +22,7 @@ | |||
<w>mittelfrequenz</w> | |||
<w>nachname</w> | |||
<w>ohren</w> | |||
<w>passband</w> | |||
<w>rauschen</w> | |||
<w>rauschens</w> | |||
<w>rechtem</w> | |||
@@ -30,6 +32,7 @@ | |||
<w>rechts</w> | |||
<w>speichere</w> | |||
<w>speicherversuch</w> | |||
<w>sperrbereichs</w> | |||
<w>variablen</w> | |||
<w>vorname</w> | |||
<w>zwischen</w> |
@@ -2,16 +2,83 @@ | |||
<project version="4"> | |||
<component name="ChangeListManager"> | |||
<list default="true" id="5b3f2136-e422-4072-84be-e86e40fa2d55" name="Default Changelist" comment=""> | |||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/.idea/dictionaries/Julian.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dictionaries/Julian.xml" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/SoundGenerator.py" beforeDir="false" afterPath="$PROJECT_DIR$/SoundGenerator.py" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" beforeDir="false" afterPath="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/TinnitusDaten.csv" beforeDir="false" afterPath="$PROJECT_DIR$/TinnitusDaten.csv" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/musikTest.wav" beforeDir="false" afterPath="$PROJECT_DIR$/musikTest.wav" afterDir="false" /> | |||
</list> | |||
<ignored path="$PROJECT_DIR$/venv/" /> | |||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> | |||
<option name="SHOW_DIALOG" value="false" /> | |||
<option name="HIGHLIGHT_CONFLICTS" value="true" /> | |||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | |||
<option name="LAST_RESOLUTION" value="IGNORE" /> | |||
</component> | |||
<component name="FileEditorManager"> | |||
<leaf> | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="352"> | |||
<caret line="210" lean-forward="true" selection-start-line="210" selection-end-line="210" /> | |||
<folding> | |||
<element signature="e#0#30#0" expanded="true" /> | |||
</folding> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/io/wavfile.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="275"> | |||
<caret line="263" selection-start-line="263" selection-end-line="263" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/filter_design.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="66"> | |||
<caret line="2278" column="41" selection-start-line="2278" selection-start-column="41" selection-end-line="2278" selection-end-column="41" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/tkinter/__init__.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="278"> | |||
<caret line="1557" selection-start-line="1557" selection-end-line="1557" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
<file pinned="false" current-in-tab="true"> | |||
<entry file="file://$PROJECT_DIR$/SoundGenerator.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="373"> | |||
<caret line="278" selection-start-line="278" selection-end-line="278" /> | |||
<folding> | |||
<element signature="e#0#42#0" expanded="true" /> | |||
</folding> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/signaltools.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="275"> | |||
<caret line="1694" column="4" selection-start-line="1694" selection-start-column="4" selection-end-line="1694" selection-end-column="4" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
</leaf> | |||
</component> | |||
<component name="FileTemplateManagerImpl"> | |||
<option name="RECENT_TEMPLATES"> | |||
<list> | |||
@@ -43,6 +110,10 @@ | |||
<find>StringVar</find> | |||
<find>Speichern</find> | |||
<find>csv</find> | |||
<find>order</find> | |||
<find>feedback</find> | |||
<find>musikTest</find> | |||
<find>Daten er</find> | |||
</findStrings> | |||
<dirStrings> | |||
<dir>C:\Users\Julian\PycharmProjects\TinnitusAnalyse</dir> | |||
@@ -51,6 +122,20 @@ | |||
<component name="Git.Settings"> | |||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." /> | |||
</component> | |||
<component name="IdeDocumentHistory"> | |||
<option name="CHANGED_PATHS"> | |||
<list> | |||
<option value="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" /> | |||
<option value="$PROJECT_DIR$/SoundGenerator.py" /> | |||
</list> | |||
</option> | |||
</component> | |||
<component name="ProjectFrameBounds" extendedState="7"> | |||
<option name="x" value="-8" /> | |||
<option name="y" value="-8" /> | |||
<option name="width" value="1294" /> | |||
<option name="height" value="1407" /> | |||
</component> | |||
<component name="ProjectId" id="1hYkQMnWccTfUN5kAX3DpaPGeCX" /> | |||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> | |||
<component name="ProjectView"> | |||
@@ -71,7 +156,19 @@ | |||
<recent name="C:\Users\Julian\PycharmProjects\TinnitusAnalyse" /> | |||
</key> | |||
</component> | |||
<component name="RunManager" selected="Python.SoundGenerator"> | |||
<component name="RunDashboard"> | |||
<option name="ruleStates"> | |||
<list> | |||
<RuleState> | |||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" /> | |||
</RuleState> | |||
<RuleState> | |||
<option name="name" value="StatusDashboardGroupingRule" /> | |||
</RuleState> | |||
</list> | |||
</option> | |||
</component> | |||
<component name="RunManager" selected="Python.TinnitusAnalyse_GUI"> | |||
<configuration name="DigitalFilter (1)" type="PythonConfigurationType" factoryName="Python" temporary="true"> | |||
<module name="TinnitusAnalyse" /> | |||
<option name="INTERPRETER_OPTIONS" value="" /> | |||
@@ -200,6 +297,29 @@ | |||
</task> | |||
<servers /> | |||
</component> | |||
<component name="ToolWindowManager"> | |||
<frame x="-8" y="-8" width="2576" height="1416" extended-state="6" /> | |||
<editor active="true" /> | |||
<layout> | |||
<window_info id="Favorites" side_tool="true" /> | |||
<window_info content_ui="combo" id="Project" order="0" weight="0.25" /> | |||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> | |||
<window_info anchor="bottom" id="Version Control" weight="0.32969603" /> | |||
<window_info anchor="bottom" id="Python Console" weight="0.32969603" /> | |||
<window_info anchor="bottom" id="Terminal" weight="0.32969603" /> | |||
<window_info anchor="bottom" id="Event Log" side_tool="true" /> | |||
<window_info anchor="bottom" id="Message" order="0" /> | |||
<window_info anchor="bottom" id="Find" order="1" /> | |||
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32969603" /> | |||
<window_info anchor="bottom" id="Debug" order="3" weight="0.3998441" /> | |||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> | |||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> | |||
<window_info anchor="bottom" id="TODO" order="6" /> | |||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> | |||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> | |||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> | |||
</layout> | |||
</component> | |||
<component name="WindowStateProjectService"> | |||
<state x="669" y="115" key="#SoundGenerator" timestamp="1600197469354"> | |||
<screen x="0" y="0" width="1920" height="1040" /> | |||
@@ -210,4 +330,73 @@ | |||
</state> | |||
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1600261634426" /> | |||
</component> | |||
<component name="editorHistoryManager"> | |||
<entry file="file://$USER_HOME$/.PyCharmCE2019.1/system/python_stubs/-1242442885/audioop.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="-1530" /> | |||
</provider> | |||
</entry> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/wave.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="1428"> | |||
<caret line="84" column="12" selection-start-line="84" selection-start-column="12" selection-end-line="84" selection-end-column="12" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/tkinter/__init__.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="278"> | |||
<caret line="1557" selection-start-line="1557" selection-end-line="1557" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$USER_HOME$/.PyCharmCE2019.1/system/python_stubs/-1242442885/builtins.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="375"> | |||
<caret line="4857" column="53" selection-start-line="4857" selection-start-column="53" selection-end-line="4857" selection-end-column="53" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/signaltools.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="275"> | |||
<caret line="1694" column="4" selection-start-line="1694" selection-start-column="4" selection-end-line="1694" selection-end-column="4" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/filter_design.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="66"> | |||
<caret line="2278" column="41" selection-start-line="2278" selection-start-column="41" selection-end-line="2278" selection-end-column="41" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/io/wavfile.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="275"> | |||
<caret line="263" selection-start-line="263" selection-end-line="263" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="352"> | |||
<caret line="210" lean-forward="true" selection-start-line="210" selection-end-line="210" /> | |||
<folding> | |||
<element signature="e#0#30#0" expanded="true" /> | |||
</folding> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$PROJECT_DIR$/SoundGenerator.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="373"> | |||
<caret line="278" selection-start-line="278" selection-end-line="278" /> | |||
<folding> | |||
<element signature="e#0#42#0" expanded="true" /> | |||
</folding> | |||
</state> | |||
</provider> | |||
</entry> | |||
</component> | |||
</project> |
@@ -5,7 +5,9 @@ import numpy as np | |||
import sys # für Fehlermeldungen | |||
from scipy import signal | |||
import csv | |||
#import matplotlib.pyplot as plt | |||
import time | |||
import matplotlib.pyplot as plt | |||
"""--------------------------------------------------------------------------------------------------------------------- | |||
In .wav-Dateien wird der Ton in absoluten Werte eingetragen. Die Standart-framerate ist 44100 | |||
das heißt für jede Sekunde an Ton gibt es 44100 Werte, die die Tonwelle über die Zeit beschreiben | |||
@@ -168,97 +170,140 @@ class Sound: | |||
return outdata | |||
def musik_filtern(self): | |||
""" Die Tinnitus Frequenz aus der Musik Filtern... easy""" | |||
# Die Parameter des Tinnitus aus .csv Datei getten | |||
""" | |||
Diese Funktion filtert die Tinnitus Frequenz aus einer gewählten Musikdatei. Dabei geht sie in 3 großen | |||
Schritten vor: | |||
1. Die nötigen Informationen über den Tinnitus aus der .csv Datei herausholen | |||
2. Die digitalen Filter erstellen und die Tinnitus Frequenz aus der Audiodatei "herausschneiden" | |||
3. Die fertigen Audiodatei als .wav Datei speichern | |||
""" | |||
# ------------1. Die nötigen Informationen über den Tinnitus aus der .csv Datei herausholen--------------------- | |||
csvstring = open("TinnitusDaten.csv").read() | |||
#print(csvstring) | |||
x = csvstring.split("\n") | |||
#print("\nx= ", x) | |||
tinnitus_data = csvstring.split("\n") | |||
# linke Frequenz aus csv Datei holen | |||
lf = x[2] | |||
lf = tinnitus_data[2] | |||
lf = lf.split(";") | |||
lf = float(lf[1]) | |||
# rechte Frequenz aus csv Datei holen | |||
rf = x[7] | |||
rf = tinnitus_data[7] | |||
rf = rf.split(";") | |||
rf = float(rf[1]) | |||
# linke Lautstärke aus cvs Datei holen | |||
ll = x[3] | |||
ll = tinnitus_data[3] | |||
ll = ll.split(";") | |||
ll = float(ll[1]) | |||
# rechte Lautstärke aus cvs Datei holen | |||
rl = x[8] | |||
rl = tinnitus_data[8] | |||
rl = rl.split(";") | |||
rl = float(rl[1]) | |||
# Die Musik filtern | |||
w0 = float(lf/(self.music_samplerate/2)) # Frequency to remove from a signal. If fs is specified, this is in the same units as fs. By default, it is a normalized scalar that must satisfy 0 < w0 < 1, with w0 = 1 corresponding to half of the sampling frequency. | |||
Q = 30.0 # Quality factor. Dimensionless parameter that characterizes notch filter -3 dB bandwidth bw relative to its center frequency, Q = w0/bw. | |||
# -------- 2. Die digitalen Filter erstellen und die Tinnitus Frequenz aus der Audiodatei "herausschneiden------ | |||
start_time = time.time() # einen Timer laufen lassen um zu sehen wie lange Filterung dauert | |||
self.music_data = self.music_data/32767 * 0.8 # convert array from int16 to float | |||
""" OLD IIR Notch Filter 2nd Order---------------------------------------------------------------------- | |||
w0 = float(lf / (self.music_samplerate / 2)) # Frequency to remove from a signal. If fs is specified, this is | |||
in the same units as fs. By default, it is a normalized scalar that must satisfy 0 < w0 < 1, with w0 = 1 | |||
corresponding to half of the sampling frequency. | |||
Q = 30.0 # Quality factor. Dimensionless parameter that characterizes notch filter -3 dB bandwidth bw relative | |||
to its center frequency, Q = w0/bw. | |||
b, a = signal.iirnotch(lf, Q, fs=self.music_samplerate) | |||
if ll != 0.0: | |||
print("Links wird gefiltert...") | |||
musicLinks = signal.lfilter(b, a , self.music_data[:, 0]) # links | |||
print("Filtern beendet") | |||
else: | |||
musicLinks = self.music_data[:, 0] # ungefiltert, wenn kein Tinnitus angegeben wurde | |||
#Plot | |||
# freq, h = signal.freqz(b, a, fs=self.music_samplerate) | |||
# fig, ax = plt.subplots(2, 1, figsize=(8, 6)) | |||
# ax[0].plot(freq, 20 * np.log10(abs(h)), color='blue') | |||
# ax[0].set_title("Frequency Response") | |||
# ax[0].set_ylabel("Amplitude (dB)", color='blue') | |||
# ax[0].set_xlim([0, 10000]) | |||
# ax[0].set_ylim([-25, 10]) | |||
# ax[0].grid() | |||
# ax[1].plot(freq, np.unwrap(np.angle(h)) * 180 / np.pi, color='green') | |||
# ax[1].set_ylabel("Angle (degrees)", color='green') | |||
# ax[1].set_xlabel("Frequency (Hz)") | |||
# ax[1].set_xlim([0, 10000]) | |||
# ax[1].set_yticks([-90, -60, -30, 0, 30, 60, 90]) | |||
# ax[1].set_ylim([-90, 90]) | |||
# ax[1].grid() | |||
# plt.show() | |||
b, a = signal.iirnotch(rf, Q, fs=self.music_samplerate) | |||
if rl != 0.0: | |||
print("Rechts wird gefiltert...") | |||
musicRechts = signal.lfilter(b, a, self.music_data[:, 1]) # rechts | |||
print("Filtern beendet") | |||
---------------------------------------------------------------------------------------------------------------- | |||
""" | |||
""" New IIR Notch Filter 5th order--------------------------------------------------------------------------""" | |||
# ------------------------------------------LEFT EAR FILTERING------------------------------------------------- | |||
# Filterparameter festlegen------------ | |||
order = 5 # Filterordnung | |||
bandwidth = 175 # Bandbreite des Sperrbereichs in Hz | |||
#stop_attenuation = 100 # minimum Attenuation (Damping, Reduction) in stop Band [only for elliptic filter necessary] | |||
cutoff_frequencies = [(lf - (bandwidth / 2)),(lf + (bandwidth / 2))] # the cutoff frequencies (lower and upper) | |||
max_ripple_passband = 50 # Maximal erlaubte Welligkeit im Passbereich | |||
# ------------------------------------- | |||
if ll != 0.0: # nur wenn die Lautstärke des linken Tinnitus ungleich 0 ist, wird auf diesem Ohr auch gefiltert | |||
b, a = signal.iirfilter(order, cutoff_frequencies, rp=max_ripple_passband, btype='bandstop', ftype='butter', | |||
fs=self.music_samplerate) # Diese Funktion erstellt den IIR-Bandpassfilter (links) | |||
music_links = signal.lfilter(b, a, self.music_data[:, 0]) # diese Funktion filtert die Audiodaten | |||
else: | |||
musicRechts = self.music_data[:, 1] # ungefiltert, wenn kein Tinnitus angegeben wurde | |||
music_links = self.music_data[:, 0] # ungefiltert, wenn kein Tinnitus angegeben wurde | |||
# ------------------------------------- RIGHT EAR FILTERING ------------------------------------------------ | |||
if rl != 0.0: # nur wenn die Lautstärke des rechten Tinnitus ungleich 0 ist, wird auf diesem Ohr auch gefiltert | |||
cutoff_frequencies = [(rf - (bandwidth / 2)), ( | |||
rf + (bandwidth / 2))] # change the cutoff frequencies to the tinnitus of the RIGHT EAR | |||
wav_obj = wave.open("musikTest.wav", "w") | |||
b, a = signal.iirfilter(order, cutoff_frequencies, rp=max_ripple_passband, btype='bandstop', ftype='butter', | |||
fs=self.music_samplerate) # Diese Funktion erstellt den IIR-Bandpassfilter (rechts) | |||
music_rechts = signal.lfilter(b, a, self.music_data[:, 1]) # rechts | |||
else: | |||
music_rechts = self.music_data[:, 1] # diese Funktion filtert die Audiodaten(die Tinnitusfreq wird entfernt) | |||
endTimeFiltering = time.time() | |||
print("benötigte Zeit zum Filtern rechts Ohr =", endTimeFiltering - start_time, "s") | |||
# ------------------------- 3. Die fertigen Audiodatei als .wav Datei speichern -------------------------------- | |||
start_time = time.time() | |||
wav_obj = wave.open("MyTinnitusFreeSong.wav", "w") | |||
# Rahmenparameter für die .wav-Datei setzen | |||
nframes = len(self.music_data) #Gesamtanzahl der Frames in der Musikdatei | |||
wav_obj.setparams((self.nchannels, self.sampwidth, self.music_samplerate, nframes, self.comptype, self.compname)) | |||
print("Maximum musicLinks: ", max(musicLinks)) | |||
print("Minimum musikLinks: ", min(musicLinks)) | |||
"""The values are stored in a temporary list, and when the process is finished, they are joined together into | |||
an string which is then sent to the output with the traditional writeframes method.""" | |||
packedMusic = [] # Liste an die wir die einzelnen frames bereits in binär umgewandelt aneinanderreihen | |||
# Die Audiosamples schreiben | |||
print("Musikdatei wird erstellt...") | |||
for x in range(self.music_samplerate * 20): #Kann mit nframes ersetzt werden, für den ganzen Song | |||
for tinnitus_data in range(self.music_samplerate * 60): #Kann mit nframes ersetzt werden, für den ganzen Song | |||
# Die Audiodaten müssen von float in einen passenden int-Wert umgerechnet werden | |||
wav_obj.writeframes(struct.pack('h', int(musicLinks[x] * 32767.0))) # Werte für links und rechts werden bei | |||
wav_obj.writeframes(struct.pack('h', int(musicRechts[x] * 32767.0))) # wav abwechselnd eingetragen | |||
if x % 10000 == 0: | |||
fortschritt = x/(self.music_samplerate*20)*100 | |||
packedMusic.append(struct.pack('h', int(music_links[tinnitus_data] * 32767.0))) | |||
packedMusic.append(struct.pack('h', int(music_rechts[tinnitus_data] * 32767.0))) | |||
# wav_obj.writeframes(struct.pack('h', int(music_links[x] * 32767.0))) # Werte für links und rechts werden bei | |||
# wav_obj.writeframes(struct.pack('h', int(musicRechts[x] * 32767.0))) # wav abwechselnd eingetragen | |||
if tinnitus_data % 10000 == 0: | |||
fortschritt = tinnitus_data/(self.music_samplerate*20)*100 | |||
print(" ", round(fortschritt, 1), "%") | |||
end_time = time.time() | |||
print("Zeitaufwand für das packen der einzelnen Samples =", end_time - start_time, "s") | |||
value_str = b"".join(packedMusic) | |||
start = time.time() | |||
wav_obj.writeframes(value_str) | |||
end = time.time() | |||
print("Zeitaufwand für das schreiben aller Frames in die wav Datei =", end - start, "s") | |||
wav_obj.close() | |||
print("Speichern beendet.") | |||
# # Plot (hilfreich für Filterentwurf) | |||
# freq, h = signal.freqz(b, a, fs=self.music_samplerate) | |||
# fig, ax = plt.subplots(2, 1, figsize=(8, 6)) | |||
# ax[0].plot(freq, 20 * np.log10(abs(h)), color='blue') | |||
# ax[0].set_title("Frequency Response") | |||
# ax[0].set_ylabel("Amplitude (dB)", color='blue') | |||
# ax[0].set_xlim([0, 10000]) | |||
# ax[0].set_ylim([-120, 10]) | |||
# ax[0].grid() | |||
# ax[1].plot(freq, np.unwrap(np.angle(h)) * 180 / np.pi, color='green') | |||
# ax[1].set_ylabel("Angle (degrees)", color='green') | |||
# ax[1].set_xlabel("Frequency (Hz)") | |||
# ax[1].set_xlim([0, 10000]) | |||
# ax[1].set_yticks([-90, -60, -30, 0, 30, 60, 90]) | |||
# ax[1].set_ylim([-90, 90]) | |||
# ax[1].grid() | |||
# plt.show() |
@@ -6,9 +6,6 @@ import sounddevice as sd | |||
from scipy.io import wavfile | |||
"""--------------------------FUNKTIONEN DIE DURCH GUI KLICKS AUSGEFÜHRT WERDEN---------------------------------------""" | |||
"""-------Funktionen links-------------""" | |||
@@ -201,10 +198,15 @@ def unten_button_musikdatei_laden_press(): | |||
def unten_button_filtere_tinnitus_aus_musik(): | |||
print("button filtere tinnitus aus musik pressed") | |||
feedback("Gefilterte Musikdatei erstellt", "blue") | |||
sound.musik_filtern() | |||
# except: | |||
# feedback("Fehlgeschlagener Filterversuch!", "red", "white") | |||
try: | |||
feedback("Starte Filtervorgang (dies kann einige Minuten dauern)...", "blue") | |||
sound.musik_filtern() | |||
feedback("Filtervorgang erfolgreich abgeschlossen. \n" | |||
"Audiodatei unter dem Namen MyTinnitusFreeSong.wav erstellt", "white", "green") | |||
except: | |||
feedback("Fehlgeschlagener Filterversuch. Drücke zuerst den Speichern Knopf" | |||
"Stelle sicher, dass die Lautstärke mindestens einer Seite über 0" | |||
"gestellt ist. Sonst gehen wir davon aus, dass auf diesem Ohr kein Tinnitus vorliegt.", "red", "white") | |||
""" Initialisierungen """ |
@@ -1,13 +1,14 @@ | |||
Vorname;asd | |||
Nachname;asd | |||
linke Frequenz;10000.0 | |||
linke Lautstärke;0.2 | |||
linke Frequenz;5040.0 | |||
linke Lautstärke;0.04 | |||
linkes Rauschen Lautstärke;0.0 | |||
linkes Rauschen untere Grenzfrequenz;10.0 | |||
linkes Rauschen obere Grenzfrequenz;20000.0 | |||
rechte Frequenz;920.0 | |||
rechte Lautstärke;0.28 | |||
rechte Frequenz;5040.0 | |||
rechte Lautstärke;0.02 | |||
rechtes Rauschen Lautstärke;0.0 | |||
rechtes Rauschen untere Grenzfrequenz;10.0 | |||
rechtes Rauschen obere Grenzfrequenz;20000.0 | |||
Kommentar; | |||