1
/*******************************************/
2
/* Real-Time Audio Output Class, */
3
/* by Perry R. Cook, 1996 */
4
/* Revised by Gary P. Scavone, 2000 */
6
/* This object opens a realtime soundout */
7
/* device, and pokes buffers of samples */
9
/*******************************************/
13
#if defined(__STK_REALTIME_)
15
RtWvOut :: RtWvOut(int chans, int device)
17
// We'll let RTSoundIO deal with channel and srate limitations.
19
sound_dev = new RtAudio(channels, SRATE, "play", device);
20
data_length = RT_BUFFER_SIZE*channels;
21
// Add a few extra samples for good measure
22
data = (INT16 *) new INT16[data_length+10];
27
sound_dev->playBuffer(data,counter);
29
while (counter<data_length) {
32
sound_dev->playBuffer(data,counter);
33
sound_dev->playBuffer(data,counter); // Are these extra writes necessary?
34
sound_dev->playBuffer(data,counter);
38
void RtWvOut :: tick(MY_FLOAT sample)
40
for (int i=0;i<channels;i++)
41
data[counter++] = (INT16) (sample * 32000.0);
43
if (counter >= data_length) {
44
sound_dev->playBuffer(data,data_length);
49
void RtWvOut :: mtick(MY_MULTI samples)
51
for (int i=0;i<channels;i++)
52
data[counter++] = (INT16) (*samples++ * 32000.0);
54
if (counter >= data_length) {
55
sound_dev->playBuffer(data,data_length);
60
//windows stop and start methods ... because windoze sucks
61
#if (defined(__OS_Win_) )
63
void RtWvOut :: stopPlay() {
64
sound_dev->stopPlay();
67
void RtWvOut :: startPlay() {
68
sound_dev->startPlay();
71
void RtWvOut :: stopRecord() {
72
sound_dev->stopRecord();
75
void RtWvOut :: startRecord() {
76
sound_dev->startRecord();
79
#endif // extra windoze crap