VibeFast
Customizing Features

Voice Notes

Learn how the voice recording feature works and how to customize its settings.

VibeFast includes a complete voice recording feature that allows users to capture, store, and play back audio notes. It's built using expo-av for audio capture and Convex for storage and data management.

Overview

  • Audio Capture: The useVoiceRecording hook in src/features/voice-notes/hooks/use-voice-recording.ts is the heart of the feature. It manages the entire recording lifecycle, including starting, stopping, and handling audio metering data for animations.
  • File Storage: When a recording is complete, the audio file is uploaded to Convex File Storage.
  • Data Persistence: The metadata for each recording (such as duration, file URI, and the metering array for waveform visualization) is stored in the recordings table in your Convex database, managed by functions in convex/recordingFunctions.ts.

How It Works

  1. When the user presses the record button, the startRecording function is called, which uses Audio.Recording.createAsync() from expo-av to begin capturing audio.
  2. While recording, the hook captures audio metering data (sound levels) and duration, which are used to drive the UI animations.
  3. When the user stops recording, the stopRecording function is called. It finalizes the audio file and uploads it to Convex.
  4. The finalizeRecording mutation in convex/recordingFunctions.ts is then called to save the file's storage ID and other metadata to the database.

Waveform Visualization

The metering array captured during recording contains a series of decibel values. This data is what allows the playback component to render a visual representation of the audio waveform, even before the audio is fully analyzed.

How-To: Change Recording Limits

You can easily change the maximum recording duration for different user tiers. All voice note settings are centralized in a single configuration file.

Step 1: Open the Configuration File

Navigate to src/features/voice-notes/config/voice-notes.config.ts.

Step 2: Adjust the Values

Modify the freeTierMaxLengthSeconds or premiumTierMaxLengthSeconds values to fit your needs. The useVoiceRecording hook automatically uses these values to stop recordings when the limit is reached.

src/features/voice-notes/config/voice-notes.config.ts
/**
 * Voice Notes feature configuration
 */
export const VoiceNotesConfig = {
  /** Maximum recording length for free tier users (in seconds) */
  freeTierMaxLengthSeconds: 300, // 5 minutes

  /** Maximum recording length for premium tier users (in seconds) */
  premiumTierMaxLengthSeconds: 3600, // 60 minutes

  /** Interval for updating draft recordings during recording (in milliseconds) */
  draftUpdateInterval: 5000, // 5 seconds
};

This centralized configuration makes it simple to manage the behavior of the voice notes feature without needing to dig into the core logic of the hooks or components.