aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornext2w2022-10-03 19:44:50 -0400
committernext2w2022-10-03 19:45:38 -0400
commit9a9e7d15d91bc9f7325b4709ce3d041331713f10 (patch)
tree9464706892029fd71c6c35fa66c5c9b539aa2813
parent14e7fe85f0af25200ae29130f9e8355bee4ee62e (diff)
Fix a crap ton of bugs
-rw-r--r--backend/app.py41
-rw-r--r--src/App.js2
2 files changed, 16 insertions, 27 deletions
diff --git a/backend/app.py b/backend/app.py
index 97f9491..b0c6ade 100644
--- a/backend/app.py
+++ b/backend/app.py
@@ -6,42 +6,31 @@ import subprocess
app = Flask(__name__)
-threadFlag = True
-def playFunction(freq):
- global threadFlag
- p = subprocess.Popen(["beep", "-f", freq, "-l", "100000"])
- while not threadFlag:
- pass
- #print("beep -f %f" % (freq))
- os.kill(p.pid, 15)
-
-thread2 = 0
+curf = 0
+p = 0
+
tc = 0
@app.before_first_request
def activate_job():
global tc
tc = 0
-@app.route('/startfreq/<freq>')
-def freq(freq):
- global threadFlag
- global thread2
- threadFlag = False
- print(freq)
- thread2 = Thread(target=playFunction, args=(freq,))
- thread2.start()
+@app.route('/startfreq/<f>')
+def startfreq(f):
+ global curf
+ global p
+ print(f)
+ curf = f
+ p = subprocess.Popen(["beep", "-f", f, "-l", "100000"]).pid
return("200")
-@app.route('/stopfreq/<freq2>')
-def freq2(freq2):
- global threadFlag
- global thread2
- threadFlag = True
+@app.route('/stopfreq/<f>')
+def stopfreq(f):
+ print(f, curf)
+ if f == curf:
+ os.kill(p, 15)
return("200")
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')
-
-
-
diff --git a/src/App.js b/src/App.js
index 8190cb1..7cf9d75 100644
--- a/src/App.js
+++ b/src/App.js
@@ -5,7 +5,7 @@ import 'react-piano/dist/styles.css';
function App() {
- const firstNote = MidiNumbers.fromNote('c3');
+ const firstNote = MidiNumbers.fromNote('a2');
const lastNote = MidiNumbers.fromNote('f5');
const keyboardShortcuts = KeyboardShortcuts.create({
firstNote: firstNote,