| 1 |
#include <stdio.h> |
| 2 |
|
| 3 |
#include "portmixer.h" |
| 4 |
#include "portaudio.h" |
| 5 |
|
| 6 |
static int DummyCallbackFunc(const void *inputBuffer, |
| 7 |
void *outputBuffer, |
| 8 |
unsigned long framesPerBuffer, |
| 9 |
const PaStreamCallbackTimeInfo* timeInfo, |
| 10 |
PaStreamCallbackFlags statusFlags, |
| 11 |
void *userData ) |
| 12 |
{ |
| 13 |
return 0; |
| 14 |
} |
| 15 |
#define NUM_CHANNELS (2) |
| 16 |
#define PA_SAMPLE_TYPE paFloat32 |
| 17 |
#define SAMPLE_RATE (44100) |
| 18 |
#define FRAMES_PER_BUFFER (1024) |
| 19 |
|
| 20 |
int main(int argc, char **argv) |
| 21 |
{ |
| 22 |
int num_mixers; |
| 23 |
int i; |
| 24 |
PaError error; |
| 25 |
PaStream* stream; |
| 26 |
PaStreamParameters inputParameters; |
| 27 |
PaStreamParameters outputParameters; |
| 28 |
|
| 29 |
error = Pa_Initialize(); |
| 30 |
if ( error != paNoError ) { |
| 31 |
printf("PortAudio error %d: %s\n", error, Pa_GetErrorText(error)); |
| 32 |
return -1; |
| 33 |
} |
| 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; |
| 40 |
|
| 41 |
outputParameters.device = Pa_GetDefaultOutputDevice(); |
| 42 |
outputParameters.channelCount = 2; |
| 43 |
outputParameters.sampleFormat = paFloat32; |
| 44 |
outputParameters.suggestedLatency = |
| 45 |
Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; |
| 46 |
outputParameters.hostApiSpecificStreamInfo = NULL; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
error = Pa_OpenStream(&stream, &inputParameters, &outputParameters, |
| 51 |
SAMPLE_RATE,FRAMES_PER_BUFFER, |
| 52 |
paClipOff | paDitherOff, |
| 53 |
DummyCallbackFunc, NULL); |
| 54 |
|
| 55 |
if (error) { |
| 56 |
printf("PortAudio error %d: %s\n", error, Pa_GetErrorText(error)); |
| 57 |
return -1; |
| 58 |
} |
| 59 |
|
| 60 |
num_mixers = Px_GetNumMixers(stream); |
| 61 |
printf("Number of mixers: %d\n", num_mixers); |
| 62 |
for(i=0; i<num_mixers; i++) { |
| 63 |
PxMixer *mixer; |
| 64 |
int num; |
| 65 |
int j; |
| 66 |
|
| 67 |
printf("Mixer %d: %s\n", i, Px_GetMixerName(stream, i)); |
| 68 |
mixer = Px_OpenMixer(stream, i); |
| 69 |
if (!mixer) { |
| 70 |
printf(" Could not open mixer!\n"); |
| 71 |
continue; |
| 72 |
} |
| 73 |
|
| 74 |
printf(" Master volume: %.2f\n", Px_GetMasterVolume(mixer)); |
| 75 |
printf(" PCM output volume: %.2f\n", Px_GetPCMOutputVolume(mixer)); |
| 76 |
|
| 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", |
| 81 |
j, |
| 82 |
Px_GetOutputVolumeName(mixer, j), |
| 83 |
Px_GetOutputVolume(mixer, j)); |
| 84 |
} |
| 85 |
|
| 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", |
| 90 |
j, |
| 91 |
Px_GetInputSourceName(mixer, j), |
| 92 |
(Px_GetCurrentInputSource(mixer)==j? |
| 93 |
"SELECTED": "")); |
| 94 |
} |
| 95 |
printf(" Input volume: %.2f\n", Px_GetInputVolume(mixer)); |
| 96 |
|
| 97 |
Px_CloseMixer(mixer); |
| 98 |
} |
| 99 |
|
| 100 |
Pa_CloseStream(stream); |
| 101 |
|
| 102 |
return 0; |
| 103 |
} |