[Tutor] Musical note on python

D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsarma at gmail.com
Fri Sep 14 02:37:24 CEST 2012


Error: "name data undefined"


On Fri, Sep 14, 2012 at 12:33 AM, eryksun <eryksun at gmail.com> wrote:

> On Thu, Sep 13, 2012 at 11:48 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ
> <dvnsarma at gmail.com> wrote:
> >
> > As far as programming volume is concerned winsound.Beep has only
> frequency
> > and duration. pyaudio module appears to have provision for volume
> control.
>
> You should be able to add a wave header to a raw byte string. For example:
>
>
>     import wave
>     import winsound
>     from cStringIO import StringIO
>
>     def get_wave(data):
>         f = StringIO()
>         w = wave.open(f, 'w')
>         w.setnchannels(1) # mono
>         w.setsampwidth(2) # 2 bytes
>         w.setframerate(48000) # samples/second
>         w.writeframes(data)
>         return f.getvalue()
>
>
> Then play the sound like this (_untested_):
>
>
>     wave_data = get_wave(data)
>     windsound.PlaySound(wave_data, winsound.SND_MEMORY)
>
>
>
>
-- 
regards,
Sarma.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120914/463162e1/attachment.html>


More information about the Tutor mailing list