From dd7ceac2cc3fd4c795a2d6ae8ebd39c511678f9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Lehnhoff?= <loic.lehnhoff@gmail.com>
Date: Wed, 3 Jul 2024 11:04:16 +0200
Subject: [PATCH] readability improvements

---
 README.md                 | 52 +++++++++++++++++++++++++--------------
 interface.py              |  2 +-
 last-parameters-used.json |  2 +-
 3 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/README.md b/README.md
index 290b802..a014752 100644
--- a/README.md
+++ b/README.md
@@ -9,22 +9,26 @@
 
 ## Features
 
-- [x] Same tools as matplotlib.pyplot plots.
-- [x] Spectrogram contour annotations. 
+- [x] Same tools as matplotlib plots.
 - [x] Spectrogram automatically computed from waveform.
-- [x] Choose custom spectrogram resolutions (fft, hop length, clipping of lowest dB values and PCEN).
-- [x] Exportation of contours to local `.json`.
+- [x] Direct modification of spectrogram included
+    - Choose FFT size
+    - Choose Hop length
+    - Clip lowest dBFS values
+    - Switch between PCEN/spectrogram
+- [x] Spectrogram contour/bounding box annotations. 
+- [x] Exportation of contours to local `.json` (custom format).
 - [x] Possibility to move points that are already placed.
-- [x] Modification of previous annotation files. Save & return later!
+- [x] Modification of previously annotated files.
 
 ## Known issues
-- laggy when high number of contours/points per contour
+- Optimisation necessary when many annotations
 
 ## Requirements
-
-- Ubuntu / Windows / macOS (tested only on Ubuntu but it *should* work on any OS).
 - Python 3.9.7
 - Packages in `requirements.txt`
+- Linux / Windows / macOS (only tested with Ubuntu & Windows10 but it *should* work on any OS).
+
 
 Install packages in your python environment with `$ pip install -r requirements.txt`.
 
@@ -32,14 +36,20 @@ Install packages in your python environment with `$ pip install -r requirements.
 ## Usage
 
 ### Execution
-For classic usage, download PyAVA folder, then open a terminal in the folder and run `$ python PyAVA.py -dir myWavefileFolder -out myOutputFolder` in terminal.  
+For classic usage:
+- Download PyAVA folder
+- Open a terminal in the folder 
+- Run `$ python PyAVA.py` in terminal.  
+- Select audio file to annotate.
+- Make annotations (see User actions)
+- Save and quit
 
-Run `$python PyAVA.py --help` for details.  
+Run `$python PyAVA.py --help` for details and additional options.  
 
-The annotations are saved as [JSON](http://www.json.org/) files. Each file contains a dictionnary with the categories annotated. For each category there is a list of points, each point is defined by a list of two elements : [time (in sec), frequency (in Hz)].
+The annotations are saved as [JSON](http://www.json.org/) files. Each file contains a dictionnary with keys corresponding to each annotation. For each contour there is a list of points, each point is defined by a list of two elements : [time (in sec), frequency (in Hz)].
 
 ### User actions
-- Use the toolbar to interact with the plot (same as with matplotlib.pyplot)
+- Use the toolbar to interact with the plot (same as with matplotlib)
 - Shortcuts "p" and "w" to activate panning, "z" to activate zoom. 
 - Draw lines :
     - User must not have any toolbar item selected in order to annotate the spectrogram.
@@ -54,9 +64,18 @@ The annotations are saved as [JSON](http://www.json.org/) files. Each file conta
 - Click on `Switch to PCEN` to switch between PCEN and spectrogram image.
 
 ### Re-use data
-To load and display the saved annotations, use the "Results" object. It contains several infos: coordinates of the annotations, spectrogram, waveform and more.  
-
-Open a terminal window in PyAVA folder and run the following lines with Python to see an exemple of use:  
+#### Modification
+To modify previous annotations using PyAVA interface:
+- Open a terminal window in PyAVA folder 
+- Run the following command:
+`$python PyAVA.py --modify annotation_file audio_file`
+
+#### Display
+To display previous annotations, use the `Results` object. 
+It contains several infos: coordinates of the annotations, spectrogram, waveform and more.  
+- Open a terminal window in PyAVA folder 
+- Open python terminal
+- Run the following lines (an exemple of use):  
 ```python
 import os
 import json
@@ -77,9 +96,6 @@ print(json.dumps(annot_data.coords, indent=4)) # show file content
 annot_data.display_contours() # or annot_data.display_contours(img="pcen")
 ```
 
-To modify previous annotations, run the following line (using annotations on file SCW6070_20220717_174215.wav as an example):
-`$python PyAVA.py --modify SCW6070_20220717_174215-contours.json SCW6070_20220717_174215.wav`
-
 ## Support
 
 Please contact [me](mailto:loic.lehnhoff@gmail.com) for any question and/or idea.
diff --git a/interface.py b/interface.py
index 24e7dcc..4160219 100644
--- a/interface.py
+++ b/interface.py
@@ -288,7 +288,7 @@ class App(object):
             self.NEW_SR = parameter_dict["SR"]
             self._default_pcen = parameter_dict["PCEN"]
         
-        if self._default_pcen:
+        if not self._default_pcen:
             self.initial_text_pcen = "Switch to PCEN"
         else:
             self.initial_text_pcen = "Switch to Spectrogram"
diff --git a/last-parameters-used.json b/last-parameters-used.json
index d56a73d..a348159 100644
--- a/last-parameters-used.json
+++ b/last-parameters-used.json
@@ -3,5 +3,5 @@
     "SR": 96000,
     "NFFT": 2048,
     "HOP_LENGTH": 512,
-    "CLIPPING": -80
+    "CLIPPING": -60
 }
\ No newline at end of file
-- 
GitLab