Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit bd6d7bb

Browse files
authored
Merge pull request #48 from lukewys/main
Update to clip note expression output between 0 and 1. Bump up version.
2 parents 6902240 + 9eaf8e9 commit bd6d7bb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

midi_ddsp/utils/inference_utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,25 @@ def conditioning_df_to_midi_features(conditioning_df, length=None):
8282

8383
def expression_generator_output_to_conditioning_df(expression_generator_outputs,
8484
expression_generator_cond,
85-
frame_size=0.004):
85+
frame_size=0.004,
86+
clip_value=True):
8687
"""
8788
Convert expression generator outputs to conditioning_df.
8889
Args:
8990
expression_generator_outputs: The output of the expression generator.
9091
expression_generator_cond: (in dataset data['cond'])
9192
frame_size: the frame size, in second.
93+
clip_value: clip the expression generator output between [0, 1].
9294
9395
Returns:
9496
9597
"""
9698
expression_generator_outputs = scale_expression_generator_output(
9799
expression_generator_outputs[0])
100+
if clip_value: # clip the expression generator output between [0, 1].
101+
expression_generator_outputs = tf.clip_by_value(
102+
expression_generator_outputs, clip_value_min=0.0, clip_value_max=1.0
103+
)
98104
conditioning_dict_keys = CONDITIONING_KEYS
99105
data_all = []
100106
onset = 0
@@ -129,7 +135,10 @@ def conditioning_df_to_expression_generator_output(conditioning_df,
129135

130136

131137
def scale_expression_generator_output(output):
132-
"""Scale expression generator output."""
138+
"""Scale expression generator output.
139+
This function now is useless. But it is a plcaeholder
140+
if you want to post-process your note expression output.
141+
"""
133142
scale = np.ones((1, output.shape[-1]))
134143
scale = tf.convert_to_tensor(scale, tf.float32)
135144
output /= scale

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
setuptools.setup(
2323
name='midi-ddsp',
24-
version='0.2.3',
24+
version='0.2.4',
2525
description='Synthesis of MIDI with DDSP',
2626
long_description=long_description,
2727
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)