Getting SDataEx from a Sound
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 11:05, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13
Platform: Mac OSX ;
Language(s) : C++ ;---------
Hello all,I've got a button that's loading a sound and playing it. I want to get the volume of sound at each update which I think SDataEx will give me. So I have a loop that runs when the sound is playing and I'm printing out the data for SDataEx, but it always prints out 0.
Here's my code.
if (ID==BTNCREATESOUND) { Filename fn; if (!fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, "Load Sound")) return FALSE; AutoAlloc<BaseSound> sound; if (!sound) return FALSE; sound->Init(5,5,5); if (!sound->Load(fn)) return FALSE; GeSndInfo sndinfo(sound); AutoAlloc<GePlaySnd> playsound; if (!playsound) return FALSE; playsound->Open(sound); playsound->Scrub(0, sndinfo.GetLength().Get()); SDataEx sounddata; while(playsound->IsPlaying()) { GePrint("pos: " + RealToString(playsound->GetPositionEstimate())); sound->GetSampleEx(playsound->GetPositionEstimate(),&sounddata); GePrint("L:"+RealToString(sounddata.l)); GePrint("R:"+RealToString(sounddata.r)); } }
I'm almost positive that I'm making a simple mistake, but I can't figure what it is.
Thanks,
Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 01:39, xxxxxxxx wrote:
Hi Dan,
I tested your code (with maxon_technoloop2.wav located in CINEMA ex utorials ) and it does work as expected; left and right sound samples have useful values.
Also, I think it's not necessary to call sound->Init(5,5,5);
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 16:33, xxxxxxxx wrote:
Thanks for the response, Yannick. I tested the same file and it worked! I'm glad my code was right, but my sound file wasn't despite my best attempt to convert it to the correct type. I'm glad I was half right.
Thanks!
Dan