Skip to content

Commit 269f04c

Browse files
committed
Re-added logging options to core module for -v output
1 parent 6bd808e commit 269f04c

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Diff for: pymusiclooper/__main__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
def loop_track(filename, min_duration_multiplier):
3232
try:
3333
# Load the file
34-
logging.info("Loading {}...".format(filename))
34+
print("Loading {}...".format(filename))
3535

3636
track = MusicLooper(filename, min_duration_multiplier)
3737

@@ -155,10 +155,10 @@ def bounded_float(x):
155155
warnings.filterwarnings("ignore")
156156
logging.basicConfig(level=logging.ERROR)
157157
elif args.verbose:
158+
logging.basicConfig(level=logging.INFO)
159+
else:
158160
warnings.filterwarnings("ignore")
159161
logging.basicConfig(level=logging.ERROR)
160-
else:
161-
logging.basicConfig(level=logging.INFO)
162162

163163
output_dir = args.output_dir
164164

Diff for: pymusiclooper/core.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import json
2020
import os
21+
import time
22+
import logging
2123

2224
import librosa
2325
import numpy as np
@@ -74,6 +76,8 @@ def db_diff(self, power_db_f1, power_db_f2):
7476
return average_diff
7577

7678
def find_loop_pairs(self, combine_beat_plp=False, concurrency=False):
79+
runtime_start = time.time()
80+
7781
S = librosa.core.stft(y=self.audio)
7882
S_power = np.abs(S) ** 2
7983
S_weighed = librosa.core.perceptual_weighting(
@@ -84,19 +88,28 @@ def find_loop_pairs(self, combine_beat_plp=False, concurrency=False):
8488
bpm, beats = librosa.beat.beat_track(onset_envelope=onset_env)
8589

8690
beats = np.sort(beats)
91+
logging.info("Detected {} beats at {:.0f} bpm".format(beats.size, bpm))
8792

8893
chroma = librosa.feature.chroma_stft(S=S_power)
8994

9095
power_db = librosa.power_to_db(mel_spectrogram, ref=np.max)
9196
min_duration = int(chroma.shape[-1] * self.min_duration_multiplier)
9297

98+
runtime_end = time.time()
99+
prep_time = runtime_end - runtime_start
100+
logging.info("Finished initial prep in {:.3}s".format(prep_time))
101+
93102
def loop_subroutine(combine_beat_plp=combine_beat_plp, beats=beats):
94103
if combine_beat_plp:
95104
onset_env = librosa.onset.onset_strength(S=mel_spectrogram)
96105
pulse = librosa.beat.plp(onset_envelope=onset_env)
97106
beats_plp = np.flatnonzero(librosa.util.localmax(pulse))
98107
beats = np.union1d(beats, beats_plp)
99-
108+
logging.info(
109+
"Detected {} total points by combining PLP with existing beats".format(
110+
beats.size
111+
)
112+
)
100113
candidate_pairs = []
101114

102115
self._loop_finding_routine(
@@ -156,6 +169,9 @@ def loop_subroutine(combine_beat_plp=combine_beat_plp, beats=beats):
156169
break
157170

158171
if retry and not combine_beat_plp:
172+
logging.info(
173+
"No suitable loop points found with current parameters. Retrying with additional beat points from PLP method."
174+
)
159175
pruned_list = loop_subroutine(combine_beat_plp=True)
160176

161177
if self.trim_offset[0] > 0:
@@ -167,6 +183,8 @@ def loop_subroutine(combine_beat_plp=combine_beat_plp, beats=beats):
167183
pruned_list[i]["loop_end"]
168184
)
169185

186+
logging.info(f"Found {len(pruned_list)} possible loop points")
187+
170188
return pruned_list
171189

172190
def apply_trim_offset(self, frame):

0 commit comments

Comments
 (0)