diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/voice-memos/app.js | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/html/voice-memos/app.js b/html/voice-memos/app.js index 445fffc..d21d1fa 100644 --- a/html/voice-memos/app.js +++ b/html/voice-memos/app.js @@ -49,7 +49,6 @@ const elements = { }; /** - * State management using closure * @returns {Object} State management functions */ const createStateManager = () => { @@ -67,7 +66,7 @@ const createStateManager = () => { const stateManager = createStateManager(); /** - * Formats elapsed time in seconds to MM:SS format + * Formats elapsed time to MM:SS * @param {number} seconds - Time in seconds * @returns {string} Formatted time string */ @@ -77,9 +76,6 @@ const formatTime = (seconds) => { return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`; }; -/** - * Updates the UI based on current state - */ const updateUI = () => { const { isRecording, @@ -127,6 +123,7 @@ const updateUI = () => { /** * Saves the selected device ID to local storage + * Retains the last selected audio input device ID * @param {string} deviceId - The device ID to save */ const saveSelectedDevice = (deviceId) => { @@ -139,6 +136,7 @@ const saveSelectedDevice = (deviceId) => { /** * Gets the last selected device ID from local storage + * so that the user doesn't have to select the same device every time * @returns {string|null} The last selected device ID or null if not found */ const getLastSelectedDevice = () => { @@ -150,9 +148,6 @@ const getLastSelectedDevice = () => { } }; -/** - * Populates the input source dropdown with available audio devices - */ const populateInputSources = async () => { try { // First, request microphone permission to get device labels @@ -245,22 +240,18 @@ const setupWaveformVisualization = (analyser) => { // Draw waveform canvasCtx.beginPath(); - - // Modern style with thicker lines and smoother curves canvasCtx.lineWidth = 2; canvasCtx.strokeStyle = '#ff3b30'; const sliceWidth = canvas.width / bufferLength; let x = 0; - // First pass to smooth the data const smoothedData = []; const smoothingFactor = 0.2; for (let i = 0; i < bufferLength; i++) { const raw = dataArray[i] / 128.0 - 1.0; - // Apply smoothing if (i > 0) { smoothedData.push(smoothedData[i-1] * smoothingFactor + raw * (1 - smoothingFactor)); } else { @@ -268,7 +259,6 @@ const setupWaveformVisualization = (analyser) => { } } - // Draw the smoothed waveform for (let i = 0; i < bufferLength; i++) { const v = smoothedData[i]; const y = (v * canvas.height / 4) + canvas.height / 2; @@ -284,7 +274,7 @@ const setupWaveformVisualization = (analyser) => { canvasCtx.stroke(); - // Draw a reflection of the waveform (mirrored and more subtle) + // Draw a reflection of the waveform canvasCtx.beginPath(); canvasCtx.strokeStyle = 'rgba(255, 59, 48, 0.3)'; x = 0; @@ -343,7 +333,7 @@ const getSupportedMimeType = () => { }; /** - * Starts the recording process with a countdown + * Starts the recording process after a countdown */ const startRecording = async () => { try { @@ -394,6 +384,7 @@ const startRecording = async () => { }; // Start recording with 1 second timeslices to ensure we get data chunks + // FIXME: experiment with different chunk sizes mediaRecorder.start(1000); stateManager.setState({ @@ -560,7 +551,7 @@ const saveRecording = async () => { // Create metadata object const metadata = { title: `Voice Memo ${formattedDate}`, - artist: 'Voice Memos App', + artist: 'Audio Gremlins', album: 'Voice Recordings', date: now.toISOString(), device: deviceLabel, |