Added PSharedptr class
[pwlib.git] / samples / audio / audio.cxx
blob8086ea20fc4b2c5ccdad9a7085fc0cdd163744c5
1 //
2 // audio.cxx
3 //
4 // Roger Hardiman
5 //
7 #include <ptlib.h>
9 class Audio : public PProcess
11 PCLASSINFO(Audio, PProcess)
12 public:
13 void Main();
16 PCREATE_PROCESS(Audio)
18 void Audio::Main()
20 cout << "Audio Test Program\n";
22 PSoundChannel::Directions dir;
23 PStringArray names;
25 cout << "\n";
26 cout << "List of Play devices\n";
28 dir = PSoundChannel::Player;
29 names = PSoundChannel::GetDeviceNames(dir);
30 for (PINDEX i = 0; i < names.GetSize(); i++)
31 cout << " \"" << names[i] << "\"\n";
33 cout << "The default play device is \"" << PSoundChannel::GetDefaultDevice(dir) << "\"\n";
36 cout << "\n";
37 cout << "List of Record devices\n";
39 dir = PSoundChannel::Recorder;
40 names = PSoundChannel::GetDeviceNames(dir);
41 for (PINDEX i = 0; i < names.GetSize(); i++)
42 cout << " \"" << names[i] << "\"\n";
44 cout << "The default record device is \"" << PSoundChannel::GetDefaultDevice(dir) << "\"\n";
46 cout << "\n";
49 // Display the mixer settings for the default devices
50 PSoundChannel sound;
51 dir = PSoundChannel::Player;
52 sound.Open(PSoundChannel::GetDefaultDevice(dir),dir);
54 unsigned int vol;
55 if (sound.GetVolume(vol))
56 cout << "Play volume is " << vol << endl;
57 else
58 cout << "Play volume cannot be obtained" << endl;
60 sound.Close();
62 dir = PSoundChannel::Recorder;
63 sound.Open(PSoundChannel::GetDefaultDevice(dir),dir);
65 if (sound.GetVolume(vol))
66 cout << "Record volume is " << vol << endl;
67 else
68 cout << "Record volume cannot be obtained" << endl;
70 sound.Close();
73 // End of hello.cxx