DATX02-20-04 / code

4 stars 0 forks source link

Create function for generating a note with tensorflow #60

Closed ericnorman98 closed 4 years ago

ericnorman98 commented 4 years ago

Example generating 8 (n) different notes at the same time:

sr = 16000
samples_per_note = 8000
pitch_start = 60.0
n = 8
pitch = tf.reshape(tf.range(tf.cast(n, tf.float32)) + pitch_start, [n, 1])
vel = tf.ones([n, 1])*2
amp = tf.ones([n, 1])*0.5
# Important part:
note = generate(pitch, amp, vel, samples_per_note, sr)
Kyuuhachi commented 4 years ago

Why all the […, 1] dimensions?

ericnorman98 commented 4 years ago

Oh right, forgot to move that into the function. It was to be able to multiply with the waveform. It should look like this now:

sr = 16000
samples_per_note = 8000
pitch_start = 60.0
n = 8
pitch = tf.range(tf.cast(n, tf.float32)) + pitch_start
vel = tf.ones([n])*2
amp = tf.ones([n])*0.5
note = generate(pitch, amp, vel, samples_per_note, sr)