May have fixed indexing issue with tiny audio files (less than 1 grain's worth of audio). untested

This commit is contained in:
2016-04-10 19:32:02 +01:00
parent 2ddabe1276
commit 67bd063829
3 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ class Analysis(object):
# be saved in the HDF5 file
data_dict, attrs_dict = self.hdf5_dataset_formatter(*args, **kwargs)
for key, value in data_dict.iteritems():
self.analysis.create_dataset(key, data=value, dtype=np.float, chunks=True)
self.analysis.create_dataset(key, data=value, chunks=True)
for key, value in attrs_dict.iteritems():
self.analysis.attrs[key] = value
+1 -1
View File
@@ -86,7 +86,7 @@ matcher = {
"overlap": 2,
# Defines the number of matches to keep for synthesis. Note that this must
# also be specified in the synthesis config
"match_quantity": 20,
"match_quantity": 1,
# Choose the algorithm used to perform matching. kdtree is recommended for
# larger datasets.
"method": 'kdtree'
+5 -3
View File
@@ -457,7 +457,6 @@ class Matcher:
match_vals = best_match_vals[:, :self.match_quantity]
match_grain_inds = self.calculate_db_inds(match_indexes, source_sample_indexes)
pdb.set_trace()
datafile_path = ''.join(("match/", target_entry.name))
try:
@@ -703,11 +702,15 @@ class Matcher:
grain, a dimension for each match of said grain and a dimension
containing database sample index and the sample's grain index.
"""
# source_sample_indexes = source_sample_indexes[source_sample_indexes[:, 1] != 0.]
mi_shape = match_indexes.shape
x = match_indexes.flatten()
# Find indexes within the range of each source sample index.
x = np.logical_and(
np.vstack(x)>=source_sample_indexes[:,0],
np.vstack(x)<=source_sample_indexes[:,1]
np.vstack(x)<source_sample_indexes[:,1]
)
x = x.reshape(mi_shape[0], mi_shape[1], x.shape[1])
x = np.argmax(x, axis=2)
@@ -797,7 +800,6 @@ class Synthesizer:
# from available matches.
match_index = np.random.randint(matches.shape[0])
match_db_ind, match_grain_ind = matches[match_index]
pdb.set_trace()
with self.match_db.analysed_audio[match_db_ind] as match_sample:
match_sample.generate_grain_times(match_grain_size, match_overlap, save_times=True)