summaryrefslogtreecommitdiff
path: root/src/audio/mock_audio_backend.cc
blob: 3f5a57ac79a23141c99c6939e6ed1dee0c5489ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// This file is part of the 64k demo project.
// It implements the mock audio backend for testing.
// Records voice trigger events with precise timestamps.

#include "mock_audio_backend.h"

#if !defined(STRIP_ALL)

MockAudioBackend::MockAudioBackend() : current_time_sec_(0.0f) {
}

MockAudioBackend::~MockAudioBackend() {
}

void MockAudioBackend::init() {
  // No-op for mock backend
}

void MockAudioBackend::start() {
  // No-op for mock backend
}

void MockAudioBackend::shutdown() {
  // No-op for mock backend
}

void MockAudioBackend::on_voice_triggered(float timestamp, int spectrogram_id,
                                           float volume, float pan) {
  // Record the event with the timestamp provided by synth
  VoiceTriggerEvent event;
  event.timestamp_sec = timestamp;
  event.spectrogram_id = spectrogram_id;
  event.volume = volume;
  event.pan = pan;
  recorded_events_.push_back(event);
}

void MockAudioBackend::on_frames_rendered(int num_frames) {
  // Update internal time based on frames rendered
  // This is called by audio_render_silent() for seek/fast-forward simulation
  const float delta_sec = (float)num_frames / (float)kSampleRate;
  current_time_sec_ += delta_sec;
}

#endif /* !defined(STRIP_ALL) */