Skip to content

Moved audioio.WaveFile -> audiocore.WaveFile #1374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ABC_Soundboards_for_NeoTrellis/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
import board
import audioio
import audiocore
import adafruit_fancyled.adafruit_fancyled as fancy
import adafruit_trellism4

Expand Down Expand Up @@ -76,7 +77,7 @@
with audioio.AudioOut(board.A1, right_channel=board.A0) as audio:
try:
f = open(SAMPLE_FOLDER+SAMPLES[27][0], "rb") # Use 02.wav as welcome
wave = audioio.WaveFile(f)
wave = audiocore.WaveFile(f)
audio.play(wave)
swirl = 0 # we'll swirl through the colors in the gradient
while audio.playing:
Expand All @@ -99,7 +100,7 @@
bits_per_sample = None
sample_rate = None
with open(SAMPLE_FOLDER+SAMPLES[0][0], "rb") as f:
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)
print("%d channels, %d bits per sample, %d Hz sample rate " %
(wav.channel_count, wav.bits_per_sample, wav.sample_rate))

Expand All @@ -117,7 +118,7 @@
filename = SAMPLE_FOLDER+v[0]
try:
with open(filename, "rb") as f:
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)
print(filename,
"%d channels, %d bits per sample, %d Hz sample rate " %
(wav.channel_count, wav.bits_per_sample, wav.sample_rate))
Expand Down Expand Up @@ -162,7 +163,7 @@ def stop_playing_sample(playback_details):
try:
filename = SAMPLE_FOLDER+SAMPLES[sample_num][0]
f = open(filename, "rb")
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)

# is something else playing? interrupt it!
if currently_playing['voice'] != None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import digitalio
import board
import audioio
import audiocore

WAV_FILE_NAME = "StreetChicken.wav" # Change to the name of your wav file!

Expand All @@ -12,7 +13,7 @@

with audioio.AudioOut(board.A0) as audio: # Speaker connector
wave_file = open(WAV_FILE_NAME, "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)

audio.play(wave)
while audio.playing:
Expand Down
4 changes: 2 additions & 2 deletions Adafruit_UDA1334A/CircuitPython_I2S_Tone.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import time
import array
import math
import audioio
import audiocore
import board
import audiobusio

Expand All @@ -18,7 +18,7 @@
# audio = audiobusio.I2SOut(board.D1, board.D10, board.D11)
# For Metro M4 Express
# audio = audiobusio.I2SOut(board.D3, board.D9, board.D8)
sine_wave_sample = audioio.RawSample(sine_wave)
sine_wave_sample = audiocore.RawSample(sine_wave)

while True:
audio.play(sine_wave_sample, loop=True)
Expand Down
4 changes: 2 additions & 2 deletions Adafruit_UDA1334A/CircuitPython_I2S_Wave.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import audioio
import audiocore
import board
import audiobusio

wave_file = open("StreetChicken.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)

# For Feather M0 Express, ItsyBitsy M0 Express, Metro M0 Express
audio = audiobusio.I2SOut(board.D1, board.D0, board.D9)
Expand Down
3 changes: 2 additions & 1 deletion Animatronic_Hand/binary_counting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
from digitalio import DigitalInOut, Direction, Pull
import audioio
import audiocore
import board
from adafruit_crickit import crickit

Expand All @@ -22,7 +23,7 @@
cpx_audio = audioio.AudioOut(board.A0)
def play_file(wavfile):
with open(wavfile, "rb") as f:
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)
cpx_audio.play(wav)
while cpx_audio.playing:
pass
Expand Down
3 changes: 2 additions & 1 deletion CP101_StateMachines/brute-force/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import busio
import adafruit_ds3231
import audioio
import audiocore
import pulseio
from adafruit_motor import servo
import neopixel
Expand Down Expand Up @@ -227,7 +228,7 @@ def shower(time_now):

def start_playing(fname):
sound_file = open(fname, 'rb')
wav = audioio.WaveFile(sound_file)
wav = audiocore.WaveFile(sound_file)
audio.play(wav, loop=False)

def stop_playing():
Expand Down
3 changes: 2 additions & 1 deletion CP101_StateMachines/classes/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import busio
import adafruit_ds3231
import audioio
import audiocore
import pulseio
from adafruit_motor import servo
import neopixel
Expand Down Expand Up @@ -191,7 +192,7 @@ def shower(machine, time_now):

def start_playing(fname):
sound_file = open(fname, 'rb')
wav = audioio.WaveFile(sound_file)
wav = audiocore.WaveFile(sound_file)
audio.play(wav, loop=False)

def stop_playing():
Expand Down
7 changes: 4 additions & 3 deletions CPX_DAC_Guide/scope_xy_adafruitlogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import board
import audioio
import audiocore
import analogio

### Vector data for logo
Expand Down Expand Up @@ -95,7 +96,7 @@ def addpoints(points, min_dist):
### 32768 and 32000 exhibit this bug but 25000 so far appears to be a
### workaround, albeit a mysterious one
### https://github.com/adafruit/circuitpython/issues/1992
### Using "h" for audioio.RawSample() DAC range will be 20268 to 45268
### Using "h" for audiocore.RawSample() DAC range will be 20268 to 45268
dac_x_min = 0
dac_y_min = 0
dac_x_max = 25000
Expand Down Expand Up @@ -129,7 +130,7 @@ def addpoints(points, min_dist):

### A0 will be x, A1 will be y
if use_wav:
print("Using audioio.RawSample for DACs")
print("Using audiocore.RawSample for DACs")
dacs = audioio.AudioOut(board.A0, right_channel=board.A1)
else:
print("Using analogio.AnalogOut for DACs")
Expand Down Expand Up @@ -166,7 +167,7 @@ def addpoints(points, min_dist):
if use_wav:
### 200k (maybe 166.667k) seems to be practical limit
### 1M permissible but seems same as around 200k
output_wave = audioio.RawSample(rawdata,
output_wave = audiocore.RawSample(rawdata,
channel_count=2,
sample_rate=200 * 1000)

Expand Down
3 changes: 2 additions & 1 deletion CPX_Sound_Box/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import board
from digitalio import DigitalInOut, Direction, Pull
import audioio
import audiocore
import neopixel

filename = "electrons.wav"
Expand Down Expand Up @@ -37,7 +38,7 @@ def simpleCircle(wait):
def play_file(playname):
print("Playing File " + playname)
wave_file = open(playname, "rb")
with audioio.WaveFile(wave_file) as wave:
with audiocore.WaveFile(wave_file) as wave:
with audioio.AudioOut(board.A0) as audio:
audio.play(wave)
while audio.playing:
Expand Down
3 changes: 2 additions & 1 deletion Cat_Treat_Dispenser/code.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
import board
import audioio
import audiocore
from adafruit_crickit import crickit

print("Cat Feeder")
Expand All @@ -10,7 +11,7 @@
# audio output
cpx_audio = audioio.AudioOut(board.A0)
f = open("activate.wav", "rb")
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)

while True:
if crickit.touch_1.value:
Expand Down
9 changes: 5 additions & 4 deletions Christmas_Soundboard/code.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
import board
import audioio
import audiocore
import adafruit_fancyled.adafruit_fancyled as fancy
import adafruit_trellism4
from color_names import * # pylint: disable=wildcard-import,unused-wildcard-import
Expand Down Expand Up @@ -56,7 +57,7 @@
with audioio.AudioOut(board.A1, right_channel=board.A0) as audio:
try:
f = open("welcome.wav", "rb")
wave = audioio.WaveFile(f)
wave = audiocore.WaveFile(f)
audio.play(wave)
swirl = 0 # we'll swirl through the colors in the gradient
while audio.playing:
Expand All @@ -81,7 +82,7 @@
bits_per_sample = None
sample_rate = None
with open(SAMPLE_FOLDER+SAMPLES[0][0], "rb") as f:
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)
print("%d channels, %d bits per sample, %d Hz sample rate " %
(wav.channel_count, wav.bits_per_sample, wav.sample_rate))

Expand All @@ -102,7 +103,7 @@
filename = SAMPLE_FOLDER+v[0]
try:
with open(filename, "rb") as f:
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)
print(filename,
"%d channels, %d bits per sample, %d Hz sample rate " %
(wav.channel_count, wav.bits_per_sample, wav.sample_rate))
Expand Down Expand Up @@ -147,7 +148,7 @@ def stop_playing_sample(playback_details):
try:
filename = SAMPLE_FOLDER+SAMPLES[sample_num][0]
f = open(filename, "rb")
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)

# is something else playing? interrupt it!
if currently_playing['voice'] != None:
Expand Down
3 changes: 2 additions & 1 deletion CircuitPython_Star_Gazer/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@
# music!
if PLAY_SOUND_ON_CHANGE:
import audioio
import audiocore
wave_file = open("coin.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)

# we'll save the value in question
last_value = value = 0
Expand Down
13 changes: 7 additions & 6 deletions CircuitPython_WeatherCloud/code.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
import random
import audioio
import audiocore
import board
import busio
from digitalio import DigitalInOut
Expand All @@ -16,7 +17,7 @@
button.switch_to_input(pull=digitalio.Pull.UP)

wave_file = open("sound/Rain.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)
audio = audioio.AudioOut(board.A0)


Expand Down Expand Up @@ -130,17 +131,17 @@
if weather_type == 'Sunny':
palette = sunny_palette
wave_file = open("sound/Clear.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)
has_sound = True
if weather_type == 'Clouds':
palette = cloudy_palette
wave_file = open("sound/Clouds.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)
has_sound = True
if weather_type == 'Rain':
palette = cloudy_palette
wave_file = open("sound/Rain.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)
raining = True
has_sound = True
if weather_type == 'Thunderstorm':
Expand All @@ -152,7 +153,7 @@
if weather_type == 'Snow':
palette = cloudy_palette
wave_file = open("sound/Snow.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)
snowing = True
has_sound = True
weather_refresh = time.monotonic()
Expand Down Expand Up @@ -204,6 +205,6 @@
wave_file = open("sound/Thunderstorm1.wav", "rb")
elif Thunder == 2:
wave_file = open("sound/Thunderstorm2.wav", "rb")
wave = audioio.WaveFile(wave_file)
wave = audiocore.WaveFile(wave_file)
audio.play(wave)
next_bolt_time = time.monotonic() + random.randint(5, 15) # between 5 and 15 s
3 changes: 2 additions & 1 deletion Circuit_Playground_Express_Rocket_Lamp/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import neopixel
import digitalio
import audioio
import audiocore

# enables the speaker for audio output
spkrenable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
Expand Down Expand Up @@ -49,7 +50,7 @@ def play_audio():
#open the file
wave_file = open("liftoff.wav", "rb")
#play the file
with audioio.WaveFile(wave_file) as wave:
with audiocore.WaveFile(wave_file) as wave:
with audioio.AudioOut(board.A0) as audio:
audio.play(wave)
#wait until audio is done
Expand Down
3 changes: 2 additions & 1 deletion Circuit_Playground_Express_USB_MIDI/cpx-basic-synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import digitalio
import audioio
import audiocore
import board
import usb_midi
import neopixel
Expand Down Expand Up @@ -90,7 +91,7 @@ def waveform_sawtooth(length, waves, volumes):
* twopi
+ math.pi))
for idx in list(range(length))])
waves.append((audioio.RawSample(waveraw), waveraw))
waves.append((audiocore.RawSample(waveraw), waveraw))

# Make some square waves of different volumes volumes, generated with
# n=10;[round(math.sqrt(x)/n*32767*n/math.sqrt(n)) for x in range(1, n+1)]
Expand Down
3 changes: 2 additions & 1 deletion Crickit_Hello_World/code.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
import audioio
import audiocore
import board
import neopixel
from adafruit_crickit import crickit
Expand All @@ -10,7 +11,7 @@
# Start playing the file (in the background)
def play_file(wavfile):
audio_file = open(wavfile, "rb")
wav = audioio.WaveFile(audio_file)
wav = audiocore.WaveFile(audio_file)
speaker.play(wav)
while speaker.playing:
pass
Expand Down
3 changes: 2 additions & 1 deletion Crickit_Sparky_Automaton/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
import board
import audioio
import audiocore
from adafruit_crickit import crickit

# Sparky automaton
Expand Down Expand Up @@ -31,7 +32,7 @@
def play_file(wavfile):
print("Playing", wavfile)
with open(wavfile, "rb") as f:
wav = audioio.WaveFile(f)
wav = audiocore.WaveFile(f)
a.play(wav)
while a.playing: # turn servos, motors, etc. during playback
mouth_servo.angle = MOUTH_END
Expand Down
Loading