blob: 963d9cbe6e5d2772ccf049fbea2391fad2e1589c (
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
46
47
48
49
50
51
52
53
54
55
56
|
// This file is part of the 64k demo project.
// It implements a test-only mock audio backend for event recording.
// Used for tracker timing verification and audio synchronization tests.
#pragma once
#if !defined(STRIP_ALL)
#include "audio_backend.h"
#include <vector>
// Event structure for recorded voice triggers
struct VoiceTriggerEvent {
float timestamp_sec;
int spectrogram_id;
float volume;
float pan;
};
// Mock audio backend that records all voice trigger events
// Used for testing tracker timing and synchronization
class MockAudioBackend : public AudioBackend {
public:
MockAudioBackend();
~MockAudioBackend() override;
// AudioBackend interface (no-ops for mock)
void init() override;
void start() override;
void shutdown() override;
// Event recording hooks
void on_voice_triggered(float timestamp, int spectrogram_id, float volume,
float pan) override;
void on_frames_rendered(int num_frames) override;
// Test interface methods
const std::vector<VoiceTriggerEvent>& get_events() const {
return recorded_events_;
}
void clear_events() { recorded_events_.clear(); }
// Manual time control for deterministic testing
void advance_time(float delta_sec) { current_time_sec_ += delta_sec; }
void set_time(float time_sec) { current_time_sec_ = time_sec; }
float get_current_time() const { return current_time_sec_; }
// Sample rate used for frame-to-time conversion
static const int kSampleRate = 32000;
private:
std::vector<VoiceTriggerEvent> recorded_events_;
float current_time_sec_;
};
#endif /* !defined(STRIP_ALL) */
|