[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/poetaster/harbour-audiocut.git</param>
<param name="branch">main</param>
- <param name="revision">1.3</param>
+ <param name="revision">1.4</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Deleted |
_service:tar_git:harbour-audiocut-1.3.tar.bz2/src/harbour-audiocut.cpp
^
|
@@ -1,20 +0,0 @@
-#ifdef QT_QML_DEBUG
-#include <QtQuick>
-#endif
-
-#include <sailfishapp.h>
-
-int main(int argc, char *argv[])
-{
- // SailfishApp::main() will display "qml/harbour-audiocut.qml", if you need more
- // control over initialization, you can use:
- //
- // - SailfishApp::application(int, char *[]) to get the QGuiApplication *
- // - SailfishApp::createView() to get a new QQuickView * instance
- // - SailfishApp::pathTo(QString) to get a QUrl to a resource file
- // - SailfishApp::pathToMainQml() to get a QUrl to the main QML file
- //
- // To display the view, call "show()" (will show fullscreen on device).
-
- return SailfishApp::main(argc, argv);
-}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/harbour-audiocut.desktop
^
|
@@ -2,7 +2,7 @@
Type=Application
X-Nemo-Application-Type=silica-qt5
Icon=harbour-audiocut
-Exec=harbour-audiocut %u
+Exec=sailfish-qml harbour-audiocut %u
Name=Audioworks
# translation example:
# your app name in German locale (de)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/harbour-audiocut.pro
^
|
@@ -12,9 +12,7 @@
# The name of your application
TARGET = harbour-audiocut
-CONFIG += sailfishapp
-
-SOURCES += src/harbour-audiocut.cpp
+CONFIG += sailfishapp_qml
DISTFILES += qml/harbour-audiocut.qml \
qml/cover/CoverPage.qml \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/lib/pydub/audio_segment.py
^
|
@@ -503,7 +503,7 @@
)
@classmethod
- def from_file_using_temporary_files(cls, file, format=None, codec=None, parameters=None, **kwargs):
+ def from_file_using_temporary_files(cls, file, format=None, codec=None, parameters=None, start_second=None, duration=None, **kwargs):
orig_file = file
file, close_file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False)
@@ -526,7 +526,14 @@
obj = cls._from_safe_wav(file)
if close_file:
file.close()
- return obj
+ if start_second is None and duration is None:
+ return obj
+ elif start_second is not None and duration is None:
+ return obj[start_second*1000:]
+ elif start_second is None and duration is not None:
+ return obj[:duration*1000]
+ else:
+ return obj[start_second*1000:(start_second+duration)*1000]
except:
file.seek(0)
elif is_format("raw") or is_format("pcm"):
@@ -542,7 +549,14 @@
obj = cls(data=file.read(), metadata=metadata)
if close_file:
file.close()
- return obj
+ if start_second is None and duration is None:
+ return obj
+ elif start_second is not None and duration is None:
+ return obj[start_second * 1000:]
+ elif start_second is None and duration is not None:
+ return obj[:duration * 1000]
+ else:
+ return obj[start_second * 1000:(start_second + duration) * 1000]
input_file = NamedTemporaryFile(mode='wb', delete=False)
try:
@@ -581,10 +595,17 @@
conversion_command += [
"-i", input_file.name, # input_file options (filename last)
"-vn", # Drop any video streams if there are any
- "-f", "wav", # output options (filename last)
- output.name
+ "-f", "wav" # output options (filename last)
]
+ if start_second is not None:
+ conversion_command += ["-ss", str(start_second)]
+
+ if duration is not None:
+ conversion_command += ["-t", str(duration)]
+
+ conversion_command += [output.name]
+
if parameters is not None:
# extend arguments with arbitrary set
conversion_command.extend(parameters)
@@ -610,10 +631,18 @@
os.unlink(input_file.name)
os.unlink(output.name)
- return obj
+ if start_second is None and duration is None:
+ return obj
+ elif start_second is not None and duration is None:
+ return obj[0:]
+ elif start_second is None and duration is not None:
+ return obj[:duration * 1000]
+ else:
+ return obj[0:duration * 1000]
+
@classmethod
- def from_file(cls, file, format=None, codec=None, parameters=None, **kwargs):
+ def from_file(cls, file, format=None, codec=None, parameters=None, start_second=None, duration=None, **kwargs):
orig_file = file
try:
filename = fsdecode(file)
@@ -637,7 +666,14 @@
if is_format("wav"):
try:
- return cls._from_safe_wav(file)
+ if start_second is None and duration is None:
+ return cls._from_safe_wav(file)
+ elif start_second is not None and duration is None:
+ return cls._from_safe_wav(file)[start_second*1000:]
+ elif start_second is None and duration is not None:
+ return cls._from_safe_wav(file)[:duration*1000]
+ else:
+ return cls._from_safe_wav(file)[start_second*1000:(start_second+duration)*1000]
except:
file.seek(0)
elif is_format("raw") or is_format("pcm"):
@@ -650,7 +686,14 @@
'channels': channels,
'frame_width': channels * sample_width
}
- return cls(data=file.read(), metadata=metadata)
+ if start_second is None and duration is None:
+ return cls(data=file.read(), metadata=metadata)
+ elif start_second is not None and duration is None:
+ return cls(data=file.read(), metadata=metadata)[start_second*1000:]
+ elif start_second is None and duration is not None:
+ return cls(data=file.read(), metadata=metadata)[:duration*1000]
+ else:
+ return cls(data=file.read(), metadata=metadata)[start_second*1000:(start_second+duration)*1000]
conversion_command = [cls.converter,
'-y', # always overwrite existing files
@@ -703,10 +746,17 @@
conversion_command += [
"-vn", # Drop any video streams if there are any
- "-f", "wav", # output options (filename last)
- "-"
+ "-f", "wav" # output options (filename last)
]
+ if start_second is not None:
+ conversion_command += ["-ss", str(start_second)]
+
+ if duration is not None:
+ conversion_command += ["-t", str(duration)]
+
+ conversion_command += ["-"]
+
if parameters is not None:
# extend arguments with arbitrary set
conversion_command.extend(parameters)
@@ -726,12 +776,20 @@
p_out = bytearray(p_out)
fix_wav_headers(p_out)
- obj = cls._from_safe_wav(BytesIO(p_out))
+ p_out = bytes(p_out)
+ obj = cls(p_out)
if close_file:
file.close()
- return obj
+ if start_second is None and duration is None:
+ return obj
+ elif start_second is not None and duration is None:
+ return obj[0:]
+ elif start_second is None and duration is not None:
+ return obj[:duration * 1000]
+ else:
+ return obj[0:duration * 1000]
@classmethod
def from_mp3(cls, file, parameters=None):
@@ -839,6 +897,7 @@
# for easy wav files, we're done (wav data is written directly to out_f)
if easy_wav:
+ out_f.seek(0)
return out_f
output = NamedTemporaryFile(mode="w+b", delete=False)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/lib/pydub/playback.py
^
|
@@ -9,11 +9,8 @@
from tempfile import NamedTemporaryFile
from .utils import get_player_name, make_chunks
-PLAYER = get_player_name()
-
-
-
def _play_with_ffplay(seg):
+ PLAYER = get_player_name()
with NamedTemporaryFile("w+b", suffix=".wav") as f:
seg.export(f.name, "wav")
subprocess.call([PLAYER, "-nodisp", "-autoexit", "-hide_banner", f.name])
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/lib/pydub/pyaudioop.py
^
|
@@ -6,7 +6,10 @@
from builtins import min as builtin_min
import math
import struct
-from fractions import gcd
+try:
+ from fractions import gcd
+except ImportError: # Python 3.9+
+ from math import gcd
from ctypes import create_string_buffer
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/lib/pydub/scipy_effects.py
^
|
@@ -10,7 +10,7 @@
provided by pydub.effects.
"""
from scipy.signal import butter, sosfilt
-from .utils import register_pydub_effect
+from .utils import (register_pydub_effect,stereo_to_ms,ms_to_stereo)
def _mk_butter_filter(freq, type, order):
@@ -62,3 +62,114 @@
def low_pass_filter(seg, cutoff_freq, order=5):
filter_fn = _mk_butter_filter(cutoff_freq, 'lowpass', order=order)
return seg.apply_mono_filter_to_each_channel(filter_fn)
+
+
+@register_pydub_effect
+def _eq(seg, focus_freq, bandwidth=100, mode="peak", gain_dB=0, order=2):
+ """
+ Args:
+ focus_freq - middle frequency or known frequency of band (in Hz)
+ bandwidth - range of the equalizer band
+ mode - Mode of Equalization(Peak/Notch(Bell Curve),High Shelf, Low Shelf)
+ order - Rolloff factor(1 - 6dB/Octave 2 - 12dB/Octave)
+
+ Returns:
+ Equalized/Filtered AudioSegment
+ """
+ filt_mode = ["peak", "low_shelf", "high_shelf"]
+ if mode not in filt_mode:
+ raise ValueError("Incorrect Mode Selection")
+
+ if gain_dB >= 0:
+ if mode == "peak":
+ sec = band_pass_filter(seg, focus_freq - bandwidth/2, focus_freq + bandwidth/2, order = order)
+ seg = seg.overlay(sec - (3 - gain_dB))
+ return seg
+
+ if mode == "low_shelf":
+ sec = low_pass_filter(seg, focus_freq, order=order)
+ seg = seg.overlay(sec - (3 - gain_dB))
+ return seg
+
+ if mode == "high_shelf":
+ sec = high_pass_filter(seg, focus_freq, order=order)
+ seg = seg.overlay(sec - (3 - gain_dB))
+ return seg
+
+ if gain_dB < 0:
+ if mode == "peak":
+ sec = high_pass_filter(seg, focus_freq - bandwidth/2, order=order)
+ seg = seg.overlay(sec - (3 + gain_dB)) + gain_dB
+ sec = low_pass_filter(seg, focus_freq + bandwidth/2, order=order)
+ seg = seg.overlay(sec - (3 + gain_dB)) + gain_dB
+ return seg
+
+ if mode == "low_shelf":
+ sec = high_pass_filter(seg, focus_freq, order=order)
+ seg = seg.overlay(sec - (3 + gain_dB)) + gain_dB
+ return seg
+
+ if mode=="high_shelf":
+ sec=low_pass_filter(seg, focus_freq, order=order)
+ seg=seg.overlay(sec - (3 + gain_dB)) +gain_dB
+ return seg
+
+
+@register_pydub_effect
+def eq(seg, focus_freq, bandwidth=100, channel_mode="L+R", filter_mode="peak", gain_dB=0, order=2):
+ """
+ Args:
+ focus_freq - middle frequency or known frequency of band (in Hz)
+ bandwidth - range of the equalizer band
+ channel_mode - Select Channels to be affected by the filter.
+ L+R - Standard Stereo Filter
+ L - Only Left Channel is Filtered
+ R - Only Right Channel is Filtered
+ M+S - Blumlien Stereo Filter(Mid-Side)
+ M - Only Mid Channel is Filtered
+ S - Only Side Channel is Filtered
+ Mono Audio Segments are completely filtered.
+ filter_mode - Mode of Equalization(Peak/Notch(Bell Curve),High Shelf, Low Shelf)
+ order - Rolloff factor(1 - 6dB/Octave 2 - 12dB/Octave)
+
+ Returns:
+ Equalized/Filtered AudioSegment
+ """
+ channel_modes = ["L+R", "M+S", "L", "R", "M", "S"]
+ if channel_mode not in channel_modes:
+ raise ValueError("Incorrect Channel Mode Selection")
+
+ if seg.channels == 1:
+ return _eq(seg, focus_freq, bandwidth, filter_mode, gain_dB, order)
+
+ if channel_mode == "L+R":
+ return _eq(seg, focus_freq, bandwidth, filter_mode, gain_dB, order)
+
+ if channel_mode == "L":
+ seg = seg.split_to_mono()
+ seg = [_eq(seg[0], focus_freq, bandwidth, filter_mode, gain_dB, order), seg[1]]
+ return AudioSegment.from_mono_audio_segements(seg[0], seg[1])
+
+ if channel_mode == "R":
+ seg = seg.split_to_mono()
+ seg = [seg[0], _eq(seg[1], focus_freq, bandwidth, filter_mode, gain_dB, order)]
+ return AudioSegment.from_mono_audio_segements(seg[0], seg[1])
+
+ if channel_mode == "M+S":
+ seg = stereo_to_ms(seg)
+ seg = _eq(seg, focus_freq, bandwidth, filter_mode, gain_dB, order)
+ return ms_to_stereo(seg)
+
+ if channel_mode == "M":
+ seg = stereo_to_ms(seg).split_to_mono()
+ seg = [_eq(seg[0], focus_freq, bandwidth, filter_mode, gain_dB, order), seg[1]]
+ seg = AudioSegment.from_mono_audio_segements(seg[0], seg[1])
+ return ms_to_stereo(seg)
+
+ if channel_mode == "S":
+ seg = stereo_to_ms(seg).split_to_mono()
+ seg = [seg[0], _eq(seg[1], focus_freq, bandwidth, filter_mode, gain_dB, order)]
+ seg = AudioSegment.from_mono_audio_segements(seg[0], seg[1])
+ return ms_to_stereo(seg)
+
+
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/lib/pydub/silence.py
^
|
@@ -1,9 +1,21 @@
+"""
+Various functions for finding/manipulating silence in AudioSegments
+"""
import itertools
from .utils import db_to_float
def detect_silence(audio_segment, min_silence_len=1000, silence_thresh=-16, seek_step=1):
+ """
+ Returns a list of all silent sections [start, end] in milliseconds of audio_segment.
+ Inverse of detect_nonsilent()
+
+ audio_segment - the segment to find silence in
+ min_silence_len - the minimum length for any silent section
+ silence_thresh - the upper bound for how quiet is silent in dFBS
+ seek_step - step size for interating over the segment in ms
+ """
seg_len = len(audio_segment)
# you can't have a silent portion of a sound that is longer than the sound
@@ -62,6 +74,15 @@
def detect_nonsilent(audio_segment, min_silence_len=1000, silence_thresh=-16, seek_step=1):
+ """
+ Returns a list of all nonsilent sections [start, end] in milliseconds of audio_segment.
+ Inverse of detect_silent()
+
+ audio_segment - the segment to find silence in
+ min_silence_len - the minimum length for any silent section
+ silence_thresh - the upper bound for how quiet is silent in dFBS
+ seek_step - step size for interating over the segment in ms
+ """
silent_ranges = detect_silence(audio_segment, min_silence_len, silence_thresh, seek_step)
len_seg = len(audio_segment)
@@ -91,6 +112,8 @@
def split_on_silence(audio_segment, min_silence_len=1000, silence_thresh=-16, keep_silence=100,
seek_step=1):
"""
+ Returns list of audio segments from splitting audio_segment on silent sections
+
audio_segment - original pydub.AudioSegment() object
min_silence_len - (in ms) minimum length of a silence to be used for
@@ -107,6 +130,8 @@
segments.
If True is specified, all the silence is kept, if False none is kept.
default: 100ms
+
+ seek_step - step size for interating over the segment in ms
"""
# from the itertools documentation
@@ -139,17 +164,19 @@
def detect_leading_silence(sound, silence_threshold=-50.0, chunk_size=10):
- '''
- sound is a pydub.AudioSegment
- silence_threshold in dB
- chunk_size in ms
- iterate over chunks until you find the first one with sound
- '''
+ """
+ Returns the millisecond/index that the leading silence ends.
+
+ audio_segment - the segment to find silence in
+ silence_threshold - the upper bound for how quiet is silent in dFBS
+ chunk_size - chunk size for interating over the segment in ms
+ """
trim_ms = 0 # ms
assert chunk_size > 0 # to avoid infinite loop
while sound[trim_ms:trim_ms+chunk_size].dBFS < silence_threshold and trim_ms < len(sound):
trim_ms += chunk_size
- return trim_ms
+ # if there is no end it should return the length of the segment
+ return min(trim_ms, len(sound))
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-audiocut-1.4.tar.bz2/lib/pydub/utils.py
^
|
@@ -415,3 +415,20 @@
def get_supported_encoders():
return get_supported_codecs()[1]
+
+def stereo_to_ms(audio_segment):
+ '''
+ Left-Right -> Mid-Side
+ '''
+ channel = audio_segment.split_to_mono()
+ channel = [channel[0].overlay(channel[1]), channel[0].overlay(channel[1].invert_phase())]
+ return AudioSegment.from_mono_audiosegments(channel[0], channel[1])
+
+def ms_to_stereo(audio_segment):
+ '''
+ Mid-Side -> Left-Right
+ '''
+ channel = audio_segment.split_to_mono()
+ channel = [channel[0].overlay(channel[1]) - 3, channel[0].overlay(channel[1].invert_phase()) - 3]
+ return AudioSegment.from_mono_audiosegments(channel[0], channel[1])
+
|