diff --git a/Pi-Recorder.py b/Pi-Recorder.py new file mode 100644 index 0000000..a7370d0 --- /dev/null +++ b/Pi-Recorder.py @@ -0,0 +1,76 @@ +#!/usr/bin/python + +from ntpath import altsep +import os +import tkinter as tk +from tkinter import * + +def checkUSB(): + stream = os.popen('lsusb | grep "Audio" | cut -d" " -f7') + output = stream.read() + if (output.find("PreSonus") != -1): + return True + else: + return False + +def checkRecordStatus(): + stream = os.popen('screen -list | grep -c "Pi-ARecord" || true') + output = stream.read() + if (output.find("1")): + return True + else: + return False + +def record(): + if checkRecordStatus(): + os.system('screen -S record -X stuff "^C"') + btn_record_var.set('Start Recording') + else: + if (checkUSB()): + os.system('screen -S record -d -m arecord -D plughw:2,0 -f dat -vv /home/pi/test_input.wav') + btn_record_var.set('Stop Recording') + else: + btn_record_var.set('PreSonus N/A') + +### tkinter variables +run_tk = True +light_mode = True + +### tkinter theme +btn_light_color = '#BA09C6' +btn_dark_color = '#3C0340' +bg_light_color = '#F171DA' +bg_dark_color = '#8a3f7c' +text_light_color = '#000000' +text_dark_color = '#adadad' + +### tkinter functions +def onExit(): + global run_tk + if checkRecordStatus(): + record() + run_tk = False + main_window.destroy() + exit() + +def btnRecord(): + record() + +### tkinter main window setup +main_window = Tk() +main_window.attributes("-fullscreen", False) +main_window.protocol("WM_DELETE_WINDOW", onExit) +main_window.configure(background=bg_light_color) +main_window.title("Momo\'s Awesome Recorder") +main_window.columnconfigure(0, weight=1) +main_window.columnconfigure(1, weight=1) +main_window.columnconfigure(2, weight=1) +### tkinter record button +btn_record_var = tk.StringVar() +btn_record_var.set('Start Recording') +btn_record = Button(main_window, textvariable=btn_record_var, bg=btn_light_color, command=btnRecord) +btn_record.grid(column=0, row=0, sticky='NSEW', padx=5, pady=5) + +while run_tk: + main_window.update_idletasks() + main_window.update() \ No newline at end of file