lundi 9 février 2015

Making a drum sound from Math, Struct and Wave

I am developing a python sound application and this is my code;



if "kick" in line:
kick = line

print (kick)

k = remove_tags(kick).split()

print k

kick = wave.open('kick.wav', 'w')

kick.setparams((2, 2, 44100, 0, 'NONE', 'not compressed'))

values = []

for t in k:
for i in range(0, SAMPLE_LEN):
j = float (i)/notes.factor(t) # 44100 / 3.142 x 2 = 7,018 Hz
valuej = math.sin(j)
value = int ((valuej) * 30000)
packed_value = struct.pack('h', value)
values.append(packed_value)
values.append(packed_value)
value_str = ''.join(values)
kick.writeframes(value_str)

kick.close()

"kick":22.9935580952,
"rest":1000000,


I am stuck on making kick actually sound like a kick.


Any help?


I am using Math, Struct and Wave.


It works so if you write something like



<kick>kick rest kick rest</kick>


Then it should make a kick sound, leave a pause, a kick sound, pause.


It makes a beep noise but it sounds nothing like a kick you would hear in an actual instrumental.


Aucun commentaire:

Enregistrer un commentaire