Skip to content
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

add sample recording and playback capabilities #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

utz82
Copy link

@utz82 utz82 commented May 16, 2017

Added a new class for creating sample recordings from microphone input, and added sample playback capabilities to CalliopeSoundMotor.

The sample format is optimized for 1-bit output, and allows for efficient data compression at the cost of sound quality. Efficiency depends on the harmonic spectrum of the sample, with higher frequencies generating larger data. On average, 2-3 seconds of human speech can be compressed into 1 KB of sample data at the default sample rate. Sample format is unsigned 8-bit PWM, which is a simple record of the time taken until the next output state change. If a sample byte is 0, then no state change occurs and the next state change is delayed by 256 ticks. Samples are recorded and played back at a rate of 8 KHz by default, this can be changed to up to ~11KHz. At faster rates, correct playback is not ensured.

Both recording and playback are implemented as interrupt services. CPU load will be approx. 85% at 8 KHz, so it is not possible to run other load-heavy tasks in parallel.

Sampling thresholds for recording are tuned to the current board setup, they will need to be adjusted once the planned changes to the board are implemented. Likewise, there will be some minor changes necessary if the piezo is replaced by a true speaker.

This is my first contribution to the Calliope mini project, please be patient with me and let me know about any mistakes. Also note that I have not changed the versioning.

utz82 added 2 commits May 16, 2017 09:58
…s, fix check for motorA activity in motorBOn(), adjust mic sampling thresholds and provide a sensitivity parameter for recording function
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