Browse Source

Skript Fusion GUI+SoundGen

Fuisonierung der Arbeiten von Heiko und Julian.

Die ersten GUI Funktionen mit Sound Sachen gefüllt.

Kleine Änderung am SoundGenerator in Form eines Booleans der die Play Funktion verhindert.
master
seyffejn 4 years ago
parent
commit
5e00186874

+ 1
- 0
.gitignore View File

@@ -2,3 +2,4 @@
TinnitusAnalyse/.idea/dictionaries/Julian.xml
TinnitusAnalyse/.idea/workspace.xml
TinnitusAnalyse/eggs.csv
TinnitusAnalyse/.idea/workspace.xml

+ 3
- 0
TinnitusAnalyse/.idea/dictionaries/Julian.xml View File

@@ -8,7 +8,9 @@
<w>definieren</w>
<w>frequenz</w>
<w>kommentare</w>
<w>lautstaerke</w>
<w>lautstärke</w>
<w>liefert</w>
<w>linkem</w>
<w>linken</w>
<w>linkes</w>
@@ -23,6 +25,7 @@
<w>rechter</w>
<w>rechtes</w>
<w>rechts</w>
<w>speicherversuch</w>
<w>variablen</w>
<w>vorname</w>
<w>zwischen</w>

+ 55
- 23
TinnitusAnalyse/.idea/workspace.xml View File

@@ -2,8 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="5b3f2136-e422-4072-84be-e86e40fa2d55" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/../.gitignore" 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$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/27130.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Headphones Icon.ico" 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" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -17,8 +21,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="396">
<caret line="93" lean-forward="true" selection-start-line="93" selection-end-line="93" />
<state relative-caret-position="97">
<caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" />
<folding>
<element signature="e#0#117#0" expanded="true" />
</folding>
@@ -29,7 +33,7 @@
<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="26435">
<state relative-caret-position="935">
<caret line="1557" selection-start-line="1557" selection-end-line="1557" />
</state>
</provider>
@@ -38,8 +42,8 @@
<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="170">
<caret line="14" column="14" selection-start-line="14" selection-start-column="14" selection-end-line="14" selection-end-column="14" />
<state relative-caret-position="-1326">
<caret line="18" column="36" lean-forward="true" selection-start-line="18" selection-start-column="36" selection-end-line="18" selection-end-column="36" />
<folding>
<element signature="e#0#11#0" expanded="true" />
</folding>
@@ -77,6 +81,8 @@
<find>linker</find>
<find>für alle</find>
<find>scale_lautstärke_links_change</find>
<find>mute</find>
<find>Sound(</find>
</findStrings>
<dirStrings>
<dir>C:\Users\Julian\PycharmProjects\TinnitusAnalyse</dir>
@@ -88,15 +94,17 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/WriteToCSV.py" />
<option value="$PROJECT_DIR$/SoundGenerator.py" />
<option value="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="1696" />
<option name="height" value="1066" />
<option name="x" value="2971" />
<option name="y" value="-27" />
<option name="width" value="1113" />
<option name="height" value="769" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
@@ -171,10 +179,32 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="WriteToCSV" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="TinnitusAnalyse" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/WriteToCSV.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.TinnitusAnalyse_GUI" />
<item itemvalue="Python.SoundGenerator" />
<item itemvalue="Python.WriteToCSV" />
</list>
</recent_temporary>
</component>
@@ -192,14 +222,15 @@
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="2576" height="1416" extended-state="6" />
<frame x="2552" y="-8" width="1696" height="1026" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" weight="0.18479118" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<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 anchor="bottom" id="Run" order="2" weight="0.21200311" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.29787233" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39977604" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -236,37 +267,38 @@
<entry file="file://$PROJECT_DIR$/.idea/TinnitusAnalyse.iml">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py">
<entry file="file://$PROJECT_DIR$/WriteToCSV.py" />
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/tkinter/ttk.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="396">
<caret line="93" lean-forward="true" selection-start-line="93" selection-end-line="93" />
<folding>
<element signature="e#0#117#0" expanded="true" />
</folding>
<state relative-caret-position="9367">
<caret line="552" selection-start-line="552" selection-end-line="552" />
</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="26435">
<state relative-caret-position="935">
<caret line="1557" selection-start-line="1557" selection-end-line="1557" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SoundGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="14" column="14" selection-start-line="14" selection-start-column="14" selection-end-line="14" selection-end-column="14" />
<state relative-caret-position="-1326">
<caret line="18" column="36" lean-forward="true" selection-start-line="18" selection-start-column="36" selection-end-line="18" selection-end-column="36" />
<folding>
<element signature="e#0#11#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/tkinter/ttk.py">
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="9367">
<caret line="552" selection-start-line="552" selection-end-line="552" />
<state relative-caret-position="97">
<caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" />
<folding>
<element signature="e#0#117#0" expanded="true" />
</folding>
</state>
</provider>
</entry>

BIN
TinnitusAnalyse/27130.png View File


BIN
TinnitusAnalyse/Headphones Icon.ico View File


+ 37
- 33
TinnitusAnalyse/SoundGenerator.py View File

@@ -9,7 +9,7 @@ import time #nur für die Tests, um Zeit zum Anhören der Sounds einzubauen
#das heißt für jede Sekunde an Ton gibt es 44100 Werte, die die Tonwelle über die Zeit beschreiben

class Tinnitus: #beinhaltet alle Werte, die vom Nutzer eingestellt werden
def __init__(self, l_freq=600, r_freq=600, l_amp=1, r_amp=1, l_rausch=0, r_rausch=0, ear=0):
def __init__(self, l_freq=600, r_freq=600, l_amp=0, r_amp=0, l_rausch=0, r_rausch=0, ear=0):
self.linksFrequenz = l_freq
self.rechtsFrequenz = r_freq
self.linksLautstaerke = l_amp
@@ -38,7 +38,7 @@ class Tinnitus: #beinhaltet alle Werte, die vom Nutzer eingestellt werden
#Die Klasse beinhaltet alle Werte, die zum Erstellen einer .wav-Datei benötigt werden und ein Tinnitus-Objekt, das beim Initialisieren übergeben werden muss.
#Die Audiodaten werden in das Array "audio" geschrieben
class Sound:
def __init__(self, tinnitus, name="sound.wav", audio=None, nchannels=1, sampwidth=2, framerate=44100, comptype="NONE", compname="not compressed"):
def __init__(self, tinnitus, name="sound.wav", audio=None, nchannels=1, sampwidth=2, framerate=44100, comptype="NONE", compname="not compressed", mute=True):
if audio is None:
audio = []
self.tinnitus = tinnitus
@@ -50,6 +50,7 @@ class Sound:
self.nframes = len(audio) #Anzahl der Sound-Werte -> Muss bei jeder audio-Änderung aktuallisiert werden
self.comptype = comptype
self.compname = compname
self.mute = True # wenn der mute boolean auf true gesetzt ist, sollte kein Ton ausgegeben werden
return

def neu_audio(self): #Schreibt Werte in das audio-Array. Soll später abhängig sein von den Tinnitus-Werten(Frequenz, Rauschen, ...)
@@ -92,38 +93,41 @@ class Sound:

def play(self):
self.neu_audio()
sd.play(self.audio, self.framerate, loop=1)
if not self.mute: # NEVER play sound when patient mutes GUI
sd.play(self.audio, self.framerate, loop=1)
return

def stop(self):
sd.stop()
return


tinnitus1 = Tinnitus()
sound = Sound(tinnitus1)

if(0):
print("======abnehmende Lautstärke==========")
for x in range(10):
print(" Lautstärke = ", tinnitus1.linksLautstaerke)
sound.play()
time.sleep(0.6)
tinnitus1.linksLautstaerke -= 0.1
print("\n\n")
time.sleep(1)
tinnitus1.linksLautstaerke = 1



if(0):
print("=========RauschTest============")
for x in range(10):
tinnitus1.linksRauschenLautstaerke += 0.01
print(" Rauschen = ", tinnitus1.linksRauschenLautstaerke)
sound.play()
time.sleep(1)
if(0):
tinnitus1.speichern()

sd.stop()
print("ENDE")
# tinnitus1 = Tinnitus()
# sound = Sound(tinnitus1)
#
# if(1):
# print("======abnehmende Lautstärke==========")
# for x in range(10):
# print(" Lautstärke = ", tinnitus1.linksLautstaerke)
# sound.play()
# time.sleep(0.6)
# tinnitus1.linksLautstaerke -= 0.1
# print("\n\n")
# time.sleep(1)
# tinnitus1.linksLautstaerke = 1
#
#
#
# if(0):
# print("=========RauschTest============")
# for x in range(10):
# tinnitus1.linksRauschenLautstaerke += 0.01
# print(" Rauschen = ", tinnitus1.linksRauschenLautstaerke)
# sound.play()
# time.sleep(1)
#
# if(0):
# tinnitus1.speichern()
#
# sd.stop()
# print("ENDE")


+ 28
- 7
TinnitusAnalyse/TinnitusAnalyse_GUI.py View File

@@ -1,5 +1,6 @@
from tkinter.ttk import Frame, Label, Button, LabelFrame, Combobox, Style, Checkbutton, Entry, Panedwindow, Separator
from tkinter import *
from SoundGenerator import *
import csv


@@ -8,28 +9,33 @@ import csv


def links_scale_lautstärke_change(self):
linksLautstärke = float(linksScaleLautstärke.get())
print("Links Lautstärke =", linksLautstärke)
tinnitus.linksLautstaerke = float(linksScaleLautstärke.get())/100 # scale liefert 0-100%, tinnitus.lautstärke 0-1
print("Links Lautstärke =", tinnitus.linksLautstaerke*100)
sound.play()


def links_scale_frequenz_change(self):
linksFrequenz = float(linksScaleFrequenz.get())
#tinnitus.linksFrequenz = float(linksScaleFrequenz.get())/1000 # scale liefert 20-20kHz, tinnitus.frequenz in Hz
print("Links Frequenz = ", linksFrequenz)
sound.play()


def links_scale_rauschen_lautstärke_change(self):
linksRauschenLautstärke = float(linksScaleRauschenLautstärke.get())
print("Links Rauschen Lautstärke = ", linksRauschenLautstärke)
sound.play()


def links_scale_rauschen_mittelfrequenz_change(self):
linksRauschenMittelfrequenz = float(linksScaleRauschenMittelFrequenz.get())
print("Links Rauschen Mittelfrequenz = ", linksRauschenMittelfrequenz)
sound.play()


def links_scale_rauschen_bandbreite_change(self):
linksRauschenBandbreite = float(linksScaleRauschenBandbreite.get())
print("Links Rauschen Bandbreite = ", linksRauschenBandbreite)
sound.play()


"""----------Funktionen rechts----------"""
@@ -38,26 +44,31 @@ def links_scale_rauschen_bandbreite_change(self):
def rechts_scale_lautstärke_change(self):
rechtsLautstärke = float(rechtsScaleLautstärke.get())
print("Rechts Lautstärke =", rechtsLautstärke)
sound.play()


def rechts_scale_frequenz_change(self):
rechtsFrequenz = float(rechtsScaleFrequenz.get())
print("Rechts Frequenz= ", rechtsFrequenz)
sound.play()


def rechts_scale_rauschen_lautstärke_change(self):
rechtsRauschenLautstärke = float(rechtsScaleRauschenLautstärke.get())
print("Rechts Rauschen Lautstärke = ", rechtsRauschenLautstärke)
sound.play()


def rechts_scale_rauschen_mittelfrequenz_change(self):
rechtsRauschenMittelfrequenz = float(rechtsScaleRauschenMittelFrequenz.get())
print("Rechts Rauschen Mittelfrequenz = ", rechtsRauschenMittelfrequenz)
sound.play()


def rechts_scale_rauschen_bandbreite_change(self):
rechtsRauschenBandbreite = float(rechtsScaleRauschenBandbreite.get())
print("Rechts Rauschen Bandbreite = ", rechtsRauschenBandbreite)
sound.play()


"""--------------Funktionen unten------------------"""
@@ -89,17 +100,27 @@ def unten_button_speichern_press():
(untenEntryNachname == "Erst Namen..") or (untenEntryVorname == "..eintragen bitte"):
nachname.set("Erst Namen..")
vorname.set("..eintragen bitte")
print("fehlgeschlagener Speicherversuch - Keine Eingaben gemacht")
else:
print("TEST")
print("Speichere Patientendaten, siehe TinnitusDaten.csv")
tinnitus.speichern()


def unten_button_play_press():
print("button play pressed")

print("button play pressed -> mute=false")
sound.mute = False
sound.play()

def unten_button_stop_press():
print("button stop press")
print("button stop press -> mute=true")
sound.mute = True
sound.stop()


""""""
tinnitus = Tinnitus()
sound = Sound(tinnitus)
print("test")

"""------------------------------------------ AUFBAU DES ROOT WINDOWS -----------------------------------------------"""
root = Tk() # build the main window

BIN
TinnitusAnalyse/__pycache__/SoundGenerator.cpython-35.pyc View File


Loading…
Cancel
Save