I recently spent some time trying to use a microphone as a sound input in Panda3D under Windows.
Several old posts described this possibility, but no detailed implementation was given.
So, just for those of you interested, this is how I managed to make it work.
This is a quick (and dirty?) practical approach
- grab MicrophoneAudioDS.cxx file from Panda3D source
edit it and merely make public the call to open()
// private:
virtual PT(MovieAudioCursor) open();
- in your c++ program add the following includes
#include "audioManager.h"
#include "microphoneAudio.h"
#include "microphoneAudioDS.cxx"
#include "userDataAudio.h"
- define microphone access
PT(MicrophoneAudio) mic; // micro
PT(MicrophoneAudioCursorDS) micCursor;// audio cursor for micro stream
PT(UserDataAudio) micAudio; // micro channel 2 , 44100hz
- then explore all possible microphone input
MicrophoneAudioDS::find_all_microphones_ds(); // check microphone options
int num_options = MicrophoneAudioDS::get_num_options();
for (int m=0; m<num_options; m++)
cout << "mike option "<< m << " "<<MicrophoneAudioDS::get_option(m)->get_name()<< "\n";
mic = MicrophoneAudioDS::get_option(2); // channel 2 , 44100hz
micCursor = DCAST(MicrophoneAudioCursorDS,mic->open());
then you can get audio samples and play them with Audio Manager