≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Capturing data from audio devices
Posted by:
(you are not logged in)
Enter the missing letter in: "Inte?national"
(you are not logged in)
Text:
[quote][b]Opifex[/b] wrote: I've started experimenting with the stuff we've discussed, but I need a bit of advice. I'm trying to create Sidetone for a headset (Playback mic recordings to headset). I've created a class that inherits from "ICapturedAudioDataReceiver" so I could use "OnReceiveAudioDataStreamChunk". This function is now called constantly with audioData and a length which is good. Now I need to figure out how to actually play that audioData to an output device. The only function I can see which I "think" is correct is to use "addSoundSourceFromPCMData" but my attempts to use it have failed. Am I on the right track? [code] // derive a class from ICapturedAudioDataReceiver that receives the captured audio data class SideToneGen : public ICapturedAudioDataReceiver { public: SideToneGen(void) { sidetoneFormat.ChannelCount = 1; sidetoneFormat.SampleFormat = ESF_U8; sidetoneFormat.SampleRate = 22000; sidetoneFormat.FrameCount = sidetoneFormat.ChannelCount * sidetoneFormat.getSampleSize(); }; virtual void OnReceiveAudioDataStreamChunk(unsigned char *audioData, unsigned long lengthInBytes); ISoundEngine* enginePtr; SAudioStreamFormat sidetoneFormat; }; // Called often; Play mic audio straight back to the speakers void SideToneGen::OnReceiveAudioDataStreamChunk(unsigned char *audioData, unsigned long lengthInBytes) { enginePtr->addSoundSourceFromPCMData(audioData, lengthInBytes, "SideToneAudio", sidetoneFormat); //???? enginePtr->play2D("SideToneAudio"); //???? } int main(int argc, char ** argv) { // start sound engine ISoundEngine* engine = createIrrKlangDevice(ESOD_WIN_MM); if (!engine) return 0; // start listening to the input IAudioRecorder* listener = createIrrKlangAudioRecorder(engine); SideToneGen* sidetone = new SideToneGen(); sidetone->enginePtr = engine; //dirty listener->startRecordingCustomHandledAudio(sidetone, 22000, ESF_U8, 1); // loop indefinitely while (true) this_thread::sleep_for(chrono::milliseconds(100)); listener->drop(); engine->drop(); return 0; } [/code] Code sample came from another thread. I figured it would be as simple as directing the audioData from "OnReceiveAudioDataStreamChunk" straight into "addSoundSourceFromPCMData". But when this function is called I get the error: Cannot add sound source, it exists already: SideToneAudio I don't actually understand this error because I thought "OnReceiveAudioDataStreamChunk" gives the audio buffer to the user, the data isn't stored internally to IrrKlang anymore.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact