@@ -2,13 +2,10 @@ | |||
<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$/BeispielMusikDateien/whitenoise.wav" beforeDir="false" afterPath="$PROJECT_DIR$/BeispielMusikDateien/whitenoise.wav" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/MyTinnitusFreeSong.wav" beforeDir="false" afterPath="$PROJECT_DIR$/MyTinnitusFreeSong.wav" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/Projektbericht/~$ojektbericht.docx" beforeDir="false" afterPath="$PROJECT_DIR$/Projektbericht/~$ojektbericht.docx" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/Projektbericht/~WRL0004.tmp" beforeDir="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" /> | |||
</list> | |||
<ignored path="$PROJECT_DIR$/venv/" /> | |||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> | |||
@@ -22,8 +19,8 @@ | |||
<file pinned="false" current-in-tab="true"> | |||
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="82"> | |||
<caret line="231" column="64" selection-start-line="231" selection-start-column="64" selection-end-line="231" selection-end-column="64" /> | |||
<state relative-caret-position="377"> | |||
<caret line="220" column="36" lean-forward="true" selection-start-line="220" selection-start-column="36" selection-end-line="220" selection-end-column="36" /> | |||
<folding> | |||
<element signature="e#0#30#0" expanded="true" /> | |||
</folding> | |||
@@ -34,17 +31,26 @@ | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/fir_filter_design.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="6562"> | |||
<state relative-caret-position="594"> | |||
<caret line="399" selection-start-line="399" selection-end-line="399" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/threading.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="217"> | |||
<caret line="913" selection-start-line="913" selection-end-line="913" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
</file> | |||
<file pinned="false" current-in-tab="false"> | |||
<entry file="file://$PROJECT_DIR$/SoundGenerator.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="275"> | |||
<caret line="382" column="34" selection-start-line="376" selection-start-column="8" selection-end-line="392" selection-end-column="18" /> | |||
<state relative-caret-position="674"> | |||
<caret line="308" column="30" lean-forward="true" selection-start-line="308" selection-start-column="30" selection-end-line="308" selection-end-column="30" /> | |||
<folding> | |||
<element signature="e#0#42#0" expanded="true" /> | |||
</folding> | |||
@@ -55,7 +61,7 @@ | |||
<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="-636"> | |||
<state relative-caret-position="28492"> | |||
<caret line="1694" column="4" selection-start-line="1694" selection-start-column="4" selection-end-line="1694" selection-end-column="4" /> | |||
</state> | |||
</provider> | |||
@@ -94,12 +100,14 @@ | |||
<find>StringVar</find> | |||
<find>Speichern</find> | |||
<find>csv</find> | |||
<find>order</find> | |||
<find>musikTest</find> | |||
<find>Daten er</find> | |||
<find>samples</find> | |||
<find>feedback</find> | |||
<find>framerate</find> | |||
<find>sample</find> | |||
<find>samplerate</find> | |||
<find>order</find> | |||
<find>feedback</find> | |||
</findStrings> | |||
<dirStrings> | |||
<dir>C:\Users\Julian\PycharmProjects\TinnitusAnalyse</dir> | |||
@@ -111,12 +119,12 @@ | |||
<component name="IdeDocumentHistory"> | |||
<option name="CHANGED_PATHS"> | |||
<list> | |||
<option value="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" /> | |||
<option value="$PROJECT_DIR$/SoundGenerator.py" /> | |||
<option value="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" /> | |||
</list> | |||
</option> | |||
</component> | |||
<component name="ProjectFrameBounds" extendedState="7"> | |||
<component name="ProjectFrameBounds" extendedState="6"> | |||
<option name="x" value="313" /> | |||
<option name="y" value="-25" /> | |||
<option name="width" value="1294" /> | |||
@@ -284,7 +292,7 @@ | |||
<servers /> | |||
</component> | |||
<component name="ToolWindowManager"> | |||
<frame x="-8" y="-8" width="2576" height="1416" extended-state="7" /> | |||
<frame x="-8" y="-8" width="2576" height="1416" extended-state="6" /> | |||
<editor active="true" /> | |||
<layout> | |||
<window_info content_ui="combo" id="Project" order="0" weight="0.25" /> | |||
@@ -292,7 +300,7 @@ | |||
<window_info id="Favorites" order="2" 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.4731099" /> | |||
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.2182385" /> | |||
<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" /> | |||
@@ -357,24 +365,31 @@ | |||
</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="28492"> | |||
<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/fir_filter_design.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="6562"> | |||
<state relative-caret-position="594"> | |||
<caret line="399" selection-start-line="399" selection-end-line="399" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/signaltools.py"> | |||
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/threading.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="-636"> | |||
<caret line="1694" column="4" selection-start-line="1694" selection-start-column="4" selection-end-line="1694" selection-end-column="4" /> | |||
<state relative-caret-position="217"> | |||
<caret line="913" selection-start-line="913" selection-end-line="913" /> | |||
</state> | |||
</provider> | |||
</entry> | |||
<entry file="file://$PROJECT_DIR$/SoundGenerator.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="275"> | |||
<caret line="382" column="34" selection-start-line="376" selection-start-column="8" selection-end-line="392" selection-end-column="18" /> | |||
<state relative-caret-position="674"> | |||
<caret line="308" column="30" lean-forward="true" selection-start-line="308" selection-start-column="30" selection-end-line="308" selection-end-column="30" /> | |||
<folding> | |||
<element signature="e#0#42#0" expanded="true" /> | |||
</folding> | |||
@@ -383,8 +398,8 @@ | |||
</entry> | |||
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py"> | |||
<provider selected="true" editor-type-id="text-editor"> | |||
<state relative-caret-position="82"> | |||
<caret line="231" column="64" selection-start-line="231" selection-start-column="64" selection-end-line="231" selection-end-column="64" /> | |||
<state relative-caret-position="377"> | |||
<caret line="220" column="36" lean-forward="true" selection-start-line="220" selection-start-column="36" selection-end-line="220" selection-end-column="36" /> | |||
<folding> | |||
<element signature="e#0#30#0" expanded="true" /> | |||
</folding> |
@@ -232,42 +232,35 @@ class Sound: | |||
rl = float(rl[1]) | |||
# -------- 2. Die digitalen Filter erstellen und die Tinnitus Frequenz aus der Audiodatei "herausschneiden------ | |||
self.filterfortschritt = 2, 0 # der zweite schritt | |||
self.filterfortschritt = 2, 0 # der zweite schritt im Feedback | |||
start_time = time.time() # einen Timer laufen lassen um zu sehen wie lange Filterung dauert | |||
self.music_data = self.music_data/32767 # 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) | |||
---------------------------------------------------------------------------------------------------------------- | |||
""" | |||
self.music_data = self.music_data/32767 # convert array from int16 to float | |||
""" New IIR Notch Filter 5th order--------------------------------------------------------------------------""" | |||
# ------------------------------------------LEFT EAR FILTERING------------------------------------------------- | |||
# Filterparameter festlegen------------ | |||
order = 5 # Filterordnung | |||
bandwidth = 175 # Bandbreite des Sperrbereichs in Hz | |||
order = 501 # Filterordnung | |||
bandwidth = 1000 # 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) | |||
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 wendet den Filter an | |||
# FIR Filterversuch | |||
# b = signal.firwin(order, cutoff_frequencies, pass_zero="bandstop", fs=self.music_samplerate, width=bandwidth, | |||
# window="hamming") | |||
# 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 wendet den Filter an | |||
# | |||
# music_links = signal.lfilter(b, [1.0], self.music_data[:, 0]) | |||
# print("b=", b) | |||
# print("a=", a) | |||
# FIR Filterversuch | |||
#h = signal.firwin(order, cutoff_frequencies, pass_zero="bandstop", fs=self.music_samplerate, width=bandwidth, | |||
# window="hamming") | |||
h = signal.firwin(order, [cutoff_frequencies[0], cutoff_frequencies[1]], fs=self.music_samplerate) | |||
print("h= ", h) | |||
music_links = signal.lfilter(h, 1.0, self.music_data[:, 0]) | |||
else: | |||
music_links = self.music_data[:, 0] # ungefiltert, wenn kein Tinnitus angegeben wurde | |||
@@ -277,16 +270,16 @@ class Sound: | |||
cutoff_frequencies = [(rf - (bandwidth / 2)), ( | |||
rf + (bandwidth / 2))] # change the cutoff frequencies to the tinnitus of the RIGHT EAR | |||
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 | |||
# h = 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 | |||
# FIR Filterversuch | |||
# b = signal.firwin(order, cutoff_frequencies, pass_zero="bandstop", fs=self.music_samplerate, width=bandwidth, | |||
# window="hamming") | |||
# | |||
# music_rechts = signal.lfilter(b, [1.0], self.music_data[:, 1]) | |||
print("UG Freq = ", cutoff_frequencies[0]/(self.music_samplerate/2)) | |||
h = signal.firwin(order, [cutoff_frequencies[0], cutoff_frequencies[1]], fs=self.music_samplerate) | |||
music_rechts = signal.lfilter(h, [1.0], self.music_data[:, 1]) | |||
else: | |||
music_rechts = self.music_data[:, 1] # diese Funktion filtert die Audiodaten(die Tinnitusfreq wird entfernt) | |||
@@ -310,9 +303,9 @@ class Sound: | |||
# self.filterfortschritt = 3, round(fortschritt, 1) | |||
# print(" max: ", self.filterfortschritt[1], "%") | |||
fortschritt += 10 | |||
self.filterfortschritt = 3, round(fortschritt, 1) | |||
print(" max: ", self.filterfortschritt[1], "%") | |||
fortschritt += 10 | |||
end_time = time.time() | |||
print("Zeitaufwand Maxima-Suche: ", end_time - start_time) | |||
@@ -375,19 +368,19 @@ class Sound: | |||
print("Speichern beendet.") | |||
self.filterfortschritt = 5, 0 #Nach erfolgreichem Filtern Fortschritt zur Bestätigung auf 5 setzen | |||
# 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() | |||
# 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() |