it says
Wave_write.writeframes(data)
will that mean
"from array import array"
is a must?

this does the job:

import oil
import wave
from array import array

a = oil.Sa()

w = wave.open("current.wav", "w")
w.setnchannels(2)
w.setsampwidth(2)
w.setframerate(44100)

data = array('h')

for gas in range(44100 * 5):
    a.breath()
    r = int(32767 * (a.pulse(1) + a.pulse(2) + a.pulse(3)) / 3.0)
    l = int(32767 * (a.pulse(4) + a.pulse(5) + a.pulse(6)) / 3.0)
    data.append(r)
    data.append(l)

w.writeframes(data.tostring())
w.close()

don't like array becoming so huge so tested this and it was also okay:

for gas in range(44100 * 5):
    a.breath()
    data = array('h')
    r = int(32767 * (a.pulse(1) + a.pulse(2) + a.pulse(3)) / 3.0)
    l = int(32767 * (a.pulse(4) + a.pulse(5) + a.pulse(6)) / 3.0)
    data.append(r)
    data.append(l)
    w.writeframes(data.tostring())

but without array .. it becomes 15secs(3 times longer than was
intended to be) of wav file:

for gas in range(44100 * 5):
    a.breath()
    r = int(32767 * (a.pulse(1) + a.pulse(2) + a.pulse(3)) / 3.0)
    l = int(32767 * (a.pulse(4) + a.pulse(5) + a.pulse(6)) / 3.0)
    w.writeframes(hex(r))
    w.writeframes(hex(l))

should i just be happy with depennding on using array?
or is there a solution to make the last one work properly?

tia

-- 
SaRiGaMa's Oil Vending Orchestra
is podcasting:
http://sarigama.namaste.jp/podcast/rss.xml
and supplying oil.py for free:
http://oilpy.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to