Skip to content

MonoWavefile with speed adjustment#1

Open
ggVGc wants to merge 5 commits intomainfrom
wavefile-playback-speed
Open

MonoWavefile with speed adjustment#1
ggVGc wants to merge 5 commits intomainfrom
wavefile-playback-speed

Conversation

@ggVGc
Copy link
Owner

@ggVGc ggVGc commented Aug 25, 2024

Example code:

import board
import audiopwmio
import audiocore
import audiomixer

class SamplePlayer:
    def __init__(self):
        self.audio = audiopwmio.PWMAudioOut(board.D12)
        self.mixer = audiomixer.Mixer(
            voice_count=1,
            sample_rate=16000,
            channel_count=1,
            bits_per_sample=8,
            samples_signed=False,
        )

        self.audio.play(self.mixer)
        self.sample = audiocore.MonoWaveFile(open("boink.wav", "rb"))

    def play_sample(self):
        sample = self.sample
        voice = self.mixer.voice[0]

        sample.set_speed(0.3)
        voice.play(sample)


player = SamplePlayer()

import time
while True:
    player.play_sample()
    time.sleep(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant