6
static int DummyCallbackFunc(const void *inputBuffer,
8
unsigned long framesPerBuffer,
9
const PaStreamCallbackTimeInfo* timeInfo,
10
PaStreamCallbackFlags statusFlags,
15
#define NUM_CHANNELS (2)
16
#define PA_SAMPLE_TYPE paFloat32
17
#define SAMPLE_RATE (44100)
18
#define FRAMES_PER_BUFFER (1024)
20
int main(int argc, char **argv)
26
PaStreamParameters inputParameters;
27
PaStreamParameters outputParameters;
29
error = Pa_Initialize();
30
if ( error != paNoError ) {
31
printf("PortAudio error %d: %s\n", error, Pa_GetErrorText(error));
34
inputParameters.device = Pa_GetDefaultInputDevice();
35
inputParameters.channelCount = NUM_CHANNELS;
36
inputParameters.sampleFormat = PA_SAMPLE_TYPE;
37
inputParameters.suggestedLatency =
38
Pa_GetDeviceInfo(inputParameters.device )->defaultLowInputLatency;
39
inputParameters.hostApiSpecificStreamInfo = NULL;
41
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
42
outputParameters.channelCount = 2; /* stereo output */
43
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
44
outputParameters.suggestedLatency =
45
Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
46
outputParameters.hostApiSpecificStreamInfo = NULL;
50
error = Pa_OpenStream(&stream, &inputParameters, &outputParameters,
51
SAMPLE_RATE,FRAMES_PER_BUFFER,
52
paClipOff | paDitherOff,
53
DummyCallbackFunc, NULL);
56
printf("PortAudio error %d: %s\n", error, Pa_GetErrorText(error));
60
num_mixers = Px_GetNumMixers(stream);
61
printf("Number of mixers: %d\n", num_mixers);
62
for(i=0; i<num_mixers; i++) {
67
printf("Mixer %d: %s\n", i, Px_GetMixerName(stream, i));
68
mixer = Px_OpenMixer(stream, i);
70
printf(" Could not open mixer!\n");
74
printf(" Master volume: %.2f\n", Px_GetMasterVolume(mixer));
75
printf(" PCM output volume: %.2f\n", Px_GetPCMOutputVolume(mixer));
77
num = Px_GetNumOutputVolumes(mixer);
78
printf(" Num outputs: %d\n", num);
79
for(j=0; j<num; j++) {
80
printf(" Output %d (%s): %.2f\n",
82
Px_GetOutputVolumeName(mixer, j),
83
Px_GetOutputVolume(mixer, j));
86
num = Px_GetNumInputSources(mixer);
87
printf(" Num input sources: %d\n", num);
88
for(j=0; j<num; j++) {
89
printf(" Input %d (%s) %s\n",
91
Px_GetInputSourceName(mixer, j),
92
(Px_GetCurrentInputSource(mixer)==j?
95
printf(" Input volume: %.2f\n", Px_GetInputVolume(mixer));
100
Pa_CloseStream(stream);