Fix a crap ton of bugs

This commit is contained in:
next2w 2022-10-03 19:44:50 -04:00
parent 14e7fe85f0
commit 9a9e7d15d9
2 changed files with 15 additions and 26 deletions

View file

@ -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)
curf = 0
p = 0
thread2 = 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')

View file

@ -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,