Page 1 of 1

WAV player

Posted: Fri Aug 12, 2016 10:14 pm
by bobricius
I have try wave.py from AMP skin tutorial on my nucleoL476 board (http://docs.micropython.org/en/latest/p ... _skin.html)
but I get some errors, maybe is something changed in interpreter.
First my maybe good solved error is change from _collections to ucollections ... maybe is ok but after
command >>>f = wave.open('test.wav')
I get error AttributeError: 'module' object has no attribute 'open'
???? can anybody confirm if wave player working?

Re: WAV player

Posted: Fri Aug 12, 2016 10:53 pm
by dhylands
What does your import statement look like?

It should just be: import wave

Re: WAV player

Posted: Sat Aug 13, 2016 5:06 am
by bobricius
>>> import wave
>>> from pyb import DAC
>>> dac = DAC(1)
>>> f = wave.open('test.wav')
>>> dac.write_timed(f.readframes(f.getnframes()), f.getframerate())

Re: WAV player

Posted: Sat Aug 13, 2016 6:56 am
by dhylands
It works for me:

Code: Select all

MicroPython v1.8.2-19-gc3f519a-dirty on 2016-07-18; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> 
>>> import wave
>>> f = wave.open('test.wav')
>>> 
If I had to guess I would say that your wave.py file is corrupted.

Re: WAV player

Posted: Fri Jan 06, 2017 12:28 am
by cworkman
I had the same issue related to 'import wave' when testing my new AMP skin. It was due to the namedtuple import in wave.py. If you change line 89 of wave.py to:

from ucollections import namedtuple

the 'import wave' should work correctly.

You may need to define volume() and set it to volume(127) before trying

f = wave.open('test.wav')
dac.write_timed(f.readframes(f.getnframes()), f.getframerate())

-Chris Workman

Re: WAV player

Posted: Sun Apr 30, 2017 9:10 pm
by JoeGoodbread
I have the same problem. Made the change on line 89 from:
from _collections import namedtuple
to:
from ucollections import namedtuple

I still get the error message: AttributeError: 'module' object has no attribute 'open'