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.
bobricius
Posts: 14
Joined: Sat Jul 30, 2016 11:07 pm

WAV player

Postby 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: 2264
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: WAV player

Postby 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

Postby 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: 2264
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: WAV player

Postby 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

Postby 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


Return to “Other Boards”

Who is online

Users browsing this forum: No registered users and 2 guests