≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
record what's being played through ISound*
Posted by:
(you are not logged in)
Enter the missing letter in: "In?ernational"
(you are not logged in)
Text:
[quote][b]petesound[/b] wrote: Hello, After doing some research I implemented a class which derives from ISoundMixedOutputReceiver and ICapturedAudioDataReceiver to record a final mixdown of a song currently playing. If i print printf("Audio data size %d\n", data) from OnAudioDataReady( i actually receive data packages, but the recorded memory is always null. What am I doing wrong? Any help would be kindly appreciated! Pete Here is the cpp: // IrrKl.cpp : Defines the entry point for the console application. include "stdafx.h" include <iostream> include <string> include "include/irrKlang.h" include "include/ik_ISoundMixedOutputReceiver.h" include "include/ik_IAudioRecorder.h" using namespace irrklang; pragma comment(lib, "irrKlang.lib") class MySoundMixedOutputReceiver : public ISoundMixedOutputReceiver, public ICapturedAudioDataReceiver { public: virtual void OnAudioDataReady(const void* data, int byteCount, int playbackrate) { //printf("Audio data size %d\n", data); } virtual void OnReceiveAudioDataStreamChunk(unsigned char *audioData, unsigned long lengthInBytes) { int total = 0; for (unsigned long i = 0; i<lengthInBytes; i++) if (total != 0) total += audioData[i]; printf("%.3f\n", ((float)total / lengthInBytes)); } }; int main(int argc, const char** argv) { ISoundEngine* engine = createIrrKlangDevice(ESOD_WIN_MM); if (!engine) return 0; // error starting up the engine ISound* myMusic = engine->play2D("song.mp3", true, false, true, ESM_AUTO_DETECT, true); IAudioRecorder* recorder = irrklang::createIrrKlangAudioRecorder(engine); if (!engine) return 0; if (myMusic) { MySoundMixedOutputReceiver* receiver = new MySoundMixedOutputReceiver(); //record recorder->startRecordingCustomHandledAudio(receiver, 22000, ESF_U8, 1); engine->setMixedDataOutputReceiver(receiver); std::cout << "recording started \n"; std::getchar(); //stop record recorder->stopRecordingAudio(); std::cout << "recording stopped \n"; printf("\nRecording done, recorded %dms of audio.\n", recorder->getAudioFormat().FrameCount * 1000 / recorder->getAudioFormat().SampleRate); printf("Press any key to play back recorded audio...\n"); engine->stopAllSounds(); std::getchar(); // play the recorded audio recorder->addSoundSourceFromRecordedAudio("myRecordedSong"); engine->play2D("myRecordedSong", true); printf("\nPress any key to quit..."); std::getchar(); } engine->drop(); return 0; }[/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