Skip to content

Feature/audio prep#49

Open
aaronrobinsona wants to merge 6 commits intomainfrom
feature/audio-prep
Open

Feature/audio prep#49
aaronrobinsona wants to merge 6 commits intomainfrom
feature/audio-prep

Conversation

@aaronrobinsona
Copy link
Copy Markdown
Contributor

Audio Engine + Playback System + UI Controls

Summary

This PR introduces a complete audio playback system along with playback controls and visual feedback. The application can now render and play musical input with correct timing, support user interaction through audio, and visualize playback progression.


Features Added

1. Audio Engine (SoundFont-based)

  • Implemented AudioEngine using SoundFont (.sf2)
  • Converts grid notes → MIDI → frequency → PCM audio
  • Uses continuous buffer rendering for smooth playback (no timer jitter)
  • Supports:
    • full sequence playback
    • chord playback (stacked notes)
    • short preview playback on note placement

2. Sequential Playback (Phase 2)

  • Plays notes across beats in correct order
  • Respects note lengths:
    • eighth, quarter, half, whole
  • Uses global tempo (BPM)
  • Eliminates previous QTimer audio jitter by rendering one full PCM buffer

3. Note Preview

  • When a note is placed on the staff, it plays immediately
  • Helps user hear pitch while composing

4. Stop Playback

  • Added stop() in AudioEngine
  • Added stopPlayback() in GridController
  • Stops:
    • sequence playback
    • chord playback
    • preview playback
  • Safe to call at any time

5. Tempo Control

  • Added tempoBpm Q_PROPERTY in GridController
  • Range: 40–200 BPM
  • UI controls:
    • Increase/decrease tempo by 5 BPM
  • Fixed QML binding loop issue by introducing:
    • increaseTempo()
    • decreaseTempo()

6. Playback Cursor (Visual Beat Highlight)

  • Highlights current beat during playback
  • Implemented via:
    • AudioEngine::beatAdvanced(int)
    • GridController::currentPlaybackBeat
    • QML overlay rectangle in Screen01.qml
  • Uses timer-based beat notifications (UI only, audio remains buffer-driven)
  • Clears on stop or playback end

Architecture Overview

  • AudioEngine

    • Responsible for audio synthesis and playback
    • Renders full PCM buffer before playback
    • Emits beat updates for UI
  • GridController

    • Acts as controller between UI and audio
    • Exposes playback state via Q_PROPERTY
    • Handles tempo and playback control
  • QML (UI)

    • Triggers playback and control actions
    • Displays playback cursor
    • Provides tempo controls

Files Modified

  • core/AudioEngine.h / .cpp
  • core/GridController.h / .cpp
  • app/Screen01.qml
  • app/NoteSlot.qml

Manual Testing

  • C major scale:
    • plays sequentially
    • highlight follows beats
  • C major chord:
    • plays simultaneously
    • single beat highlight
  • Tempo:
    • affects playback speed
  • Stop:
    • immediately halts audio and clears highlight
  • Note preview:
    • plays on placement

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