Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Getting SDataEx from a Sound

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 272 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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);

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post