Skip to content

Doc error for audioio.WaveFile example #851

@jerryneedell

Description

@jerryneedell

The documentation for playing a file from flash in:
https://github.com/adafruit/circuitpython/blob/master/shared-bindings/audioio/AudioOut.c#L83
needs to be updated to be consistent with
https://github.com/adafruit/circuitpython/blob/master/shared-bindings/audioio/WaveFile.c#L61

the first one gives an error while the second one works but it is the first one that is seen in ReadTheDocs:
http://circuitpython.readthedocs.io/en/latest/shared-bindings/audioio/AudioOut.html

Example of error when using example in ReadTheDocs

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 3.0.0-alpha.6-143-g990da6d on 2018-05-19; Adafruit CircuitPlayground Express with samd21g18
>>> 
>>> 
>>> import audio_test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "audio_test.py", line 9, in <module>
TypeError: file must be a file opened in byte mode
>>> 

for

import board
import audioio
import digitalio

# Required for CircuitPlayground Express
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.switch_to_output(value=True)

f = audioio.WaveFile("WhoHitMe.wav")
a = audioio.AudioOut(board.A0)

print("playing")
a.play(f)
while a.playing:
  pass
print("stopped")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions