Figured out pitch shifter glitch problems and found cause of the small clicks - the sox pitch shifter
This commit is contained in:
@@ -44,10 +44,10 @@ class Analysis(object):
|
||||
"""
|
||||
|
||||
try:
|
||||
self.analysis = self.analysis_group[self.name]
|
||||
except KeyError:
|
||||
self.logger.info("{0} analysis group already exists".format(self.name))
|
||||
self.analysis = self.analysis_group.create_group(self.name)
|
||||
except ValueError:
|
||||
self.logger.info("{0} analysis group already exists".format(self.name))
|
||||
self.analysis = self.analysis_group[self.name]
|
||||
|
||||
# If forcing new analysis creation then delete old analysis and create
|
||||
# a new one
|
||||
|
||||
@@ -630,9 +630,9 @@ class AudioFile(object):
|
||||
position = self.ms_to_samps(position)
|
||||
# multiply samples by the fade values from the start position for
|
||||
# the duration of the fade
|
||||
audio[position:position+fade.size] *= fade
|
||||
audio[-position:position-fade.size] *= fade
|
||||
# zero any samples after the fade in
|
||||
audio[position+fade.size:] *= 0
|
||||
audio[-position-fade.size:] *= 0
|
||||
else:
|
||||
self.logger.exception("{0} is not a valid fade option. Use either \"in\" or "
|
||||
"\"out\"".format(mode))
|
||||
|
||||
+20
-20
@@ -1,36 +1,36 @@
|
||||
# Specify analysis parameters for root mean square analysis.
|
||||
rms = {
|
||||
"window_size": 100,
|
||||
"overlap": 4,
|
||||
"overlap": 8,
|
||||
}
|
||||
|
||||
f0 = {
|
||||
"window_size": 2048,
|
||||
"window_size": 4096,
|
||||
"overlap": 8,
|
||||
"ratio_threshold": 0.6
|
||||
"ratio_threshold": 0.7
|
||||
}
|
||||
|
||||
# Specify analysis parameters for variance analysis.
|
||||
variance = {
|
||||
"window_size": 100,
|
||||
"overlap": 4
|
||||
"overlap": 8
|
||||
}
|
||||
|
||||
# Specify analysis parameters for temporal kurtosis analysis.
|
||||
kurtosis = {
|
||||
"window_size": 100,
|
||||
"overlap": 4
|
||||
"overlap": 8
|
||||
}
|
||||
|
||||
# Specify analysis parameters for temporal skewness analysis.
|
||||
skewness = {
|
||||
"window_size": 100,
|
||||
"overlap": 4
|
||||
"overlap": 8
|
||||
}
|
||||
|
||||
# Specify analysis parameters for FFT analysis.
|
||||
fft = {
|
||||
"window_size": 2048
|
||||
"window_size": 4096
|
||||
}
|
||||
|
||||
database = {
|
||||
@@ -44,18 +44,18 @@ database = {
|
||||
matcher_weightings = {
|
||||
"f0" : 1,
|
||||
"spccntr" : 1.,
|
||||
"spcsprd" : 2.,
|
||||
"spcflux" : 2.,
|
||||
"spccf" : 2.,
|
||||
"spcflatness": 3.,
|
||||
"spcsprd" : 1.,
|
||||
"spcflux" : 1.,
|
||||
"spccf" : 1.,
|
||||
"spcflatness": 1.,
|
||||
"zerox" : 1.,
|
||||
"rms" : 1,
|
||||
"peak": 2.,
|
||||
"peak": 1.,
|
||||
"centroid": 1.,
|
||||
"kurtosis": 1.,
|
||||
"skewness": 1.,
|
||||
"variance": 2.,
|
||||
"harm_ratio": 1.
|
||||
"variance": 1.,
|
||||
"harm_ratio": 1
|
||||
}
|
||||
|
||||
# Specifies the method for averaging analysis frames to create a single value
|
||||
@@ -89,10 +89,10 @@ matcher = {
|
||||
# Force the re-matching of analyses
|
||||
"rematch": False,
|
||||
"grain_size": 100,
|
||||
"overlap": 4,
|
||||
"overlap": 8,
|
||||
# Defines the number of matches to keep for synthesis. Note that this must
|
||||
# also be specified in the synthesis config
|
||||
"match_quantity": 10,
|
||||
"match_quantity": 5,
|
||||
# Choose the algorithm used to perform matching. kdtree is recommended for
|
||||
# larger datasets.
|
||||
"method": 'kdtree'
|
||||
@@ -103,20 +103,20 @@ synthesizer = {
|
||||
# between source and target.
|
||||
"enforce_intensity": True,
|
||||
# Specify the ratio limit that is the grain can be scaled by.
|
||||
"enf_intensity_ratio_limit": 25.,
|
||||
"enf_intensity_ratio_limit": 1000.,
|
||||
# Artificially modify the pitch by the difference in f0 values between
|
||||
# source and target.
|
||||
"enforce_f0": True,
|
||||
# Specify the ratio limit that is the grain can be modified by.
|
||||
"enf_f0_ratio_limit": 100.,
|
||||
"enf_f0_ratio_limit": 3.,
|
||||
"grain_size": 100,
|
||||
"overlap": 4,
|
||||
"overlap": 8,
|
||||
# Normalize output, avoid clipping of final output by scaling the final
|
||||
# frames.
|
||||
"normalize" : True,
|
||||
# Defines the number of potential grains to choose from matches when
|
||||
# synthesizing output.
|
||||
"match_quantity": 10
|
||||
"match_quantity": 5
|
||||
}
|
||||
|
||||
output_file = {
|
||||
|
||||
@@ -820,8 +820,8 @@ class Synthesizer:
|
||||
channels=output_config["channels"]
|
||||
) as output:
|
||||
hop_size = (grain_size / overlap) * output.samplerate/1000
|
||||
_grain_size *= output.samplerate / 1000
|
||||
output_frames = np.zeros(_grain_size + (hop_size*len(grain_matches)-1))
|
||||
_grain_size *= int(output.samplerate / 1000)
|
||||
output_frames = np.zeros(_grain_size*2 + (int(hop_size*len(grain_matches))))
|
||||
offset = 0
|
||||
for target_grain_ind, matches in enumerate(grain_matches):
|
||||
# If there are multiple matches, choose a match at random
|
||||
@@ -871,7 +871,10 @@ class Synthesizer:
|
||||
|
||||
# Apply hanning window to grain
|
||||
match_grain *= np.hanning(match_grain.size)
|
||||
output_frames[offset:offset+match_grain.size] += match_grain
|
||||
try:
|
||||
output_frames[offset:offset+match_grain.size] += match_grain
|
||||
except:
|
||||
pdb.set_trace()
|
||||
offset += hop_size
|
||||
# If output normalization is active, normalize output.
|
||||
if self.config.synthesizer["normalize"]:
|
||||
@@ -905,7 +908,7 @@ class Synthesizer:
|
||||
hr_array = np.array([source_harmonic_ratio, target_harmonic_ratio])
|
||||
|
||||
if np.any(np.isnan(hr_array)):
|
||||
return grain
|
||||
return grain*0
|
||||
|
||||
# Get mean of f0 frames in time range specified.
|
||||
source_f0 = source_sample.analysis_data_grains(source_times, "f0", format="median")[0][0]
|
||||
@@ -913,7 +916,7 @@ class Synthesizer:
|
||||
ratio_difference = target_f0 / source_f0
|
||||
|
||||
if not np.isfinite(ratio_difference):
|
||||
return grain
|
||||
return grain*0
|
||||
|
||||
# If the ratio difference is within the limits
|
||||
ratio_limit = self.config.synthesizer["enf_f0_ratio_limit"]
|
||||
@@ -932,6 +935,8 @@ class Synthesizer:
|
||||
ratio_difference = 1./ratio_limit
|
||||
|
||||
grain = pitch_shift.shift(grain, ratio_difference)
|
||||
if ratio_difference > ratio_limit or ratio_difference < 1./ratio_limit:
|
||||
grain *= 0
|
||||
|
||||
return grain
|
||||
|
||||
@@ -979,6 +984,7 @@ class Synthesizer:
|
||||
|
||||
grain *= ratio_difference
|
||||
|
||||
|
||||
return grain
|
||||
|
||||
def swap_databases(self):
|
||||
|
||||
Reference in New Issue
Block a user