Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mzivic7 committed Dec 21, 2024
1 parent 08a3867 commit 44cc9f0
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions easyeffects-record.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/python3

import sys
import time
import os.path
import argparse
import os.path
import subprocess
import sys
import time


def launch_easyeffects(preset):
"""If easyeffects is not running, launch it with desired preset"""
command = "ps cax | grep easyeffects"
ps = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
running = ps.communicate()[0]
Expand All @@ -21,16 +22,15 @@ def launch_easyeffects(preset):
easyeffects = subprocess.Popen(command, shell=True)
time.sleep(3)
return easyeffects
if preset and preset != "auto":
print("Easy Effects is already running, cannot set preset")
else:
if preset and preset != "auto":
print("Easy Effects is already running, cannot set preset")
else:
print("Easy Effects is already running")
return None
print("Easy Effects is already running")
return None


def disconnect_output():
"""Disconnects Easy Effects from speaker output"""
"""Disconnect Easy Effects from speaker output"""
command = "pw-link --id --links"
pw_link = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
links = pw_link.communicate()[0].decode()
Expand All @@ -44,7 +44,7 @@ def disconnect_output():


def re_record(root, file_path, output_extension, mute):
"""Re-records song by playing it and recording output from Easy Effects"""
"""Re-record song by playing it and recording output from Easy Effects"""
# start recorder
command = "pw-record --target 0 temp.wav"
recorder = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE)
Expand Down Expand Up @@ -88,6 +88,7 @@ def re_record(root, file_path, output_extension, mute):


def main(args):
"""Main function"""
song_path = args.song_path
input_extensions = args.input_extensions
output_extension = args.output_extension
Expand Down Expand Up @@ -142,10 +143,10 @@ def main(args):


def argparser():
"""Sets up argument parser for CLI"""
"""Setup argument parser for CLI"""
parser = argparse.ArgumentParser(
prog="easyeffects-record",
description="Automated player and recorder, allowing re-recording one or multiple songs with applied effects from Easy Effects tool"
description="Automated player and recorder, allowing re-recording one or multiple songs with applied effects from Easy Effects tool",
)
parser._positionals.title = "arguments"
parser.add_argument(
Expand All @@ -155,7 +156,7 @@ def argparser():
help='Path to target song file, if not specified, will run recursively in current directory. \
When recursing, input-extension will be used to filter files, \
and files from "output" directory will be omitted. If file path is provided, \
new file will be saved in "output" directory in current directory'
new file will be saved in "output" directory in current directory',
)
parser.add_argument(
"-i",
Expand All @@ -164,34 +165,34 @@ def argparser():
type=str,
metavar="EXT",
default=["mp3", "m4a"],
help="list of input extensions to scan for in directories, default: mp3, m4a"
help="list of input extensions to scan for in directories, default: mp3, m4a",
)
parser.add_argument(
"-o",
"--output-extension",
type=str,
metavar="EXT",
default="mp3",
help="output file extension, default: mp3"
help="output file extension, default: mp3",
)
parser.add_argument(
"-p",
"--preset",
type=str,
action=None,
help="Easy Effects preset, default: auto"
help="Easy Effects preset, default: auto",
)
parser.add_argument(
"-s",
"--slent",
action="store_true",
help="disconnects Easy Effects from device sound output, but still records sound"
help="disconnects Easy Effects from device sound output, but still records sound",
)
parser.add_argument(
"-v",
"--version",
action="version",
version="%(prog)s 0.1.0"
version="%(prog)s 0.1.0",
)
return parser.parse_args()

Expand Down

0 comments on commit 44cc9f0

Please sign in to comment.