WAV player

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
bobricius
Posts: 14
Joined: Sat Jul 30, 2016 11:07 pm

WAV player

Post by bobricius » Fri Aug 12, 2016 10:14 pm

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?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: WAV player

Post by dhylands » Fri Aug 12, 2016 10:53 pm

What does your import statement look like?

It should just be: import wave

bobricius
Posts: 14
Joined: Sat Jul 30, 2016 11:07 pm

Re: WAV player

Post by bobricius » Sat Aug 13, 2016 5:06 am

>>> import wave
>>> from pyb import DAC
>>> dac = DAC(1)
>>> f = wave.open('test.wav')
>>> dac.write_timed(f.readframes(f.getnframes()), f.getframerate())

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: WAV player

Post by dhylands » Sat Aug 13, 2016 6:56 am

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.

cworkman
Posts: 1
Joined: Fri Jan 06, 2017 12:17 am

Re: WAV player

Post by cworkman » Fri Jan 06, 2017 12:28 am

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

JoeGoodbread
Posts: 10
Joined: Sun Apr 30, 2017 8:52 pm

Re: WAV player

Post by JoeGoodbread » Sun Apr 30, 2017 9:10 pm

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'

Post Reply