Skip to content

Conversation

@BeanRepo
Copy link

@BeanRepo BeanRepo commented Nov 6, 2025

Replace SineGenerator with WaveGenerator Brick

@rjtokenring rjtokenring requested a review from mirkokurt November 7, 2025 12:53
@rjtokenring rjtokenring marked this pull request as ready for review November 7, 2025 12:53
@BeanRepo
Copy link
Author

BeanRepo commented Nov 7, 2025

Overview

This PR updates the Theremin example to use the new WaveGenerator brick instead of the previous SineGenerator implementation, providing improved audio quality and smoother transitions.

Changes

Audio Generation

  • Replaced custom SineGenerator implementation with the WaveGenerator brick
  • Added configurable envelope parameters (attack=0.01s, release=0.03s, glide=0.02s) for smooth frequency and amplitude transitions
  • Improved audio streaming with automatic background thread management and reduced latency (~30ms blocks)

Volume Handling

  • Updated volume control to use integer values (0-100) instead of normalized floats (0.0-1.0)
  • Simplified volume handling by using consistent 0-100 range for both amplitude and hardware volume
  • Improved real-time volume response and state synchronization

Documentation

  • Updated README with detailed information about the WaveGenerator brick
  • Added technical specifications (sample rate, audio format, block duration)
  • Improved troubleshooting section and hardware compatibility notes

Benefits

  • Better audio quality: Eliminates cracks and pops with smooth envelope transitions
  • Simplified code: Reduced code complexity by ~60 lines, leveraging brick functionality
  • Enhanced performance: Non-blocking audio playback with automatic resource management
  • Improved UX: Smoother frequency/amplitude changes and better volume control

@BeanRepo BeanRepo changed the title Replace SineGenerator with WaveGenerator Brick Replace SineGenerator with WaveGenerator Brick in Theremin Nov 7, 2025
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.

3 participants