Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/lynx/sound/Stereo_Buffer.h
2 views
1
2
// Simple stereo Blip_Buffer for sound emulators whose oscillators output
3
// either on the left only, center, or right only.
4
5
// Blip_Buffer 0.3.0. Copyright (C) 2003-2004 Shay Green. GNU GPL license.
6
7
#ifndef STEREO_BUFFER_H
8
#define STEREO_BUFFER_H
9
10
#include "Blip_Buffer.h"
11
12
class Stereo_Buffer {
13
public:
14
Stereo_Buffer();
15
~Stereo_Buffer();
16
17
// Same as in Blip_Buffer (see Blip_Buffer.h)
18
bool set_sample_rate( long, int msec = 0 );
19
void clock_rate( long );
20
void bass_freq( int );
21
void clear();
22
23
// Buffers to output synthesis to
24
Blip_Buffer* left();
25
Blip_Buffer* center();
26
Blip_Buffer* right();
27
28
// Same as in Blip_Buffer. For more efficient operation, pass false
29
// for was_stereo if the left and right buffers had nothing added
30
// to them for this frame.
31
void end_frame( blip_time_t, bool was_stereo = true );
32
33
// Output is stereo with channels interleved, left before right. Counts
34
// are in samples, *not* pairs.
35
long samples_avail() const;
36
long read_samples( blip_sample_t*, long );
37
38
private:
39
// noncopyable
40
Stereo_Buffer( const Stereo_Buffer& );
41
Stereo_Buffer& operator = ( const Stereo_Buffer& );
42
43
enum { buf_count = 3 };
44
Blip_Buffer bufs [buf_count];
45
bool stereo_added;
46
bool was_stereo;
47
48
void mix_stereo( blip_sample_t*, long );
49
void mix_mono( blip_sample_t*, long );
50
};
51
52
inline Blip_Buffer* Stereo_Buffer::left() {
53
return &bufs [1];
54
}
55
56
inline Blip_Buffer* Stereo_Buffer::center() {
57
return &bufs [0];
58
}
59
60
inline Blip_Buffer* Stereo_Buffer::right() {
61
return &bufs [2];
62
}
63
64
inline long Stereo_Buffer::samples_avail() const {
65
return bufs [0].samples_avail();
66
}
67
68
#endif
69
70
71