0
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
| |
#include "stdafx.h"
#include "PaSnd.h"
#define ISOURCES 2
#define OUTCHANNELS 1
#define SAMPLELATE 44100
#define PA_SAMPLE_TYPE paFloat32
#define LOFTBL 44100/2
PaSnd::PaSnd(void){
}
PaSnd::~PaSnd(void){
}
int paCallback(
void *inputBuffer,
void *outputBuffer,
unsigned long framesPerBuffer,
PaTimestamp tms,
void *userData
){
paData *mdata=(paData*)userData;
unsigned int frameIndex,chn;
float *out = (float*)outputBuffer;
for( frameIndex = 0; frameIndex < framesPerBuffer; frameIndex++ ){
for( chn = 0; chn < OUTCHANNELS; chn++ ){
if( chn == 0 ){
*out++ = mdata->asunit.sigProc() + mdata->runit.sigProc() + mdata->rdunit.sigProc();
}
else{
}
}
}
return 0;
}
void PaSnd::init(){
this->err=Pa_Initialize();
if(this->err !=paNoError ){
this->stop();
}
else{
err=Pa_OpenStream(
&this->stream,
Pa_GetDefaultInputDeviceID(), ISOURCES,
paFloat32,
NULL,
Pa_GetDefaultOutputDeviceID(),
OUTCHANNELS,
paFloat32,
NULL,
SAMPLELATE, 128, 0,
paClipOff,
paCallback,
&this->mdata
);
}
printf("stream opend=%d\n",this->err);
mdata.asunit.load( "data/zaa.wav", 3*44100 );
mdata.asunit.mVol = 1.0;
mdata.runit.load( "data/shitoshito.wav", 5*44100 );
mdata.runit.mVol = 0.0;
mdata.rdunit.load( "data/potupotu.wav", 3*44100 );
mdata.rdunit.mVol = 1.0;
}
void PaSnd::start(){
this->err=Pa_StartStream(this->stream);
printf("stream started=%d\n",this->err);
}
void PaSnd::stop(){
Pa_StopStream(this->stream);
printf("stream stoprd=%d\n",this->err);
}
void PaSnd::releace(){
Pa_StopStream(this->stream);
Pa_CloseStream(this->stream);
Pa_Terminate();
}
|